@johnoscott/isometric-engine 0.10.1 → 0.12.6
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/EDITOR-GUIDE.md +12 -1
- package/README.md +1 -1
- package/assets/app.css +37 -0
- package/assets/icons.svg +1 -1
- package/iso-editor.js +182 -182
- package/iso-render.js +105 -105
- package/iso-systems.js +108 -108
- package/js/iso-editor/commands.js +7 -0
- package/js/iso-editor/connections.js +24 -0
- package/js/iso-editor/doc.js +4 -0
- package/js/iso-editor/model.js +17 -3
- package/js/iso-editor/ui/actions.js +22 -24
- package/js/iso-editor/ui/canvas.js +277 -20
- package/js/iso-editor/ui/mount.js +2 -1
- package/js/iso-editor/ui/plain-icons.js +2 -0
- package/js/iso-editor/ui/props.js +2 -2
- package/js/iso-editor/ui/rename.js +114 -0
- package/js/iso-editor/ui/setup.js +3 -1
- package/js/iso-objects/board.js +6 -1
- package/js/iso-objects/scene.js +3 -2
- package/js/iso-viewer/index.js +4 -1
- package/js/iso-viewer/viewport.js +17 -5
- package/package.json +92 -92
- package/src/iso-core/compile-schema.ts +3 -1
- package/src/iso-editor/commands.ts +9 -0
- package/src/iso-editor/connections.ts +28 -0
- package/src/iso-editor/doc.ts +6 -0
- package/src/iso-editor/model.ts +17 -3
- package/src/iso-editor/ui/actions.ts +20 -23
- package/src/iso-editor/ui/app.css +37 -0
- package/src/iso-editor/ui/canvas.ts +214 -25
- package/src/iso-editor/ui/mount.ts +4 -3
- package/src/iso-editor/ui/plain-icons.ts +2 -0
- package/src/iso-editor/ui/props.ts +3 -3
- package/src/iso-editor/ui/rename.ts +105 -0
- package/src/iso-editor/ui/setup.ts +9 -2
- package/src/iso-objects/board.ts +6 -2
- package/src/iso-objects/scene.ts +4 -2
- package/src/iso-viewer/index.ts +2 -2
- package/src/iso-viewer/morph.ts +5 -2
- package/src/iso-viewer/viewport.ts +25 -5
- package/types/iso-core/compile-schema.d.ts +2 -2
- package/types/iso-editor/connections.d.ts +8 -0
- package/types/iso-editor/model.d.ts +8 -2
- package/types/iso-editor/ui/actions.d.ts +5 -2
- package/types/iso-editor/ui/canvas.d.ts +18 -1
- package/types/iso-editor/ui/monaco-entry.d.ts +2 -0
- package/types/iso-editor/ui/mount.d.ts +6 -2
- package/types/iso-editor/ui/props.d.ts +1 -1
- package/types/iso-editor/ui/rename.d.ts +43 -0
- package/types/iso-editor/ui/setup.d.ts +6 -0
- package/types/iso-systems/validate.d.ts +4 -0
- package/types/iso-viewer/bundle.d.ts +1 -0
- package/types/iso-viewer/index.d.ts +2 -2
- package/types/iso-viewer/morph.d.ts +6 -3
- package/types/iso-viewer/viewport.d.ts +13 -1
package/iso-editor.js
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
var Cf=Object.defineProperty;var Qo=(t,e)=>{for(var n in e)Cf(t,n,{get:e[n],enumerable:!0})};var ru={};Qo(ru,{Bounds:()=>ro,C:()=>It,DiagError:()=>zi,FONTS:()=>Bt,Kernel:()=>yr,S:()=>xt,VEl:()=>Ao,allowed:()=>Yl,apply:()=>no,bubble:()=>ti,buildSvg:()=>To,center:()=>Zo,colorRef:()=>Zn,createHash:()=>su,depthSort:()=>io,didYouMean:()=>Is,distance:()=>Gl,envelope:()=>ei,esc:()=>Dt,extendTheme:()=>Ki,faceFrame:()=>fl,fileLines:()=>ni,formatDiag:()=>Hl,formatDiags:()=>Jd,iso:()=>Xe,keyGlyph:()=>nd,loadTheme:()=>Bi,matStr:()=>so,n1:()=>Lt,parse:()=>Qd,parseSvg:()=>ql,placeholderFace:()=>rd,pt:()=>Xs,screenFaces:()=>xr,screenGlass:()=>od,serialize:()=>Vi,sha256Hex:()=>Ul,socketGlyph:()=>sd,tag:()=>Ve,termLines:()=>oo,textWidth:()=>$n,themeCss:()=>_i,themeParts:()=>Vl,vdoc:()=>tu});var td={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 xt=34,It=Math.cos(Math.PI/6),Xe=(t,e,n=0)=>[(t-e)*It*xt,(t+e)*.5*xt-n*xt],Lt=t=>{let e=Math.round(t*10)/10;return Object.is(e,-0)?"0":String(e)},Xs=t=>`${Lt(t[0])},${Lt(t[1])}`,Dt=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function Ve(t,e={},n){let s="";for(let r in e){let o=e[r];o==null||o===!1||o===""||(s+=` ${r}="${Dt(typeof o=="number"?Lt(o):o)}"`)}return n===void 0?`<${t}${s}/>`:`<${t}${s}>${n}</${t}>`}var Bt={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 $n(t,e){let n=td[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 no=(t,e,n)=>[t[0]*e+t[2]*n+t[4],t[1]*e+t[3]*n+t[5]],so=t=>`matrix(${t.map(e=>Math.round(e*1e4)/1e4).join(" ")})`;function fl(t,e){if(e==="left"){let[r,o]=Xe(t.x0,t.y1,t.z1);return{m:[It,.5,0,1,r,o],w:(t.x1-t.x0)*xt,h:(t.z1-t.z0)*xt}}if(e==="right"){let[r,o]=Xe(t.x1,t.y1,t.z1);return{m:[It,-.5,0,1,r,o],w:(t.y1-t.y0)*xt,h:(t.z1-t.z0)*xt}}let[n,s]=Xe(t.x0,t.y0,t.z1);return{m:[It,.5,-It,.5,n,s],w:(t.x1-t.x0)*xt,h:(t.y1-t.y0)*xt}}var ro=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}},yr=class{bounds=new ro;texts=[];planes=[];planePolys=[];defs=new Map;poly(e,n,s={}){let r=e.map(o=>Xe(o[0],o[1],o[2]));return r.forEach(o=>this.bounds.add(o)),Ve("polygon",{points:r.map(Xs).join(" "),class:n,...s})}line3(e,n,s,r={}){let o=Xe(...e),i=Xe(...n);return this.bounds.add(o),this.bounds.add(i),Ve("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=fl(e,n);for(let[i,a]of[[0,0],[o.w,0],[0,o.h],[o.w,o.h]])this.bounds.add(no(o.m,i,a));return Ve("g",{class:r,transform:so(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(no(e,i,a));return Ve("g",{class:o,transform:so(e)},r(n,s))}text(e,n,s,r,o,i="middle",a={},l){let c=$n(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),Ve("text",{x:e,y:n,class:r,"text-anchor":i==="start"?void 0:i,...a},Dt(s))}planeText(e,n,s,r,o="start",i={}){let a=$n(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(([f,p])=>no(e,f,p));c.forEach(f=>this.bounds.add(f));let d=c.map(f=>f[0]),u=c.map(f=>f[1]);return this.planePolys.push([c[0],c[1],c[3],c[2]]),this.planes.push({x:Math.min(...d),y:Math.min(...u),w:Math.max(...d)-Math.min(...d),h:Math.max(...u)-Math.min(...u)}),Ve("text",{transform:so(e),class:s,"text-anchor":o==="start"?void 0:o,...i},Dt(n))}floorText(e,n,s,r,o,i="x",a="start",l={}){let[c,d]=Xe(e,n,s),u=i==="x"?[It,.5,-It,.5,c,d]:[It,-.5,It,.5,c,d];return this.planeText(u,r,o,Bt.floor,a,l)}faceText(e,n,s,r,o,i,a="left",l="start",c={}){let[d,u]=Xe(e,n,s),f=a==="left"?[It,.5,0,1,d,u]:[It,-.5,0,1,d,u];return this.planeText(f,r,o,i,l,c)}def(e,n){this.defs.set(e,n)}},Zo=t=>[(t.x0+t.x1)/2,(t.y0+t.y1)/2,t.z1];function oo(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 ei(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 ti(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 ni(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 nd(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 sd(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 Qs=(t,e,n,s,r,o=0)=>Ve("rect",{class:t,x:e,y:n,width:s,height:r,rx:o||void 0}),xr={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+=Ve("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 Qs(s[2],i,8+r*(e-18)/4,o,(e-18)/4-4,3)}).join("")},desktop(t,e){return Qs("wall",5,5,t-10,e-10,2)+Qs("bar",5,5,t-10,6)+Qs("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 d=0;d<3;d++){let u=6+d*(i+2.5),f=6+c*(a+2.5);l+=Qs("t",u,f,i,a,1.5),[.3,.52,.74].forEach((p,g)=>{l+=Ve("line",{class:"ln",x1:u+2.5,y1:f+a*p,x2:u+2.5+(i-5)*[.8,.5,.65][(g+c+d)%3],y2:f+a*p})})}return l}};function rd(t,e){let n=t/2,s=e/2,r=Math.min(t,e)*.22;return Qs("unk",t*.2,e*.2,t*.6,e*.6,2)+Ve("path",{class:"unk-q",d:`M${Lt(n-r*.5)},${Lt(s-r*.45)}a${Lt(r*.5)},${Lt(r*.5)} 0 1 1 ${Lt(r*.5)},${Lt(r*.55)}v${Lt(r*.3)}`})+Ve("circle",{class:"unk-dot",cx:Lt(n),cy:Lt(s+r*.75),r:Lt(Math.max(.8,r*.1))})}function od(t,e){return Qs("glass",3,3,t-6,e-6,3)}function Rf(t){let e=[Xe(t.x0,t.y0,t.z1),Xe(t.x1,t.y0,t.z0),Xe(t.x0,t.y1,t.z0),Xe(t.x1,t.y1,t.z0),Xe(t.x1,t.y1,t.z1),Xe(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 If(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,d=r||i||l;return c&&!d?-1:d&&!c?1:0}function io(t){let e=t.length,n=t.map(c=>Rf(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 d=c+1;d<e;d++){let u=n[c],f=n[d];if(u[2]<=f[0]||f[2]<=u[0]||u[3]<=f[1]||f[3]<=u[1])continue;let p=If(t[c].box,t[d].box);p<0?(r[c].push(d),o[d]++):p>0&&(r[d].push(c),o[c]++)}let i=[],a=t.map((c,d)=>d).filter(c=>!o[c]),l=new Array(e).fill(!1);for(;i.length<e;){if(!a.length){let d=t.map((u,f)=>f).filter(u=>!l[u]).sort((u,f)=>s(t[u])-s(t[f]));a.push(d[0]),o[d[0]]=0}a.sort((d,u)=>s(t[d])-s(t[u])||d-u);let c=a.shift();if(!l[c]){l[c]=!0,i.push(t[c]);for(let d of r[c])!l[d]&&--o[d]===0&&a.push(d)}}return i}var si=Symbol.for("yaml.alias"),ri=Symbol.for("yaml.document"),Ln=Symbol.for("yaml.map"),pl=Symbol.for("yaml.pair"),xn=Symbol.for("yaml.scalar"),fs=Symbol.for("yaml.seq"),ln=Symbol.for("yaml.node.type"),Rn=t=>!!t&&typeof t=="object"&&t[ln]===si,In=t=>!!t&&typeof t=="object"&&t[ln]===ri,lt=t=>!!t&&typeof t=="object"&&t[ln]===Ln,tt=t=>!!t&&typeof t=="object"&&t[ln]===pl,He=t=>!!t&&typeof t=="object"&&t[ln]===xn,At=t=>!!t&&typeof t=="object"&&t[ln]===fs;function wt(t){if(t&&typeof t=="object")switch(t[ln]){case Ln:case fs:return!0}return!1}function mt(t){if(t&&typeof t=="object")switch(t[ln]){case si:case Ln:case xn:case fs:return!0}return!1}var oi=t=>(He(t)||wt(t))&&!!t.anchor;var pn=Symbol("break visit"),id=Symbol("skip children"),qn=Symbol("remove node");function Un(t,e){let n=ad(e);In(t)?wr(null,t.contents,n,Object.freeze([t]))===qn&&(t.contents=null):wr(null,t,n,Object.freeze([]))}Un.BREAK=pn;Un.SKIP=id;Un.REMOVE=qn;function wr(t,e,n,s){let r=ld(t,e,n,s);if(mt(r)||tt(r))return cd(t,s,r),wr(t,r,n,s);if(typeof r!="symbol"){if(wt(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=wr(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===pn)return pn;i===qn&&(e.items.splice(o,1),o-=1)}}}else if(tt(e)){s=Object.freeze(s.concat(e));let o=wr("key",e.key,n,s);if(o===pn)return pn;o===qn&&(e.key=null);let i=wr("value",e.value,n,s);if(i===pn)return pn;i===qn&&(e.value=null)}}return r}async function ii(t,e){let n=ad(e);In(t)?await vr(null,t.contents,n,Object.freeze([t]))===qn&&(t.contents=null):await vr(null,t,n,Object.freeze([]))}ii.BREAK=pn;ii.SKIP=id;ii.REMOVE=qn;async function vr(t,e,n,s){let r=await ld(t,e,n,s);if(mt(r)||tt(r))return cd(t,s,r),vr(t,r,n,s);if(typeof r!="symbol"){if(wt(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=await vr(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===pn)return pn;i===qn&&(e.items.splice(o,1),o-=1)}}}else if(tt(e)){s=Object.freeze(s.concat(e));let o=await vr("key",e.key,n,s);if(o===pn)return pn;o===qn&&(e.key=null);let i=await vr("value",e.value,n,s);if(i===pn)return pn;i===qn&&(e.value=null)}}return r}function ad(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 ld(t,e,n,s){if(typeof n=="function")return n(t,e,s);if(lt(e))return n.Map?.(t,e,s);if(At(e))return n.Seq?.(t,e,s);if(tt(e))return n.Pair?.(t,e,s);if(He(e))return n.Scalar?.(t,e,s);if(Rn(e))return n.Alias?.(t,e,s)}function cd(t,e,n){let s=e[e.length-1];if(wt(s))s.items[t]=n;else if(tt(s))t==="key"?s.key=n:s.value=n;else if(In(s))s.contents=n;else{let r=Rn(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}var Df={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ff=t=>t.replace(/[!,[\]{}]/g,e=>Df[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+Ff(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&&mt(e.contents)){let o={};Un(e.contents,(i,a)=>{mt(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 mp=Object.defineProperty;var vi=(t,e)=>{for(var n in e)mp(t,n,{get:e[n],enumerable:!0})};var Bu={};vi(Bu,{Bounds:()=>So,C:()=>Kt,DiagError:()=>ua,FONTS:()=>It,Kernel:()=>Or,S:()=>yt,VEl:()=>Yo,allowed:()=>vc,apply:()=>vo,bubble:()=>Mi,buildSvg:()=>Ho,center:()=>ki,colorRef:()=>cs,createHash:()=>ju,depthSort:()=>$o,didYouMean:()=>Us,distance:()=>xc,envelope:()=>Si,esc:()=>_t,extendTheme:()=>ca,faceFrame:()=>_l,fileLines:()=>$i,formatDiag:()=>wc,formatDiags:()=>Ou,iso:()=>Xe,keyGlyph:()=>Fd,loadTheme:()=>la,matStr:()=>ko,n1:()=>Rt,parse:()=>Nu,parseSvg:()=>kc,placeholderFace:()=>Bd,pt:()=>cr,screenFaces:()=>Lr,screenGlass:()=>Kd,serialize:()=>fa,sha256Hex:()=>Sc,socketGlyph:()=>jd,tag:()=>_e,termLines:()=>Mo,textWidth:()=>Nn,themeCss:()=>da,themeParts:()=>yc,vdoc:()=>Du});var Dd={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 yt=34,Kt=Math.cos(Math.PI/6),Xe=(t,e,n=0)=>[(t-e)*Kt*yt,(t+e)*.5*yt-n*yt],Rt=t=>{let e=Math.round(t*10)/10;return Object.is(e,-0)?"0":String(e)},cr=t=>`${Rt(t[0])},${Rt(t[1])}`,_t=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function _e(t,e={},n){let s="";for(let r in e){let o=e[r];o==null||o===!1||o===""||(s+=` ${r}="${_t(typeof o=="number"?Rt(o):o)}"`)}return n===void 0?`<${t}${s}/>`:`<${t}${s}>${n}</${t}>`}var It={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 Nn(t,e){let n=Dd[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 vo=(t,e,n)=>[t[0]*e+t[2]*n+t[4],t[1]*e+t[3]*n+t[5]],ko=t=>`matrix(${t.map(e=>Math.round(e*1e4)/1e4).join(" ")})`;function _l(t,e){if(e==="left"){let[r,o]=Xe(t.x0,t.y1,t.z1);return{m:[Kt,.5,0,1,r,o],w:(t.x1-t.x0)*yt,h:(t.z1-t.z0)*yt}}if(e==="right"){let[r,o]=Xe(t.x1,t.y1,t.z1);return{m:[Kt,-.5,0,1,r,o],w:(t.y1-t.y0)*yt,h:(t.z1-t.z0)*yt}}let[n,s]=Xe(t.x0,t.y0,t.z1);return{m:[Kt,.5,-Kt,.5,n,s],w:(t.x1-t.x0)*yt,h:(t.y1-t.y0)*yt}}var So=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}},Or=class{bounds=new So;texts=[];planes=[];planePolys=[];defs=new Map;poly(e,n,s={}){let r=e.map(o=>Xe(o[0],o[1],o[2]));return r.forEach(o=>this.bounds.add(o)),_e("polygon",{points:r.map(cr).join(" "),class:n,...s})}line3(e,n,s,r={}){let o=Xe(...e),i=Xe(...n);return this.bounds.add(o),this.bounds.add(i),_e("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=_l(e,n);for(let[i,a]of[[0,0],[o.w,0],[0,o.h],[o.w,o.h]])this.bounds.add(vo(o.m,i,a));return _e("g",{class:r,transform:ko(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(vo(e,i,a));return _e("g",{class:o,transform:ko(e)},r(n,s))}text(e,n,s,r,o,i="middle",a={},l){let c=Nn(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),_e("text",{x:e,y:n,class:r,"text-anchor":i==="start"?void 0:i,...a},_t(s))}planeText(e,n,s,r,o="start",i={}){let a=Nn(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(([f,p])=>vo(e,f,p));c.forEach(f=>this.bounds.add(f));let d=c.map(f=>f[0]),u=c.map(f=>f[1]);return this.planePolys.push([c[0],c[1],c[3],c[2]]),this.planes.push({x:Math.min(...d),y:Math.min(...u),w:Math.max(...d)-Math.min(...d),h:Math.max(...u)-Math.min(...u)}),_e("text",{transform:ko(e),class:s,"text-anchor":o==="start"?void 0:o,...i},_t(n))}floorText(e,n,s,r,o,i="x",a="start",l={}){let[c,d]=Xe(e,n,s),u=i==="x"?[Kt,.5,-Kt,.5,c,d]:[Kt,-.5,Kt,.5,c,d];return this.planeText(u,r,o,It.floor,a,l)}faceText(e,n,s,r,o,i,a="left",l="start",c={}){let[d,u]=Xe(e,n,s),f=a==="left"?[Kt,.5,0,1,d,u]:[Kt,-.5,0,1,d,u];return this.planeText(f,r,o,i,l,c)}def(e,n){this.defs.set(e,n)}},ki=t=>[(t.x0+t.x1)/2,(t.y0+t.y1)/2,t.z1];function Mo(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 Si(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 Mi(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 $i(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 Fd(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 jd(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 dr=(t,e,n,s,r,o=0)=>_e("rect",{class:t,x:e,y:n,width:s,height:r,rx:o||void 0}),Lr={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+=_e("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 dr(s[2],i,8+r*(e-18)/4,o,(e-18)/4-4,3)}).join("")},desktop(t,e){return dr("wall",5,5,t-10,e-10,2)+dr("bar",5,5,t-10,6)+dr("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 d=0;d<3;d++){let u=6+d*(i+2.5),f=6+c*(a+2.5);l+=dr("t",u,f,i,a,1.5),[.3,.52,.74].forEach((p,g)=>{l+=_e("line",{class:"ln",x1:u+2.5,y1:f+a*p,x2:u+2.5+(i-5)*[.8,.5,.65][(g+c+d)%3],y2:f+a*p})})}return l}};function Bd(t,e){let n=t/2,s=e/2,r=Math.min(t,e)*.22;return dr("unk",t*.2,e*.2,t*.6,e*.6,2)+_e("path",{class:"unk-q",d:`M${Rt(n-r*.5)},${Rt(s-r*.45)}a${Rt(r*.5)},${Rt(r*.5)} 0 1 1 ${Rt(r*.5)},${Rt(r*.55)}v${Rt(r*.3)}`})+_e("circle",{class:"unk-dot",cx:Rt(n),cy:Rt(s+r*.75),r:Rt(Math.max(.8,r*.1))})}function Kd(t,e){return dr("glass",3,3,t-6,e-6,3)}function bp(t){let e=[Xe(t.x0,t.y0,t.z1),Xe(t.x1,t.y0,t.z0),Xe(t.x0,t.y1,t.z0),Xe(t.x1,t.y1,t.z0),Xe(t.x1,t.y1,t.z1),Xe(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 yp(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,d=r||i||l;return c&&!d?-1:d&&!c?1:0}function $o(t){let e=t.length,n=t.map(c=>bp(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 d=c+1;d<e;d++){let u=n[c],f=n[d];if(u[2]<=f[0]||f[2]<=u[0]||u[3]<=f[1]||f[3]<=u[1])continue;let p=yp(t[c].box,t[d].box);p<0?(r[c].push(d),o[d]++):p>0&&(r[d].push(c),o[c]++)}let i=[],a=t.map((c,d)=>d).filter(c=>!o[c]),l=new Array(e).fill(!1);for(;i.length<e;){if(!a.length){let d=t.map((u,f)=>f).filter(u=>!l[u]).sort((u,f)=>s(t[u])-s(t[f]));a.push(d[0]),o[d[0]]=0}a.sort((d,u)=>s(t[d])-s(t[u])||d-u);let c=a.shift();if(!l[c]){l[c]=!0,i.push(t[c]);for(let d of r[c])!l[d]&&--o[d]===0&&a.push(d)}}return i}var Ei=Symbol.for("yaml.alias"),Ti=Symbol.for("yaml.document"),Gn=Symbol.for("yaml.map"),zl=Symbol.for("yaml.pair"),Tn=Symbol.for("yaml.scalar"),ks=Symbol.for("yaml.seq"),gn=Symbol.for("yaml.node.type"),Hn=t=>!!t&&typeof t=="object"&&t[gn]===Ei,Yn=t=>!!t&&typeof t=="object"&&t[gn]===Ti,ct=t=>!!t&&typeof t=="object"&&t[gn]===Gn,st=t=>!!t&&typeof t=="object"&&t[gn]===zl,Ge=t=>!!t&&typeof t=="object"&&t[gn]===Tn,Lt=t=>!!t&&typeof t=="object"&&t[gn]===ks;function kt(t){if(t&&typeof t=="object")switch(t[gn]){case Gn:case ks:return!0}return!1}function gt(t){if(t&&typeof t=="object")switch(t[gn]){case Ei:case Gn:case Tn:case ks:return!0}return!1}var Ai=t=>(Ge(t)||kt(t))&&!!t.anchor;var vn=Symbol("break visit"),_d=Symbol("skip children"),ss=Symbol("remove node");function rs(t,e){let n=zd(e);Yn(t)?Nr(null,t.contents,n,Object.freeze([t]))===ss&&(t.contents=null):Nr(null,t,n,Object.freeze([]))}rs.BREAK=vn;rs.SKIP=_d;rs.REMOVE=ss;function Nr(t,e,n,s){let r=Vd(t,e,n,s);if(gt(r)||st(r))return Gd(t,s,r),Nr(t,r,n,s);if(typeof r!="symbol"){if(kt(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=Nr(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===vn)return vn;i===ss&&(e.items.splice(o,1),o-=1)}}}else if(st(e)){s=Object.freeze(s.concat(e));let o=Nr("key",e.key,n,s);if(o===vn)return vn;o===ss&&(e.key=null);let i=Nr("value",e.value,n,s);if(i===vn)return vn;i===ss&&(e.value=null)}}return r}async function Pi(t,e){let n=zd(e);Yn(t)?await Rr(null,t.contents,n,Object.freeze([t]))===ss&&(t.contents=null):await Rr(null,t,n,Object.freeze([]))}Pi.BREAK=vn;Pi.SKIP=_d;Pi.REMOVE=ss;async function Rr(t,e,n,s){let r=await Vd(t,e,n,s);if(gt(r)||st(r))return Gd(t,s,r),Rr(t,r,n,s);if(typeof r!="symbol"){if(kt(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=await Rr(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===vn)return vn;i===ss&&(e.items.splice(o,1),o-=1)}}}else if(st(e)){s=Object.freeze(s.concat(e));let o=await Rr("key",e.key,n,s);if(o===vn)return vn;o===ss&&(e.key=null);let i=await Rr("value",e.value,n,s);if(i===vn)return vn;i===ss&&(e.value=null)}}return r}function zd(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 Vd(t,e,n,s){if(typeof n=="function")return n(t,e,s);if(ct(e))return n.Map?.(t,e,s);if(Lt(e))return n.Seq?.(t,e,s);if(st(e))return n.Pair?.(t,e,s);if(Ge(e))return n.Scalar?.(t,e,s);if(Hn(e))return n.Alias?.(t,e,s)}function Gd(t,e,n){let s=e[e.length-1];if(kt(s))s.items[t]=n;else if(st(s))t==="key"?s.key=n:s.value=n;else if(Yn(s))s.contents=n;else{let r=Hn(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}var xp={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},wp=t=>t.replace(/[!,[\]{}]/g,e=>xp[e]),os=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+wp(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&>(e.contents)){let o={};rs(e.contents,(i,a)=>{gt(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
|
+
`)}};os.defaultYaml={explicit:!1,version:"1.2"};os.defaultTags={"!!":"tag:yaml.org,2002:"};function Ci(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function Vl(t){let e=new Set;return rs(t,{Value(n,s){s.anchor&&e.add(s.anchor)}}),e}function Gl(t,e){for(let n=1;;++n){let s=`${t}${n}`;if(!e.has(s))return s}}function Hd(t,e){let n=[],s=new Map,r=null;return{onAnchor:o=>{n.push(o),r??(r=Vl(t));let i=Gl(e,r);return r.add(i),i},setAnchors:()=>{for(let o of n){let i=s.get(o);if(typeof i=="object"&&i.anchor&&(Ge(i.node)||kt(i.node)))i.node.anchor=i.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:s}}function zs(t,e,n,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let r=0,o=s.length;r<o;++r){let i=s[r],a=zs(t,s,String(r),i);a===void 0?delete s[r]:a!==i&&(s[r]=a)}else if(s instanceof Map)for(let r of Array.from(s.keys())){let o=s.get(r),i=zs(t,s,r,o);i===void 0?s.delete(r):i!==o&&s.set(r,i)}else if(s instanceof Set)for(let r of Array.from(s)){let o=zs(t,s,r,r);o===void 0?s.delete(r):o!==r&&(s.delete(r),s.add(o))}else for(let[r,o]of Object.entries(s)){let i=zs(t,s,r,o);i===void 0?delete s[r]:i!==o&&(s[r]=i)}return t.call(e,n,s)}function tn(t,e,n){if(Array.isArray(t))return t.map((s,r)=>tn(s,String(r),n));if(t&&typeof t.toJSON=="function"){if(!n||!Ai(t))return t.toJSON(e,n);let s={aliasCount:0,count:1,res:void 0};n.anchors.set(t,s),n.onCreate=o=>{s.res=o,delete n.onCreate};let r=t.toJSON(e,n);return n.onCreate&&n.onCreate(r),r}return typeof t=="bigint"&&!n?.keep?Number(t):t}var Vs=class{constructor(e){Object.defineProperty(this,gn,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:s,onAnchor:r,reviver:o}={}){if(!Yn(e))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},a=tn(this,"",i);if(typeof r=="function")for(let{count:l,res:c}of i.anchors.values())r(c,l);return typeof o=="function"?zs(o,{"":a},"",a):a}};var Ss=class extends Vs{constructor(e){super(Ei),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let s;n?.aliasResolveCache?s=n.aliasResolveCache:(s=[],rs(e,{Node:(o,i)=>{(Hn(i)||Ai(i))&&s.push(i)}}),n&&(n.aliasResolveCache=s));let r;for(let o of s){if(o===this)break;o.anchor===this.source&&(r=o)}if(r&&n){let{anchors:o,doc:i,maxAliasCount:a}=n,l=o.get(r);if(l||(tn(r,null,n),l=o.get(r)),l?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=Oi(i,r,o)),l.count*l.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}}return r}toJSON(e,n){if(!n)return{source:this.source};let s=this.resolve(n.doc,n);if(!s){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(r)}return n.anchors.get(s).res}toString(e,n,s){let r=`*${this.source}`;if(e){if(Ci(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 Oi(t,e,n){if(Hn(e)){let s=e.resolve(t),r=n&&s&&n.get(s);return r?r.count*r.aliasCount:0}else if(kt(e)){let s=0;for(let r of e.items){let o=Oi(t,r,n);o>s&&(s=o)}return s}else if(st(e)){let s=Oi(t,e.key,n),r=Oi(t,e.value,n);return Math.max(s,r)}return 1}var Li=t=>!t||typeof t!="function"&&typeof t!="object",Be=class extends Vs{constructor(e){super(Tn),this.value=e}toJSON(e,n){return n?.keep?this.value:tn(this.value,e,n)}toString(){return String(this.value)}};Be.BLOCK_FOLDED="BLOCK_FOLDED";Be.BLOCK_LITERAL="BLOCK_LITERAL";Be.PLAIN="PLAIN";Be.QUOTE_DOUBLE="QUOTE_DOUBLE";Be.QUOTE_SINGLE="QUOTE_SINGLE";var vp="tag:yaml.org,2002:";function kp(t,e,n){if(e){let s=n.filter(o=>o.tag===e),r=s.find(o=>!o.format)??s[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return n.find(s=>s.identify?.(t)&&!s.format)}function Ms(t,e,n){if(Yn(t)&&(t=t.contents),gt(t))return t;if(st(t)){let u=n.schema[Gn].createNode?.(n.schema,null,n);return u.items.push(t),u}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:s,onAnchor:r,onTagObj:o,schema:i,sourceObjects:a}=n,l;if(s&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=r(t)),new Ss(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=vp+e.slice(2));let c=kp(t,e,i.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new Be(t);return l&&(l.node=u),u}c=t instanceof Map?i[Gn]:Symbol.iterator in Object(t)?i[ks]:i[Gn]}o&&(o(c),delete n.onTagObj);let d=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new Be(t);return e?d.tag=e:c.default||(d.tag=c.tag),l&&(l.node=d),d}function Eo(t,e,n){let s=n;for(let r=e.length-1;r>=0;--r){let o=e[r];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let i=[];i[o]=s,s=i}else s=new Map([[o,s]])}return Ms(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Dr=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Ir=class extends Vs{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(s=>gt(s)||st(s)?s.clone(e):s),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(Dr(e))this.add(n);else{let[s,...r]=e,o=this.get(s,!0);if(kt(o))o.addIn(r,n);else if(o===void 0&&this.schema)this.set(s,Eo(this.schema,r,n));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}deleteIn(e){let[n,...s]=e;if(s.length===0)return this.delete(n);let r=this.get(n,!0);if(kt(r))return r.deleteIn(s);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}getIn(e,n){let[s,...r]=e,o=this.get(s,!0);return r.length===0?!n&&Ge(o)?o.value:o:kt(o)?o.getIn(r,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!st(n))return!1;let s=n.value;return s==null||e&&Ge(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){let[n,...s]=e;if(s.length===0)return this.has(n);let r=this.get(n,!0);return kt(r)?r.hasIn(s):!1}setIn(e,n){let[s,...r]=e;if(r.length===0)this.set(s,n);else{let o=this.get(s,!0);if(kt(o))o.setIn(r,n);else if(o===void 0&&this.schema)this.set(s,Eo(this.schema,r,n));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}};var Yd=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Rn(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var is=(t,e,n)=>t.endsWith(`
|
|
3
|
+
`)?Rn(n,e):n.includes(`
|
|
4
4
|
`)?`
|
|
5
|
-
`+
|
|
6
|
-
`)n===
|
|
7
|
-
`&&p!==" "){let
|
|
8
|
-
`&&
|
|
9
|
-
${e}${t.slice(0,
|
|
10
|
-
${e}${t.slice(
|
|
11
|
-
`);s=e,r=e+1,o=t[r]}return s}var
|
|
12
|
-
`){if(o-i>s)return!0;if(i=o+1,r-i<=s)return!1}return!0}function
|
|
5
|
+
`+Rn(n,e):(t.endsWith(" ")?"":" ")+n;var Hl="flow",Ni="block",To="quoted";function Ao(t,e,n="flow",{indentAtStart:s,lineWidth:r=80,minContentWidth:o=20,onFold:i,onOverflow:a}={}){if(!r||r<0)return t;r<o&&(o=0);let l=Math.max(1+o,1+r-e.length);if(t.length<=l)return t;let c=[],d={},u=r-e.length;typeof s=="number"&&(s>r-Math.max(2,o)?c.push(0):u=r-s);let f,p,g=!1,h=-1,b=-1,v=-1;n===Ni&&(h=qd(t,h,e.length),h!==-1&&(u=h+l));for(let k;k=t[h+=1];){if(n===To&&k==="\\"){switch(b=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}v=h}if(k===`
|
|
6
|
+
`)n===Ni&&(h=qd(t,h,e.length)),u=h+e.length+l,f=void 0;else{if(k===" "&&p&&p!==" "&&p!==`
|
|
7
|
+
`&&p!==" "){let y=t[h+1];y&&y!==" "&&y!==`
|
|
8
|
+
`&&y!==" "&&(f=h)}if(h>=u)if(f)c.push(f),u=f+l,f=void 0;else if(n===To){for(;p===" "||p===" ";)p=k,k=t[h+=1],g=!0;let y=h>v+1?h-2:b-1;if(d[y])return t;c.push(y),d[y]=!0,u=y+l,f=void 0}else g=!0}p=k}if(g&&a&&a(),c.length===0)return t;i&&i();let w=t.slice(0,c[0]);for(let k=0;k<c.length;++k){let y=c[k],M=c[k+1]||t.length;y===0?w=`
|
|
9
|
+
${e}${t.slice(0,M)}`:(n===To&&d[y]&&(w+=`${t[y]}\\`),w+=`
|
|
10
|
+
${e}${t.slice(y+1,M)}`)}return w}function qd(t,e,n){let s=e,r=e+1,o=t[r];for(;o===" "||o===" ";)if(e<r+n)o=t[++e];else{do o=t[++e];while(o&&o!==`
|
|
11
|
+
`);s=e,r=e+1,o=t[r]}return s}var Ii=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Di=t=>/^(%|---|\.\.\.)/m.test(t);function Sp(t,e,n){if(!e||e<0)return!1;let s=e-n,r=t.length;if(r<=s)return!1;for(let o=0,i=0;o<r;++o)if(t[o]===`
|
|
12
|
+
`){if(o-i>s)return!0;if(i=o+1,r-i<=s)return!1}return!0}function Po(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:s}=e,r=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Di(t)?" ":""),i="",a=0;for(let l=0,c=n[l];c;c=n[++l])if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n"&&(i+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(n[l+1]){case"u":{i+=n.slice(a,l);let d=n.substr(l+2,4);switch(d){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:d.substr(0,2)==="00"?i+="\\x"+d.substr(2):i+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(s||n[l+2]==='"'||n.length<r)l+=1;else{for(i+=n.slice(a,l)+`
|
|
13
13
|
|
|
14
14
|
`;n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"';)i+=`
|
|
15
|
-
`,l+=2;i+=o,n[l+2]===" "&&(i+="\\"),l+=1,a=l+1}break;default:l+=1}return i=a?i+n.slice(a):n,s?i:
|
|
16
|
-
`)||/[ \t]\n|\n[ \t]/.test(t))return
|
|
17
|
-
${n}`)+"'";return e.implicitKey?s:
|
|
15
|
+
`,l+=2;i+=o,n[l+2]===" "&&(i+="\\"),l+=1,a=l+1}break;default:l+=1}return i=a?i+n.slice(a):n,s?i:Ao(i,o,To,Ii(e,!1))}function Yl(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
16
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return Po(t,e);let n=e.indent||(Di(t)?" ":""),s="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
17
|
+
${n}`)+"'";return e.implicitKey?s:Ao(s,n,Hl,Ii(e,!1))}function Fr(t,e){let{singleQuote:n}=e.options,s;if(n===!1)s=Po;else{let r=t.includes('"'),o=t.includes("'");r&&!o?s=Yl:o&&!r?s=Po:s=n?Yl:Po}return s(t,e)}var ql;try{ql=new RegExp(`(^|(?<!
|
|
18
18
|
))
|
|
19
19
|
+(?!
|
|
20
|
-
|$)`,"g")}catch{
|
|
20
|
+
|$)`,"g")}catch{ql=/\n+(?!\n|$)/g}function Ri({comment:t,type:e,value:n},s,r,o){let{blockQuote:i,commentString:a,lineWidth:l}=s.options;if(!i||/\n[\t ]+$/.test(n))return Fr(n,s);let c=s.indent||(s.forceBlockIndent||Di(n)?" ":""),d=i==="literal"?!0:i==="folded"||e===Be.BLOCK_FOLDED?!1:e===Be.BLOCK_LITERAL?!0:!Sp(n,l,c.length);if(!n)return d?`|
|
|
21
21
|
`:`>
|
|
22
|
-
`;let u,f;for(f=n.length;f>0;--f){let
|
|
23
|
-
`&&
|
|
22
|
+
`;let u,f;for(f=n.length;f>0;--f){let M=n[f-1];if(M!==`
|
|
23
|
+
`&&M!==" "&&M!==" ")break}let p=n.substring(f),g=p.indexOf(`
|
|
24
24
|
`);g===-1?u="-":n===p||g!==p.length-1?(u="+",o&&o()):u="",p&&(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
25
|
-
`&&(p=p.slice(0,-1)),p=p.replace(
|
|
26
|
-
`)
|
|
27
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),
|
|
28
|
-
${c}${
|
|
29
|
-
${c}${
|
|
30
|
-
`)||d&&/[[\]{},]/.test(o))return
|
|
31
|
-
`)?
|
|
32
|
-
`))return
|
|
33
|
-
${l}`);if(i){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:g}=e.doc.schema;if(g.some(f)||p?.some(f))return
|
|
34
|
-
${e.indent}${a}`:a}function
|
|
35
|
-
${a}:`):(b=`${b}:`,f&&(b+=
|
|
36
|
-
`:"",
|
|
37
|
-
${
|
|
38
|
-
`&&
|
|
25
|
+
`&&(p=p.slice(0,-1)),p=p.replace(ql,`$&${c}`));let h=!1,b,v=-1;for(b=0;b<n.length;++b){let M=n[b];if(M===" ")h=!0;else if(M===`
|
|
26
|
+
`)v=b;else break}let w=n.substring(0,v<b?v+1:b);w&&(n=n.substring(w.length),w=w.replace(/\n+/g,`$&${c}`));let y=(h?c?"2":"1":"")+u;if(t&&(y+=" "+a(t.replace(/ ?[\r\n]+/g," ")),r&&r()),!d){let M=n.replace(/\n+/g,`
|
|
27
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),T=!1,A=Ii(s,!0);i!=="folded"&&e!==Be.BLOCK_FOLDED&&(A.onOverflow=()=>{T=!0});let I=Ao(`${w}${M}${p}`,c,Ni,A);if(!T)return`>${y}
|
|
28
|
+
${c}${I}`}return n=n.replace(/\n+/g,`$&${c}`),`|${y}
|
|
29
|
+
${c}${w}${n}${p}`}function Mp(t,e,n,s){let{type:r,value:o}=t,{actualString:i,implicitKey:a,indent:l,indentStep:c,inFlow:d}=e;if(a&&o.includes(`
|
|
30
|
+
`)||d&&/[[\]{},]/.test(o))return Fr(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||d||!o.includes(`
|
|
31
|
+
`)?Fr(o,e):Ri(t,e,n,s);if(!a&&!d&&r!==Be.PLAIN&&o.includes(`
|
|
32
|
+
`))return Ri(t,e,n,s);if(Di(o)){if(l==="")return e.forceBlockIndent=!0,Ri(t,e,n,s);if(a&&l===c)return Fr(o,e)}let u=o.replace(/\n+/g,`$&
|
|
33
|
+
${l}`);if(i){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:g}=e.doc.schema;if(g.some(f)||p?.some(f))return Fr(o,e)}return a?u:Ao(u,l,Hl,Ii(e,!1))}function ur(t,e,n,s){let{implicitKey:r,inFlow:o}=e,i=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==Be.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(a=Be.QUOTE_DOUBLE);let l=d=>{switch(d){case Be.BLOCK_FOLDED:case Be.BLOCK_LITERAL:return r||o?Fr(i.value,e):Ri(i,e,n,s);case Be.QUOTE_DOUBLE:return Po(i.value,e);case Be.QUOTE_SINGLE:return Yl(i.value,e);case Be.PLAIN:return Mp(i,e,n,s);default:return null}},c=l(a);if(c===null){let{defaultKeyType:d,defaultStringType:u}=e.options,f=r&&d||u;if(c=l(f),c===null)throw new Error(`Unsupported default string type ${f}`)}return c}function Fi(t,e){let n=Object.assign({blockQuote:!0,commentString:Yd,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),s;switch(n.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:s,options:n}}function $p(t,e){if(e.tag){let r=t.filter(o=>o.tag===e.tag);if(r.length>0)return r.find(o=>o.format===e.format)??r[0]}let n,s;if(Ge(e)){s=e.value;let r=t.filter(o=>o.identify?.(s));if(r.length>1){let o=r.filter(i=>i.test);o.length>0&&(r=o)}n=r.find(o=>o.format===e.format)??r.find(o=>!o.format)}else s=e,n=t.find(r=>r.nodeClass&&s instanceof r.nodeClass);if(!n){let r=s?.constructor?.name??(s===null?"null":typeof s);throw new Error(`Tag not resolved for ${r} value`)}return n}function Ep(t,e,{anchors:n,doc:s}){if(!s.directives)return"";let r=[],o=(Ge(t)||kt(t))&&t.anchor;o&&Ci(o)&&(n.add(o),r.push(`&${o}`));let i=t.tag??(e.default?null:e.tag);return i&&r.push(s.directives.tagString(i)),r.join(" ")}function $s(t,e,n,s){if(st(t))return t.toString(e,n,s);if(Hn(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let r,o=gt(t)?t:e.doc.createNode(t,{onTagObj:l=>r=l});r??(r=$p(e.doc.schema.tags,o));let i=Ep(o,r,e);i.length>0&&(e.indentAtStart=(e.indentAtStart??0)+i.length+1);let a=typeof r.stringify=="function"?r.stringify(o,e,n,s):Ge(o)?ur(o,e,n,s):o.toString(e,n,s);return i?Ge(o)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
|
|
34
|
+
${e.indent}${a}`:a}function Ud({key:t,value:e},n,s,r){let{allNullValues:o,doc:i,indent:a,indentStep:l,options:{commentString:c,indentSeq:d,simpleKeys:u}}=n,f=gt(t)&&t.comment||null;if(u){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(kt(t)||!gt(t)&&typeof t=="object"){let A="With simple keys, collection cannot be used as a key value";throw new Error(A)}}let p=!u&&(!t||f&&e==null&&!n.inFlow||kt(t)||(Ge(t)?t.type===Be.BLOCK_FOLDED||t.type===Be.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(u||!o),indent:a+l});let g=!1,h=!1,b=$s(t,n,()=>g=!0,()=>h=!0);if(!p&&!n.inFlow&&b.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(o||e==null)return g&&s&&s(),b===""?"?":p?`? ${b}`:b}else if(o&&!u||e==null&&p)return b=`? ${b}`,f&&!g?b+=is(b,n.indent,c(f)):h&&r&&r(),b;g&&(f=null),p?(f&&(b+=is(b,n.indent,c(f))),b=`? ${b}
|
|
35
|
+
${a}:`):(b=`${b}:`,f&&(b+=is(b,n.indent,c(f))));let v,w,k;gt(e)?(v=!!e.spaceBefore,w=e.commentBefore,k=e.comment):(v=!1,w=null,k=null,e&&typeof e=="object"&&(e=i.createNode(e))),n.implicitKey=!1,!p&&!f&&Ge(e)&&(n.indentAtStart=b.length+1),h=!1,!d&&l.length>=2&&!n.inFlow&&!p&&Lt(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let y=!1,M=$s(e,n,()=>y=!0,()=>h=!0),T=" ";if(f||v||w){if(T=v?`
|
|
36
|
+
`:"",w){let A=c(w);T+=`
|
|
37
|
+
${Rn(A,n.indent)}`}M===""&&!n.inFlow?T===`
|
|
38
|
+
`&&k&&(T=`
|
|
39
39
|
|
|
40
|
-
`):
|
|
41
|
-
${n.indent}`}else if(!p&&
|
|
42
|
-
`),
|
|
43
|
-
${n.indent}`)}}else(
|
|
44
|
-
`)&&(
|
|
40
|
+
`):T+=`
|
|
41
|
+
${n.indent}`}else if(!p&&kt(e)){let A=M[0],I=M.indexOf(`
|
|
42
|
+
`),j=I!==-1,L=n.inFlow??e.flow??e.items.length===0;if(j||!L){let B=!1;if(j&&(A==="&"||A==="!")){let S=M.indexOf(" ");A==="&"&&S!==-1&&S<I&&M[S+1]==="!"&&(S=M.indexOf(" ",S+1)),(S===-1||I<S)&&(B=!0)}B||(T=`
|
|
43
|
+
${n.indent}`)}}else(M===""||M[0]===`
|
|
44
|
+
`)&&(T="");return b+=T+M,n.inFlow?y&&s&&s():k&&!y?b+=is(b,n.indent,c(k)):h&&r&&r(),b}function ji(t,e){(t==="debug"||t==="warn")&&console.warn(e)}var Bi="<<",qn={identify:t=>t===Bi||typeof t=="symbol"&&t.description===Bi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Be(Symbol(Bi)),{addToJSMap:Wl}),stringify:()=>Bi},Wd=(t,e)=>(qn.identify(e)||Ge(e)&&(!e.type||e.type===Be.PLAIN)&&qn.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===qn.tag&&n.default);function Wl(t,e,n){let s=Jd(t,n);if(Lt(s))for(let r of s.items)Ul(t,e,r);else if(Array.isArray(s))for(let r of s)Ul(t,e,r);else Ul(t,e,s)}function Ul(t,e,n){let s=Jd(t,n);if(!ct(s))throw new Error("Merge sources must be maps or map aliases");let r=s.toJSON(null,t,Map);for(let[o,i]of r)e instanceof Map?e.has(o)||e.set(o,i):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0});return e}function Jd(t,e){return t&&Hn(e)?e.resolve(t.doc,t):e}function Ki(t,e,{key:n,value:s}){if(gt(n)&&n.addToJSMap)n.addToJSMap(t,e,s);else if(Wd(t,n))Wl(t,e,s);else{let r=tn(n,"",t);if(e instanceof Map)e.set(r,tn(s,r,t));else if(e instanceof Set)e.add(r);else{let o=Tp(n,r,t),i=tn(s,o,t);o in e?Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):e[o]=i}}return e}function Tp(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(gt(t)&&n?.doc){let s=Fi(n.doc,{});s.anchors=new Set;for(let o of n.anchors.keys())s.anchors.add(o.anchor);s.inFlow=!0,s.inStringifyKey=!0;let r=t.toString(s);if(!n.mapKeyWarned){let o=JSON.stringify(r);o.length>40&&(o=o.substring(0,36)+'..."'),ji(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(e)}function jr(t,e,n){let s=Ms(t,void 0,n),r=Ms(e,void 0,n);return new Yt(s,r)}var Yt=class t{constructor(e,n=null){Object.defineProperty(this,gn,{value:zl}),this.key=e,this.value=n}clone(e){let{key:n,value:s}=this;return gt(n)&&(n=n.clone(e)),gt(s)&&(s=s.clone(e)),new t(n,s)}toJSON(e,n){let s=n?.mapAsMap?new Map:{};return Ki(n,s,this)}toString(e,n,s){return e?.doc?Ud(this,e,n,s):JSON.stringify(this)}};function zi(t,e,n){return(e.inFlow??t.flow?Pp:Ap)(t,e,n)}function Ap({comment:t,items:e},n,{blockItemPrefix:s,flowChars:r,itemIndent:o,onChompKeep:i,onComment:a}){let{indent:l,options:{commentString:c}}=n,d=Object.assign({},n,{indent:o,type:null}),u=!1,f=[];for(let g=0;g<e.length;++g){let h=e[g],b=null;if(gt(h))!u&&h.spaceBefore&&f.push(""),_i(n,f,h.commentBefore,u),h.comment&&(b=h.comment);else if(st(h)){let w=gt(h.key)?h.key:null;w&&(!u&&w.spaceBefore&&f.push(""),_i(n,f,w.commentBefore,u))}u=!1;let v=$s(h,d,()=>b=null,()=>u=!0);b&&(v+=is(v,o,c(b))),u&&b&&(u=!1),f.push(s+v)}let p;if(f.length===0)p=r.start+r.end;else{p=f[0];for(let g=1;g<f.length;++g){let h=f[g];p+=h?`
|
|
45
45
|
${l}${h}`:`
|
|
46
46
|
`}}return t?(p+=`
|
|
47
|
-
`+
|
|
48
|
-
`)),g<t.length-1?
|
|
47
|
+
`+Rn(c(t),l),a&&a()):u&&i&&i(),p}function Pp({items:t},e,{flowChars:n,itemIndent:s}){let{indent:r,indentStep:o,flowCollectionPadding:i,options:{commentString:a}}=e;s+=o;let l=Object.assign({},e,{indent:s,inFlow:!0,type:null}),c=!1,d=0,u=[];for(let g=0;g<t.length;++g){let h=t[g],b=null;if(gt(h))h.spaceBefore&&u.push(""),_i(e,u,h.commentBefore,!1),h.comment&&(b=h.comment);else if(st(h)){let w=gt(h.key)?h.key:null;w&&(w.spaceBefore&&u.push(""),_i(e,u,w.commentBefore,!1),w.comment&&(c=!0));let k=gt(h.value)?h.value:null;k?(k.comment&&(b=k.comment),k.commentBefore&&(c=!0)):h.value==null&&w?.comment&&(b=w.comment)}b&&(c=!0);let v=$s(h,l,()=>b=null);c||(c=u.length>d||v.includes(`
|
|
48
|
+
`)),g<t.length-1?v+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(c||(c=u.reduce((w,k)=>w+k.length+2,2)+(v.length+2)>e.options.lineWidth)),c&&(v+=",")),b&&(v+=is(v,s,a(b))),u.push(v),d=u.length}let{start:f,end:p}=n;if(u.length===0)return f+p;if(!c){let g=u.reduce((h,b)=>h+b.length+2,2);c=e.options.lineWidth>0&&g>e.options.lineWidth}if(c){let g=f;for(let h of u)g+=h?`
|
|
49
49
|
${o}${r}${h}`:`
|
|
50
50
|
`;return`${g}
|
|
51
|
-
${r}${p}`}else return`${f}${i}${u.join(" ")}${i}${p}`}function
|
|
52
|
-
`:" ")}return
|
|
51
|
+
${r}${p}`}else return`${f}${i}${u.join(" ")}${i}${p}`}function _i({indent:t,options:{commentString:e}},n,s,r){if(s&&r&&(s=s.replace(/^\n+/,"")),s){let o=Rn(e(s),t);n.push(o.trimStart())}}function Gs(t,e){let n=Ge(e)?e.value:e;for(let s of t)if(st(s)&&(s.key===e||s.key===n||Ge(s.key)&&s.key.value===n))return s}var Xt=class extends Ir{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Gn,e),this.items=[]}static from(e,n,s){let{keepUndefined:r,replacer:o}=s,i=new this(e),a=(l,c)=>{if(typeof o=="function")c=o.call(n,l,c);else if(Array.isArray(o)&&!o.includes(l))return;(c!==void 0||r)&&i.items.push(jr(l,c,s))};if(n instanceof Map)for(let[l,c]of n)a(l,c);else if(n&&typeof n=="object")for(let l of Object.keys(n))a(l,n[l]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,n){let s;st(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=Gs(this.items,s.key),o=this.schema?.sortMapEntries;if(r){if(!n)throw new Error(`Key ${s.key} already set`);Ge(r.value)&&Li(s.value)?r.value.value=s.value:r.value=s.value}else if(o){let i=this.items.findIndex(a=>o(s,a)<0);i===-1?this.items.push(s):this.items.splice(i,0,s)}else this.items.push(s)}delete(e){let n=Gs(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let r=Gs(this.items,e)?.value;return(!n&&Ge(r)?r.value:r)??void 0}has(e){return!!Gs(this.items,e)}set(e,n){this.add(new Yt(e,n),!0)}toJSON(e,n,s){let r=s?new s:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(r);for(let o of this.items)Ki(n,r,o);return r}toString(e,n,s){if(!e)return JSON.stringify(this);for(let r of this.items)if(!st(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})),zi(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:n})}};var Un={collection:"map",default:!0,nodeClass:Xt,tag:"tag:yaml.org,2002:map",resolve(t,e){return ct(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>Xt.from(t,e,n)};var an=class extends Ir{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ks,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=Vi(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let s=Vi(e);if(typeof s!="number")return;let r=this.items[s];return!n&&Ge(r)?r.value:r}has(e){let n=Vi(e);return typeof n=="number"&&n<this.items.length}set(e,n){let s=Vi(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);let r=this.items[s];Ge(r)&&Li(n)?r.value=n:this.items[s]=n}toJSON(e,n){let s=[];n?.onCreate&&n.onCreate(s);let r=0;for(let o of this.items)s.push(tn(o,String(r++),n));return s}toString(e,n,s){return e?zi(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:n}):JSON.stringify(this)}static from(e,n,s){let{replacer:r}=s,o=new this(e);if(n&&Symbol.iterator in Object(n)){let i=0;for(let a of n){if(typeof r=="function"){let l=n instanceof Set?a:String(i++);a=r.call(n,l,a)}o.items.push(Ms(a,void 0,s))}}return o}};function Vi(t){let e=Ge(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}var Wn={collection:"seq",default:!0,nodeClass:an,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Lt(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>an.from(t,e,n)};var Hs={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,s){return e=Object.assign({actualString:!0},e),ur(t,e,n,s)}};var fr={identify:t=>t==null,createNode:()=>new Be(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Be(null),stringify:({source:t},e)=>typeof t=="string"&&fr.test.test(t)?t:e.options.nullStr};var Co={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Be(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Co.test.test(t)){let s=t[0]==="t"||t[0]==="T";if(e===s)return t}return e?n.options.trueStr:n.options.falseStr}};function ln({format:t,minFractionDigits:e,tag:n,value:s}){if(typeof s=="bigint")return String(s);let r=typeof s=="number"?s:Number(s);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let o=Object.is(s,-0)?"-0":JSON.stringify(s);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let i=o.indexOf(".");i<0&&(i=o.length,o+=".");let a=e-(o.length-i-1);for(;a-- >0;)o+="0"}return o}var Gi={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:ln},Hi={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():ln(t)}},Yi={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new Be(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:ln};var qi=t=>typeof t=="bigint"||Number.isInteger(t),Jl=(t,e,n,{intAsBigInt:s})=>s?BigInt(t):parseInt(t.substring(e),n);function Xd(t,e,n){let{value:s}=t;return qi(s)&&s>=0?n+s.toString(e):ln(t)}var Ui={identify:t=>qi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Jl(t,2,8,n),stringify:t=>Xd(t,8,"0o")},Wi={identify:qi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Jl(t,0,10,n),stringify:ln},Ji={identify:t=>qi(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Jl(t,2,16,n),stringify:t=>Xd(t,16,"0x")};var Qd=[Un,Wn,Hs,fr,Co,Ui,Wi,Ji,Gi,Hi,Yi];function Zd(t){return typeof t=="bigint"||Number.isInteger(t)}var Xi=({value:t})=>JSON.stringify(t),Cp=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Xi},{identify:t=>t==null,createNode:()=>new Be(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Xi},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Xi},{identify:Zd,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>Zd(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:Xi}],Op={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},eu=[Un,Wn].concat(Cp,Op);var Oo={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),s=new Uint8Array(n.length);for(let r=0;r<n.length;++r)s[r]=n.charCodeAt(r);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},s,r,o){if(!n)return"";let i=n,a;if(typeof btoa=="function"){let l="";for(let c=0;c<i.length;++c)l+=String.fromCharCode(i[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Be.BLOCK_LITERAL),e!==Be.QUOTE_DOUBLE){let l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(a.length/l),d=new Array(c);for(let u=0,f=0;u<c;++u,f+=l)d[u]=a.substr(f,l);a=d.join(e===Be.BLOCK_LITERAL?`
|
|
52
|
+
`:" ")}return ur({comment:t,type:e,value:a},s,r,o)}};function Xl(t,e){if(Lt(t))for(let n=0;n<t.items.length;++n){let s=t.items[n];if(!st(s)){if(ct(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");let r=s.items[0]||new Yt(new Be(null));if(s.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${s.commentBefore}
|
|
53
53
|
${r.key.commentBefore}`:s.commentBefore),s.comment){let o=r.value??r.key;o.comment=o.comment?`${s.comment}
|
|
54
|
-
${o.comment}`:s.comment}s=r}t.items[n]=
|
|
55
|
-
`)?(n.push("..."),n.push(
|
|
54
|
+
${o.comment}`:s.comment}s=r}t.items[n]=st(s)?s:new Yt(s)}}else e("Expected a sequence for this tag");return t}function Ql(t,e,n){let{replacer:s}=n,r=new an(t);r.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let i of e){typeof s=="function"&&(i=s.call(e,String(o++),i));let a,l;if(Array.isArray(i))if(i.length===2)a=i[0],l=i[1];else throw new TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let c=Object.keys(i);if(c.length===1)a=c[0],l=i[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=i;r.items.push(jr(a,l,n))}return r}var Lo={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Xl,createNode:Ql};var Br=class t extends an{constructor(){super(),this.add=Xt.prototype.add.bind(this),this.delete=Xt.prototype.delete.bind(this),this.get=Xt.prototype.get.bind(this),this.has=Xt.prototype.has.bind(this),this.set=Xt.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let s=new Map;n?.onCreate&&n.onCreate(s);for(let r of this.items){let o,i;if(st(r)?(o=tn(r.key,"",n),i=tn(r.value,o,n)):o=tn(r,"",n),s.has(o))throw new Error("Ordered maps must not include duplicate keys");s.set(o,i)}return s}static from(e,n,s){let r=Ql(e,n,s),o=new this;return o.items=r.items,o}};Br.tag="tag:yaml.org,2002:omap";var No={collection:"seq",identify:t=>t instanceof Map,nodeClass:Br,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Xl(t,e),s=[];for(let{key:r}of n.items)Ge(r)&&(s.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):s.push(r.value));return Object.assign(new Br,n)},createNode:(t,e,n)=>Br.from(t,e,n)};function tu({value:t,source:e},n){return e&&(t?Zl:ec).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Zl={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Be(!0),stringify:tu},ec={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Be(!1),stringify:tu};var nu={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:ln},su={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():ln(t)}},ru={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new Be(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let s=t.substring(n+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:ln};var Ro=t=>typeof t=="bigint"||Number.isInteger(t);function Qi(t,e,n,{intAsBigInt:s}){let r=t[0];if((r==="-"||r==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),s){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let i=BigInt(t);return r==="-"?BigInt(-1)*i:i}let o=parseInt(t,n);return r==="-"?-1*o:o}function tc(t,e,n){let{value:s}=t;if(Ro(s)){let r=s.toString(e);return s<0?"-"+n+r.substr(1):n+r}return ln(t)}var ou={identify:Ro,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>Qi(t,2,2,n),stringify:t=>tc(t,2,"0b")},iu={identify:Ro,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>Qi(t,1,8,n),stringify:t=>tc(t,8,"0")},au={identify:Ro,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>Qi(t,0,10,n),stringify:ln},lu={identify:Ro,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>Qi(t,2,16,n),stringify:t=>tc(t,16,"0x")};var Kr=class t extends Xt{constructor(e){super(e),this.tag=t.tag}add(e){let n;st(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new Yt(e.key,null):n=new Yt(e,null),Gs(this.items,n.key)||this.items.push(n)}get(e,n){let s=Gs(this.items,e);return!n&&st(s)?Ge(s.key)?s.key.value:s.key:s}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let s=Gs(this.items,e);s&&!n?this.items.splice(this.items.indexOf(s),1):!s&&n&&this.items.push(new Yt(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,s);throw new Error("Set items must all have null values")}static from(e,n,s){let{replacer:r}=s,o=new this(e);if(n&&Symbol.iterator in Object(n))for(let i of n)typeof r=="function"&&(i=r.call(n,i,i)),o.items.push(jr(i,null,s));return o}};Kr.tag="tag:yaml.org,2002:set";var Io={collection:"map",identify:t=>t instanceof Set,nodeClass:Kr,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>Kr.from(t,e,n),resolve(t,e){if(ct(t)){if(t.hasAllNullValues(!0))return Object.assign(new Kr,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};function nc(t,e){let n=t[0],s=n==="-"||n==="+"?t.substring(1):t,r=i=>e?BigInt(i):Number(i),o=s.replace(/_/g,"").split(":").reduce((i,a)=>i*r(60)+r(a),r(0));return n==="-"?r(-1)*o:o}function cu(t){let{value:e}=t,n=i=>i;if(typeof e=="bigint")n=i=>BigInt(i);else if(isNaN(e)||!isFinite(e))return ln(t);let s="";e<0&&(s="-",e*=n(-1));let r=n(60),o=[e%r];return e<60?o.unshift(0):(e=(e-o[0])/r,o.unshift(e%r),e>=60&&(e=(e-o[0])/r,o.unshift(e))),s+o.map(i=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Zi={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>nc(t,n),stringify:cu},ea={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>nc(t,!1),stringify:cu},_r={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(_r.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,s,r,o,i,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,s-1,r,o||0,i||0,a||0,l),d=e[8];if(d&&d!=="Z"){let u=nc(d,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var sc=[Un,Wn,Hs,fr,Zl,ec,ou,iu,au,lu,nu,su,ru,Oo,qn,No,Lo,Io,Zi,ea,_r];var du=new Map([["core",Qd],["failsafe",[Un,Wn,Hs]],["json",eu],["yaml11",sc],["yaml-1.1",sc]]),uu={binary:Oo,bool:Co,float:Yi,floatExp:Hi,floatNaN:Gi,floatTime:ea,int:Wi,intHex:Ji,intOct:Ui,intTime:Zi,map:Un,merge:qn,null:fr,omap:No,pairs:Lo,seq:Wn,set:Io,timestamp:_r},fu={"tag:yaml.org,2002:binary":Oo,"tag:yaml.org,2002:merge":qn,"tag:yaml.org,2002:omap":No,"tag:yaml.org,2002:pairs":Lo,"tag:yaml.org,2002:set":Io,"tag:yaml.org,2002:timestamp":_r};function ta(t,e,n){let s=du.get(e);if(s&&!t)return n&&!s.includes(qn)?s.concat(qn):s.slice();let r=s;if(!r)if(Array.isArray(t))r=[];else{let o=Array.from(du.keys()).filter(i=>i!=="yaml11").map(i=>JSON.stringify(i)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)r=r.concat(o);else typeof t=="function"&&(r=t(r.slice()));return n&&(r=r.concat(qn)),r.reduce((o,i)=>{let a=typeof i=="string"?uu[i]:i;if(!a){let l=JSON.stringify(i),c=Object.keys(uu).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return o.includes(a)||o.push(a),o},[])}var Lp=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Do=class t{constructor({compat:e,customTags:n,merge:s,resolveKnownTags:r,schema:o,sortMapEntries:i,toStringDefaults:a}){this.compat=Array.isArray(e)?ta(e,"compat"):e?ta(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=r?fu:{},this.tags=ta(n,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,Gn,{value:Un}),Object.defineProperty(this,Tn,{value:Hs}),Object.defineProperty(this,ks,{value:Wn}),this.sortMapEntries=typeof i=="function"?i:i===!0?Lp:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};function pu(t,e){let n=[],s=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(n.push(l),s=!0):t.directives.docStart&&(s=!0)}s&&n.push("---");let r=Fi(t,e),{commentString:o}=r.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=o(t.commentBefore);n.unshift(Rn(l,""))}let i=!1,a=null;if(t.contents){if(gt(t.contents)){if(t.contents.spaceBefore&&s&&n.push(""),t.contents.commentBefore){let d=o(t.contents.commentBefore);n.push(Rn(d,""))}r.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>i=!0,c=$s(t.contents,r,()=>a=null,l);a&&(c+=is(c,"",o(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push($s(t.contents,r));if(t.directives?.docEnd)if(t.comment){let l=o(t.comment);l.includes(`
|
|
55
|
+
`)?(n.push("..."),n.push(Rn(l,""))):n.push(`... ${l}`)}else n.push("...");else{let l=t.comment;l&&i&&(l=l.replace(/^\n+/,"")),l&&((!i||a)&&n[n.length-1]!==""&&n.push(""),n.push(Rn(o(l),"")))}return n.join(`
|
|
56
56
|
`)+`
|
|
57
|
-
`}var
|
|
57
|
+
`}var Jn=class t{constructor(e,n,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,gn,{value:Ti});let r=null;typeof n=="function"||Array.isArray(n)?r=n:s===void 0&&n&&(s=n,n=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=o;let{version:i}=o;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(i=this.directives.yaml.version)):this.directives=new os({version:i}),this.setSchema(i,s),this.contents=e===void 0?null:this.createNode(e,r,s)}clone(){let e=Object.create(t.prototype,{[gn]:{value:Ti}});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=gt(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){zr(this.contents)&&this.contents.add(e)}addIn(e,n){zr(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let s=Vl(this);e.anchor=!n||s.has(n)?Gl(n||"a",s):n}return new Ss(e.anchor)}createNode(e,n,s){let r;if(typeof n=="function")e=n.call({"":e},"",e),r=n;else if(Array.isArray(n)){let b=w=>typeof w=="number"||w instanceof String||w instanceof Number,v=n.filter(b).map(String);v.length>0&&(n=n.concat(v)),r=n}else s===void 0&&n&&(s=n,n=void 0);let{aliasDuplicateObjects:o,anchorPrefix:i,flow:a,keepUndefined:l,onTagObj:c,tag:d}=s??{},{onAnchor:u,setAnchors:f,sourceObjects:p}=Hd(this,i||"a"),g={aliasDuplicateObjects:o??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:p},h=Ms(e,d,g);return a&&kt(h)&&(h.flow=!0),f(),h}createPair(e,n,s={}){let r=this.createNode(e,null,s),o=this.createNode(n,null,s);return new Yt(r,o)}delete(e){return zr(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Dr(e)?this.contents==null?!1:(this.contents=null,!0):zr(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return kt(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Dr(e)?!n&&Ge(this.contents)?this.contents.value:this.contents:kt(this.contents)?this.contents.getIn(e,n):void 0}has(e){return kt(this.contents)?this.contents.has(e):!1}hasIn(e){return Dr(e)?this.contents!==void 0:kt(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Eo(this.schema,[e],n):zr(this.contents)&&this.contents.set(e,n)}setIn(e,n){Dr(e)?this.contents=n:this.contents==null?this.contents=Eo(this.schema,Array.from(e),n):zr(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new os({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 os({version:e}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{let r=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(s)this.schema=new Do(Object.assign(s,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:s,maxAliasCount:r,onAnchor:o,reviver:i}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},l=tn(this.contents,n??"",a);if(typeof o=="function")for(let{count:c,res:d}of a.anchors.values())o(d,c);return typeof i=="function"?zs(i,{"":l},"",l):l}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return pu(this,e)}};function zr(t){if(kt(t))return!0;throw new Error("Expected a YAML collection as document contents")}var Fo=class extends Error{constructor(e,n,s,r){super(),this.name=e,this.code=s,this.message=r,this.pos=n}},Xn=class extends Fo{constructor(e,n,s){super("YAMLParseError",e,n,s)}},jo=class extends Fo{constructor(e,n,s){super("YAMLWarning",e,n,s)}},rc=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:s,col:r}=n.linePos[0];n.message+=` at line ${s}, column ${r}`;let o=r-1,i=t.substring(e.lineStarts[s-1],e.lineStarts[s]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){let a=Math.min(o-39,i.length-79);i="\u2026"+i.substring(a),o-=a-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),s>1&&/^ *$/.test(i.substring(0,o))){let a=t.substring(e.lineStarts[s-2],e.lineStarts[s-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
58
58
|
`),i=a+i}if(/[^ ]/.test(i)){let a=1,l=n.linePos[1];l?.line===s&&l.col>r&&(a=Math.max(1,Math.min(l.col-r,80-o)));let c=" ".repeat(o)+"^".repeat(a);n.message+=`:
|
|
59
59
|
|
|
60
60
|
${i}
|
|
61
61
|
${c}
|
|
62
|
-
`}};function
|
|
63
|
-
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(
|
|
64
|
-
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||
|
|
65
|
-
`+
|
|
66
|
-
`+
|
|
67
|
-
`+A:
|
|
68
|
-
`+
|
|
69
|
-
`+b.comment:c.comment=b.comment),c.range=[s.offset,h,b.offset]}else c.range=[s.offset,h,h];return c}function
|
|
70
|
-
`.repeat(Math.max(1,i.length-1)):"",b=s+r.length;return e.source&&(b+=e.source.length),{value:h,type:o,comment:r.comment,range:[s,b,b]}}let l=e.indent+r.indent,c=e.offset+r.length,d=0;for(let h=0;h<a;++h){let[b,
|
|
71
|
-
`;for(let h=d;h<a;++h){let[b,
|
|
72
|
-
`):b.length>l||
|
|
62
|
+
`}};function as(t,{flow:e,indicator:n,next:s,offset:r,onError:o,parentIndent:i,startOnNewline:a}){let l=!1,c=a,d=a,u="",f="",p=!1,g=!1,h=null,b=null,v=null,w=null,k=null,y=null,M=null;for(let I of t)switch(g&&(I.type!=="space"&&I.type!=="newline"&&I.type!=="comma"&&o(I.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),h&&(c&&I.type!=="comment"&&I.type!=="newline"&&o(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),I.type){case"space":!e&&(n!=="doc-start"||s?.type!=="flow-collection")&&I.source.includes(" ")&&(h=I),d=!0;break;case"comment":{d||o(I,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let j=I.source.substring(1)||" ";u?u+=f+j:u=j,f="",c=!1;break}case"newline":c?u?u+=I.source:(!y||n!=="seq-item-ind")&&(l=!0):f+=I.source,c=!0,p=!0,(b||v)&&(w=I),d=!0;break;case"anchor":b&&o(I,"MULTIPLE_ANCHORS","A node can have at most one anchor"),I.source.endsWith(":")&&o(I.offset+I.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),b=I,M??(M=I.offset),c=!1,d=!1,g=!0;break;case"tag":{v&&o(I,"MULTIPLE_TAGS","A node can have at most one tag"),v=I,M??(M=I.offset),c=!1,d=!1,g=!0;break}case n:(b||v)&&o(I,"BAD_PROP_ORDER",`Anchors and tags must be after the ${I.source} indicator`),y&&o(I,"UNEXPECTED_TOKEN",`Unexpected ${I.source} in ${e??"collection"}`),y=I,c=n==="seq-item-ind"||n==="explicit-key-ind",d=!1;break;case"comma":if(e){k&&o(I,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=I,c=!1,d=!1;break}default:o(I,"UNEXPECTED_TOKEN",`Unexpected ${I.type} token`),c=!1,d=!1}let T=t[t.length-1],A=T?T.offset+T.source.length:r;return g&&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"),h&&(c&&h.indent<=i||s?.type==="block-map"||s?.type==="block-seq")&&o(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:y,spaceBefore:l,comment:u,hasNewline:p,anchor:b,tag:v,newlineAfterProp:w,end:A,start:M??A}}function Ys(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
|
|
63
|
+
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(Ys(e.key)||Ys(e.value))return!0}return!1;default:return!0}}function Bo(t,e,n){if(e?.type==="flow-collection"){let s=e.end[0];s.indent===t&&(s.source==="]"||s.source==="}")&&Ys(e)&&n(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function na(t,e,n){let{uniqueKeys:s}=t.options;if(s===!1)return!1;let r=typeof s=="function"?s:(o,i)=>o===i||Ge(o)&&Ge(i)&&o.value===i.value;return e.some(o=>r(o.key,n))}var mu="All mapping items must start at the same column";function hu({composeNode:t,composeEmptyNode:e},n,s,r,o){let i=o?.nodeClass??Xt,a=new i(n.schema);n.atRoot&&(n.atRoot=!1);let l=s.offset,c=null;for(let d of s.items){let{start:u,key:f,sep:p,value:g}=d,h=as(u,{indicator:"explicit-key-ind",next:f??p?.[0],offset:l,onError:r,parentIndent:s.indent,startOnNewline:!0}),b=!h.found;if(b){if(f&&(f.type==="block-seq"?r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==s.indent&&r(l,"BAD_INDENT",mu)),!h.anchor&&!h.tag&&!p){c=h.end,h.comment&&(a.comment?a.comment+=`
|
|
64
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||Ys(f))&&r(f??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==s.indent&&r(l,"BAD_INDENT",mu);n.atKey=!0;let v=h.end,w=f?t(n,f,h,r):e(n,v,u,null,h,r);n.schema.compat&&Bo(s.indent,f,r),n.atKey=!1,na(n,a.items,w)&&r(v,"DUPLICATE_KEY","Map keys must be unique");let k=as(p??[],{indicator:"map-value-ind",next:g,offset:w.range[2],onError:r,parentIndent:s.indent,startOnNewline:!f||f.type==="block-scalar"});if(l=k.end,k.found){b&&(g?.type==="block-map"&&!k.hasNewline&&r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&h.start<k.found.offset-1024&&r(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let y=g?t(n,g,k,r):e(n,l,p,null,k,r);n.schema.compat&&Bo(s.indent,g,r),l=y.range[2];let M=new Yt(w,y);n.options.keepSourceTokens&&(M.srcToken=d),a.items.push(M)}else{b&&r(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(w.comment?w.comment+=`
|
|
65
|
+
`+k.comment:w.comment=k.comment);let y=new Yt(w);n.options.keepSourceTokens&&(y.srcToken=d),a.items.push(y)}}return c&&c<l&&r(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[s.offset,l,c??l],a}function gu({composeNode:t,composeEmptyNode:e},n,s,r,o){let i=o?.nodeClass??an,a=new i(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=s.offset,c=null;for(let{start:d,value:u}of s.items){let f=as(d,{indicator:"seq-item-ind",next:u,offset:l,onError:r,parentIndent:s.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||u)u?.type==="block-seq"?r(f.end,"BAD_INDENT","All sequence items must start at the same column"):r(l,"MISSING_CHAR","Sequence item without - indicator");else{c=f.end,f.comment&&(a.comment=f.comment);continue}let p=u?t(n,u,f,r):e(n,f.end,d,null,f,r);n.schema.compat&&Bo(s.indent,u,r),l=p.range[2],a.items.push(p)}return a.range=[s.offset,l,c??l],a}function ls(t,e,n,s){let r="";if(t){let o=!1,i="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":o=!0;break;case"comment":{n&&!o&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=l.substring(1)||" ";r?r+=i+d:r=d,i="";break}case"newline":r&&(i+=l),o=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:r,offset:e}}var oc="Block collections are not allowed within flow collections",ic=t=>t&&(t.type==="block-map"||t.type==="block-seq");function bu({composeNode:t,composeEmptyNode:e},n,s,r,o){let i=s.start.source==="{",a=i?"flow map":"flow sequence",l=o?.nodeClass??(i?Xt:an),c=new l(n.schema);c.flow=!0;let d=n.atRoot;d&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let u=s.offset+s.start.source.length;for(let b=0;b<s.items.length;++b){let v=s.items[b],{start:w,key:k,sep:y,value:M}=v,T=as(w,{flow:a,indicator:"explicit-key-ind",next:k??y?.[0],offset:u,onError:r,parentIndent:s.indent,startOnNewline:!1});if(!T.found){if(!T.anchor&&!T.tag&&!y&&!M){b===0&&T.comma?r(T.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):b<s.items.length-1&&r(T.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),T.comment&&(c.comment?c.comment+=`
|
|
66
|
+
`+T.comment:c.comment=T.comment),u=T.end;continue}!i&&n.options.strict&&Ys(k)&&r(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(b===0)T.comma&&r(T.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(T.comma||r(T.start,"MISSING_CHAR",`Missing , between ${a} items`),T.comment){let A="";e:for(let I of w)switch(I.type){case"comma":case"space":break;case"comment":A=I.source.substring(1);break e;default:break e}if(A){let I=c.items[c.items.length-1];st(I)&&(I=I.value??I.key),I.comment?I.comment+=`
|
|
67
|
+
`+A:I.comment=A,T.comment=T.comment.substring(A.length+1)}}if(!i&&!y&&!T.found){let A=M?t(n,M,T,r):e(n,T.end,y,null,T,r);c.items.push(A),u=A.range[2],ic(M)&&r(A.range,"BLOCK_IN_FLOW",oc)}else{n.atKey=!0;let A=T.end,I=k?t(n,k,T,r):e(n,A,w,null,T,r);ic(k)&&r(I.range,"BLOCK_IN_FLOW",oc),n.atKey=!1;let j=as(y??[],{flow:a,indicator:"map-value-ind",next:M,offset:I.range[2],onError:r,parentIndent:s.indent,startOnNewline:!1});if(j.found){if(!i&&!T.found&&n.options.strict){if(y)for(let S of y){if(S===j.found)break;if(S.type==="newline"){r(S,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}T.start<j.found.offset-1024&&r(j.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else M&&("source"in M&&M.source?.[0]===":"?r(M,"MISSING_CHAR",`Missing space after : in ${a}`):r(j.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let L=M?t(n,M,j,r):j.found?e(n,j.end,y,null,j,r):null;L?ic(M)&&r(L.range,"BLOCK_IN_FLOW",oc):j.comment&&(I.comment?I.comment+=`
|
|
68
|
+
`+j.comment:I.comment=j.comment);let B=new Yt(I,L);if(n.options.keepSourceTokens&&(B.srcToken=v),i){let S=c;na(n,S.items,I)&&r(A,"DUPLICATE_KEY","Map keys must be unique"),S.items.push(B)}else{let S=new Xt(n.schema);S.flow=!0,S.items.push(B);let E=(L??I).range;S.range=[I.range[0],E[1],E[2]],c.items.push(S)}u=L?L.range[2]:j.end}}let f=i?"}":"]",[p,...g]=s.end,h=u;if(p?.source===f)h=p.offset+p.source.length;else{let b=a[0].toUpperCase()+a.substring(1),v=d?`${b} must end with a ${f}`:`${b} in block collection must be sufficiently indented and end with a ${f}`;r(u,d?"MISSING_CHAR":"BAD_INDENT",v),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let b=ls(g,h,n.options.strict,r);b.comment&&(c.comment?c.comment+=`
|
|
69
|
+
`+b.comment:c.comment=b.comment),c.range=[s.offset,h,b.offset]}else c.range=[s.offset,h,h];return c}function ac(t,e,n,s,r,o){let i=n.type==="block-map"?hu(t,e,n,s,o):n.type==="block-seq"?gu(t,e,n,s,o):bu(t,e,n,s,o),a=i.constructor;return r==="!"||r===a.tagName?(i.tag=a.tagName,i):(r&&(i.tag=r),i)}function yu(t,e,n,s,r){let o=s.tag,i=o?e.directives.tagName(o.source,f=>r(o,"TAG_RESOLVE_FAILED",f)):null;if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=s,g=f&&o?f.offset>o.offset?f:o:f??o;g&&(!p||p.offset<g.offset)&&r(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!o||!i||i==="!"||i===Xt.tagName&&a==="map"||i===an.tagName&&a==="seq")return ac(t,e,n,r,i);let l=e.schema.tags.find(f=>f.tag===i&&f.collection===a);if(!l){let f=e.schema.knownTags[i];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),l=f;else return f?r(o,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):r(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),ac(t,e,n,r,i)}let c=ac(t,e,n,r,i,l),d=l.resolve?.(c,f=>r(o,"TAG_RESOLVE_FAILED",f),e.options)??c,u=gt(d)?d:new Be(d);return u.range=c.range,u.tag=i,l?.format&&(u.format=l.format),u}function lc(t,e,n){let s=e.offset,r=Np(e,t.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[s,s,s]};let o=r.mode===">"?Be.BLOCK_FOLDED:Be.BLOCK_LITERAL,i=e.source?Rp(e.source):[],a=i.length;for(let h=i.length-1;h>=0;--h){let b=i[h][1];if(b===""||b==="\r")a=h;else break}if(a===0){let h=r.chomp==="+"&&i.length>0?`
|
|
70
|
+
`.repeat(Math.max(1,i.length-1)):"",b=s+r.length;return e.source&&(b+=e.source.length),{value:h,type:o,comment:r.comment,range:[s,b,b]}}let l=e.indent+r.indent,c=e.offset+r.length,d=0;for(let h=0;h<a;++h){let[b,v]=i[h];if(v===""||v==="\r")r.indent===0&&b.length>l&&(l=b.length);else{b.length<l&&n(c+b.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),r.indent===0&&(l=b.length),d=h,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=b.length+v.length+1}for(let h=i.length-1;h>=a;--h)i[h][0].length>l&&(a=h+1);let u="",f="",p=!1;for(let h=0;h<d;++h)u+=i[h][0].slice(l)+`
|
|
71
|
+
`;for(let h=d;h<a;++h){let[b,v]=i[h];c+=b.length+v.length+1;let w=v[v.length-1]==="\r";if(w&&(v=v.slice(0,-1)),v&&b.length<l){let y=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;n(c-v.length-(w?2:1),"BAD_INDENT",y),b=""}o===Be.BLOCK_LITERAL?(u+=f+b.slice(l)+v,f=`
|
|
72
|
+
`):b.length>l||v[0]===" "?(f===" "?f=`
|
|
73
73
|
`:!p&&f===`
|
|
74
74
|
`&&(f=`
|
|
75
75
|
|
|
76
|
-
`),u+=f+b.slice(l)+
|
|
77
|
-
`,p=!0):
|
|
76
|
+
`),u+=f+b.slice(l)+v,f=`
|
|
77
|
+
`,p=!0):v===""?f===`
|
|
78
78
|
`?u+=`
|
|
79
79
|
`:f=`
|
|
80
|
-
`:(u+=f+
|
|
80
|
+
`:(u+=f+v,f=" ",p=!1)}switch(r.chomp){case"-":break;case"+":for(let h=a;h<i.length;++h)u+=`
|
|
81
81
|
`+i[h][0].slice(l);u[u.length-1]!==`
|
|
82
82
|
`&&(u+=`
|
|
83
83
|
`);break;default:u+=`
|
|
84
|
-
`}let g=s+r.length+e.source.length;return{value:u,type:o,comment:r.comment,range:[s,g,g]}}function
|
|
84
|
+
`}let g=s+r.length+e.source.length;return{value:u,type:o,comment:r.comment,range:[s,g,g]}}function Np({offset:t,props:e},n,s){if(e[0].type!=="block-scalar-header")return s(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=e[0],o=r[0],i=0,a="",l=-1;for(let f=1;f<r.length;++f){let p=r[f];if(!a&&(p==="-"||p==="+"))a=p;else{let g=Number(p);!i&&g?i=g:l===-1&&(l=t+f)}}l!==-1&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,d="",u=r.length;for(let f=1;f<e.length;++f){let p=e[f];switch(p.type){case"space":c=!0;case"newline":u+=p.source.length;break;case"comment":n&&!c&&s(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,d=p.source.substring(1);break;case"error":s(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{let g=`Unexpected token in block scalar header: ${p.type}`;s(p,"UNEXPECTED_TOKEN",g);let h=p.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:o,indent:i,chomp:a,comment:d,length:u}}function Rp(t){let e=t.split(/\n( *)/),n=e[0],s=n.match(/^( *)/),o=[s?.[1]?[s[1],n.slice(s[1].length)]:["",n]];for(let i=1;i<e.length;i+=2)o.push([e[i],e[i+1]]);return o}function cc(t,e,n){let{offset:s,type:r,source:o,end:i}=t,a,l,c=(f,p,g)=>n(s+f,p,g);switch(r){case"scalar":a=Be.PLAIN,l=Ip(o,c);break;case"single-quoted-scalar":a=Be.QUOTE_SINGLE,l=Dp(o,c);break;case"double-quoted-scalar":a=Be.QUOTE_DOUBLE,l=Fp(o,c);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[s,s+o.length,s+o.length]}}let d=s+o.length,u=ls(i,d,e,n);return{value:l,type:a,comment:u.comment,range:[s,d,u.offset]}}function Ip(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),xu(t)}function Dp(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),xu(t.slice(1,-1)).replace(/''/g,"'")}function xu(t){let e=/(.*?)\r?\n/sy,n=e.exec(t);if(!n)return t;let s,r;try{s=new RegExp("(?<![ ])[ ]+$"),r=new RegExp("^[ ]+|(?<![ ])[ ]+$","g")}catch{s=/[ \t]+$/,r=/^[ \t]+|[ \t]+$/g}let o=n[1].replace(s,""),i=" ",a=e.lastIndex;for(;n=e.exec(t);){let c=n[1].replace(r,"");c===""?i===`
|
|
85
85
|
`?o+=i:i=`
|
|
86
|
-
`:(o+=i+c,i=" "),a=e.lastIndex}let l=/[ \t]*(.*)/sy;return l.lastIndex=a,n=l.exec(t),o+i+(n?.[1]??"")}function
|
|
86
|
+
`:(o+=i+c,i=" "),a=e.lastIndex}let l=/[ \t]*(.*)/sy;return l.lastIndex=a,n=l.exec(t),o+i+(n?.[1]??"")}function Fp(t,e){let n="";for(let s=1;s<t.length-1;++s){let r=t[s];if(!(r==="\r"&&t[s+1]===`
|
|
87
87
|
`))if(r===`
|
|
88
|
-
`){let{fold:o,offset:i}=
|
|
88
|
+
`){let{fold:o,offset:i}=jp(t,s);n+=o,s=i}else if(r==="\\"){let o=t[++s],i=Bp[o];if(i)n+=i;else if(o===`
|
|
89
89
|
`)for(o=t[s+1];o===" "||o===" ";)o=t[++s+1];else if(o==="\r"&&t[s+1]===`
|
|
90
|
-
`)for(o=t[++s+1];o===" "||o===" ";)o=t[++s+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;n+=
|
|
90
|
+
`)for(o=t[++s+1];o===" "||o===" ";)o=t[++s+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;n+=Kp(t,s+1,a,e),s+=a}else{let a=t.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(r===" "||r===" "){let o=s,i=t[s+1];for(;i===" "||i===" ";)i=t[++s+1];i!==`
|
|
91
91
|
`&&!(i==="\r"&&t[s+2]===`
|
|
92
|
-
`)&&(n+=s>o?t.slice(o,s+1):r)}else n+=r}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function
|
|
92
|
+
`)&&(n+=s>o?t.slice(o,s+1):r)}else n+=r}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function jp(t,e){let n="",s=t[e+1];for(;(s===" "||s===" "||s===`
|
|
93
93
|
`||s==="\r")&&!(s==="\r"&&t[e+2]!==`
|
|
94
94
|
`);)s===`
|
|
95
95
|
`&&(n+=`
|
|
96
|
-
`),e+=1,s=t[e+1];return n||(n=" "),{fold:n,offset:e}}var
|
|
97
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
96
|
+
`),e+=1,s=t[e+1];return n||(n=" "),{fold:n,offset:e}}var Bp={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 Kp(t,e,n,s){let r=t.substr(e,n),i=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(i)}catch{let a=t.substr(e-2,n+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}function dc(t,e,n,s){let{value:r,type:o,comment:i,range:a}=e.type==="block-scalar"?lc(t,e,s):cc(e,t.options.strict,s),l=n?t.directives.tagName(n.source,u=>s(n,"TAG_RESOLVE_FAILED",u)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[Tn]:l?c=_p(t.schema,r,l,n,s):e.type==="scalar"?c=zp(t,r,e,s):c=t.schema[Tn];let d;try{let u=c.resolve(r,f=>s(n??e,"TAG_RESOLVE_FAILED",f),t.options);d=Ge(u)?u:new Be(u)}catch(u){let f=u instanceof Error?u.message:String(u);s(n??e,"TAG_RESOLVE_FAILED",f),d=new Be(r)}return d.range=a,d.source=r,o&&(d.type=o),l&&(d.tag=l),c.format&&(d.format=c.format),i&&(d.comment=i),d}function _p(t,e,n,s,r){if(n==="!")return t[Tn];let o=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(e))return a;let i=t.knownTags[n];return i&&!i.collection?(t.tags.push(Object.assign({},i,{default:!1,test:void 0})),i):(r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[Tn])}function zp({atKey:t,directives:e,schema:n},s,r,o){let i=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(s))||n[Tn];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(s))??n[Tn];if(i.tag!==a.tag){let l=e.tagString(i.tag),c=e.tagString(a.tag),d=`Value may be parsed as either ${l} or ${c}`;o(r,"TAG_RESOLVE_FAILED",d,!0)}}return i}function wu(t,e,n){if(e){n??(n=e.length);for(let s=n-1;s>=0;--s){let r=e[s];switch(r.type){case"space":case"comment":case"newline":t-=r.source.length;continue}for(r=e[++s];r?.type==="space";)t+=r.source.length,r=e[++s];break}}return t}var Vp={composeNode:uc,composeEmptyNode:sa};function uc(t,e,n,s){let r=t.atKey,{spaceBefore:o,comment:i,anchor:a,tag:l}=n,c,d=!0;switch(e.type){case"alias":c=Gp(t,e,s),(a||l)&&s(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=dc(t,e,l,s),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=yu(Vp,t,e,n,s),a&&(c.anchor=a.source.substring(1))}catch(u){let f=u instanceof Error?u.message:String(u);s(e,"RESOURCE_EXHAUSTION",f)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;s(e,"UNEXPECTED_TOKEN",u),d=!1}}return c??(c=sa(t,e.offset,void 0,null,n,s)),a&&c.anchor===""&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),r&&t.options.stringKeys&&(!Ge(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(c.spaceBefore=!0),i&&(e.type==="scalar"&&e.source===""?c.comment=i:c.commentBefore=i),t.options.keepSourceTokens&&d&&(c.srcToken=e),c}function sa(t,e,n,s,{spaceBefore:r,comment:o,anchor:i,tag:a,end:l},c){let d={type:"scalar",offset:wu(e,n,s),indent:-1,source:""},u=dc(t,d,a,c);return i&&(u.anchor=i.source.substring(1),u.anchor===""&&c(i,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(u.spaceBefore=!0),o&&(u.comment=o,u.range[2]=l),u}function Gp({options:t},{offset:e,source:n,end:s},r){let o=new Ss(n.substring(1));o.source===""&&r(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&r(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=e+n.length,a=ls(s,i,t.strict,r);return o.range=[e,i,a.offset],a.comment&&(o.comment=a.comment),o}function vu(t,e,{offset:n,start:s,value:r,end:o},i){let a=Object.assign({_directives:e},t),l=new Jn(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},d=as(s,{indicator:"doc-start",next:r??o?.[0],offset:n,onError:i,parentIndent:0,startOnNewline:!0});d.found&&(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!d.hasNewline&&i(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=r?uc(c,r,d,i):sa(c,d.end,s,null,d,i);let u=l.contents.range[2],f=ls(o,u,!1,i);return f.comment&&(l.comment=f.comment),l.range=[n,u,f.offset],l}function Ko(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function ku(t){let e="",n=!1,s=!1;for(let r=0;r<t.length;++r){let o=t[r];switch(o[0]){case"#":e+=(e===""?"":s?`
|
|
98
98
|
|
|
99
99
|
`:`
|
|
100
|
-
`)+(o.substring(1)||" "),n=!0,s=!1;break;case"%":t[r+1]?.[0]!=="#"&&(r+=1),n=!1;break;default:n||(s=!0),n=!1}}return{comment:e,afterEmptyLine:s}}var
|
|
101
|
-
${s}`:s;else if(r||e.directives.docStart||!o)e.commentBefore=s;else if(
|
|
100
|
+
`)+(o.substring(1)||" "),n=!0,s=!1;break;case"%":t[r+1]?.[0]!=="#"&&(r+=1),n=!1;break;default:n||(s=!0),n=!1}}return{comment:e,afterEmptyLine:s}}var _o=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,s,r,o)=>{let i=Ko(n);o?this.warnings.push(new jo(i,s,r)):this.errors.push(new Xn(i,s,r))},this.directives=new os({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:s,afterEmptyLine:r}=ku(this.prelude);if(s){let o=e.contents;if(n)e.comment=e.comment?`${e.comment}
|
|
101
|
+
${s}`:s;else if(r||e.directives.docStart||!o)e.commentBefore=s;else if(kt(o)&&!o.flow&&o.items.length>0){let i=o.items[0];st(i)&&(i=i.key);let a=i.commentBefore;i.commentBefore=a?`${s}
|
|
102
102
|
${a}`:s}else{let i=o.commentBefore;o.commentBefore=i?`${s}
|
|
103
|
-
${i}`:s}}if(n){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
104
|
-
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new
|
|
103
|
+
${i}`:s}}if(n){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ku(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,s=-1){for(let r of e)yield*this.next(r);yield*this.end(n,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(n,s,r)=>{let o=Ko(e);o[0]+=n,this.onError(o,"BAD_DIRECTIVE",s,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=vu(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new Xn(Ko(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(s):this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){let s="Unexpected doc-end without preceding document";this.errors.push(new Xn(Ko(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;let n=ls(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let s=this.doc.comment;this.doc.comment=s?`${s}
|
|
104
|
+
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new Xn(Ko(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let s=Object.assign({_directives:this.directives},this.options),r=new Jn(void 0,s);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,n,n],this.decorate(r,!1),yield r}}};var fc=Symbol("break visit"),Hp=Symbol("skip children"),Su=Symbol("remove item");function pr(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Mu(Object.freeze([]),t,e)}pr.BREAK=fc;pr.SKIP=Hp;pr.REMOVE=Su;pr.itemAtPath=(t,e)=>{let n=t;for(let[s,r]of e){let o=n?.[s];if(o&&"items"in o)n=o.items[r];else return}return n};pr.parentCollection=(t,e)=>{let n=pr.itemAtPath(t,e.slice(0,-1)),s=e[e.length-1][0],r=n?.[s];if(r&&"items"in r)return r;throw new Error("Parent collection not found")};function Mu(t,e,n){let s=n(e,t);if(typeof s=="symbol")return s;for(let r of["key","value"]){let o=e[r];if(o&&"items"in o){for(let i=0;i<o.items.length;++i){let a=Mu(Object.freeze(t.concat([[r,i]])),o.items[i],n);if(typeof a=="number")i=a-1;else{if(a===fc)return fc;a===Su&&(o.items.splice(i,1),i-=1)}}typeof s=="function"&&r==="key"&&(s=s(e,t))}}return typeof s=="function"?s(e,t):s}var pc="\uFEFF",mc="",hc="",ra="";function $u(t){switch(t){case pc:return"byte-order-mark";case mc:return"doc-mode";case hc:return"flow-error-end";case ra: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(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function
|
|
107
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
108
|
-
\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(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function Qn(t){switch(t){case void 0:case" ":case`
|
|
107
|
+
`:case"\r":case" ":return!0;default:return!1}}var Eu=new Set("0123456789ABCDEFabcdef"),qp=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),oa=new Set(",[]{}"),Up=new Set(` ,[]{}
|
|
108
|
+
\r `),gc=t=>!t||Up.has(t),zo=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let s=this.next??"stream";for(;s&&(n||this.hasChars(1));)s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
|
|
109
109
|
`?!0:n==="\r"?this.buffer[e+1]===`
|
|
110
110
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let s=0;for(;n===" ";)n=this.buffer[++s+e];if(n==="\r"){let r=this.buffer[s+e+1];if(r===`
|
|
111
111
|
`||!r&&!this.atEnd)return e+s+1}return n===`
|
|
112
|
-
`||s>=this.indentNext||!n&&!this.atEnd?e+s:-1}if(n==="-"||n==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&
|
|
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]===
|
|
112
|
+
`||s>=this.indentNext||!n&&!this.atEnd?e+s:-1}if(n==="-"||n==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&Qn(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]===pc&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,s=e.indexOf("#");for(;s!==-1;){let o=e[s-1];if(o===" "||o===" "){n=s-1;break}else s=e.indexOf("#",s+1)}for(;;){let o=e[n-1];if(o===" "||o===" ")n-=1;else break}let r=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield mc,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&Qn(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Qn(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Qn(n)){let s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(gc),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,s=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=s=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let r=this.getLine();if(r===null)return this.setNext("flow");if((s!==-1&&s<this.indentNext&&r[0]!=="#"||s===0&&(r.startsWith("---")||r.startsWith("..."))&&Qn(r[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield hc,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(gc),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||Qn(i)||i===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let o=0;for(;this.buffer[n-1-o]==="\\";)o+=1;if(o%2===0)break;n=this.buffer.indexOf('"',n+1)}let s=this.buffer.substring(0,n),r=s.indexOf(`
|
|
114
114
|
`,this.pos);if(r!==-1){for(;r!==-1;){let o=this.continueScalar(r+1);if(o===-1)break;r=s.indexOf(`
|
|
115
|
-
`,o)}r!==-1&&(n=r-(s[r-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>
|
|
115
|
+
`,o)}r!==-1&&(n=r-(s[r-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>Qn(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,s;e:for(let o=this.pos;s=this.buffer[o];++o)switch(s){case" ":n+=1;break;case`
|
|
116
116
|
`:e=o,n=0;break;case"\r":{let i=this.buffer[o+1];if(!i&&!this.atEnd)return this.setNext("block-scalar");if(i===`
|
|
117
117
|
`)break}default:break e}if(!s&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n: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
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 a=o;for(;i===" ";)i=this.buffer[--o];if(i===`
|
|
120
|
-
`&&o>=this.pos&&o+1+n>a)e=o;else break}while(!0);return yield
|
|
120
|
+
`&&o>=this.pos&&o+1+n>a)e=o;else break}while(!0);return yield ra,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,s=this.pos-1,r;for(;r=this.buffer[++s];)if(r===":"){let o=this.buffer[s+1];if(Qn(o)||e&&oa.has(o))break;n=s}else if(Qn(r)){let o=this.buffer[s+1];if(r==="\r"&&(o===`
|
|
121
121
|
`?(s+=1,r=`
|
|
122
|
-
`,o=this.buffer[s+1]):n=s),o==="#"||e&&
|
|
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]):n=s),o==="#"||e&&oa.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&&oa.has(r))break;n=s}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield ra,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let s=this.buffer.slice(this.pos,e);return s?(yield s,this.pos+=s.length,s.length):(n&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(gc),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,s=this.charAt(1);if(Qn(s)||n&&oa.has(s)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!Qn(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(qp.has(n))n=this.buffer[++e];else if(n==="%"&&Eu.has(this.buffer[e+1])&&Eu.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
124
124
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
125
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,s;do s=this.buffer[++n];while(s===" "||e&&s===" ");let r=n-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=n),r}*pushUntil(e){let n=this.pos,s=this.buffer[n];for(;!e(s);)s=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};var
|
|
125
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,s;do s=this.buffer[++n];while(s===" "||e&&s===" ");let r=n-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=n),r}*pushUntil(e){let n=this.pos,s=this.buffer[n];for(;!e(s);)s=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};var Es=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,s=this.lineStarts.length;for(;n<s;){let o=n+s>>1;this.lineStarts[o]<e?n=o+1:s=o}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let r=this.lineStarts[n-1];return{line:n,col:e-r+1}}}};function qs(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function Tu(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Pu(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function ia(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Vr(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function aa(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let n=0;n<e.length;++n)t.push(e[n])}function Au(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!qs(e.start,"explicit-key-ind")&&!qs(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Pu(e.value)?e.value.end?aa(e.value.end,e.sep):e.value.end=e.sep:aa(e.start,e.sep),delete e.sep)}var Vo=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 zo,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let s of this.lexer.lex(e,n))yield*this.next(s);n||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=$u(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let s=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in s?s.indent:0:n.type==="flow-collection"&&s.type==="document"&&(n.indent=0),n.type==="flow-collection"&&Au(n),s.type){case"document":s.value=n;break;case"block-scalar":s.props.push(n);break;case"block-map":{let r=s.items[s.items.length-1];if(r.value){s.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=n;else{Object.assign(r,{key:n,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=s.items[s.items.length-1];r.value?s.items.push({start:[],value:n}):r.value=n;break}case"flow-collection":{let r=s.items[s.items.length-1];!r||r.value?s.items.push({start:[],key:n,sep:[]}):r.sep?r.value=n:Object.assign(r,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let r=n.items[n.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&Tu(r.start)===-1&&(n.indent===0||r.start.every(o=>o.type!=="comment"||o.indent<n.indent))&&(s.type==="document"?s.end=r.start:s.items.push({start:r.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Tu(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=ia(this.peek(2)),s=Vr(n),r;e.end?(r=e.end,r.push(this.sourceToken),delete e.end):r=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
|
|
126
126
|
`)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
|
|
127
|
-
`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let s="end"in n.value?n.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){
|
|
127
|
+
`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let s="end"in n.value?n.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){aa(r,n.start),r.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,r=s&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",o=[];if(r&&n.sep&&!n.value){let i=[];for(let a=0;a<n.sep.length;++a){let l=n.sep[a];switch(l.type){case"newline":i.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(i.length=0);break;default:i.length=0}}i.length>=2&&(o=n.sep.splice(i[1]))}switch(this.type){case"anchor":case"tag":r||n.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):r||n.value?(o.push(this.sourceToken),e.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(qs(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(Pu(n.key)&&!qs(n.sep,"newline")){let i=Vr(n.start),a=n.key,l=n.sep;l.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:a,sep:l}]})}else o.length>0?n.sep=n.sep.concat(o,this.sourceToken):n.sep.push(this.sourceToken);else if(qs(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let i=Vr(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||r?e.items.push({start:o,key:null,sep:[this.sourceToken]}):qs(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);r||n.value?(e.items.push({start:o,key:i,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(i):(Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!0);return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!n.explicitKey&&n.sep&&!qs(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else s&&e.items.push({start:o});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let s="end"in n.value?n.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){aa(r,n.start),r.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||qs(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:r,sep:[]}):n.sep?this.stack.push(r):Object.assign(n,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{let s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){let r=ia(s),o=Vr(r);Au(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
|
|
128
128
|
`)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
|
|
129
|
-
`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=
|
|
129
|
+
`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=ia(e),s=Vr(n);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=ia(e),s=Vr(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(s=>s.type==="newline"||s.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function Wp(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Es||null,prettyErrors:e}}function cn(t,e={}){let{lineCounter:n,prettyErrors:s}=Wp(e),r=new Vo(n?.addNewLine),o=new _o(e),i=null;for(let a of o.compose(r.parse(t),!0,t.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new Xn(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&n&&(i.errors.forEach(rc(t,n)),i.warnings.forEach(rc(t,n))),i}function Go(t,e,n){let s;typeof e=="function"?s=e:n===void 0&&e&&typeof e=="object"&&(n=e);let r=cn(t,n);if(!r)return null;if(r.warnings.forEach(o=>ji(r.options.logLevel,o)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:s},n))}function bc(t,e,n){let s=null;if(typeof e=="function"||Array.isArray(e)?s=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let r=Math.round(n);n=r<1?void 0:r>8?{indent:8}:{indent:r}}if(t===void 0){let{keepUndefined:r}=n??e??{};if(!r)return}return Yn(t)&&!s?t.toString(n):new Jn(t,s,n).toString(n)}function la(t){let e=Go(t);for(let n of["light","dark","kinds","roles"])if(!e||typeof e[n]!="object")throw new Error(`theme: missing "${n}"`);return e}function ca(t,e={},n={}){let s={...t.kinds};for(let[r,o]of Object.entries(n)){let i=s[o.like??r]??s.control;s[r]={color:o.color??i.color,dash:o.dash??i.dash,legend:o.legend??i.legend}}return{...t,roles:{...t.roles,...e},kinds:s}}var Cu=t=>Object.entries(t).map(([e,n])=>`--${e}:${n}`).join(";");function cs(t,e){return e in t.light?`var(--${e})`:e}function da(t){let{light:e,dark:n,rest:s}=yc(t);return`:root{${e}}
|
|
130
130
|
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${n}}}
|
|
131
131
|
:root[data-theme="dark"]{${n}}
|
|
132
|
-
${s}`}function
|
|
133
|
-
`;for(let[n,s]of Object.entries(t.kinds)){let r=
|
|
134
|
-
`}return{light:
|
|
135
|
-
`)),this.diags=e}};function
|
|
132
|
+
${s}`}function yc(t){let e="";for(let[n,s]of Object.entries(t.roles))e+=`.k-${n}{--h:${s.h};--s:${s.s}%}`,s.top?e+=`.k-${n} .top{fill:${s.top}}`:s.tint&&(e+=`.k-${n} .top{fill:color-mix(in srgb,hsl(${s.h} ${Math.min(100,s.s+15)}% 50%) ${s.tint}%,var(--pad-top))}`),e+=`
|
|
133
|
+
`;for(let[n,s]of Object.entries(t.kinds)){let r=cs(t,s.color),o=s.dash==="dashed"?";stroke-dasharray:7 6;stroke-width:2.4":s.dash==="dotted"?";stroke-dasharray:3 6;stroke-width:2.4":"";e+=`.f-${n}{stroke:${r}${o}} .t-${n}{fill:${r}} .c-${n}{--c:${r}}
|
|
134
|
+
`}return{light:Cu(t.light),dark:Cu(t.dark),rest:e}}var ua=class extends Error{diags;constructor(e){super(e.map(n=>`${n.line}:${n.col} ${n.message}`).join(`
|
|
135
|
+
`)),this.diags=e}};function xc(t,e){let n=t.length,s=e.length;if(!n)return s;if(!s)return n;let r=Array.from({length:n+1},(o,i)=>[i,...Array(s).fill(0)]);for(let o=0;o<=s;o++)r[0][o]=o;for(let o=1;o<=n;o++)for(let i=1;i<=s;i++){let a=t[o-1]===e[i-1]?0:1;r[o][i]=Math.min(r[o-1][i]+1,r[o][i-1]+1,r[o-1][i-1]+a),o>1&&i>1&&t[o-1]===e[i-2]&&t[o-2]===e[i-1]&&(r[o][i]=Math.min(r[o][i],r[o-2][i-2]+1))}return r[n][s]}function Us(t,e){let n,s=1/0,r=t.toLowerCase();for(let i of e){let a=xc(r,i.toLowerCase());a<s&&(s=a,n=i)}if(n===void 0)return;let o=Math.max(1,Math.min(3,Math.floor(Math.max(t.length,n.length)/3)));return s<=o?n:void 0}function wc(t,e,n){t.file&&(e=t.file,n=t.source);let r=`${t.line?`${e}:${t.line}:${t.col}`:e} ${t.severity}: ${t.message}`;if(t.hint&&(r+=`
|
|
136
136
|
${t.hint}`),n&&t.line){let i=n.split(/\r?\n/)[t.line-1]??"",a=String(t.line).padStart(4);r+=`
|
|
137
137
|
${a} | ${i}
|
|
138
|
-
${" ".repeat(a.length)} | ${" ".repeat(Math.max(0,t.col-1))}^`}return r}function
|
|
138
|
+
${" ".repeat(a.length)} | ${" ".repeat(Math.max(0,t.col-1))}^`}return r}function Ou(t,e,n){return t.map(s=>wc(s,e,n)).join(`
|
|
139
139
|
|
|
140
|
-
`)}function
|
|
140
|
+
`)}function Lu(t){return t.split("/").slice(1).map(e=>{let n=e.replace(/~1/g,"/").replace(/~0/g,"~");return/^\d+$/.test(n)?Number(n):n})}function Nu(t){let e=new Es,n=cn(t,{lineCounter:e,prettyErrors:!1,uniqueKeys:!0}),s=[],r=l=>{let c=e.linePos(l);return{line:c.line,col:c.col}};for(let l of n.errors){let c=r(l.pos[0]),d=l.message.split(`
|
|
141
141
|
`)[0],u=/Nested mappings|Implicit keys|mapping values/i.test(d)?`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(d)?"a key is written twice in the same map":void 0;s.push({severity:"error",message:`YAML: ${d}`,line:c.line,col:c.col,path:"",hint:u})}for(let l of n.warnings){let c=r(l.pos[0]);s.push({severity:"warning",message:`YAML: ${l.message.split(`
|
|
142
|
-
`)[0]}`,line:c.line,col:c.col,path:""})}function o(l,c={}){let d=Xd(l),u=n.contents,f={line:1,col:1},p=g=>{let h=g?.range;h&&(f=r(h[0]))};p(u);for(let g=0;g<d.length;g++){let h=d[g];if(lt(u)){let b=u.items.find(k=>tt(k)&&He(k.key)&&String(k.key.value)===String(h));if(!b)break;if(c.key&&g===d.length-1)return p(b.key),f;p(b.key),u=b.value,u&&p(u)}else if(At(u)&&typeof h=="number"){if(u=u.items[h],!u)break;p(u)}else break}return f}function i(l){let c=n.contents;for(let p of Xd(l)){if(lt(c)){let g=c.items.find(h=>tt(h)&&He(h.key)&&String(h.key.value)===String(p));if(!g)return;c=g.value}else if(At(c)&&typeof p=="number")c=c.items[p];else return;if(!c)return}let d=c.range;if(!d)return;let u=e.linePos(Math.max(d[0],d[1]-1)).line,f=t.split(/\r?\n/);for(;u>e.linePos(d[0]).line&&/^\s*(#.*)?$/.test(f[u-1]??"");)u--;return{start:e.linePos(d[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 mp=new Set(["svg","g","defs","marker","symbol","title","desc","path","polygon","polyline","line","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath"]),hp=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"]),gp=new Set(["fill","stroke","marker-start","marker-mid","marker-end","clip-path","style"]),bp={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"},Zd=t=>t.replace(/&(amp|lt|gt|quot|apos|#39);/g,(e,n)=>bp[n]);function Yl(t,e){return t.startsWith("data-")||t.startsWith("aria-")?/^[a-z][\w-]*$/.test(t):!(!hp.has(t)||gp.has(t)&&/url\(\s*(?!['"]?#)|javascript:|expression\(|@import/i.test(e))}function ql(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 f=u[1],p=Zd(u[2]);f==="xmlns"||f.startsWith("xmlns:")||Yl(f,p)&&l.push([f,p])}let c={name:a,attrs:l,children:[]},d=i.dropped||!mp.has(a);d||i.node.children.push(c),r[4]||n.push({node:c,dropped:d});continue}!i.dropped&&r[5].trim()&&i.node.children.push(Zd(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 yp="http://www.w3.org/2000/svg",eu=t=>t.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1");function To(t,e=document){let n=r=>{let o=e.createElementNS(yp,r.name);for(let[i,a]of r.attrs)i==="style"?o.style.cssText=eu(a):o.setAttribute(i,/var\(--/.test(a)?eu(a):a);for(let i of r.children)o.append(typeof i=="string"?e.createTextNode(i):n(i));return o},s=ql(t).children.find(r=>typeof r!="string"&&r.name==="svg");if(!s)throw new Error("the drawing has no <svg>");return n(s)}var xp=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Ao=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])=>`${xp(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)}}},tu={createElementNS:(t,e)=>new Ao(e)},nu=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),wp=t=>nu(t).replace(/"/g,""");function Vi(t,e=new Set(["style"])){if(typeof t=="string")return nu(t);let n=t.attrs.map(([r,o])=>` ${r}="${wp(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,"<\\/"):Vi(r,e)).join(""):t.children.map(r=>Vi(r,e)).join("");return`<${t.name}${n}>${s}</${t.name}>`}var vp=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 Ul(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,d)=>c>>>d|c<<32-d;for(let c=0;c<s;c++){for(let v=0;v<16;v++)a[v]=o.getUint32(c*64+v*4);for(let v=16;v<64;v++){let M=l(a[v-15],7)^l(a[v-15],18)^a[v-15]>>>3,x=l(a[v-2],17)^l(a[v-2],19)^a[v-2]>>>10;a[v]=a[v-16]+M+a[v-7]+x>>>0}let[d,u,f,p,g,h,b,k]=i;for(let v=0;v<64;v++){let M=k+(l(g,6)^l(g,11)^l(g,25))+(g&h^~g&b)+vp[v]+a[v]>>>0,x=(l(d,2)^l(d,13)^l(d,22))+(d&u^d&f^u&f)>>>0;k=b,b=h,h=g,g=p+M>>>0,p=f,f=u,u=d,d=M+x>>>0}i[0]+=d,i[1]+=u,i[2]+=f,i[3]+=p,i[4]+=g,i[5]+=h,i[6]+=b,i[7]+=k}return[...i].map(c=>c.toString(16).padStart(8,"0")).join("")}function su(t){if(t!=="sha256")throw new Error(`only sha256 here, not ${t}`);let e="",n={update(s){return e+=s,n},digest(s){return Ul(e)}};return n}var Mu={};Qo(Mu,{BOARD_3D:()=>js,BOARD_CSS:()=>vu,FLAT_DEFAULTS:()=>bc,FLAT_FONTS:()=>yc,GRID_CSS:()=>mc,LABEL_BUDGET:()=>ma,MARKS_CSS:()=>fc,Obstacles:()=>sr,PAGE_CSS:()=>dc,PLAYER_CSS:()=>ya,PLAYER_UI_CSS:()=>pc,ROUTE_BUDGET:()=>na,WALL_T:()=>es,assembly:()=>da,baseCss:()=>ba,boardCatalog:()=>ku,boardDiagram:()=>Su,boardErrors:()=>wa,boardOf:()=>or,boxAsset:()=>iu,boxSilhouette:()=>xa,calloutRect:()=>ic,cardAsset:()=>xc,cloudPath:()=>Zl,compileRaw:()=>yu,convexOverlap:()=>Lo,defaultLabel:()=>lu,drawCloud:()=>Ui,drawDecos:()=>Ql,drawingCss:()=>uc,durationFor:()=>lc,facePainter:()=>qi,flatHit:()=>wu,floorAt:()=>Cr,floorOf:()=>Ir,focusView:()=>bu,gateBox:()=>Co,iconPainter:()=>Po,inConvex:()=>ac,kindsCss:()=>Hi,labelRect:()=>Ro,layoutFlat:()=>Fs,lineRectArea:()=>mu,localAt:()=>Rr,markCss:()=>Yi,metricsMeasure:()=>xu,midpoint:()=>cc,noSource:()=>hc,nodeKind:()=>nr,nodeKindOr:()=>Tn,offscreen:()=>ca,openList:()=>nc,overlap2:()=>Ji,overlaps:()=>rr,paddingOf:()=>Do,parseEnd:()=>wn,place:()=>Xi,placeBoard:()=>jo,placeCallout:()=>aa,placeNodeLabel:()=>Io,placeholderIcon:()=>Xl,plate:()=>au,polyBounds:()=>xs,polyRectArea:()=>Lr,rectArea:()=>oc,regionKind:()=>Ft,regionRole:()=>ha,registerMarks:()=>ou,renderScene:()=>ga,resolveSteps:()=>ua,routeAll:()=>sa,screenToGrid:()=>ws,silhouette:()=>vn,simplify:()=>No,snapMove:()=>Fo,wallHeight:()=>Gi,wallsOf:()=>pa});var Ft=(t,e)=>e!==void 0&&Object.hasOwn(t.regions,e)?t.regions[e]:void 0,nr=(t,e)=>t.nodes[e??t.defaultNode],Tn=(t,e)=>nr(t,e)??t.nodes[t.defaultNode],Gi=t=>Object.values(t.regions).find(e=>e.shape==="walled")?.z[1]??.8,Hi=t=>Object.values(t.regions).map(e=>e.css??"").join("");var Wl=Object.create(null),Jl=[];function ou(t){Object.assign(Wl,t.icons??{}),Object.assign(xr,t.faces??{}),t.css&&!Jl.includes(t.css)&&Jl.push(t.css)}var Yi=()=>Jl.join(""),Po=t=>Object.hasOwn(Wl,t)?Wl[t]:void 0,qi=t=>Object.hasOwn(xr,t)?xr[t]:void 0;function Xl(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 Ql(t,e,n){let s="";for(let r of n??[])r==="terminal"?s+=oo(t,e,3):r==="envelope"?s+=ei(t,e):r==="bubble"?s+=ti(t,e):r==="file-lines"?s+=ni(t,e):typeof r=="object"&&(r.terminal&&(s+=oo(t,e,r.terminal)),r.icon&&(s+=(Po(r.icon)??Xl)(t,e)));return s}var kp=(t,e)=>(t.deco??e.deco??[]).filter(n=>n!=="ghost");function iu(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)+Ql(a,l,kp(c,i))+(o?o(a,l):"")};return i}function au(t){let[e,n]=Zo(t);return{x0:e-.75,y0:n-.75,x1:e+.75,y1:n+.75,z0:t.z0,z1:t.z0+.18}}function Zl(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,d,u,f)=>{let p=Math.hypot(u-c,f-d),g=Math.max(1,Math.round(p/(n*1.7))),h="";for(let b=1;b<=g;b++){let k=c+(u-c)*b/g,v=d+(f-d)*b/g,M=p/g/2*1.08;h+=` A${M.toFixed(1)},${M.toFixed(1)} 0 0 1 ${k.toFixed(1)},${v.toFixed(1)}`}return h};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 Ui(t,e){let n={...e,z0:e.z1},s=a=>{let[l,c]=Xe(e.x0,e.y0,a);return[It,.5,-It,.5,l,c]},r=(e.x1-e.x0)*xt,o=(e.y1-e.y0)*xt,i=Zl(r,o);return t.onMatrix(s(e.z0),r,o,()=>Ve("path",{d:i,class:"lft cloud-side"}))+t.onMatrix(s(e.z1),r,o,()=>Ve("path",{d:i,class:"top cloud-top"}))}function lu(t,e){let[n,s]=Xe((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 es=.16,ec=["right-of","left-of","below","behind"];function Xi(t,e,n,s,r,o={},i){let a=[],l=(S,$,w,N=!1,F="error")=>{let J=n.locate(S,{key:N});a.push({severity:F,message:$,line:J.line,col:J.col,path:S,hint:w})},c=[],d=new Map,u=[],f=new Map,p=new Set([...Object.keys(s.roles),...Object.keys(o)]);function g(S,$){let w=d.get(S.id);if(w){let N=n.locate(w.path+"/id");return l(S.path+"/id",`duplicate id "${S.id}" (first used on line ${N.line})`),!1}return d.set(S.id,S),c.push(S),S.parent=$,$?$.children.push(S):u.push(S),!0}let h=()=>({x0:0,y0:0,z0:0,x1:0,y1:0,z1:0});function b(S,$,w){let N={id:S.id,type:"node",path:$,children:[],box:h(),floor:0,node:S,appears:S.appears,disappears:S.disappears};g(N,w)&&(S.nodes??[]).forEach((F,J)=>b(F,`${$}/nodes/${J}`,N))}function k(S,$,w){let N={id:S.id,type:"region",path:$,children:[],box:h(),floor:0,region:S,appears:S.appears,disappears:S.disappears};g(N,w)&&((S.nodes??[]).forEach((F,J)=>b(F,`${$}/nodes/${J}`,N)),(S.regions??[]).forEach((F,J)=>k(F,`${$}/regions/${J}`,N)))}(t.regions??[]).forEach((S,$)=>k(S,`${e}/regions/${$}`,void 0)),(t.nodes??[]).forEach((S,$)=>b(S,`${e}/nodes/${$}`,void 0));let v=()=>d.keys(),M=()=>c.filter(S=>S.type==="region").map(S=>S.id);for(let S of[...c]){let $=S.node??S.region;if($.in!==void 0){let N=d.get($.in);if(!N){l(S.path+"/in",`unknown region "${$.in}"`+Oo($.in,M()));continue}if(N.type!=="region"){l(S.path+"/in",`"${$.in}" is a node, not a region; put nodes on a node with its own "nodes:" list`);continue}if(S.parent&&S.parent!==N){l(S.path+"/in",`"${S.id}" is written inside "${S.parent.id}" but says in: ${$.in}; use one or the other`);continue}for(let F=N;F;F=F.parent)if(F===S){l(S.path+"/in",`"${S.id}" cannot be inside itself`);continue}S.parent||(u.splice(u.indexOf(S),1),S.parent=N,N.children.push(S))}if(S.node){let N=S.node.asset;N!==void 0&&!nr(r,N)&&l(S.path+"/asset",`unknown asset "${N}"`+Oo(N,Object.keys(r.nodes)),`assets: ${Object.keys(r.nodes).join(", ")}`)}let w=(S.node??S.region).role;w!==void 0&&!p.has(w)&&l(S.path+"/role",`unknown colour role "${w}"`+Oo(w,p),`add it under "roles:" at the top of the file, or use one of: ${[...p].join(", ")}`)}for(let S of c){let $=S.region?.gate;if(!$?.node)continue;let w=d.get($.node);if(!w){l(S.path+"/gate/node",`unknown node "${$.node}"`+Oo($.node,v()));continue}if(w.type!=="node"){l(S.path+"/gate/node",`"${$.node}" is a region; a gate is a node`);continue}w.placedBy=S.id;let N=w.node;(N.at||ec.some(F=>N[F]))&&l(w.path,`"${w.id}" is the gate of "${S.id}", which places it; its own placement is ignored`,void 0,!1,"warning")}let x=S=>S.gap??t.gap??2;function T(S){let $=S.node,w=Tn(r,$.asset),N=$.size,F=w.size[0],J=w.size[1],ae=w.size[2];if(N&&(F=N[0],J=N[1],N.length>2&&(ae=N[2])),S.placedBy){let we=d.get(S.placedBy).region,j=we.gate,U=j.width??2,ee=N?Math.min(F,J):.3;ae=N&&N.length>2?ae:j.height??(we.height??Gi(r))+.3,j.side==="e"||j.side==="w"?(F=ee,J=U):(F=U,J=ee)}return[F,J,ae]}function y(S,$,w,N,F){for(let ye of $)D(ye);let J=$.filter(ye=>!ye.placedBy),ae=new Set(J),we=new Set,j=[],U=new Set,ee=ye=>{let xe=ye.node??ye.region,Re=[];for(let Ue of ec){let I=xe[Ue];if(I===void 0)continue;let re=d.get(I);if(!re){l(`${ye.path}/${Ue}`,`unknown id "${I}"`+Oo(I,v()));continue}if(re===ye){l(`${ye.path}/${Ue}`,`"${ye.id}" cannot be placed ${Ue} itself`);continue}if(!ae.has(re)){let $e=Pe=>Pe.parent?`"${Pe.parent.id}"`:"the scene";l(`${ye.path}/${Ue}`,`"${I}" is in ${$e(re)} but "${ye.id}" is in ${$e(ye)}; relative placement works between items in the same region`,re.placedBy?`"${I}" is a gate, placed by its ${d.get(re.placedBy)?.region?.kind??"region"}`:`place "${ye.id}" relative to something in ${$e(ye)}, or use "at:"`);continue}Re.push(re)}if(!Re.length&&!xe.at){let Ue=J.indexOf(ye);Ue>0&&Re.push(J[Ue-1])}return Re},fe=ye=>{if(!we.has(ye)){if(U.has(ye)){l(ye.path,`placement loop: "${ye.id}" is placed relative to something placed relative to it`);return}U.add(ye),ee(ye).forEach(fe),U.delete(ye),we.add(ye),j.push(ye)}};J.forEach(fe);for(let ye of j){let xe=ye.node??ye.region,Re=f.get(ye),Ue=ec.find(I=>xe[I]!==void 0&&d.get(xe[I])&&ae.has(d.get(xe[I])));if(xe.at&&Ue&&l(`${ye.path}/at`,`"${ye.id}" has both "at" and "${Ue}"; "at" wins`,void 0,!0,"warning"),xe.at)Re.x=xe.at[0],Re.y=xe.at[1];else if(Ue)A(Re,f.get(d.get(xe[Ue])),Ue,x(xe),xe.align??"center");else{let I=J.indexOf(ye);I>0?A(Re,f.get(J[I-1]),N==="row"?"right-of":"below",x(xe),"center"):(Re.x=w,Re.y=w)}xe.shift&&(Re.x+=xe.shift[0],Re.y+=xe.shift[1])}if(F||!J.length)return{w:0,d:0};let B=1/0,X=1/0,Q=-1/0,te=-1/0;for(let ye of J){let xe=f.get(ye);B=Math.min(B,xe.x),X=Math.min(X,xe.y),Q=Math.max(Q,xe.x+xe.w),te=Math.max(te,xe.y+xe.d)}let ne=Math.min(0,B-w),me=Math.min(0,X-w);if(ne||me)for(let ye of J){let xe=f.get(ye);xe.x-=ne,xe.y-=me}return{w:Q-ne+w,d:te-me+w}}function A(S,$,w,N,F){let J=()=>{S.y=F==="start"?$.y:F==="end"?$.y+$.d-S.d:$.y+($.d-S.d)/2},ae=()=>{S.x=F==="start"?$.x:F==="end"?$.x+$.w-S.w:$.x+($.w-S.w)/2};w==="right-of"?(S.x=$.x+$.w+N,J()):w==="left-of"?(S.x=$.x-N-S.w,J()):w==="below"?(S.y=$.y+$.d+N,ae()):(S.y=$.y-N-S.d,ae())}function D(S){if(S.type==="node"){let[j,U,ee]=T(S);f.set(S,{x:0,y:0,w:j,d:U,h:ee,z:S.node.z??0}),S.children.length&&y(S,S.children,0,"row",!0);return}let $=S.region,w=$.padding??Ft(r,$.kind)?.pad,N=!!$.size,F=y(S,S.children,w,$.flow??"row",N),J=$.size?$.size[0]:Math.max(F.w,w*2+.5),ae=$.size?$.size[1]:Math.max(F.d,w*2+.5);if(!$.size&&$.gate){let j=($.gate.width??2)+1;$.gate.side==="e"||$.gate.side==="w"?ae=Math.max(ae,j):J=Math.max(J,j)}let we=$.size&&$.size.length>2?$.size[2]:$.height??Ft(r,$.kind).z[1];f.set(S,{x:0,y:0,w:J,d:ae,h:we,z:0})}y(void 0,u,0,t.flow??"row",!0);function K(S,$,w,N){let F=f.get(S),J=$+F.x,ae=w+F.y;if(S.type==="region"){let we=Ft(r,S.region.kind),[j]=we.z,U=we.floor,ee=we.shape==="slab"&&Ft(r,S.parent?.region?.kind)?.shape==="slab"?0:j,fe=S.region.z??0,B=N+ee+fe,X=N+F.h+fe;S.box={x0:J,y0:ae,z0:B,x1:J+F.w,y1:ae+F.d,z1:X},S.floor=U?X:N}else{let we=N+F.z;S.box={x0:J,y0:ae,z0:we,x1:J+F.w,y1:ae+F.d,z1:we+F.h},S.floor=S.box.z1}for(let we of S.children)we.placedBy||K(we,J,ae,S.floor)}for(let S of u)S.placedBy||K(S,0,0,0);if(i){let S=w=>Math.round(w/i)*i,$=w=>Math.round(w*1e9)/1e9;for(let w of c){if(w.placedBy)continue;let N=w.box,F=S(N.x0),J=S(N.x1),ae=S(N.y0),we=S(N.y1);J-F<i&&(J=F+i),we-ae<i&&(we=ae+i),w.box={...N,x0:$(F),x1:$(J),y0:$(ae),y1:$(we)};let j=w.node??w.region;j.at&&j.at.forEach((U,ee)=>{let fe=U/i;Math.abs(fe-Math.round(fe))>1e-6&&l(`${w.path}/at/${ee}`,`${U} is not on the ${i} grid; it is drawn at ${$(S(U))}`,void 0,!1,"warning")})}}for(let S of c){let $=S.region?.gate;if(!$?.node)continue;let w=d.get($.node);!w||w.placedBy!==S.id||(w.box=Co(S,f.get(w).h,f.get(w).w,f.get(w).d),w.floor=w.box.z1)}for(let S of c){let $=S.children.filter(w=>!w.placedBy);for(let w=0;w<$.length;w++)for(let N=w+1;N<$.length;N++){let F=$[w],J=$[N];Wi(F,r)||Wi(J,r)||Ji(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(S.parent&&S.parent.type==="region"&&!S.placedBy){let w=S.parent.box,N=S.box,F=1e-6;(N.x0<w.x0-F||N.y0<w.y0-F||N.x1>w.x1+F||N.y1>w.y1+F)&&l(S.path,`"${S.id}" sticks out of region "${S.parent.id}"`,`make "${S.parent.id}" bigger, or leave out its "size" so it fits its contents`,!1,"warning")}}{let S=u.filter($=>!$.placedBy);for(let $=0;$<S.length;$++)for(let w=$+1;w<S.length;w++){let N=S[$],F=S[w];Ji(N.box,F.box)&&!Wi(N,r)&&!Wi(F,r)&&l(F.path,`"${F.id}" overlaps "${N.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}}let C=new Set,_=a.filter(S=>{let $=S.path+S.message;return C.has($)?!1:(C.add($),!0)});return{items:c,byId:d,roots:u,diags:_,catalog:r}}var Wi=(t,e)=>t.type==="region"&&["zone","tunnel"].includes(Ft(e,t.region.kind)?.shape??"");function Co(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+es/2:o.x1-es/2,f=o.y0+(o.y1-o.y0)*a;return{x0:u-n/2,x1:u+n/2,y0:f-l/2,y1:f+l/2,z0:i,z1:i+e}}let c=r.side==="n"?o.y0+es/2:o.y1-es/2,d=o.x0+(o.x1-o.x0)*a;return{x0:d-l/2,x1:d+l/2,y0:c-s/2,y1:c+s/2,z0:i,z1:i+e}}function Ji(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 Oo(t,e){let n=Is(t,e);return n?` (did you mean "${n}"?)`:""}var bs=.2,Qi=.05,Sp=.6,Zi=.25,ea={n:[0,-1],s:[0,1],e:[1,0],w:[-1,0]};function wn(t){let e=/^(.*?)(?:\.(n|e|s|w|top))?$/.exec(t);return{id:e[1],side:e[2]}}var cu=new WeakMap;function Cr(t,e,n){let s=cu.get(t);if(!s){s=[];for(let i of t.items){if(i.type!=="region"||!Ft(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})}cu.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 Mp(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 na=5e5;function sa(t,e,n,s,r,o){let i=[],a=(M,x,T,y="error")=>{let A=s.locate(M);i.push({severity:y,message:x,line:A.line,col:A.col,path:M,hint:T})},l=t.routes??[],c={left:na},d=0,u=()=>n.items.map(M=>M.id),f=new Map,p=[],g=[];l.forEach((M,x)=>{let T=`${e}/routes/${x}`;(f.has(M.id)||n.byId.has(M.id))&&a(T+"/id",`duplicate id "${M.id}"`),f.set(M.id,x);let y=M.kind??"send";r.has(y)||a(T+"/kind",`unknown flow kind "${y}"`+tc(y,r),`kinds: ${[...r].join(", ")}; add one under "kinds:"`);let A={id:M.id,raw:M,path:T,kind:y,points:[]},D=(K,C)=>{let{id:_}=wn(K),S=n.byId.get(_);if(!S){a(`${T}/${C}`,`unknown node "${_}"`+tc(_,u()));return}return S};A.from=D(M.from,"from"),A.to=D(M.to,"to"),p.push(A),g.push({r:A})});let h=new Map;for(let M of g){let{r:x}=M;if(!x.from||!x.to||x.raw.points)continue;let T=wn(x.raw.from).side,y=wn(x.raw.to).side,A=x.raw.via?.[0],D=x.raw.via?.[x.raw.via.length-1],K=($,w)=>{if(Array.isArray($))return{x0:$[0],x1:$[0],y0:$[1],y1:$[1],z0:0,z1:0};if(typeof $=="string"){let N=n.byId.get(wn($).id);if(N)return N.box}return w.box},C=($,w,N)=>{let F=w??Mp($.box,N);return{node:$,side:F,explicit:!!w,p:[0,0],z:0}};M.a=C(x.from,T,K(A,x.to)),M.b=C(x.to,y,K(D,x.from));let _=K(A,x.to),S=K(D,x.from);for(let[$,w]of[[M.a,_],[M.b,S]]){let N=`${$.node.id}.${$.side}`;h.has(N)||h.set(N,[]),h.get(N).push({e:$,other:[(w.x0+w.x1)/2,(w.y0+w.y1)/2]})}}for(let[,M]of h){let x=M[0].e,T=x.node.box,y=x.side,A=y==="e"||y==="w"?1:0;M.sort(($,w)=>$.other[A]-w.other[A]);let D=A?T.y0:T.x0,K=A?T.y1:T.x1,C=(D+K)/2,_=Math.max(0,K-D-.3),S=M.length>1?Math.min(Sp,_/(M.length-1)):0;M.forEach(($,w)=>{let N=(w-(M.length-1)/2)*S,F=C+N,J=$.e.node.box.z0;if(y==="top"){$.e.p=[(T.x0+T.x1)/2,(T.y0+T.y1)/2],$.e.z=T.z1;return}let[ae,we]=ea[y];$.e.p=A?[ae>0?T.x1+Qi:T.x0-Qi,F]:[F,we>0?T.y1+Qi:T.y0-Qi],$.e.z=J})}let b=[];for(let M of n.items)M.type==="node"&&b.push(M.box);let k=[];for(let M of n.items.filter(x=>Ft(n.catalog,x.region?.kind)?.shape==="walled")){let{x0:x,y0:T,x1:y,y1:A}=M.box,D=es,K=M.region.gate,C=[[{x0:x,y0:T,x1:y,y1:T+D,z0:0,z1:0},"n"],[{x0:x,y0:A-D,x1:y,y1:A,z0:0,z1:0},"s"],[{x0:x,y0:T,x1:x+D,y1:A,z0:0,z1:0},"w"],[{x0:y-D,y0:T,x1:y,y1:A,z0:0,z1:0},"e"]];for(let[_,S]of C)if(K&&K.side===S){if(K.node)continue;let $=K.at??.5,w=K.width??2;if(S==="e"||S==="w"){let N=T+(A-T)*$;k.push({..._,y1:N-w/2},{..._,y0:N+w/2})}else{let N=x+(y-x)*$;k.push({..._,x1:N-w/2},{..._,x0:N+w/2})}}else k.push(_)}let v=new Map;for(let M of g){let{r:x,a:T,b:y}=M;if(x.raw.points){x.points=x.raw.points.map(F=>[F[0],F[1],F.length>2?F[2]:Cr(n,F[0],F[1])+.01]);continue}if(!T||!y)continue;let A=[];(x.raw.via??[]).forEach((F,J)=>{if(Array.isArray(F))if(o){let ae=we=>Math.round(Math.round(we/o)*o*1e9)/1e9;F.forEach((we,j)=>{Math.abs(we/o-Math.round(we/o))>1e-6&&a(`${x.path}/via/${J}/${j}`,`${we} is not on the ${o} grid; it is drawn at ${ae(we)}`,void 0,"warning")}),A.push({p:[ae(F[0]),ae(F[1])]})}else A.push({p:[F[0],F[1]]});else{let{id:ae,side:we}=wn(F),j=n.byId.get(ae);if(!j){a(`${x.path}/via/${J}`,`unknown node "${ae}"`+tc(ae,u()));return}let U=we&&we!=="top"?we:"n",[ee,fe]=ea[U],B=j.box;A.push({p:[ee?ee>0?B.x1+.4:B.x0-.4:(B.x0+B.x1)/2,fe?fe>0?B.y1+.4:B.y0-.4:(B.y0+B.y1)/2]})}});let K=b.filter(F=>F!==T.node.box&&F!==y.node.box).concat(x.raw.cross?[]:k).filter(F=>!ta(T.node.box,F)&&!ta(y.node.box,F)&&!ta(F,T.node.box)&&!ta(F,y.node.box)),C=T.side==="top"?void 0:ea[T.side],_=y.side==="top"?void 0:ea[y.side],S=[T.p,...A.map(F=>F.p),y.p],$=[T.p],w=C,N=!0;for(let F=0;F+1<S.length;F++){let J=F+2===S.length,ae=Ep(S[F],S[F+1],K,v,w,J&&_?[-_[0],-_[1]]:void 0,c);if(!ae){N=!1;break}$.push(...ae.slice(1));let we=$.length;if(we>=2){let j=Math.sign($[we-1][0]-$[we-2][0]),U=Math.sign($[we-1][1]-$[we-2][1]);w=[j,U]}}!N&&c.left<=0?(d++,$=[T.p,[y.p[0],T.p[1]],y.p]):N||(a(x.path,`no path found for route "${x.id}" from "${T.node.id}" to "${y.node.id}"`,'add "via" points, or use "points" to draw it by hand',"warning"),$=[T.p,[y.p[0],T.p[1]],y.p]),$=No($);for(let F=0;F+1<$.length;F++)$p(v,$[F],$[F+1]);x.points=Pp(n,$,T,y)}return d&&a(e,`${d} of ${p.length} routes were drawn as plain elbows: the scene is too large to route them all around what stands in the way (${na.toLocaleString("en")} search steps)`,'split it into scenes, or give the busiest routes "via" points or "points"',"warning"),{routes:p,diags:i}}function ta(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 du=(t,e)=>`${Math.round(t/bs)},${Math.round(e/bs)}`;function $p(t,e,n){let s=Math.max(1,Math.round(Math.hypot(n[0]-e[0],n[1]-e[1])/bs));for(let r=0;r<=s;r++){let o=du(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 uu(t,e,n){for(let s of n)if(t>s.x0-Zi&&t<s.x1+Zi&&e>s.y0-Zi&&e<s.y1+Zi)return!0;return!1}function Ep(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)&&Ap(t,e,n)){let j=[Math.sign(e[0]-t[0]),Math.sign(e[1]-t[1])],U=!r||r[0]===j[0]&&r[1]===j[1],ee=!o||o[0]===j[0]&&o[1]===j[1];if(U&&ee)return[t,e]}if(i.left<=0)return null;let a=j=>Math.round((j-t[0])/bs),l=j=>Math.round((j-t[1])/bs),c=j=>t[0]+j*bs,d=j=>t[1]+j*bs,u=a(e[0]),f=l(e[1]),p=30,g=Math.min(0,u)-p,h=Math.max(0,u)+p,b=Math.min(0,f)-p,k=Math.max(0,f)+p,v=1.2,M=bs,x=.06,T=[[1,0],[-1,0],[0,1],[0,-1]],y=h-g+1,A=k-b+1,D=(j,U)=>(j-g)*A+(U-b),K=new Int8Array(y*A).fill(-1),C=new Float64Array(y*A).fill(-1),_=new Float64Array(y*A*4).fill(1/0),S=(j,U)=>{let ee=D(j,U);return K[ee]<0&&(K[ee]=uu(c(j),d(U),n)?1:0),K[ee]===1},$=(j,U)=>{let ee=D(j,U);return C[ee]<0&&(C[ee]=s.get(du(c(j),d(U)))??0),C[ee]},w=nc(),N=(j,U)=>(Math.abs(j-u)+Math.abs(U-f))*M,F=r?T.findIndex(j=>j[0]===r[0]&&j[1]===r[1]):-1;w.push({i:0,j:0,d:F,g:0,f:N(0,0),idx:0,hp:0});let J=(j,U)=>Math.abs(j)+Math.abs(U)<=2,ae=(j,U)=>Math.abs(j-u)+Math.abs(U-f)<=2,we=0;for(;w.length()&&we++<2e5;){if(i.left--<=0)return null;let j=w.take();if(j.i===u&&j.j===f&&!(o&&j.d>=0&&(T[j.d][0]!==o[0]||T[j.d][1]!==o[1]))){let U=[];for(let ee=j;ee;ee=ee.prev)U.push([c(ee.i),d(ee.j)]);return U.reverse(),U[0]=t,Tp(No(U),e)}for(let U=0;U<4;U++){let ee=T[U];if(j.d>=0&&ee[0]===-T[j.d][0]&&ee[1]===-T[j.d][1])continue;let fe=j.i+ee[0],B=j.j+ee[1];if(fe<g||fe>h||B<b||B>k||!J(fe,B)&&!ae(fe,B)&&S(fe,B))continue;if((J(fe,B)||ae(fe,B))&&S(fe,B)&&!(fe===u&&B===f)){let ne=J(fe,B)?r:o&&[-o[0],-o[1]];if(!ne||(J(fe,B)?ee[0]!==ne[0]||ee[1]!==ne[1]:ee[0]!==o[0]||ee[1]!==o[1]))continue}let X=j.d>=0&&j.d!==U?v:0,Q=j.g+M+X+$(fe,B)*x,te=D(fe,B)*4+U;_[te]<=Q||(_[te]=Q,w.push({i:fe,j:B,d:U,g:Q,f:Q+N(fe,B),prev:j,idx:0,hp:0}))}}return null}function nc(){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 Tp(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,No(n)}function Ap(t,e,n){let s=Math.max(1,Math.round(Math.hypot(e[0]-t[0],e[1]-t[1])/(bs/2)));for(let r=2;r<s-1;r++)if(uu(t[0]+(e[0]-t[0])*r/s,t[1]+(e[1]-t[1])*r/s,n))return!1;return!0}function No(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 Pp(t,e,n,s){let r=new Set,o=new Set;for(let c of t.items)c.type!=="region"||!Ft(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,d)=>Cr(t,c,d)+.01;for(let c=0;c+1<e.length;c++){let[d,u]=e[c],[f,p]=e[c+1],g=[0,1];if(Math.abs(u-p)<1e-6)for(let h of r){let b=(h-d)/(f-d);b>1e-6&&b<1-1e-6&&g.push(b)}else for(let h of o){let b=(h-u)/(p-u);b>1e-6&&b<1-1e-6&&g.push(b)}g.sort((h,b)=>h-b);for(let h=0;h+1<g.length;h++){let b=g[h],k=g[h+1],v=(b+k)/2,M=a(d+(f-d)*v,u+(p-u)*v),x=[d+(f-d)*b,u+(p-u)*b,M],T=[d+(f-d)*k,u+(p-u)*k,M],y=i[i.length-1];y&&(Math.abs(y[0]-x[0])>1e-6||Math.abs(y[1]-x[1])>1e-6||Math.abs(y[2]-x[2])>1e-6)?i.push(x):y||i.push(x),i.push(T)}}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 d=l.length;if(d>=2){let u=l[d-2],f=l[d-1],p=Math.abs(u[2]-f[2])<1e-9&&Math.abs(f[2]-c[2])<1e-9,g=Math.abs(u[0]-f[0])<1e-6&&Math.abs(f[0]-c[0])<1e-6||Math.abs(u[1]-f[1])<1e-6&&Math.abs(f[1]-c[1])<1e-6;if(p&&g){l[d-1]=c;continue}}l.push(c)}return l}function tc(t,e){let n=Is(t,e);return n?` (did you mean "${n}"?)`:""}function vn(t){return[Xe(t.x0,t.y0,t.z1),Xe(t.x1,t.y0,t.z1),Xe(t.x1,t.y0,t.z0),Xe(t.x1,t.y1,t.z0),Xe(t.x0,t.y1,t.z0),Xe(t.x0,t.y1,t.z1)]}function xs(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 Lr(t,e){let n=t,s=(a,l)=>{let c=[];for(let d=0;d<n.length;d++){let u=n[d],f=n[(d+1)%n.length],p=a(u),g=a(f);p&&c.push(u),p!==g&&c.push(l(u,f))}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 oc(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 mu(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,d=r[1]+(o[1]-r[1])*(l+.5)/a;c>=e.x&&c<=e.x+e.w&&d>=e.y&&d<=e.y+e.h&&(n+=i/a*4)}}return n}var ys=64,oa=class{cells=new Map;n=0;add(e,n,s,r,o){for(let i=Math.floor(n/ys);i<=Math.floor(r/ys);i++)for(let a=Math.floor(s/ys);a<=Math.floor(o/ys);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/ys);i<=Math.floor(s/ys);i++)for(let a=Math.floor(n/ys);a<=Math.floor(r/ys);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)}},sc=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]},ia=new WeakMap;function Ds(t,e){let n=ia.get(t);for((!n||n.n>t.length)&&ia.set(t,n=new oa);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 fu(t){let e=ia.get(t);for((!e||e.n>t.length)&&ia.set(t,e=new oa);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])/(ys/2)));for(let l=0;l<a;l++){let c=l/a,d=(l+1)/a,u=r[0]+(o[0]-r[0])*c,f=r[1]+(o[1]-r[1])*c,p=r[0]+(o[0]-r[0])*d,g=r[1]+(o[1]-r[1])*d;e.add(i,Math.min(u,p)-1,Math.min(f,g)-1,Math.max(u,p)+1,Math.max(f,g)+1)}}}return e}var ts=(t,e,n,s,r)=>t.query(e,n,s,r),Nr=t=>sc(t),ra=t=>[t.x,t.y,t.x+t.w,t.y+t.h];function pu(t,e,n,[s,r,o,i]){let a=0,l=n-1;for(let c of[0,1]){let d=e[c]-t[c],u=c?r:s,f=c?i:o;if(Math.abs(d)<1e-12){if(t[c]<u||t[c]>f)return[1,0];continue}let p=(u-t[c])/d*n-.5,g=(f-t[c])/d*n-.5;p>g&&([p,g]=[g,p]),a=Math.max(a,Math.floor(p)-1),l=Math.min(l,Math.ceil(g)+1)}return[a,l]}var sr=class t{polys=[];rects=[];lines=[];solids=[];slants=[];budget={spots:1/0,over:!1,told:!1};hidden(e){let n=0;for(let s of ts(Ds(this.solids,Nr),...ra(e)))n+=Lr(this.solids[s],e);return n}hiddenPoly(e){let n=0;for(let s of ts(Ds(this.solids,Nr),...sc(e)))n+=Lo(e,this.solids[s]);return n}costPoly(e,n=1/0){let s=sc(e),r=0;for(let o of ts(Ds(this.polys,i=>Nr(i.poly)),...s))r+=Lo(e,this.polys[o].poly);for(let o of ts(Ds(this.rects,i=>ra(i.r)),...s))r+=Lr(e,this.rects[o].r)*2;for(let o of ts(Ds(this.slants,Nr),...s))r+=Lo(e,this.slants[o])*2;if(r>=n)return r;for(let o of ts(fu(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],d=Math.hypot(c[0]-l[0],c[1]-l[1]),u=Math.max(1,Math.ceil(d/4)),[f,p]=pu(l,c,u,s);for(let g=f;g<=p;g++)ac(e,[l[0]+(c[0]-l[0])*(g+.5)/u,l[1]+(c[1]-l[1])*(g+.5)/u])&&(r+=d/u*4*.6)}return r}cost(e,n,s=.6){let r=ra(e),o=0;for(let i of ts(Ds(this.polys,a=>Nr(a.poly)),...r)){let a=this.polys[i];o+=Lr(a.poly,e)*(a.owner===n?1.5:1)}for(let i of ts(Ds(this.rects,a=>ra(a.r)),...r)){let a=this.rects[i];(a.owner!==n||!n)&&(o+=oc(a.r,e)*2)}for(let i of ts(Ds(this.slants,Nr),...r))o+=Lr(this.slants[i],e)*2;if(s){let i=-1,a=0;for(let l of ts(fu(this.lines),...r)){let c=Math.floor(l/65536);c!==i&&(i>=0&&(o+=a*s),i=c,a=0);let d=this.lines[c].pts,u=l%65536,f=d[u],p=d[u+1],g=Math.hypot(p[0]-f[0],p[1]-f[1]),h=Math.max(1,Math.ceil(g/4)),[b,k]=pu(f,p,h,r);for(let v=b;v<=k;v++){let M=f[0]+(p[0]-f[0])*(v+.5)/h,x=f[1]+(p[1]-f[1])*(v+.5)/h;M>=e.x&&M<=e.x+e.w&&x>=e.y&&x<=e.y+e.h&&(a+=g/h*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}},hu=14;function Ro(t,e,n,s){let r=Math.max(t.name?$n(t.name,Bt.lbl):0,t.sub?$n(t.sub,Bt.sub):0)+4,o=(t.name?1:0)+(t.sub?1:0),i=n-(t.name?11:9)-1,a=(o-1)*hu+(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 Io(t,e,n,s,r,o){let i=xs(n),a=Xe((e.x0+e.x1)/2,(e.y0+e.y1)/2,e.z1)[0],c=((t.name?1:0)+(t.sub?1:0)-1)*hu+4,d=i.y-6-c,u=i.y+Math.min(i.h,60)*.45,f=[];o&&f.push({...o,pen:0}),f.push({x:a,y:d,anchor:"middle",pen:o?20:0});for(let h of[12,24,40])f.push({x:a,y:d-h,anchor:"middle",pen:20+h});for(let h of[-30,30,-60,60])f.push({x:a+h,y:d-4,anchor:"middle",pen:30+Math.abs(h)});f.push({x:i.x+i.w+8,y:u,anchor:"start",pen:120}),f.push({x:i.x-8,y:u,anchor:"end",pen:120}),f.push({x:a,y:i.y+i.h+14,anchor:"middle",pen:300});let p,g=1/0;for(let h of f){let b=Ro(t,h.x,h.y,h.anchor),k=s.cost(b,r,.15)*2+h.pen;k<g&&(g=k,p={x:h.x,y:h.y,anchor:h.anchor,rect:b})}return p}function ic(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 aa(t,e,n,s,r){let o=[{...s,pen:0}];for(let d of[-46,-66,-86,-106,-126,-146])for(let u of[0,-70,70,-140,140])o.push({x:e+u,y:n+d,anchor:"middle",pen:10+(-d-46)*.5+Math.abs(u)*.4});for(let d of[34,60,86])o.push({x:e,y:n+d,anchor:"middle",pen:60+d*.3});let i=s.x-e,a=s.y-n;for(let d of[-1,1])for(let u of[16,32,48])o.push({...s,y:n+a+d*u,x:e+i,pen:5+u});for(let d of[-1,1])for(let u of[30,60,90])for(let f of[0,16,-16])o.push({...s,x:e+i+d*u,y:n+a+f,pen:8+u*.6+Math.abs(f)});let l,c=1/0;for(let d of o){let u=ic(t,d.x,d.y,d.anchor),f=r.cost(u,void 0,.05)*3+d.pen;f<c&&(c=f,l={x:d.x,y:d.y,anchor:d.anchor,rect:u})}return l}var gu=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},rc=t=>gu(t)<0?[...t].reverse():t;function ac(t,e){let n=rc(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 Lo(t,e){let n=rc(t),s=rc(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 d=l[c],u=l[(c+1)%l.length],f=a(d),p=a(u);if(f>=0&&n.push(d),f>=0!=p>=0){let g=f/(f-p);n.push([d[0]+(u[0]-d[0])*g,d[1]+(u[1]-d[1])*g])}}}return n.length>=3?Math.abs(gu(n)):0}var la=24;function ca(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((d,u)=>d[1]-u[1]);let c=l[0][0];return c==="left"?{edge:c,dx:-(t.x+t.w-n)-la,dy:0}:c==="right"?{edge:c,dx:n+r-t.x+la,dy:0}:c==="top"?{edge:c,dx:0,dy:-(t.y+t.h-s)-la}:{edge:c,dx:0,dy:s+o-t.y+la}}function da(t,e,n){let s=x=>{let T=0;for(let y=x.parent;y;y=y.parent)T++;return T},r=x=>x.box.x0+x.box.y0+x.box.z0*.01,o=t.items.filter(x=>x.type==="region").sort((x,T)=>s(x)-s(T)||r(x)-r(T)),i=t.items.filter(x=>x.type==="node").sort((x,T)=>r(x)-r(T)||x.box.z0-T.box.z0),a=[],l=Math.min(90,400/Math.max(1,o.length)),c=650;o.forEach((x,T)=>{let y=xs(vn(x.box));a.push({id:x.id,kind:"region",...ca(y,n),delay:Math.round(T*l),dur:c,bbox:y})});let d=250+Math.round(l*o.length),u=Math.min(70,700/Math.max(1,i.length)),f=600;i.forEach((x,T)=>{let y=xs(vn(x.box));a.push({id:x.id,kind:"node",...ca(y,n),delay:Math.round(d+T*u),dur:f,bbox:y})});let p=i.length?d+(i.length-1)*u:d,g=Math.round(p+300),h=Math.min(30,300/Math.max(1,e.length)),b=400,k=e.filter(x=>x.points.length>=2).map((x,T)=>({id:x.id,delay:Math.round(g+T*h),dur:b})),v={delay:g+200,dur:400},M=Math.max(...a.map(x=>x.delay+x.dur),...k.map(x=>x.delay+x.dur),v.delay+v.dur);return{pieces:a,routes:k,labels:v,total:M}}function lc(t){return Math.max(5600,Math.min(12500,2600+t.length*40))}function ua(t,e,n,s,r,o){let i=[],a=(C,_,S,$="error")=>{let w=r.locate(C);i.push({severity:$,message:_,line:w.line,col:w.col,path:C,hint:S})},l=t.steps??[],c=new Set(Object.keys(o.kinds)),d=new Map(s.map(C=>[C.id,C])),u=()=>[...n.byId.keys(),...d.keys()],f=new Map;l.forEach((C,_)=>{C.id&&(f.has(C.id)&&a(`${e}/steps/${_}/id`,`duplicate step id "${C.id}"`),f.set(C.id,_+1))});let p=l.length,g=(C,_)=>{if(typeof C=="number"){if(C<1||C>p){a(_,`there is no step ${C}; this scene has ${p} step(s)`);return}return C}let S=f.get(C);return S===void 0&&a(_,`unknown step "${C}"`+An(C,f.keys())),S},h=C=>Zn(o,o.kinds[C]?.color??"control"),b=[],k=C=>{b.includes(C)||b.push(C)};for(let C of s)k(C.kind);let v={},M=(C,_,S,$)=>{if(_===void 0&&S===void 0)return;let w=_!==void 0?g(_,$+"/appears"):1,N=S!==void 0?g(S,$+"/disappears"):p+1;v[C]=Array.from({length:p},(F,J)=>J+1>=(w??1)&&J+1<(N??p+1))};for(let C of n.items)M(C.id,C.appears,C.disappears,C.path);for(let C of s)M(C.id,C.raw.appears,C.raw.disappears,C.path);let x=[],T=[],y=[],A=[],D=()=>{for(let C of s){if(C.raw.appears!==void 0||C.raw.disappears!==void 0)continue;let _=[C.from,C.to].map(S=>S&&(v[S.id]??K(S)));_.some(Boolean)&&(v[C.id]=Array.from({length:p},(S,$)=>_.every(w=>!w||w[$])))}},K=C=>{for(let _=C.parent;_;_=_.parent)if(v[_.id])return v[_.id]};return l.forEach((C,_)=>{let S=_+1,$=`${e}/steps/${_}`,w=C.kind??"control";c.has(w)||a($+"/kind",`unknown flow kind "${w}"`+An(w,c)),k(w);let N=new Set,F=[];(C.animate??[]).forEach((j,U)=>{let ee=Array.isArray(j)?j:[j],fe=[];ee.forEach((B,X)=>{let Q=Array.isArray(j)?`${$}/animate/${U}/${X}`:`${$}/animate/${U}`,te,ne;if(typeof B=="string"){let xe=/^([^:\s]+)\s*(?::\s*(\S+))?$/.exec(B.trim());te=xe?xe[1]:B,ne=xe?.[2]}else{let xe=Object.entries(B)[0];te=xe[0],ne=xe[1]}let me=d.get(te);if(!me){a(Q,`unknown route "${te}"`+An(te,d.keys()));return}if(ne&&!c.has(ne)){a(Q,`unknown flow kind "${ne}"`+An(ne,c));return}let ye=ne??me.kind;k(ye),fe.push({route:te,kind:ye,color:h(ye)}),N.add(te),me.from&&N.add(me.from.id),me.to&&N.add(me.to.id)}),fe.length&&F.push(fe)});let J=[];(C.pulse??[]).forEach((j,U)=>{let ee=n.byId.get(j);if(!ee){a(`${$}/pulse/${U}`,`unknown node "${j}"`+An(j,n.byId.keys()));return}let fe,B,X,Q,te=ee.node?nr(n.catalog,ee.node.asset):void 0;if(te?.pulse)[fe,B,X,Q]=te.pulse(ee.box);else{let ye=ee.box;fe=(ye.x0+ye.x1)/2,B=(ye.y0+ye.y1)/2,X=ye.z1,Q=Math.max(22,Math.min(60,(ye.x1-ye.x0+ye.y1-ye.y0)*8.5))}let[ne,me]=Xe(fe,B,X);J.push([ne,me,Q*1.7,Q*.98]),N.add(j)}),(C.highlight??[]).forEach((j,U)=>{!n.byId.has(j)&&!d.has(j)&&a(`${$}/highlight/${U}`,`unknown id "${j}"`+An(j,u())),N.add(j)});for(let[j,U]of[["show",!0],["hide",!1]])(C[j]??[]).forEach((ee,fe)=>{if(!n.byId.has(ee)&&!d.has(ee)){a(`${$}/${j}/${fe}`,`unknown id "${ee}"`+An(ee,u()));return}let B=v[ee]??(v[ee]=Array(p).fill(!U));for(let X=_;X<p;X++)B[X]=U});if((C.say??[]).forEach((j,U)=>{let ee,fe;if(Array.isArray(j.at))[ee,fe]=Xe(j.at[0],j.at[1],j.at[2]??.36);else{let X=n.byId.get(j.at);if(!X){a(`${$}/say/${U}/at`,`unknown node "${j.at}"`+An(j.at,n.byId.keys()));return}let Q=X.box;[ee,fe]=Xe((Q.x0+Q.x1)/2,(Q.y0+Q.y1)/2,Q.z1+.75)}let B=j.kind??w;c.has(B)||a(`${$}/say/${U}/kind`,`unknown flow kind "${B}"`+An(B,c)),T.push({step:S,x:ee+(j.dx??0),y:fe+(j.dy??(Array.isArray(j.at)?0:-46)),ax:ee,ay:fe,text:j.text,kind:B,anchor:j.anchor??"middle"})}),(C.mark??[]).forEach((j,U)=>{if(j.at){y.push({step:S,p:[j.at[0],j.at[1],j.at[2]??.36]});return}let ee=j.on?d.get(j.on):void 0;if(!ee){a(`${$}/mark/${U}`,j.on?`unknown route "${j.on}"`+An(j.on,d.keys()):'a mark needs "on: ROUTE" or "at: [x, y]"');return}let fe=ee.points[ee.points.length-1];y.push({step:S,p:[fe[0],fe[1],fe[2]+.6],on:ee.id}),N.add(ee.id)}),t.badges&&C.badge!==!1){let j=Array.isArray(C.badge)?[C.badge[0],C.badge[1],C.badge[2]??.36]:void 0,U=typeof C.badge=="string"?C.badge:F[0]?.[0]?.route,ee=U?d.get(U):void 0;if(!j)if(ee)j=cc(ee.points);else if(U&&n.byId.get(U)){let fe=n.byId.get(U).box;j=[(fe.x0+fe.x1)/2,(fe.y0+fe.y1)/2,fe.z1+.3]}else typeof C.badge=="string"&&a(`${$}/badge`,`unknown id "${C.badge}"`+An(C.badge,u()));j&&A.push({step:S,num:C.number??S,kind:w,p:j})}for(let j of[...N])for(let U=n.byId.get(j)?.parent;U;U=U.parent)N.add(U.id);for(let j of n.items)j.region?.kind==="tunnel"&&(j.region.around??[]).some(U=>N.has(U))&&N.add(j.id);let ae;if(C.focus?.length){let j=1/0,U=1/0,ee=-1/0,fe=-1/0;C.focus.forEach((B,X)=>{let Q=n.byId.get(B);if(!Q){a(`${$}/focus/${X}`,`unknown node or region "${B}"`+An(B,n.byId.keys()));return}let te=Q.box;for(let[ne,me,ye]of[[te.x0,te.y0,te.z1],[te.x1,te.y0,te.z0],[te.x0,te.y1,te.z0],[te.x1,te.y1,te.z0],[te.x1,te.y0,te.z1],[te.x0,te.y1,te.z1]]){let[xe,Re]=Xe(ne,me,ye);j=Math.min(j,xe),U=Math.min(U,Re),ee=Math.max(ee,xe),fe=Math.max(fe,Re)}N.add(B)}),j<1/0&&(ae=[Math.round(j-60),Math.round(U-70),Math.round(ee+60),Math.round(fe+40)])}let we=C.caption??"";x.push({n:S,num:C.number??S,kind:w,color:h(w),heading:C.heading,caption:we,command:C.command??"",phases:F,pulses:J,lit:[...N],duration:C.duration===void 0||C.duration==="auto"?lc(we):C.duration,...ae?{focus:ae}:{}})}),D(),{steps:x,says:T,marks:y,badges:A,vis:v,diags:i,kindsUsed:b}}function cc(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 An(t,e){let n=Is(t,e);return n?` (did you mean "${n}"?)`:""}function bu(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,d=(s+o)/2,u=Math.max(t[0],Math.min(t[0]+t[2]-a,c-a/2)),f=Math.max(t[1],Math.min(t[1]+t[3]-l,d-l/2));return[u,f,a,l]}var ha=(t,e)=>e.role??Ft(t,e.kind)?.role,fa=(t,e)=>Ft(t,e.region.kind)?.shape;function ga({scene:t,layout:e,routes:n,steps:s,theme:r,id:o,gridStep:i=1}){let a=new yr,l={base:"",floor:"",flows:"",blocks:[],air:"",labels:"",marks:"",badges:""},c=new sr;c.budget.spots=ma;let d=w=>s.vis[w]?{"data-vis":"1"}:{},u=e.items.filter(w=>w.type==="region"),f=w=>{let N=0;for(let F=w.parent;F;F=F.parent)N++;return N},p=e.catalog,g=u.filter(w=>fa(p,w)!=="walled"&&fa(p,w)!=="tunnel"),h=io(g.map(w=>({box:w.box,r:w}))).map(w=>w.r).sort((w,N)=>f(w)-f(N));for(let w of h)l.base+=Cp(a,p,w,d(w.id),i);for(let w of u.filter(N=>fa(p,N)==="walled")){for(let F of pa(w))c.solids.push(vn(F));for(let F of pa(w))l.blocks.push({box:F,svg:Ve("g",{class:`blk k-${ha(p,w.region)} wall${w.region.ghost?" ghost":""}`,"data-id":w.id,"data-dim":"1",...d(w.id)},a.blockFaces(F))});let N=w.region.gate;if(N&&!N.node){let F=Co(w,N.height??(w.region.height??.8)+.3,.3,.3);c.solids.push(vn(F)),l.blocks.push({box:F,svg:Ve("g",{class:"blk k-gate","data-id":w.id,...d(w.id)},a.blockFaces(F))})}w.region.label&&(w.region["label-style"]??"face")!=="none"&&(l.labels+=a.faceText(w.box.x0+.3,w.box.y1,w.box.z0+.13,w.region.label,"slabname sm fz",Bt.sm,"left","start",{"data-id":w.id,...d(w.id)}))}for(let w of u.filter(N=>fa(p,N)==="tunnel"))l.air+=Lp(a,w,d(w.id));let b=e.items.filter(w=>w.type==="node");for(let w of b){let N=w.node,F=Tn(p,N.asset),J=N.ghost||(N.deco??[]).includes("ghost"),ae=["blk",`k-${N.role??F.role}`,F.cls,J?"ghost":""].filter(Boolean).join(" ");l.blocks.push({box:w.box,svg:Ve("g",{class:ae,"data-id":w.id,"data-dim":"1",...d(w.id)},F.draw(a,w.box,N))}),c.polys.push({poly:vn(w.box),owner:w.id}),c.solids.push(vn(w.box))}let k=io(l.blocks).map(w=>w.svg).join(""),v=new Set,M={};for(let w of n){if(w.points.length<2)continue;let N=w.points.map(ae=>Xe(ae[0],ae[1],ae[2]));N.forEach(ae=>a.bounds.add(ae));let F="M"+N.map(Xs).join(" L");M[w.id]=F;let J=w.raw.arrow!==!1;J&&v.add(w.kind),l.flows+=Ve("g",{"data-hl":w.id,"data-id":w.id,...d(w.id)},Ve("path",{d:F,class:`flow f-${w.kind}`,"marker-end":J?`url(#ah-${o}-${w.kind})`:void 0})),c.lines.push({pts:N,owner:w.id})}for(let w of v)a.def(`ah-${o}-${w}`,Ve("marker",{id:`ah-${o}-${w}`,viewBox:"0 0 10 10",refX:"7",refY:"5",markerWidth:"4.2",markerHeight:"4.2",orient:"auto-start-reverse"},Ve("path",{d:"M0,0 L10,5 L0,10 z",style:`fill:${Zn(r,r.kinds[w]?.color??"control")}`})));for(let w of a.planePolys)c.slants.push(w);let x=b.filter(w=>w.node.label||w.node.sub).sort((w,N)=>(N.box.x1-N.box.x0)*(N.box.y1-N.box.y0)-(w.box.x1-w.box.x0)*(w.box.y1-w.box.y0));for(let w of x)l.labels+=Np(a,p,w,c,d(w.id));let T=[];for(let w of n)if(w.raw.label&&w.points.length>=2){let N=Rp(a,w,c,d(w.id),e);l.floor+=N.svg,N.warning&&T.push({path:`${w.path}/label`,message:N.warning}),c.budget.over&&!c.budget.told&&(c.budget.told=!0,T.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 (${ma.toLocaleString("en")} spots); split it into scenes, or give the labels "along", "side" or "at"`}))}(t.notes??[]).forEach((w,N)=>{let F=Ip(a,w,e,n,`${o}-note-${N}`);w.floor?l.floor+=F:l.labels+=F});let y=[],A=new Map;for(let w of s.says){let N=A.get(w.step)??c.fork();A.set(w.step,N);let F=$n(w.text,Bt.say)+18,J=aa(F,w.ax,w.ay,{x:w.x,y:w.y,anchor:w.anchor},N);N.rects.push({r:J.rect,owner:""}),y.push({step:w.step,...J.rect,text:w.text});let ae=J.rect.x+2;a.bounds.addRect(J.rect.x,J.rect.y,J.rect.w,J.rect.h);let we=Zn(r,r.kinds[w.kind]?.color??"control");l.marks+=Ve("g",{class:"say","data-step":w.step},Ve("rect",{x:ae,y:J.y-12,width:F,height:24,rx:12,style:`stroke:${we}`})+Ve("text",{x:ae+F/2,y:J.y+4,"text-anchor":"middle",style:`fill:${we}`},Dt(w.text)))}for(let w of s.marks){let[N,F]=Xe(...w.p);a.bounds.addRect(N-12,F-12,24,24),l.marks+=Ve("g",{class:"xm","data-step":w.step,"data-hl":w.on},Ve("circle",{cx:N,cy:F,r:10})+Ve("path",{d:`M${Lt(N-4.5)},${Lt(F-4.5)} L${Lt(N+4.5)},${Lt(F+4.5)} M${Lt(N+4.5)},${Lt(F-4.5)} L${Lt(N-4.5)},${Lt(F+4.5)}`}))}for(let w of s.badges){let[N,F]=Xe(...w.p);a.bounds.addRect(N-13,F-13,26,26),l.badges+=Ve("g",{class:`badge c-${w.kind}`,"data-go":w.step,"data-badge":w.step,tabindex:"0",role:"button","aria-label":`Step ${w.num}`},Ve("circle",{cx:N,cy:F,r:11.5})+Ve("text",{x:N,y:F+.5},String(w.num)))}let D=a.bounds,K=22,C=D.empty?[0,0,100,100]:[Math.floor(D.x0-K),Math.floor(D.y0-K),Math.ceil(D.x1-D.x0+K*2),Math.ceil(D.y1-D.y0+K*2)],_=[...a.defs.values()].join(""),S=(w,N)=>Ve("g",{class:"g-"+w},N);return{svg:Ve("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:C.join(" "),role:"img","aria-label":t.aria??t.title,"data-scene":o},Ve("defs",{},_)+S("base",l.base)+S("floor",l.floor)+S("flows",l.flows)+S("blocks",k)+S("air",l.air)+S("labels",l.labels)+S("marks",l.marks)+S("badges",l.badges)+S("anim","")),viewBox:C,texts:a.texts,paths:M,warnings:T,callouts:y,assembly:da(e,n,C)}}function Op(t,e){let n=t.z1+.002,s=1e-6,r=[],o=(i,a)=>{let l=Xe(i[0],i[1],n),c=Xe(a[0],a[1],n);r.push(`M${Xs(l)}L${Xs(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?Ve("path",{class:"grid",d:r.join("")}):""}function Cp(t,e,n,s,r=1){let o=n.region,i=n.box,a=ha(e,o),l=Ft(e,o.kind),c=l?.shape,d={"data-id":n.id,"data-dim":"1",...s},u="";c==="cloud"?u=Ve("g",{class:`blk k-${a} cloud`,...d},Ui(t,i)):c==="zone"?u=Ve("g",{class:`zone k-${a}`,...d},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=Ve("g",{class:`blk k-${a}${o.ghost?" ghost":""}`,...d},t.blockFaces(i)+Op(i,r));let f=o["label-style"]??l?.labelStyle;if(o.label&&f!=="none")if(f==="face"){let p=c==="slab",g=p?i.z0+.28:i.z0+Math.min(.1,(i.z1-i.z0)*.25);u+=Ve("g",d,t.faceText(i.x0+(p?.6:.3),i.y1,g,o.label,p?"slabname":"slabname sm",p?Bt.slabname:Bt.sm,"left","start"))}else if(f==="face-right")u+=Ve("g",d,t.faceText(i.x1,i.y0+.6,i.z0+Math.max(.14,(i.z1-i.z0)*.2),o.label,"slabname",Bt.slabname,"right","end"));else{let p=c==="cloud"?"middle":"start",g=c==="cloud"?(i.x0+i.x1)/2:i.x0+.35,h=c==="cloud"?(i.y0+i.y1)/2:i.y1-.35;u+=Ve("g",d,t.floorText(g,h,i.z1+.01,o.label,"slabname sm","x",p))}return u}function pa(t){let{x0:e,y0:n,x1:s,y1:r,z0:o,z1:i}=t.box,a=es,l=t.region.gate,c=[],d=f=>{f.x1-f.x0>1e-6&&f.y1-f.y0>1e-6&&c.push({...f,z0:o,z1:i})},u=(f,p,g)=>{if(!l||l.side!==g)return[[f,p]];let h=l.at??.5,b=l.width??2,k=g==="e"||g==="w"?n+(r-n)*h:e+(s-e)*h;return[[f,k-b/2],[k+b/2,p]]};for(let[f,p]of u(e,s,"n"))d({x0:f,y0:n,x1:p,y1:n+a});for(let[f,p]of u(n+a,r-a,"w"))d({x0:e,y0:f,x1:e+a,y1:p});for(let[f,p]of u(n+a,r-a,"e"))d({x0:s-a,y0:f,x1:s,y1:p});for(let[f,p]of u(e,s,"s"))d({x0:f,y0:r-a,x1:p,y1:r});return c}function Np(t,e,n,s,r){let o=n.node,i=Tn(e,o.asset),a=n.box,l={name:o.label,sub:o.sub},c=o["label-at"],d;if(c){let f=xs(vn(a)),p=c.side??"above",g=f.y+Math.min(f.h,60)*.45;p==="right"?d={x:f.x+f.w+8,y:g,anchor:"start"}:p==="left"?d={x:f.x-8,y:g,anchor:"end"}:p==="below"?d={x:f.x+f.w/2,y:f.y+f.h+14,anchor:"middle"}:d=Io(l,a,vn(a),new sr,n.id),d={...d,x:d.x+(c.dx??0),y:d.y+(c.dy??0)}}else{let f=i.label?i.label(a,o,!!o.sub):void 0;d=Io(l,a,vn(a),s,n.id,f)}s.rects.push({r:Ro(l,d.x,d.y,d.anchor),owner:""});let u="";return o.label&&(u+=t.text(d.x,d.y,o.label,"lbl",Bt.lbl,d.anchor,{},n.id)),o.sub&&(u+=t.text(d.x,o.label?d.y+14:d.y,o.sub,"sub mono",Bt.sub,d.anchor,{},n.id)),Ve("g",{"data-id":n.id,"data-dim":"1",...r},u)}function Lp(t,e,n){let{x0:s,y0:r,x1:o,y1:i,z0:a,z1:l}=e.box,c=t.blockFaces(e.box),d=o-s>=i-r,u=Math.max(1,Math.round((d?o-s:i-r)/1.6));for(let p=1;p<u;p++){let g=d?s+(o-s)*p/u:r+(i-r)*p/u;c+=t.poly(d?[[g,r,l],[g,i,l],[g,i,a]]:[[s,g,l],[o,g,l],[o,g,a]],"rib")}let f=e.region.label;return f&&e.region["label-style"]!=="none"&&(c+=d?t.faceText(s+.35,i,a+.14,f,"tunname",Bt.tunname,"left","start"):t.faceText(o,i-.35,a+.18,f,"tunname",Bt.tunname,"right","start")),Ve("g",{class:"tunnel","data-id":e.id,"data-dim":"1",...n},c)}var ma=2e4;function Rp(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=Bt.floor;if(o.at){let v=o.at.length>2?o.at[2]:e.points[0][2];return{svg:t.floorText(o.at[0],o.at[1],v,o.text,i,o.dir??"x",o.anchor??"start",a)}}let c=e.points,d=[];for(let v=0;v+1<c.length;v++){let M=c[v],x=c[v+1];Math.abs(M[2]-x[2])>1e-6||d.push({i:v,len:Math.hypot(x[0]-M[0],x[1]-M[1])})}if(!d.length)return{svg:"",warning:`label "${o.text}" of route "${e.id}" was dropped: the route has no level segment`};let u=o.along?d.filter(v=>v.i===Math.min(o.along-1,c.length-2)):[...d].sort((v,M)=>M.len-v.len),f=.22,p=11/xt,g=v=>{let M=$n(v,l)/xt,x,T=1/0,y=0;e:for(let A of u.length?u:d){let D=c[A.i],K=c[A.i+1],C=D[2],_=Math.abs(D[1]-K[1])<1e-6,S=_?Math.min(D[0],K[0]):Math.min(D[1],K[1]),$=_?Math.max(D[0],K[0]):Math.max(D[1],K[1]),w=_?D[1]:D[0],N=o.side==="left"?[-1]:o.side==="right"?[1]:[-1,1],F=[];for(let J=S+.3;J<=Math.max(S+.3,$-M-.2)+1e-9;J+=.4)F.push(J);for(let J=$-M-.2+.4;J<$+.5&&$-S<M+.5;J+=.6)F.push(J);for(let J of N)for(let ae of F){if(T<=y*.5)break e;let we=J<0?w-f:w+f+p,j,U,ee;if(_?(j=ae,U=we,ee=[Xe(j,U-p,C),Xe(j+M,U-p,C),Xe(j+M,U,C),Xe(j,U,C)]):(j=we,U=ae+M,ee=[Xe(j-p,U,C),Xe(j-p,U-M,C),Xe(j,U-M,C),Xe(j,U,C)]),(_?[[j,U-p],[j+M,U-p],[j+M,U],[j,U]]:[[j-p,U],[j-p,U-M],[j,U-M],[j,U]]).some(([ne,me])=>Math.abs(Cr(r,ne,me)+.01-C)>.001)){y++;continue}let B=n.hiddenPoly(ee),X=B*50+y*.5,Q=n.budget.spots-- >0;Q||(n.budget.over=!0);let te=X>=T?1/0:Q?X+n.costPoly(ee,T-X):X;y++,te<T&&(T=te,x={x:j,y:U,z:C,dir:_?"x":"y",rect:xs(ee),poly:ee,hidden:B})}}return x&&x.hidden<6?x:void 0},h=o.text,b=g(h),k;if(!b){let v=o.text.split(/(\s+)/);for(let M=v.length-1;M>0&&!b;M--){let x=v.slice(0,M).join("").trimEnd().replace(/[\s,;:·–-]+$/,"")+"\u2026";if(x.length<6)break;let T=g(x);T&&(b=T,h=x)}k=b?`label of route "${e.id}" shortened to "${h}": no clear floor for the whole text`:`label "${o.text}" of route "${e.id}" was dropped: blocks cover every spot beside it`,b?k+='; give it "along", "side" or "at", or move the nodes apart':k+='; give it "at: [x, y]", or move the nodes apart'}return b?(n.slants.push(b.poly),{svg:t.floorText(b.x,b.y,b.z+.01,h,i,b.dir,"start",a),warning:k}):{svg:"",warning:k}}function Ip(t,e,n,s,r){let o=e.on?s.find(d=>d.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 d=a&&a.length>2?a[2]:o?o.points[0][2]:i?i.floor:.36,[u,f]=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,f,d+.01,e.floor,`floor mono t-${c}`,e.dir??"x",e.anchor??"start",l)}if(e.face){let d=i?.box,[u,f,p]=a?[a[0],a[1],a[2]??.45]:d?[d.x0+.3,d.y1,d.z0+.13]:[0,0,0];return t.faceText(u,f,p,e.face,"slabname sm",Bt.sm,"left",e.anchor??"start",l)}if(e.label||e.sub){let d=i?.box,u=a?[a[0],a[1],a[2]??.36]:d?[(d.x0+d.x1)/2,(d.y0+d.y1)/2,d.z1+.75]:[0,0,0],[f,p]=Xe(u[0],u[1],u[2]),g=f+(e.dx??0),h=p-18+(e.dy??0),b=e.anchor??"middle",k="";return e.label&&(k+=t.text(g,h,e.label,"lbl",Bt.lbl,b)),e.sub&&(k+=t.text(g,e.label?h+14:h,e.sub,"sub mono",Bt.sub,b)),Ve("g",l,k)}return""}var dc=`
|
|
142
|
+
`)[0]}`,line:c.line,col:c.col,path:""})}function o(l,c={}){let d=Lu(l),u=n.contents,f={line:1,col:1},p=g=>{let h=g?.range;h&&(f=r(h[0]))};p(u);for(let g=0;g<d.length;g++){let h=d[g];if(ct(u)){let b=u.items.find(v=>st(v)&&Ge(v.key)&&String(v.key.value)===String(h));if(!b)break;if(c.key&&g===d.length-1)return p(b.key),f;p(b.key),u=b.value,u&&p(u)}else if(Lt(u)&&typeof h=="number"){if(u=u.items[h],!u)break;p(u)}else break}return f}function i(l){let c=n.contents;for(let p of Lu(l)){if(ct(c)){let g=c.items.find(h=>st(h)&&Ge(h.key)&&String(h.key.value)===String(p));if(!g)return;c=g.value}else if(Lt(c)&&typeof p=="number")c=c.items[p];else return;if(!c)return}let d=c.range;if(!d)return;let u=e.linePos(Math.max(d[0],d[1]-1)).line,f=t.split(/\r?\n/);for(;u>e.linePos(d[0]).line&&/^\s*(#.*)?$/.test(f[u-1]??"");)u--;return{start:e.linePos(d[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 Xp=new Set(["svg","g","defs","marker","symbol","title","desc","path","polygon","polyline","line","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath"]),Qp=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"]),Zp=new Set(["fill","stroke","marker-start","marker-mid","marker-end","clip-path","style"]),em={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"},Ru=t=>t.replace(/&(amp|lt|gt|quot|apos|#39);/g,(e,n)=>em[n]);function vc(t,e){return t.startsWith("data-")||t.startsWith("aria-")?/^[a-z][\w-]*$/.test(t):!(!Qp.has(t)||Zp.has(t)&&/url\(\s*(?!['"]?#)|javascript:|expression\(|@import/i.test(e))}function kc(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 f=u[1],p=Ru(u[2]);f==="xmlns"||f.startsWith("xmlns:")||vc(f,p)&&l.push([f,p])}let c={name:a,attrs:l,children:[]},d=i.dropped||!Xp.has(a);d||i.node.children.push(c),r[4]||n.push({node:c,dropped:d});continue}!i.dropped&&r[5].trim()&&i.node.children.push(Ru(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 tm="http://www.w3.org/2000/svg",Iu=t=>t.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1");function Ho(t,e=document){let n=r=>{let o=e.createElementNS(tm,r.name);for(let[i,a]of r.attrs)i==="style"?o.style.cssText=Iu(a):o.setAttribute(i,/var\(--/.test(a)?Iu(a):a);for(let i of r.children)o.append(typeof i=="string"?e.createTextNode(i):n(i));return o},s=kc(t).children.find(r=>typeof r!="string"&&r.name==="svg");if(!s)throw new Error("the drawing has no <svg>");return n(s)}var nm=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Yo=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])=>`${nm(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)}}},Du={createElementNS:(t,e)=>new Yo(e)},Fu=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),sm=t=>Fu(t).replace(/"/g,""");function fa(t,e=new Set(["style"])){if(typeof t=="string")return Fu(t);let n=t.attrs.map(([r,o])=>` ${r}="${sm(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,"<\\/"):fa(r,e)).join(""):t.children.map(r=>fa(r,e)).join("");return`<${t.name}${n}>${s}</${t.name}>`}var rm=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 Sc(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,d)=>c>>>d|c<<32-d;for(let c=0;c<s;c++){for(let w=0;w<16;w++)a[w]=o.getUint32(c*64+w*4);for(let w=16;w<64;w++){let k=l(a[w-15],7)^l(a[w-15],18)^a[w-15]>>>3,y=l(a[w-2],17)^l(a[w-2],19)^a[w-2]>>>10;a[w]=a[w-16]+k+a[w-7]+y>>>0}let[d,u,f,p,g,h,b,v]=i;for(let w=0;w<64;w++){let k=v+(l(g,6)^l(g,11)^l(g,25))+(g&h^~g&b)+rm[w]+a[w]>>>0,y=(l(d,2)^l(d,13)^l(d,22))+(d&u^d&f^u&f)>>>0;v=b,b=h,h=g,g=p+k>>>0,p=f,f=u,u=d,d=k+y>>>0}i[0]+=d,i[1]+=u,i[2]+=f,i[3]+=p,i[4]+=g,i[5]+=h,i[6]+=b,i[7]+=v}return[...i].map(c=>c.toString(16).padStart(8,"0")).join("")}function ju(t){if(t!=="sha256")throw new Error(`only sha256 here, not ${t}`);let e="",n={update(s){return e+=s,n},digest(s){return Sc(e)}};return n}var of={};vi(of,{BOARD_3D:()=>Xs,BOARD_CSS:()=>nf,FLAT_DEFAULTS:()=>Yc,FLAT_FONTS:()=>qc,GRID_CSS:()=>Vc,LABEL_BUDGET:()=>Fa,MARKS_CSS:()=>_c,Obstacles:()=>hr,PAGE_CSS:()=>Bc,PLAYER_CSS:()=>_a,PLAYER_UI_CSS:()=>zc,ROUTE_BUDGET:()=>$a,WALL_T:()=>ds,assembly:()=>Na,baseCss:()=>Ka,boardCatalog:()=>sf,boardDiagram:()=>rf,boardErrors:()=>Va,boardOf:()=>br,boxAsset:()=>_u,boxSilhouette:()=>za,calloutRect:()=>Ic,cardAsset:()=>Uc,cloudPath:()=>Ac,compileRaw:()=>Zu,convexOverlap:()=>Xo,defaultLabel:()=>Vu,drawCloud:()=>ba,drawDecos:()=>Tc,drawingCss:()=>Kc,durationFor:()=>Fc,facePainter:()=>ga,flatHit:()=>tf,floorAt:()=>Gr,floorOf:()=>Ur,focusView:()=>Qu,gateBox:()=>Wo,iconPainter:()=>qo,inConvex:()=>Dc,kindsCss:()=>ma,labelRect:()=>Qo,layoutFlat:()=>Js,lineRectArea:()=>Wu,localAt:()=>qr,markCss:()=>ha,metricsMeasure:()=>ef,midpoint:()=>jc,noSource:()=>Gc,nodeKind:()=>mr,nodeKindOr:()=>In,offscreen:()=>La,openList:()=>Oc,overlap2:()=>xa,overlaps:()=>gr,paddingOf:()=>ei,parseEnd:()=>An,place:()=>wa,placeBoard:()=>ni,placeCallout:()=>Ca,placeNodeLabel:()=>Zo,placeholderIcon:()=>Ec,plate:()=>zu,polyBounds:()=>Ps,polyRectArea:()=>Yr,rectArea:()=>Rc,regionKind:()=>Dt,regionRole:()=>ja,registerMarks:()=>Ku,renderScene:()=>Ba,resolveSteps:()=>Ra,routeAll:()=>Ea,screenToGrid:()=>Cs,silhouette:()=>Pn,simplify:()=>Jo,snapMove:()=>ti,wallHeight:()=>pa,wallsOf:()=>Da});var Dt=(t,e)=>e!==void 0&&Object.hasOwn(t.regions,e)?t.regions[e]:void 0,mr=(t,e)=>t.nodes[e??t.defaultNode],In=(t,e)=>mr(t,e)??t.nodes[t.defaultNode],pa=t=>Object.values(t.regions).find(e=>e.shape==="walled")?.z[1]??.8,ma=t=>Object.values(t.regions).map(e=>e.css??"").join("");var Mc=Object.create(null),$c=[];function Ku(t){Object.assign(Mc,t.icons??{}),Object.assign(Lr,t.faces??{}),t.css&&!$c.includes(t.css)&&$c.push(t.css)}var ha=()=>$c.join(""),qo=t=>Object.hasOwn(Mc,t)?Mc[t]:void 0,ga=t=>Object.hasOwn(Lr,t)?Lr[t]:void 0;function Ec(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 Tc(t,e,n){let s="";for(let r of n??[])r==="terminal"?s+=Mo(t,e,3):r==="envelope"?s+=Si(t,e):r==="bubble"?s+=Mi(t,e):r==="file-lines"?s+=$i(t,e):typeof r=="object"&&(r.terminal&&(s+=Mo(t,e,r.terminal)),r.icon&&(s+=(qo(r.icon)??Ec)(t,e)));return s}var om=(t,e)=>(t.deco??e.deco??[]).filter(n=>n!=="ghost");function _u(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)+Tc(a,l,om(c,i))+(o?o(a,l):"")};return i}function zu(t){let[e,n]=ki(t);return{x0:e-.75,y0:n-.75,x1:e+.75,y1:n+.75,z0:t.z0,z1:t.z0+.18}}function Ac(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,d,u,f)=>{let p=Math.hypot(u-c,f-d),g=Math.max(1,Math.round(p/(n*1.7))),h="";for(let b=1;b<=g;b++){let v=c+(u-c)*b/g,w=d+(f-d)*b/g,k=p/g/2*1.08;h+=` A${k.toFixed(1)},${k.toFixed(1)} 0 0 1 ${v.toFixed(1)},${w.toFixed(1)}`}return h};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 ba(t,e){let n={...e,z0:e.z1},s=a=>{let[l,c]=Xe(e.x0,e.y0,a);return[Kt,.5,-Kt,.5,l,c]},r=(e.x1-e.x0)*yt,o=(e.y1-e.y0)*yt,i=Ac(r,o);return t.onMatrix(s(e.z0),r,o,()=>_e("path",{d:i,class:"lft cloud-side"}))+t.onMatrix(s(e.z1),r,o,()=>_e("path",{d:i,class:"top cloud-top"}))}function Vu(t,e){let[n,s]=Xe((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 ds=.16,Pc=["right-of","left-of","below","behind"];function wa(t,e,n,s,r,o={},i){let a=[],l=(S,E,x,N=!1,z="error")=>{let Q=n.locate(S,{key:N});a.push({severity:z,message:E,line:Q.line,col:Q.col,path:S,hint:x})},c=[],d=new Map,u=[],f=new Map,p=new Set([...Object.keys(s.roles),...Object.keys(o)]);function g(S,E){let x=d.get(S.id);if(x){let N=n.locate(x.path+"/id");return l(S.path+"/id",`duplicate id "${S.id}" (first used on line ${N.line})`),!1}return d.set(S.id,S),c.push(S),S.parent=E,E?E.children.push(S):u.push(S),!0}let h=()=>({x0:0,y0:0,z0:0,x1:0,y1:0,z1:0});function b(S,E,x){let N={id:S.id,type:"node",path:E,children:[],box:h(),floor:0,node:S,appears:S.appears,disappears:S.disappears};g(N,x)&&(S.nodes??[]).forEach((z,Q)=>b(z,`${E}/nodes/${Q}`,N))}function v(S,E,x){let N={id:S.id,type:"region",path:E,children:[],box:h(),floor:0,region:S,appears:S.appears,disappears:S.disappears};g(N,x)&&((S.nodes??[]).forEach((z,Q)=>b(z,`${E}/nodes/${Q}`,N)),(S.regions??[]).forEach((z,Q)=>v(z,`${E}/regions/${Q}`,N)))}(t.regions??[]).forEach((S,E)=>v(S,`${e}/regions/${E}`,void 0)),(t.nodes??[]).forEach((S,E)=>b(S,`${e}/nodes/${E}`,void 0));let w=()=>d.keys(),k=()=>c.filter(S=>S.type==="region").map(S=>S.id);for(let S of[...c]){let E=S.node??S.region;if(E.in!==void 0){let N=d.get(E.in);if(!N){l(S.path+"/in",`unknown region "${E.in}"`+Uo(E.in,k()));continue}if(N.type!=="region"){l(S.path+"/in",`"${E.in}" is a node, not a region; put nodes on a node with its own "nodes:" list`);continue}if(S.parent&&S.parent!==N){l(S.path+"/in",`"${S.id}" is written inside "${S.parent.id}" but says in: ${E.in}; use one or the other`);continue}for(let z=N;z;z=z.parent)if(z===S){l(S.path+"/in",`"${S.id}" cannot be inside itself`);continue}S.parent||(u.splice(u.indexOf(S),1),S.parent=N,N.children.push(S))}if(S.node){let N=S.node.asset;N!==void 0&&!mr(r,N)&&l(S.path+"/asset",`unknown asset "${N}"`+Uo(N,Object.keys(r.nodes)),`assets: ${Object.keys(r.nodes).join(", ")}`)}let x=(S.node??S.region).role;x!==void 0&&!p.has(x)&&l(S.path+"/role",`unknown colour role "${x}"`+Uo(x,p),`add it under "roles:" at the top of the file, or use one of: ${[...p].join(", ")}`)}for(let S of c){let E=S.region?.gate;if(!E?.node)continue;let x=d.get(E.node);if(!x){l(S.path+"/gate/node",`unknown node "${E.node}"`+Uo(E.node,w()));continue}if(x.type!=="node"){l(S.path+"/gate/node",`"${E.node}" is a region; a gate is a node`);continue}x.placedBy=S.id;let N=x.node;(N.at||Pc.some(z=>N[z]))&&l(x.path,`"${x.id}" is the gate of "${S.id}", which places it; its own placement is ignored`,void 0,!1,"warning")}let y=S=>S.gap??t.gap??2;function M(S){let E=S.node,x=In(r,E.asset),N=E.size,z=x.size[0],Q=x.size[1],re=x.size[2];if(N&&(z=N[0],Q=N[1],N.length>2&&(re=N[2])),S.placedBy){let we=d.get(S.placedBy).region,F=we.gate,X=F.width??2,Z=N?Math.min(z,Q):.3;re=N&&N.length>2?re:F.height??(we.height??pa(r))+.3,F.side==="e"||F.side==="w"?(z=Z,Q=X):(z=X,Q=Z)}return[z,Q,re]}function T(S,E,x,N,z){for(let ge of E)I(ge);let Q=E.filter(ge=>!ge.placedBy),re=new Set(Q),we=new Set,F=[],X=new Set,Z=ge=>{let ye=ge.node??ge.region,Ie=[];for(let Ue of Pc){let D=ye[Ue];if(D===void 0)continue;let se=d.get(D);if(!se){l(`${ge.path}/${Ue}`,`unknown id "${D}"`+Uo(D,w()));continue}if(se===ge){l(`${ge.path}/${Ue}`,`"${ge.id}" cannot be placed ${Ue} itself`);continue}if(!re.has(se)){let Me=Ce=>Ce.parent?`"${Ce.parent.id}"`:"the scene";l(`${ge.path}/${Ue}`,`"${D}" is in ${Me(se)} but "${ge.id}" is in ${Me(ge)}; relative placement works between items in the same region`,se.placedBy?`"${D}" is a gate, placed by its ${d.get(se.placedBy)?.region?.kind??"region"}`:`place "${ge.id}" relative to something in ${Me(ge)}, or use "at:"`);continue}Ie.push(se)}if(!Ie.length&&!ye.at){let Ue=Q.indexOf(ge);Ue>0&&Ie.push(Q[Ue-1])}return Ie},be=ge=>{if(!we.has(ge)){if(X.has(ge)){l(ge.path,`placement loop: "${ge.id}" is placed relative to something placed relative to it`);return}X.add(ge),Z(ge).forEach(be),X.delete(ge),we.add(ge),F.push(ge)}};Q.forEach(be);for(let ge of F){let ye=ge.node??ge.region,Ie=f.get(ge),Ue=Pc.find(D=>ye[D]!==void 0&&d.get(ye[D])&&re.has(d.get(ye[D])));if(ye.at&&Ue&&l(`${ge.path}/at`,`"${ge.id}" has both "at" and "${Ue}"; "at" wins`,void 0,!0,"warning"),ye.at)Ie.x=ye.at[0],Ie.y=ye.at[1];else if(Ue)A(Ie,f.get(d.get(ye[Ue])),Ue,y(ye),ye.align??"center");else{let D=Q.indexOf(ge);D>0?A(Ie,f.get(Q[D-1]),N==="row"?"right-of":"below",y(ye),"center"):(Ie.x=x,Ie.y=x)}ye.shift&&(Ie.x+=ye.shift[0],Ie.y+=ye.shift[1])}if(z||!Q.length)return{w:0,d:0};let V=1/0,J=1/0,G=-1/0,ne=-1/0;for(let ge of Q){let ye=f.get(ge);V=Math.min(V,ye.x),J=Math.min(J,ye.y),G=Math.max(G,ye.x+ye.w),ne=Math.max(ne,ye.y+ye.d)}let oe=Math.min(0,V-x),ve=Math.min(0,J-x);if(oe||ve)for(let ge of Q){let ye=f.get(ge);ye.x-=oe,ye.y-=ve}return{w:G-oe+x,d:ne-ve+x}}function A(S,E,x,N,z){let Q=()=>{S.y=z==="start"?E.y:z==="end"?E.y+E.d-S.d:E.y+(E.d-S.d)/2},re=()=>{S.x=z==="start"?E.x:z==="end"?E.x+E.w-S.w:E.x+(E.w-S.w)/2};x==="right-of"?(S.x=E.x+E.w+N,Q()):x==="left-of"?(S.x=E.x-N-S.w,Q()):x==="below"?(S.y=E.y+E.d+N,re()):(S.y=E.y-N-S.d,re())}function I(S){if(S.type==="node"){let[F,X,Z]=M(S);f.set(S,{x:0,y:0,w:F,d:X,h:Z,z:S.node.z??0}),S.children.length&&T(S,S.children,0,"row",!0);return}let E=S.region,x=E.padding??Dt(r,E.kind)?.pad,N=!!E.size,z=T(S,S.children,x,E.flow??"row",N),Q=E.size?E.size[0]:Math.max(z.w,x*2+.5),re=E.size?E.size[1]:Math.max(z.d,x*2+.5);if(!E.size&&E.gate){let F=(E.gate.width??2)+1;E.gate.side==="e"||E.gate.side==="w"?re=Math.max(re,F):Q=Math.max(Q,F)}let we=E.size&&E.size.length>2?E.size[2]:E.height??Dt(r,E.kind).z[1];f.set(S,{x:0,y:0,w:Q,d:re,h:we,z:0})}T(void 0,u,0,t.flow??"row",!0);function j(S,E,x,N){let z=f.get(S),Q=E+z.x,re=x+z.y;if(S.type==="region"){let we=Dt(r,S.region.kind),[F]=we.z,X=we.floor,Z=we.shape==="slab"&&Dt(r,S.parent?.region?.kind)?.shape==="slab"?0:F,be=S.region.z??0,V=N+Z+be,J=N+z.h+be;S.box={x0:Q,y0:re,z0:V,x1:Q+z.w,y1:re+z.d,z1:J},S.floor=X?J:N}else{let we=N+z.z;S.box={x0:Q,y0:re,z0:we,x1:Q+z.w,y1:re+z.d,z1:we+z.h},S.floor=S.box.z1}for(let we of S.children)we.placedBy||j(we,Q,re,S.floor)}for(let S of u)S.placedBy||j(S,0,0,0);if(i){let S=x=>Math.round(x/i)*i,E=x=>Math.round(x*1e9)/1e9;for(let x of c){if(x.placedBy)continue;let N=x.box,z=S(N.x0),Q=S(N.x1),re=S(N.y0),we=S(N.y1);Q-z<i&&(Q=z+i),we-re<i&&(we=re+i),x.box={...N,x0:E(z),x1:E(Q),y0:E(re),y1:E(we)};let F=x.node??x.region;F.at&&F.at.forEach((X,Z)=>{let be=X/i;Math.abs(be-Math.round(be))>1e-6&&l(`${x.path}/at/${Z}`,`${X} is not on the ${i} grid; it is drawn at ${E(S(X))}`,void 0,!1,"warning")})}}for(let S of c){let E=S.region?.gate;if(!E?.node)continue;let x=d.get(E.node);!x||x.placedBy!==S.id||(x.box=Wo(S,f.get(x).h,f.get(x).w,f.get(x).d),x.floor=x.box.z1)}for(let S of c){let E=S.children.filter(x=>!x.placedBy);for(let x=0;x<E.length;x++)for(let N=x+1;N<E.length;N++){let z=E[x],Q=E[N];ya(z,r)||ya(Q,r)||xa(z.box,Q.box)&&l(Q.path,`"${Q.id}" overlaps "${z.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}if(S.parent&&S.parent.type==="region"&&!S.placedBy){let x=S.parent.box,N=S.box,z=1e-6;(N.x0<x.x0-z||N.y0<x.y0-z||N.x1>x.x1+z||N.y1>x.y1+z)&&l(S.path,`"${S.id}" sticks out of region "${S.parent.id}"`,`make "${S.parent.id}" bigger, or leave out its "size" so it fits its contents`,!1,"warning")}}{let S=u.filter(E=>!E.placedBy);for(let E=0;E<S.length;E++)for(let x=E+1;x<S.length;x++){let N=S[E],z=S[x];xa(N.box,z.box)&&!ya(N,r)&&!ya(z,r)&&l(z.path,`"${z.id}" overlaps "${N.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}}let L=new Set,B=a.filter(S=>{let E=S.path+S.message;return L.has(E)?!1:(L.add(E),!0)});return{items:c,byId:d,roots:u,diags:B,catalog:r}}var ya=(t,e)=>t.type==="region"&&["zone","tunnel"].includes(Dt(e,t.region.kind)?.shape??"");function Wo(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+ds/2:o.x1-ds/2,f=o.y0+(o.y1-o.y0)*a;return{x0:u-n/2,x1:u+n/2,y0:f-l/2,y1:f+l/2,z0:i,z1:i+e}}let c=r.side==="n"?o.y0+ds/2:o.y1-ds/2,d=o.x0+(o.x1-o.x0)*a;return{x0:d-l/2,x1:d+l/2,y0:c-s/2,y1:c+s/2,z0:i,z1:i+e}}function xa(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 Uo(t,e){let n=Us(t,e);return n?` (did you mean "${n}"?)`:""}var Ts=.2,va=.05,im=.6,ka=.25,Sa={n:[0,-1],s:[0,1],e:[1,0],w:[-1,0]};function An(t){let e=/^(.*?)(?:\.(n|e|s|w|top))?$/.exec(t);return{id:e[1],side:e[2]}}var Gu=new WeakMap;function Gr(t,e,n){let s=Gu.get(t);if(!s){s=[];for(let i of t.items){if(i.type!=="region"||!Dt(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})}Gu.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 am(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 $a=5e5;function Ea(t,e,n,s,r,o){let i=[],a=(k,y,M,T="error")=>{let A=s.locate(k);i.push({severity:T,message:y,line:A.line,col:A.col,path:k,hint:M})},l=t.routes??[],c={left:$a},d=0,u=()=>n.items.map(k=>k.id),f=new Map,p=[],g=[];l.forEach((k,y)=>{let M=`${e}/routes/${y}`;(f.has(k.id)||n.byId.has(k.id))&&a(M+"/id",`duplicate id "${k.id}"`),f.set(k.id,y);let T=k.kind??"send";r.has(T)||a(M+"/kind",`unknown flow kind "${T}"`+Cc(T,r),`kinds: ${[...r].join(", ")}; add one under "kinds:"`);let A={id:k.id,raw:k,path:M,kind:T,points:[]},I=(j,L)=>{let{id:B}=An(j),S=n.byId.get(B);if(!S){a(`${M}/${L}`,`unknown node "${B}"`+Cc(B,u()));return}return S};A.from=I(k.from,"from"),A.to=I(k.to,"to"),p.push(A),g.push({r:A})});let h=new Map;for(let k of g){let{r:y}=k;if(!y.from||!y.to||y.raw.points)continue;let M=An(y.raw.from).side,T=An(y.raw.to).side,A=y.raw.via?.[0],I=y.raw.via?.[y.raw.via.length-1],j=(E,x)=>{if(Array.isArray(E))return{x0:E[0],x1:E[0],y0:E[1],y1:E[1],z0:0,z1:0};if(typeof E=="string"){let N=n.byId.get(An(E).id);if(N)return N.box}return x.box},L=(E,x,N)=>{let z=x??am(E.box,N);return{node:E,side:z,explicit:!!x,p:[0,0],z:0}};k.a=L(y.from,M,j(A,y.to)),k.b=L(y.to,T,j(I,y.from));let B=j(A,y.to),S=j(I,y.from);for(let[E,x]of[[k.a,B],[k.b,S]]){let N=`${E.node.id}.${E.side}`;h.has(N)||h.set(N,[]),h.get(N).push({e:E,other:[(x.x0+x.x1)/2,(x.y0+x.y1)/2]})}}for(let[,k]of h){let y=k[0].e,M=y.node.box,T=y.side,A=T==="e"||T==="w"?1:0;k.sort((E,x)=>E.other[A]-x.other[A]);let I=A?M.y0:M.x0,j=A?M.y1:M.x1,L=(I+j)/2,B=Math.max(0,j-I-.3),S=k.length>1?Math.min(im,B/(k.length-1)):0;k.forEach((E,x)=>{let N=(x-(k.length-1)/2)*S,z=L+N,Q=E.e.node.box.z0;if(T==="top"){E.e.p=[(M.x0+M.x1)/2,(M.y0+M.y1)/2],E.e.z=M.z1;return}let[re,we]=Sa[T];E.e.p=A?[re>0?M.x1+va:M.x0-va,z]:[z,we>0?M.y1+va:M.y0-va],E.e.z=Q})}let b=[];for(let k of n.items)k.type==="node"&&b.push(k.box);let v=[];for(let k of n.items.filter(y=>Dt(n.catalog,y.region?.kind)?.shape==="walled")){let{x0:y,y0:M,x1:T,y1:A}=k.box,I=ds,j=k.region.gate,L=[[{x0:y,y0:M,x1:T,y1:M+I,z0:0,z1:0},"n"],[{x0:y,y0:A-I,x1:T,y1:A,z0:0,z1:0},"s"],[{x0:y,y0:M,x1:y+I,y1:A,z0:0,z1:0},"w"],[{x0:T-I,y0:M,x1:T,y1:A,z0:0,z1:0},"e"]];for(let[B,S]of L)if(j&&j.side===S){if(j.node)continue;let E=j.at??.5,x=j.width??2;if(S==="e"||S==="w"){let N=M+(A-M)*E;v.push({...B,y1:N-x/2},{...B,y0:N+x/2})}else{let N=y+(T-y)*E;v.push({...B,x1:N-x/2},{...B,x0:N+x/2})}}else v.push(B)}let w=new Map;for(let k of g){let{r:y,a:M,b:T}=k;if(y.raw.points){y.points=y.raw.points.map(z=>[z[0],z[1],z.length>2?z[2]:Gr(n,z[0],z[1])+.01]);continue}if(!M||!T)continue;let A=[];(y.raw.via??[]).forEach((z,Q)=>{if(Array.isArray(z))if(o){let re=we=>Math.round(Math.round(we/o)*o*1e9)/1e9;z.forEach((we,F)=>{Math.abs(we/o-Math.round(we/o))>1e-6&&a(`${y.path}/via/${Q}/${F}`,`${we} is not on the ${o} grid; it is drawn at ${re(we)}`,void 0,"warning")}),A.push({p:[re(z[0]),re(z[1])]})}else A.push({p:[z[0],z[1]]});else{let{id:re,side:we}=An(z),F=n.byId.get(re);if(!F){a(`${y.path}/via/${Q}`,`unknown node "${re}"`+Cc(re,u()));return}let X=we&&we!=="top"?we:"n",[Z,be]=Sa[X],V=F.box;A.push({p:[Z?Z>0?V.x1+.4:V.x0-.4:(V.x0+V.x1)/2,be?be>0?V.y1+.4:V.y0-.4:(V.y0+V.y1)/2]})}});let j=b.filter(z=>z!==M.node.box&&z!==T.node.box).concat(y.raw.cross?[]:v).filter(z=>!Ma(M.node.box,z)&&!Ma(T.node.box,z)&&!Ma(z,M.node.box)&&!Ma(z,T.node.box)),L=M.side==="top"?void 0:Sa[M.side],B=T.side==="top"?void 0:Sa[T.side],S=[M.p,...A.map(z=>z.p),T.p],E=[M.p],x=L,N=!0;for(let z=0;z+1<S.length;z++){let Q=z+2===S.length,re=cm(S[z],S[z+1],j,w,x,Q&&B?[-B[0],-B[1]]:void 0,c);if(!re){N=!1;break}E.push(...re.slice(1));let we=E.length;if(we>=2){let F=Math.sign(E[we-1][0]-E[we-2][0]),X=Math.sign(E[we-1][1]-E[we-2][1]);x=[F,X]}}!N&&c.left<=0?(d++,E=[M.p,[T.p[0],M.p[1]],T.p]):N||(a(y.path,`no path found for route "${y.id}" from "${M.node.id}" to "${T.node.id}"`,'add "via" points, or use "points" to draw it by hand',"warning"),E=[M.p,[T.p[0],M.p[1]],T.p]),E=Jo(E);for(let z=0;z+1<E.length;z++)lm(w,E[z],E[z+1]);y.points=fm(n,E,M,T)}return d&&a(e,`${d} of ${p.length} routes were drawn as plain elbows: the scene is too large to route them all around what stands in the way (${$a.toLocaleString("en")} search steps)`,'split it into scenes, or give the busiest routes "via" points or "points"',"warning"),{routes:p,diags:i}}function Ma(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 Hu=(t,e)=>`${Math.round(t/Ts)},${Math.round(e/Ts)}`;function lm(t,e,n){let s=Math.max(1,Math.round(Math.hypot(n[0]-e[0],n[1]-e[1])/Ts));for(let r=0;r<=s;r++){let o=Hu(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 Yu(t,e,n){for(let s of n)if(t>s.x0-ka&&t<s.x1+ka&&e>s.y0-ka&&e<s.y1+ka)return!0;return!1}function cm(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)&&um(t,e,n)){let F=[Math.sign(e[0]-t[0]),Math.sign(e[1]-t[1])],X=!r||r[0]===F[0]&&r[1]===F[1],Z=!o||o[0]===F[0]&&o[1]===F[1];if(X&&Z)return[t,e]}if(i.left<=0)return null;let a=F=>Math.round((F-t[0])/Ts),l=F=>Math.round((F-t[1])/Ts),c=F=>t[0]+F*Ts,d=F=>t[1]+F*Ts,u=a(e[0]),f=l(e[1]),p=30,g=Math.min(0,u)-p,h=Math.max(0,u)+p,b=Math.min(0,f)-p,v=Math.max(0,f)+p,w=1.2,k=Ts,y=.06,M=[[1,0],[-1,0],[0,1],[0,-1]],T=h-g+1,A=v-b+1,I=(F,X)=>(F-g)*A+(X-b),j=new Int8Array(T*A).fill(-1),L=new Float64Array(T*A).fill(-1),B=new Float64Array(T*A*4).fill(1/0),S=(F,X)=>{let Z=I(F,X);return j[Z]<0&&(j[Z]=Yu(c(F),d(X),n)?1:0),j[Z]===1},E=(F,X)=>{let Z=I(F,X);return L[Z]<0&&(L[Z]=s.get(Hu(c(F),d(X)))??0),L[Z]},x=Oc(),N=(F,X)=>(Math.abs(F-u)+Math.abs(X-f))*k,z=r?M.findIndex(F=>F[0]===r[0]&&F[1]===r[1]):-1;x.push({i:0,j:0,d:z,g:0,f:N(0,0),idx:0,hp:0});let Q=(F,X)=>Math.abs(F)+Math.abs(X)<=2,re=(F,X)=>Math.abs(F-u)+Math.abs(X-f)<=2,we=0;for(;x.length()&&we++<2e5;){if(i.left--<=0)return null;let F=x.take();if(F.i===u&&F.j===f&&!(o&&F.d>=0&&(M[F.d][0]!==o[0]||M[F.d][1]!==o[1]))){let X=[];for(let Z=F;Z;Z=Z.prev)X.push([c(Z.i),d(Z.j)]);return X.reverse(),X[0]=t,dm(Jo(X),e)}for(let X=0;X<4;X++){let Z=M[X];if(F.d>=0&&Z[0]===-M[F.d][0]&&Z[1]===-M[F.d][1])continue;let be=F.i+Z[0],V=F.j+Z[1];if(be<g||be>h||V<b||V>v||!Q(be,V)&&!re(be,V)&&S(be,V))continue;if((Q(be,V)||re(be,V))&&S(be,V)&&!(be===u&&V===f)){let oe=Q(be,V)?r:o&&[-o[0],-o[1]];if(!oe||(Q(be,V)?Z[0]!==oe[0]||Z[1]!==oe[1]:Z[0]!==o[0]||Z[1]!==o[1]))continue}let J=F.d>=0&&F.d!==X?w:0,G=F.g+k+J+E(be,V)*y,ne=I(be,V)*4+X;B[ne]<=G||(B[ne]=G,x.push({i:be,j:V,d:X,g:G,f:G+N(be,V),prev:F,idx:0,hp:0}))}}return null}function Oc(){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 dm(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,Jo(n)}function um(t,e,n){let s=Math.max(1,Math.round(Math.hypot(e[0]-t[0],e[1]-t[1])/(Ts/2)));for(let r=2;r<s-1;r++)if(Yu(t[0]+(e[0]-t[0])*r/s,t[1]+(e[1]-t[1])*r/s,n))return!1;return!0}function Jo(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 fm(t,e,n,s){let r=new Set,o=new Set;for(let c of t.items)c.type!=="region"||!Dt(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,d)=>Gr(t,c,d)+.01;for(let c=0;c+1<e.length;c++){let[d,u]=e[c],[f,p]=e[c+1],g=[0,1];if(Math.abs(u-p)<1e-6)for(let h of r){let b=(h-d)/(f-d);b>1e-6&&b<1-1e-6&&g.push(b)}else for(let h of o){let b=(h-u)/(p-u);b>1e-6&&b<1-1e-6&&g.push(b)}g.sort((h,b)=>h-b);for(let h=0;h+1<g.length;h++){let b=g[h],v=g[h+1],w=(b+v)/2,k=a(d+(f-d)*w,u+(p-u)*w),y=[d+(f-d)*b,u+(p-u)*b,k],M=[d+(f-d)*v,u+(p-u)*v,k],T=i[i.length-1];T&&(Math.abs(T[0]-y[0])>1e-6||Math.abs(T[1]-y[1])>1e-6||Math.abs(T[2]-y[2])>1e-6)?i.push(y):T||i.push(y),i.push(M)}}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 d=l.length;if(d>=2){let u=l[d-2],f=l[d-1],p=Math.abs(u[2]-f[2])<1e-9&&Math.abs(f[2]-c[2])<1e-9,g=Math.abs(u[0]-f[0])<1e-6&&Math.abs(f[0]-c[0])<1e-6||Math.abs(u[1]-f[1])<1e-6&&Math.abs(f[1]-c[1])<1e-6;if(p&&g){l[d-1]=c;continue}}l.push(c)}return l}function Cc(t,e){let n=Us(t,e);return n?` (did you mean "${n}"?)`:""}function Pn(t){return[Xe(t.x0,t.y0,t.z1),Xe(t.x1,t.y0,t.z1),Xe(t.x1,t.y0,t.z0),Xe(t.x1,t.y1,t.z0),Xe(t.x0,t.y1,t.z0),Xe(t.x0,t.y1,t.z1)]}function Ps(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 Yr(t,e){let n=t,s=(a,l)=>{let c=[];for(let d=0;d<n.length;d++){let u=n[d],f=n[(d+1)%n.length],p=a(u),g=a(f);p&&c.push(u),p!==g&&c.push(l(u,f))}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 Rc(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 Wu(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,d=r[1]+(o[1]-r[1])*(l+.5)/a;c>=e.x&&c<=e.x+e.w&&d>=e.y&&d<=e.y+e.h&&(n+=i/a*4)}}return n}var As=64,Aa=class{cells=new Map;n=0;add(e,n,s,r,o){for(let i=Math.floor(n/As);i<=Math.floor(r/As);i++)for(let a=Math.floor(s/As);a<=Math.floor(o/As);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/As);i<=Math.floor(s/As);i++)for(let a=Math.floor(n/As);a<=Math.floor(r/As);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)}},Lc=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]},Pa=new WeakMap;function Ws(t,e){let n=Pa.get(t);for((!n||n.n>t.length)&&Pa.set(t,n=new Aa);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 qu(t){let e=Pa.get(t);for((!e||e.n>t.length)&&Pa.set(t,e=new Aa);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])/(As/2)));for(let l=0;l<a;l++){let c=l/a,d=(l+1)/a,u=r[0]+(o[0]-r[0])*c,f=r[1]+(o[1]-r[1])*c,p=r[0]+(o[0]-r[0])*d,g=r[1]+(o[1]-r[1])*d;e.add(i,Math.min(u,p)-1,Math.min(f,g)-1,Math.max(u,p)+1,Math.max(f,g)+1)}}}return e}var us=(t,e,n,s,r)=>t.query(e,n,s,r),Hr=t=>Lc(t),Ta=t=>[t.x,t.y,t.x+t.w,t.y+t.h];function Uu(t,e,n,[s,r,o,i]){let a=0,l=n-1;for(let c of[0,1]){let d=e[c]-t[c],u=c?r:s,f=c?i:o;if(Math.abs(d)<1e-12){if(t[c]<u||t[c]>f)return[1,0];continue}let p=(u-t[c])/d*n-.5,g=(f-t[c])/d*n-.5;p>g&&([p,g]=[g,p]),a=Math.max(a,Math.floor(p)-1),l=Math.min(l,Math.ceil(g)+1)}return[a,l]}var hr=class t{polys=[];rects=[];lines=[];solids=[];slants=[];budget={spots:1/0,over:!1,told:!1};hidden(e){let n=0;for(let s of us(Ws(this.solids,Hr),...Ta(e)))n+=Yr(this.solids[s],e);return n}hiddenPoly(e){let n=0;for(let s of us(Ws(this.solids,Hr),...Lc(e)))n+=Xo(e,this.solids[s]);return n}costPoly(e,n=1/0){let s=Lc(e),r=0;for(let o of us(Ws(this.polys,i=>Hr(i.poly)),...s))r+=Xo(e,this.polys[o].poly);for(let o of us(Ws(this.rects,i=>Ta(i.r)),...s))r+=Yr(e,this.rects[o].r)*2;for(let o of us(Ws(this.slants,Hr),...s))r+=Xo(e,this.slants[o])*2;if(r>=n)return r;for(let o of us(qu(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],d=Math.hypot(c[0]-l[0],c[1]-l[1]),u=Math.max(1,Math.ceil(d/4)),[f,p]=Uu(l,c,u,s);for(let g=f;g<=p;g++)Dc(e,[l[0]+(c[0]-l[0])*(g+.5)/u,l[1]+(c[1]-l[1])*(g+.5)/u])&&(r+=d/u*4*.6)}return r}cost(e,n,s=.6){let r=Ta(e),o=0;for(let i of us(Ws(this.polys,a=>Hr(a.poly)),...r)){let a=this.polys[i];o+=Yr(a.poly,e)*(a.owner===n?1.5:1)}for(let i of us(Ws(this.rects,a=>Ta(a.r)),...r)){let a=this.rects[i];(a.owner!==n||!n)&&(o+=Rc(a.r,e)*2)}for(let i of us(Ws(this.slants,Hr),...r))o+=Yr(this.slants[i],e)*2;if(s){let i=-1,a=0;for(let l of us(qu(this.lines),...r)){let c=Math.floor(l/65536);c!==i&&(i>=0&&(o+=a*s),i=c,a=0);let d=this.lines[c].pts,u=l%65536,f=d[u],p=d[u+1],g=Math.hypot(p[0]-f[0],p[1]-f[1]),h=Math.max(1,Math.ceil(g/4)),[b,v]=Uu(f,p,h,r);for(let w=b;w<=v;w++){let k=f[0]+(p[0]-f[0])*(w+.5)/h,y=f[1]+(p[1]-f[1])*(w+.5)/h;k>=e.x&&k<=e.x+e.w&&y>=e.y&&y<=e.y+e.h&&(a+=g/h*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}},Ju=14;function Qo(t,e,n,s){let r=Math.max(t.name?Nn(t.name,It.lbl):0,t.sub?Nn(t.sub,It.sub):0)+4,o=(t.name?1:0)+(t.sub?1:0),i=n-(t.name?11:9)-1,a=(o-1)*Ju+(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 Zo(t,e,n,s,r,o){let i=Ps(n),a=Xe((e.x0+e.x1)/2,(e.y0+e.y1)/2,e.z1)[0],c=((t.name?1:0)+(t.sub?1:0)-1)*Ju+4,d=i.y-6-c,u=i.y+Math.min(i.h,60)*.45,f=[];o&&f.push({...o,pen:0}),f.push({x:a,y:d,anchor:"middle",pen:o?20:0});for(let h of[12,24,40])f.push({x:a,y:d-h,anchor:"middle",pen:20+h});for(let h of[-30,30,-60,60])f.push({x:a+h,y:d-4,anchor:"middle",pen:30+Math.abs(h)});f.push({x:i.x+i.w+8,y:u,anchor:"start",pen:120}),f.push({x:i.x-8,y:u,anchor:"end",pen:120}),f.push({x:a,y:i.y+i.h+14,anchor:"middle",pen:300});let p,g=1/0;for(let h of f){let b=Qo(t,h.x,h.y,h.anchor),v=s.cost(b,r,.15)*2+h.pen;v<g&&(g=v,p={x:h.x,y:h.y,anchor:h.anchor,rect:b})}return p}function Ic(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 Ca(t,e,n,s,r){let o=[{...s,pen:0}];for(let d of[-46,-66,-86,-106,-126,-146])for(let u of[0,-70,70,-140,140])o.push({x:e+u,y:n+d,anchor:"middle",pen:10+(-d-46)*.5+Math.abs(u)*.4});for(let d of[34,60,86])o.push({x:e,y:n+d,anchor:"middle",pen:60+d*.3});let i=s.x-e,a=s.y-n;for(let d of[-1,1])for(let u of[16,32,48])o.push({...s,y:n+a+d*u,x:e+i,pen:5+u});for(let d of[-1,1])for(let u of[30,60,90])for(let f of[0,16,-16])o.push({...s,x:e+i+d*u,y:n+a+f,pen:8+u*.6+Math.abs(f)});let l,c=1/0;for(let d of o){let u=Ic(t,d.x,d.y,d.anchor),f=r.cost(u,void 0,.05)*3+d.pen;f<c&&(c=f,l={x:d.x,y:d.y,anchor:d.anchor,rect:u})}return l}var Xu=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},Nc=t=>Xu(t)<0?[...t].reverse():t;function Dc(t,e){let n=Nc(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 Xo(t,e){let n=Nc(t),s=Nc(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 d=l[c],u=l[(c+1)%l.length],f=a(d),p=a(u);if(f>=0&&n.push(d),f>=0!=p>=0){let g=f/(f-p);n.push([d[0]+(u[0]-d[0])*g,d[1]+(u[1]-d[1])*g])}}}return n.length>=3?Math.abs(Xu(n)):0}var Oa=24;function La(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((d,u)=>d[1]-u[1]);let c=l[0][0];return c==="left"?{edge:c,dx:-(t.x+t.w-n)-Oa,dy:0}:c==="right"?{edge:c,dx:n+r-t.x+Oa,dy:0}:c==="top"?{edge:c,dx:0,dy:-(t.y+t.h-s)-Oa}:{edge:c,dx:0,dy:s+o-t.y+Oa}}function Na(t,e,n){let s=y=>{let M=0;for(let T=y.parent;T;T=T.parent)M++;return M},r=y=>y.box.x0+y.box.y0+y.box.z0*.01,o=t.items.filter(y=>y.type==="region").sort((y,M)=>s(y)-s(M)||r(y)-r(M)),i=t.items.filter(y=>y.type==="node").sort((y,M)=>r(y)-r(M)||y.box.z0-M.box.z0),a=[],l=Math.min(90,400/Math.max(1,o.length)),c=650;o.forEach((y,M)=>{let T=Ps(Pn(y.box));a.push({id:y.id,kind:"region",...La(T,n),delay:Math.round(M*l),dur:c,bbox:T})});let d=250+Math.round(l*o.length),u=Math.min(70,700/Math.max(1,i.length)),f=600;i.forEach((y,M)=>{let T=Ps(Pn(y.box));a.push({id:y.id,kind:"node",...La(T,n),delay:Math.round(d+M*u),dur:f,bbox:T})});let p=i.length?d+(i.length-1)*u:d,g=Math.round(p+300),h=Math.min(30,300/Math.max(1,e.length)),b=400,v=e.filter(y=>y.points.length>=2).map((y,M)=>({id:y.id,delay:Math.round(g+M*h),dur:b})),w={delay:g+200,dur:400},k=Math.max(...a.map(y=>y.delay+y.dur),...v.map(y=>y.delay+y.dur),w.delay+w.dur);return{pieces:a,routes:v,labels:w,total:k}}function Fc(t){return Math.max(5600,Math.min(12500,2600+t.length*40))}function Ra(t,e,n,s,r,o){let i=[],a=(L,B,S,E="error")=>{let x=r.locate(L);i.push({severity:E,message:B,line:x.line,col:x.col,path:L,hint:S})},l=t.steps??[],c=new Set(Object.keys(o.kinds)),d=new Map(s.map(L=>[L.id,L])),u=()=>[...n.byId.keys(),...d.keys()],f=new Map;l.forEach((L,B)=>{L.id&&(f.has(L.id)&&a(`${e}/steps/${B}/id`,`duplicate step id "${L.id}"`),f.set(L.id,B+1))});let p=l.length,g=(L,B)=>{if(typeof L=="number"){if(L<1||L>p){a(B,`there is no step ${L}; this scene has ${p} step(s)`);return}return L}let S=f.get(L);return S===void 0&&a(B,`unknown step "${L}"`+Dn(L,f.keys())),S},h=L=>cs(o,o.kinds[L]?.color??"control"),b=[],v=L=>{b.includes(L)||b.push(L)};for(let L of s)v(L.kind);let w={},k=(L,B,S,E)=>{if(B===void 0&&S===void 0)return;let x=B!==void 0?g(B,E+"/appears"):1,N=S!==void 0?g(S,E+"/disappears"):p+1;w[L]=Array.from({length:p},(z,Q)=>Q+1>=(x??1)&&Q+1<(N??p+1))};for(let L of n.items)k(L.id,L.appears,L.disappears,L.path);for(let L of s)k(L.id,L.raw.appears,L.raw.disappears,L.path);let y=[],M=[],T=[],A=[],I=()=>{for(let L of s){if(L.raw.appears!==void 0||L.raw.disappears!==void 0)continue;let B=[L.from,L.to].map(S=>S&&(w[S.id]??j(S)));B.some(Boolean)&&(w[L.id]=Array.from({length:p},(S,E)=>B.every(x=>!x||x[E])))}},j=L=>{for(let B=L.parent;B;B=B.parent)if(w[B.id])return w[B.id]};return l.forEach((L,B)=>{let S=B+1,E=`${e}/steps/${B}`,x=L.kind??"control";c.has(x)||a(E+"/kind",`unknown flow kind "${x}"`+Dn(x,c)),v(x);let N=new Set,z=[];(L.animate??[]).forEach((F,X)=>{let Z=Array.isArray(F)?F:[F],be=[];Z.forEach((V,J)=>{let G=Array.isArray(F)?`${E}/animate/${X}/${J}`:`${E}/animate/${X}`,ne,oe;if(typeof V=="string"){let ye=/^([^:\s]+)\s*(?::\s*(\S+))?$/.exec(V.trim());ne=ye?ye[1]:V,oe=ye?.[2]}else{let ye=Object.entries(V)[0];ne=ye[0],oe=ye[1]}let ve=d.get(ne);if(!ve){a(G,`unknown route "${ne}"`+Dn(ne,d.keys()));return}if(oe&&!c.has(oe)){a(G,`unknown flow kind "${oe}"`+Dn(oe,c));return}let ge=oe??ve.kind;v(ge),be.push({route:ne,kind:ge,color:h(ge)}),N.add(ne),ve.from&&N.add(ve.from.id),ve.to&&N.add(ve.to.id)}),be.length&&z.push(be)});let Q=[];(L.pulse??[]).forEach((F,X)=>{let Z=n.byId.get(F);if(!Z){a(`${E}/pulse/${X}`,`unknown node "${F}"`+Dn(F,n.byId.keys()));return}let be,V,J,G,ne=Z.node?mr(n.catalog,Z.node.asset):void 0;if(ne?.pulse)[be,V,J,G]=ne.pulse(Z.box);else{let ge=Z.box;be=(ge.x0+ge.x1)/2,V=(ge.y0+ge.y1)/2,J=ge.z1,G=Math.max(22,Math.min(60,(ge.x1-ge.x0+ge.y1-ge.y0)*8.5))}let[oe,ve]=Xe(be,V,J);Q.push([oe,ve,G*1.7,G*.98]),N.add(F)}),(L.highlight??[]).forEach((F,X)=>{!n.byId.has(F)&&!d.has(F)&&a(`${E}/highlight/${X}`,`unknown id "${F}"`+Dn(F,u())),N.add(F)});for(let[F,X]of[["show",!0],["hide",!1]])(L[F]??[]).forEach((Z,be)=>{if(!n.byId.has(Z)&&!d.has(Z)){a(`${E}/${F}/${be}`,`unknown id "${Z}"`+Dn(Z,u()));return}let V=w[Z]??(w[Z]=Array(p).fill(!X));for(let J=B;J<p;J++)V[J]=X});if((L.say??[]).forEach((F,X)=>{let Z,be;if(Array.isArray(F.at))[Z,be]=Xe(F.at[0],F.at[1],F.at[2]??.36);else{let J=n.byId.get(F.at);if(!J){a(`${E}/say/${X}/at`,`unknown node "${F.at}"`+Dn(F.at,n.byId.keys()));return}let G=J.box;[Z,be]=Xe((G.x0+G.x1)/2,(G.y0+G.y1)/2,G.z1+.75)}let V=F.kind??x;c.has(V)||a(`${E}/say/${X}/kind`,`unknown flow kind "${V}"`+Dn(V,c)),M.push({step:S,x:Z+(F.dx??0),y:be+(F.dy??(Array.isArray(F.at)?0:-46)),ax:Z,ay:be,text:F.text,kind:V,anchor:F.anchor??"middle"})}),(L.mark??[]).forEach((F,X)=>{if(F.at){T.push({step:S,p:[F.at[0],F.at[1],F.at[2]??.36]});return}let Z=F.on?d.get(F.on):void 0;if(!Z){a(`${E}/mark/${X}`,F.on?`unknown route "${F.on}"`+Dn(F.on,d.keys()):'a mark needs "on: ROUTE" or "at: [x, y]"');return}let be=Z.points[Z.points.length-1];T.push({step:S,p:[be[0],be[1],be[2]+.6],on:Z.id}),N.add(Z.id)}),t.badges&&L.badge!==!1){let F=Array.isArray(L.badge)?[L.badge[0],L.badge[1],L.badge[2]??.36]:void 0,X=typeof L.badge=="string"?L.badge:z[0]?.[0]?.route,Z=X?d.get(X):void 0;if(!F)if(Z)F=jc(Z.points);else if(X&&n.byId.get(X)){let be=n.byId.get(X).box;F=[(be.x0+be.x1)/2,(be.y0+be.y1)/2,be.z1+.3]}else typeof L.badge=="string"&&a(`${E}/badge`,`unknown id "${L.badge}"`+Dn(L.badge,u()));F&&A.push({step:S,num:L.number??S,kind:x,p:F})}for(let F of[...N])for(let X=n.byId.get(F)?.parent;X;X=X.parent)N.add(X.id);for(let F of n.items)F.region?.kind==="tunnel"&&(F.region.around??[]).some(X=>N.has(X))&&N.add(F.id);let re;if(L.focus?.length){let F=1/0,X=1/0,Z=-1/0,be=-1/0;L.focus.forEach((V,J)=>{let G=n.byId.get(V);if(!G){a(`${E}/focus/${J}`,`unknown node or region "${V}"`+Dn(V,n.byId.keys()));return}let ne=G.box;for(let[oe,ve,ge]of[[ne.x0,ne.y0,ne.z1],[ne.x1,ne.y0,ne.z0],[ne.x0,ne.y1,ne.z0],[ne.x1,ne.y1,ne.z0],[ne.x1,ne.y0,ne.z1],[ne.x0,ne.y1,ne.z1]]){let[ye,Ie]=Xe(oe,ve,ge);F=Math.min(F,ye),X=Math.min(X,Ie),Z=Math.max(Z,ye),be=Math.max(be,Ie)}N.add(V)}),F<1/0&&(re=[Math.round(F-60),Math.round(X-70),Math.round(Z+60),Math.round(be+40)])}let we=L.caption??"";y.push({n:S,num:L.number??S,kind:x,color:h(x),heading:L.heading,caption:we,command:L.command??"",phases:z,pulses:Q,lit:[...N],duration:L.duration===void 0||L.duration==="auto"?Fc(we):L.duration,...re?{focus:re}:{}})}),I(),{steps:y,says:M,marks:T,badges:A,vis:w,diags:i,kindsUsed:b}}function jc(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 Dn(t,e){let n=Us(t,e);return n?` (did you mean "${n}"?)`:""}function Qu(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,d=(s+o)/2,u=Math.max(t[0],Math.min(t[0]+t[2]-a,c-a/2)),f=Math.max(t[1],Math.min(t[1]+t[3]-l,d-l/2));return[u,f,a,l]}var ja=(t,e)=>e.role??Dt(t,e.kind)?.role,Ia=(t,e)=>Dt(t,e.region.kind)?.shape;function Ba({scene:t,layout:e,routes:n,steps:s,theme:r,id:o,gridStep:i=1}){let a=new Or,l={base:"",floor:"",flows:"",blocks:[],air:"",labels:"",marks:"",badges:""},c=new hr;c.budget.spots=Fa;let d=x=>s.vis[x]?{"data-vis":"1"}:{},u=e.items.filter(x=>x.type==="region"),f=x=>{let N=0;for(let z=x.parent;z;z=z.parent)N++;return N},p=e.catalog,g=u.filter(x=>Ia(p,x)!=="walled"&&Ia(p,x)!=="tunnel"),h=$o(g.map(x=>({box:x.box,r:x}))).map(x=>x.r).sort((x,N)=>f(x)-f(N));for(let x of h)l.base+=mm(a,p,x,d(x.id),i);for(let x of u.filter(N=>Ia(p,N)==="walled")){for(let z of Da(x))c.solids.push(Pn(z));for(let z of Da(x))l.blocks.push({box:z,svg:_e("g",{class:`blk k-${ja(p,x.region)} wall${x.region.ghost?" ghost":""}`,"data-id":x.id,"data-dim":"1",...d(x.id)},a.blockFaces(z))});let N=x.region.gate;if(N&&!N.node){let z=Wo(x,N.height??(x.region.height??.8)+.3,.3,.3);c.solids.push(Pn(z)),l.blocks.push({box:z,svg:_e("g",{class:"blk k-gate","data-id":x.id,...d(x.id)},a.blockFaces(z))})}x.region.label&&(x.region["label-style"]??"face")!=="none"&&(l.labels+=a.faceText(x.box.x0+.3,x.box.y1,x.box.z0+.13,x.region.label,"slabname sm fz",It.sm,"left","start",{"data-id":x.id,...d(x.id)}))}for(let x of u.filter(N=>Ia(p,N)==="tunnel"))l.air+=gm(a,x,d(x.id));let b=e.items.filter(x=>x.type==="node");for(let x of b){let N=x.node,z=In(p,N.asset),Q=N.ghost||(N.deco??[]).includes("ghost"),re=["blk",`k-${N.role??z.role}`,z.cls,Q?"ghost":""].filter(Boolean).join(" ");l.blocks.push({box:x.box,svg:_e("g",{class:re,"data-id":x.id,"data-dim":"1",...d(x.id)},z.draw(a,x.box,N))}),c.polys.push({poly:Pn(x.box),owner:x.id}),c.solids.push(Pn(x.box))}let v=$o(l.blocks).map(x=>x.svg).join(""),w=new Set,k={};for(let x of n){if(x.points.length<2)continue;let N=x.points.map(re=>Xe(re[0],re[1],re[2]));N.forEach(re=>a.bounds.add(re));let z="M"+N.map(cr).join(" L");k[x.id]=z;let Q=x.raw.arrow!==!1;Q&&w.add(x.kind),l.flows+=_e("g",{"data-hl":x.id,"data-id":x.id,...d(x.id)},_e("path",{d:z,class:`flow f-${x.kind}`,"marker-end":Q?`url(#ah-${o}-${x.kind})`:void 0})),c.lines.push({pts:N,owner:x.id})}for(let x of w)a.def(`ah-${o}-${x}`,_e("marker",{id:`ah-${o}-${x}`,viewBox:"0 0 10 10",refX:"7",refY:"5",markerWidth:"4.2",markerHeight:"4.2",orient:"auto-start-reverse"},_e("path",{d:"M0,0 L10,5 L0,10 z",style:`fill:${cs(r,r.kinds[x]?.color??"control")}`})));for(let x of a.planePolys)c.slants.push(x);let y=b.filter(x=>x.node.label||x.node.sub).sort((x,N)=>(N.box.x1-N.box.x0)*(N.box.y1-N.box.y0)-(x.box.x1-x.box.x0)*(x.box.y1-x.box.y0));for(let x of y)l.labels+=hm(a,p,x,c,d(x.id));let M=[];for(let x of n)if(x.raw.label&&x.points.length>=2){let N=bm(a,x,c,d(x.id),e);l.floor+=N.svg,N.warning&&M.push({path:`${x.path}/label`,message:N.warning}),c.budget.over&&!c.budget.told&&(c.budget.told=!0,M.push({path:x.path,message:`from route "${x.id}" on, route labels were placed without weighing what other labels and lines cover: the scene is too large to search every spot (${Fa.toLocaleString("en")} spots); split it into scenes, or give the labels "along", "side" or "at"`}))}(t.notes??[]).forEach((x,N)=>{let z=ym(a,x,e,n,`${o}-note-${N}`);x.floor?l.floor+=z:l.labels+=z});let T=[],A=new Map;for(let x of s.says){let N=A.get(x.step)??c.fork();A.set(x.step,N);let z=Nn(x.text,It.say)+18,Q=Ca(z,x.ax,x.ay,{x:x.x,y:x.y,anchor:x.anchor},N);N.rects.push({r:Q.rect,owner:""}),T.push({step:x.step,...Q.rect,text:x.text});let re=Q.rect.x+2;a.bounds.addRect(Q.rect.x,Q.rect.y,Q.rect.w,Q.rect.h);let we=cs(r,r.kinds[x.kind]?.color??"control");l.marks+=_e("g",{class:"say","data-step":x.step},_e("rect",{x:re,y:Q.y-12,width:z,height:24,rx:12,style:`stroke:${we}`})+_e("text",{x:re+z/2,y:Q.y+4,"text-anchor":"middle",style:`fill:${we}`},_t(x.text)))}for(let x of s.marks){let[N,z]=Xe(...x.p);a.bounds.addRect(N-12,z-12,24,24),l.marks+=_e("g",{class:"xm","data-step":x.step,"data-hl":x.on},_e("circle",{cx:N,cy:z,r:10})+_e("path",{d:`M${Rt(N-4.5)},${Rt(z-4.5)} L${Rt(N+4.5)},${Rt(z+4.5)} M${Rt(N+4.5)},${Rt(z-4.5)} L${Rt(N-4.5)},${Rt(z+4.5)}`}))}for(let x of s.badges){let[N,z]=Xe(...x.p);a.bounds.addRect(N-13,z-13,26,26),l.badges+=_e("g",{class:`badge c-${x.kind}`,"data-go":x.step,"data-badge":x.step,tabindex:"0",role:"button","aria-label":`Step ${x.num}`},_e("circle",{cx:N,cy:z,r:11.5})+_e("text",{x:N,y:z+.5},String(x.num)))}let I=a.bounds,j=22,L=I.empty?[0,0,100,100]:[Math.floor(I.x0-j),Math.floor(I.y0-j),Math.ceil(I.x1-I.x0+j*2),Math.ceil(I.y1-I.y0+j*2)],B=[...a.defs.values()].join(""),S=(x,N)=>_e("g",{class:"g-"+x},N);return{svg:_e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:L.join(" "),role:"img","aria-label":t.aria??t.title,"data-scene":o},_e("defs",{},B)+S("base",l.base)+S("floor",l.floor)+S("flows",l.flows)+S("blocks",v)+S("air",l.air)+S("labels",l.labels)+S("marks",l.marks)+S("badges",l.badges)+S("anim","")),viewBox:L,texts:a.texts,paths:k,warnings:M,callouts:T,assembly:Na(e,n,L)}}function pm(t,e){let n=t.z1+.002,s=1e-6,r=[],o=(i,a)=>{let l=Xe(i[0],i[1],n),c=Xe(a[0],a[1],n);r.push(`M${cr(l)}L${cr(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?_e("path",{class:"grid",d:r.join("")}):""}function mm(t,e,n,s,r=1){let o=n.region,i=n.box,a=ja(e,o),l=Dt(e,o.kind),c=l?.shape,d={"data-id":n.id,"data-dim":"1",...s},u="";c==="cloud"?u=_e("g",{class:`blk k-${a} cloud`,...d},ba(t,i)):c==="zone"?u=_e("g",{class:`zone k-${a}`,...d},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=_e("g",{class:`blk k-${a}${o.ghost?" ghost":""}`,...d},t.blockFaces(i)+pm(i,r));let f=o["label-style"]??l?.labelStyle;if(o.label&&f!=="none")if(f==="face"){let p=i.z1-i.z0,g=w=>w.size*.73/yt,h=c==="slab"&&.28+g(It.slabname)+.08>p,b=c==="slab"&&!h,v=b?i.z0+.28:h?i.z0+Math.max(.02,(p-g(It.sm))/2):i.z0+Math.min(.1,p*.25);u+=_e("g",d,t.faceText(i.x0+(b?.6:.3),i.y1,v,o.label,b?"slabname":"slabname sm",b?It.slabname:It.sm,"left","start"))}else if(f==="face-right")u+=_e("g",d,t.faceText(i.x1,i.y0+.6,i.z0+Math.max(.14,(i.z1-i.z0)*.2),o.label,"slabname",It.slabname,"right","end"));else{let p=c==="cloud"?"middle":"start",g=c==="cloud"?(i.x0+i.x1)/2:i.x0+.35,h=c==="cloud"?(i.y0+i.y1)/2:i.y1-.35;u+=_e("g",d,t.floorText(g,h,i.z1+.01,o.label,"slabname sm","x",p))}return u}function Da(t){let{x0:e,y0:n,x1:s,y1:r,z0:o,z1:i}=t.box,a=ds,l=t.region.gate,c=[],d=f=>{f.x1-f.x0>1e-6&&f.y1-f.y0>1e-6&&c.push({...f,z0:o,z1:i})},u=(f,p,g)=>{if(!l||l.side!==g)return[[f,p]];let h=l.at??.5,b=l.width??2,v=g==="e"||g==="w"?n+(r-n)*h:e+(s-e)*h;return[[f,v-b/2],[v+b/2,p]]};for(let[f,p]of u(e,s,"n"))d({x0:f,y0:n,x1:p,y1:n+a});for(let[f,p]of u(n+a,r-a,"w"))d({x0:e,y0:f,x1:e+a,y1:p});for(let[f,p]of u(n+a,r-a,"e"))d({x0:s-a,y0:f,x1:s,y1:p});for(let[f,p]of u(e,s,"s"))d({x0:f,y0:r-a,x1:p,y1:r});return c}function hm(t,e,n,s,r){let o=n.node,i=In(e,o.asset),a=n.box,l={name:o.label,sub:o.sub},c=o["label-at"],d;if(c){let f=Ps(Pn(a)),p=c.side??"above",g=f.y+Math.min(f.h,60)*.45;p==="right"?d={x:f.x+f.w+8,y:g,anchor:"start"}:p==="left"?d={x:f.x-8,y:g,anchor:"end"}:p==="below"?d={x:f.x+f.w/2,y:f.y+f.h+14,anchor:"middle"}:d=Zo(l,a,Pn(a),new hr,n.id),d={...d,x:d.x+(c.dx??0),y:d.y+(c.dy??0)}}else{let f=i.label?i.label(a,o,!!o.sub):void 0;d=Zo(l,a,Pn(a),s,n.id,f)}s.rects.push({r:Qo(l,d.x,d.y,d.anchor),owner:""});let u="";return o.label&&(u+=t.text(d.x,d.y,o.label,"lbl",It.lbl,d.anchor,{},n.id)),o.sub&&(u+=t.text(d.x,o.label?d.y+14:d.y,o.sub,"sub mono",It.sub,d.anchor,{},n.id)),_e("g",{"data-id":n.id,"data-dim":"1",...r},u)}function gm(t,e,n){let{x0:s,y0:r,x1:o,y1:i,z0:a,z1:l}=e.box,c=t.blockFaces(e.box),d=o-s>=i-r,u=Math.max(1,Math.round((d?o-s:i-r)/1.6));for(let p=1;p<u;p++){let g=d?s+(o-s)*p/u:r+(i-r)*p/u;c+=t.poly(d?[[g,r,l],[g,i,l],[g,i,a]]:[[s,g,l],[o,g,l],[o,g,a]],"rib")}let f=e.region.label;return f&&e.region["label-style"]!=="none"&&(c+=d?t.faceText(s+.35,i,a+.14,f,"tunname",It.tunname,"left","start"):t.faceText(o,i-.35,a+.18,f,"tunname",It.tunname,"right","start")),_e("g",{class:"tunnel","data-id":e.id,"data-dim":"1",...n},c)}var Fa=2e4;function bm(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=It.floor;if(o.at){let w=o.at.length>2?o.at[2]:e.points[0][2];return{svg:t.floorText(o.at[0],o.at[1],w,o.text,i,o.dir??"x",o.anchor??"start",a)}}let c=e.points,d=[];for(let w=0;w+1<c.length;w++){let k=c[w],y=c[w+1];Math.abs(k[2]-y[2])>1e-6||d.push({i:w,len:Math.hypot(y[0]-k[0],y[1]-k[1])})}if(!d.length)return{svg:"",warning:`label "${o.text}" of route "${e.id}" was dropped: the route has no level segment`};let u=o.along?d.filter(w=>w.i===Math.min(o.along-1,c.length-2)):[...d].sort((w,k)=>k.len-w.len),f=.22,p=11/yt,g=w=>{let k=Nn(w,l)/yt,y,M=1/0,T=0;e:for(let A of u.length?u:d){let I=c[A.i],j=c[A.i+1],L=I[2],B=Math.abs(I[1]-j[1])<1e-6,S=B?Math.min(I[0],j[0]):Math.min(I[1],j[1]),E=B?Math.max(I[0],j[0]):Math.max(I[1],j[1]),x=B?I[1]:I[0],N=o.side==="left"?[-1]:o.side==="right"?[1]:[-1,1],z=[];for(let Q=S+.3;Q<=Math.max(S+.3,E-k-.2)+1e-9;Q+=.4)z.push(Q);for(let Q=E-k-.2+.4;Q<E+.5&&E-S<k+.5;Q+=.6)z.push(Q);for(let Q of N)for(let re of z){if(M<=T*.5)break e;let we=Q<0?x-f:x+f+p,F,X,Z;if(B?(F=re,X=we,Z=[Xe(F,X-p,L),Xe(F+k,X-p,L),Xe(F+k,X,L),Xe(F,X,L)]):(F=we,X=re+k,Z=[Xe(F-p,X,L),Xe(F-p,X-k,L),Xe(F,X-k,L),Xe(F,X,L)]),(B?[[F,X-p],[F+k,X-p],[F+k,X],[F,X]]:[[F-p,X],[F-p,X-k],[F,X-k],[F,X]]).some(([oe,ve])=>Math.abs(Gr(r,oe,ve)+.01-L)>.001)){T++;continue}let V=n.hiddenPoly(Z),J=V*50+T*.5,G=n.budget.spots-- >0;G||(n.budget.over=!0);let ne=J>=M?1/0:G?J+n.costPoly(Z,M-J):J;T++,ne<M&&(M=ne,y={x:F,y:X,z:L,dir:B?"x":"y",rect:Ps(Z),poly:Z,hidden:V})}}return y&&y.hidden<6?y:void 0},h=o.text,b=g(h),v;if(!b){let w=o.text.split(/(\s+)/);for(let k=w.length-1;k>0&&!b;k--){let y=w.slice(0,k).join("").trimEnd().replace(/[\s,;:·–-]+$/,"")+"\u2026";if(y.length<6)break;let M=g(y);M&&(b=M,h=y)}v=b?`label of route "${e.id}" shortened to "${h}": no clear floor for the whole text`:`label "${o.text}" of route "${e.id}" was dropped: blocks cover every spot beside it`,b?v+='; give it "along", "side" or "at", or move the nodes apart':v+='; give it "at: [x, y]", or move the nodes apart'}return b?(n.slants.push(b.poly),{svg:t.floorText(b.x,b.y,b.z+.01,h,i,b.dir,"start",a),warning:v}):{svg:"",warning:v}}function ym(t,e,n,s,r){let o=e.on?s.find(d=>d.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 d=a&&a.length>2?a[2]:o?o.points[0][2]:i?i.floor:.36,[u,f]=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,f,d+.01,e.floor,`floor mono t-${c}`,e.dir??"x",e.anchor??"start",l)}if(e.face){let d=i?.box,[u,f,p]=a?[a[0],a[1],a[2]??.45]:d?[d.x0+.3,d.y1,d.z0+.13]:[0,0,0];return t.faceText(u,f,p,e.face,"slabname sm",It.sm,"left",e.anchor??"start",l)}if(e.label||e.sub){let d=i?.box,u=a?[a[0],a[1],a[2]??.36]:d?[(d.x0+d.x1)/2,(d.y0+d.y1)/2,d.z1+.75]:[0,0,0],[f,p]=Xe(u[0],u[1],u[2]),g=f+(e.dx??0),h=p-18+(e.dy??0),b=e.anchor??"middle",v="";return e.label&&(v+=t.text(g,h,e.label,"lbl",It.lbl,b)),e.sub&&(v+=t.text(g,e.label?h+14:h,e.sub,"sub mono",It.sub,b)),_e("g",l,v)}return""}var Bc=`
|
|
143
143
|
*{box-sizing:border-box}
|
|
144
144
|
html,body{margin:0}
|
|
145
145
|
body{background:var(--bg);color:var(--ink);font:15px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;-webkit-font-smoothing:antialiased;overflow-x:hidden}
|
|
@@ -163,7 +163,7 @@ h2{font-size:20px;margin:44px 0 4px;letter-spacing:-.005em;text-wrap:balance}
|
|
|
163
163
|
.legend i{display:inline-block;width:26px;height:0;border-top:3px solid}
|
|
164
164
|
.legend i.box{height:10px;border-width:1.5px;border-style:solid;border-radius:2px}
|
|
165
165
|
footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
|
|
166
|
-
`,
|
|
166
|
+
`,Kc=t=>xm+ma(t)+wm+ha(),xm=`
|
|
167
167
|
/* blocks: hue per role, lightness per face and theme */
|
|
168
168
|
.blk .top{fill:hsl(var(--h) var(--s) var(--l-top))}
|
|
169
169
|
.blk .lft{fill:hsl(var(--h) var(--s) var(--l-left))}
|
|
@@ -204,14 +204,14 @@ footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
|
|
|
204
204
|
.floor.t-control{fill:var(--muted)}
|
|
205
205
|
.slabname{font-size:15px;font-weight:800;fill:var(--muted);letter-spacing:.12em;opacity:.8}
|
|
206
206
|
.slabname.sm{font-size:10.5px;letter-spacing:.1em;opacity:1}
|
|
207
|
-
`,
|
|
207
|
+
`,wm=`.tunnel polygon{fill:hsl(205 85% 55% / .17);stroke:hsl(205 75% 45% / .8);stroke-width:1.3;stroke-linejoin:round}
|
|
208
208
|
.tunnel .top{fill:hsl(205 85% 65% / .22)}
|
|
209
209
|
.tunnel .rib{fill:none;stroke:hsl(205 75% 45% / .5);stroke-width:1}
|
|
210
210
|
.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
211
|
|
|
212
212
|
/* flows */
|
|
213
213
|
.flow{fill:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
|
|
214
|
-
`,
|
|
214
|
+
`,Ka=t=>Bc+Kc(t),_c=`
|
|
215
215
|
/* step marks */
|
|
216
216
|
.xm circle{fill:var(--surface);stroke:var(--blocked);stroke-width:2.5}
|
|
217
217
|
.xm path{stroke:var(--blocked);stroke-width:3;stroke-linecap:round}
|
|
@@ -234,7 +234,7 @@ svg.all .badge{opacity:1}
|
|
|
234
234
|
svg.focus.all [data-hl]:not(.hl),svg.focus.all.dim-all [data-dim]:not(.hl){opacity:.9}
|
|
235
235
|
svg [data-step]:not(.on),svg.all [data-step]{opacity:0!important;pointer-events:none}
|
|
236
236
|
.pre{opacity:0!important;pointer-events:none}
|
|
237
|
-
`,
|
|
237
|
+
`,zc=`
|
|
238
238
|
/* player */
|
|
239
239
|
.player{display:flex;align-items:flex-start;gap:10px 14px;padding:12px 16px;border-top:1px solid var(--line);flex-wrap:wrap}
|
|
240
240
|
.ctrls{display:flex;gap:6px;flex:none}
|
|
@@ -269,20 +269,20 @@ details.steps li code{font-size:11.5px}
|
|
|
269
269
|
.still .ctrls,.still .tools{display:none}
|
|
270
270
|
.tools{display:flex;gap:6px;flex:none;order:3;margin-left:auto}
|
|
271
271
|
.pbtn.small{font-size:12px;padding:4px 11px;font-weight:600;color:var(--muted)}
|
|
272
|
-
.pbtn.small[aria-pressed="true"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}`,
|
|
272
|
+
.pbtn.small[aria-pressed="true"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}`,Vc=`
|
|
273
273
|
.grid{display:none;fill:none;stroke:var(--ink);stroke-width:.6;opacity:.16;pointer-events:none}
|
|
274
274
|
svg.show-grid .grid{display:inline}
|
|
275
275
|
svg.pre-assemble > g:not(.g-anim){opacity:0}
|
|
276
|
-
`,ya=fc+pc+mc;var hc=t=>({data:t,locate:()=>({line:0,col:0}),span:()=>{},diags:[]});function yu(t,e,n,s=hc(t),r,o={},i=[]){let a=Ki(Bi(e),t.roles,t.kinds),l=[],c=new Map;return t.scenes.forEach((d,u)=>{let f=`/scenes/${u}`;if(c.has(d.id)){let v=s.locate(f+"/id");i.push({severity:"error",message:`duplicate scene id "${d.id}"`,line:v.line,col:v.col,path:f+"/id"})}c.set(d.id,u);let p={...t.grid,...d.grid,...o.snap?{snap:o.snap}:{}},g=Xi(d,f,s,a,n,t.roles,p.snap);i.push(...g.diags);let h=sa(d,f,g,s,new Set(Object.keys(a.kinds)),p.snap);i.push(...h.diags);let b=ua(d,f,g,h.routes,s,a);i.push(...b.diags),i.push(...jp(d,f,n,s));let k=ga({scene:d,layout:g,routes:h.routes,steps:b,theme:a,id:d.id,gridStep:p.step??p.snap??1});for(let v of k.warnings){let M=s.locate(v.path);i.push({severity:"warning",message:v.message,line:M.line,col:M.col,path:v.path})}l.push({id:d.id,raw:d,layout:g,routes:h.routes,steps:b,rendered:k,grid:p,assemble:d.assemble??t.assemble??!1})}),i.sort((d,u)=>d.line-u.line||d.col-u.col),{ok:!i.some(d=>d.severity==="error"),diags:i,doc:t,theme:a,catalog:n,scenes:l,parsed:s,source:r}}function jp(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,d)=>{let u=`${l}/nodes/${d}`;(c.deco??Tn(n,c.asset).deco??[]).forEach((f,p)=>{typeof f=="object"&&f.icon&&!Po(f.icon)&&o(c.deco?`${u}/deco/${p}/icon`:u,`node "${c.id}": no icon "${f.icon}" is registered here, so it is drawn as a placeholder`)}),c.face!==void 0&&!qi(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,d)=>i(c,`${l}/regions/${d}`))};return i(t,e),r}function ws(t,e){let n=t/(It*xt),s=2*e/xt;return[(n+s)/2,(s-n)/2]}function Rr(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 xa(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(Xe(n,s,r));return Bp(e)}function Ir(t){return[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]].map(([e,n])=>Xe(e,n,t.z0))}function Bp(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 Do=(t,e)=>e?.padding??Ft(t,e?.kind)?.pad??0;function Fo(t,e,n,s,r){let o=d=>Math.round(d/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 d=Math.ceil(r.pad/n-1e-9)*n,u=Math.floor((r.w-r.pad-s[0])/n+1e-9)*n,f=Math.floor((r.d-r.pad-s[1])/n+1e-9)*n;i<d&&(i=d,l.left=!0),u>=d&&i>u&&(i=u,l.right=!0),a<d&&(a=d,l.top=!0),f>=d&&a>f&&(a=f,l.bottom=!0)}let c=d=>Math.round(d*1e3)/1e3;return{at:[c(i),c(a)],delta:[c(i-t[0]),c(a-t[1])],clamped:l}}function rr(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 bc=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}),yc={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}},xu=(t,e)=>$n(t,yc[e]);function wa(t){let e=[],n=new Map,s=(l,c)=>{if(typeof c!="string"||!c){e.push(`${l} has no id`);return}let d=n.get(c);d?e.push(`duplicate id "${c}": a ${d} 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(d=>Number.isInteger(d)&&d>=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 d=o[l].cells,u=o[c].cells;d[0]<=u[2]&&u[0]<=d[2]&&d[1]<=u[3]&&u[1]<=d[3]&&!gc(d,u)&&!gc(u,d)&&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 d=`link ${l.id?`"${l.id}"`:c}`;for(let u of["a","b"])i.has(l[u])||e.push(`${d}: ${u} "${l[u]}" is no card or panel`);for(let u of["aOn","bOn"])l[u]!==void 0&&!a.has(l[u])&&e.push(`${d}: ${u} "${l[u]}" is no panel`);l.id!==void 0&&s("link",l.id)}),e}var gc=(t,e)=>t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3];function jo(t,e){let{W:n,H:s,GX:r,GY:o,PAD:i,TITLE:a,CH:l}=e,c=t.panels??[],d=B=>(B[2]-B[0]+1)*(B[3]-B[1]+1),u=(B,X)=>{let Q=c[B].cells,te=c[X].cells;return gc(te,Q)?d(Q)>d(te)||B<X:!1},f=c.map((B,X)=>{let Q=-1;return c.forEach((te,ne)=>{ne!==X&&u(ne,X)&&(Q<0||u(Q,ne))&&(Q=ne)}),Q}),p=B=>f[B]<0?0:1+p(f[B]),g=(B,X)=>{let Q=-1;c.forEach((ne,me)=>{let ye=ne.cells;B>=ye[0]&&B<=ye[2]&&X>=ye[1]&&X<=ye[3]&&(Q<0||u(Q,me))&&(Q=me)});let te=[];for(let ne=Q;ne>=0;ne=f[ne])te.unshift(ne);return te},h=Math.max(1,...t.cards.map(B=>B.cell[0]+1),...c.map(B=>B.cells[2]+1)),b=Math.max(1,...t.cards.map(B=>B.cell[1]+1),...c.map(B=>B.cells[3]+1)),k=[];for(let B=0;B<h;B++){k.push([]);for(let X=0;X<b;X++)k[B].push(g(B,X))}let v=(B,X,Q)=>{let te=B.filter(me=>!X.includes(me)),ne=X.filter(me=>!B.includes(me));return!te.length&&!ne.length?0:te.length*(i+(Q?a:0))+ne.length*i+l},M=new Array(h+1).fill(0),x=new Array(b+1).fill(0);for(let B=0;B<b;B++)for(let X=1;X<h;X++){let Q=v(k[X-1][B],k[X][B],!1);Q&&(M[X]=Math.max(M[X],Q-r))}for(let B=0;B<h;B++)for(let X=1;X<b;X++){let Q=v(k[B][X-1],k[B][X],!0);Q&&(x[X]=Math.max(x[X],Q-o))}let T=B=>{let X=B*(n+r);for(let Q=1;Q<=B;Q++)X+=M[Q];return X},y=B=>{let X=B*(s+o);for(let Q=1;Q<=B;Q++)X+=x[Q];return X},A=(B,X,Q,te)=>Q===X?B(X):B(X)+(te-X)*(B(Q)-B(X))/(Q-X),D=c.map(()=>new Set),K=(B,X)=>{for(let Q=B;Q>=0;Q=f[Q])D[Q].add(X)};c.forEach((B,X)=>{K(X,B.cells[1]),K(X,B.cells[3])});for(let B of t.cards){let X=k[B.cell[0]][B.cell[1]];X.length&&K(X[X.length-1],B.cell[1])}let C=c.map(()=>new Map),_=(B,X)=>B.slice(B.indexOf(X)+1);for(let B of c.map((X,Q)=>Q).sort((X,Q)=>p(X)-p(Q)||X-Q)){let X=c[B].cells,Q=[...D[B]].sort((ne,me)=>ne-me),te=f[B]>=0?C[f[B]].get(Q[0]):y(Q[0]);C[B].set(Q[0],te);for(let ne=1;ne<Q.length;ne++){let me=0;for(let ye=X[0];ye<=X[2];ye++)me=Math.max(me,v(_(k[ye][Q[ne-1]],B),_(k[ye][Q[ne]],B),!0));te+=s+Math.max(o,me),C[B].set(Q[ne],te)}}let S=c.map(()=>new Set),$=(B,X)=>{for(let Q=B;Q>=0;Q=f[Q])S[Q].add(X)};c.forEach((B,X)=>{$(X,B.cells[0]),$(X,B.cells[2])});for(let B of t.cards){let X=k[B.cell[0]][B.cell[1]];X.length&&$(X[X.length-1],B.cell[0])}let w=c.map(()=>new Map);for(let B of c.map((X,Q)=>Q).sort((X,Q)=>p(X)-p(Q)||X-Q)){let X=c[B].cells,Q=[...S[B]].sort((ne,me)=>ne-me);if(f[B]<0&&!f.includes(B)&&Q.length===X[2]-X[0]+1){for(let ne of Q)w[B].set(ne,A(T,X[0],X[2],ne));continue}let te=f[B]>=0?w[f[B]].get(Q[0]):T(Q[0]);w[B].set(Q[0],te);for(let ne=1;ne<Q.length;ne++){let me=0;for(let ye=X[1];ye<=X[3];ye++)me=Math.max(me,v(_(k[Q[ne-1]][ye],B),_(k[Q[ne]][ye],B),!1));te+=n+Math.max(r,me),w[B].set(Q[ne],te)}}let N=(B,X)=>{let Q=k[B][X],te=Q.length?Q[Q.length-1]:-1;return te>=0?[w[te].get(B),C[te].get(X)]:[T(B),y(X)]},F=c.map((B,X)=>X).sort((B,X)=>p(X)-p(B)||B-X),J=new Array(c.length);for(let B of F){let X=c[B].cells,Q=[],te=[];for(let ye of t.cards){let xe=k[ye.cell[0]][ye.cell[1]];xe[xe.length-1]===B&&(Q.push(w[B].get(ye.cell[0])),te.push(C[B].get(ye.cell[1])))}let ne=ye=>ye.cell[0]>=X[0]&&ye.cell[0]<=X[2]&&ye.cell[1]>=X[1]&&ye.cell[1]<=X[3];for(let ye of[X[1],X[3]])t.cards.some(xe=>xe.cell[1]===ye&&ne(xe))||te.push(C[B].get(ye));for(let ye of[X[0],X[2]])t.cards.some(xe=>xe.cell[0]===ye&&ne(xe))||Q.push(w[B].get(ye));let me={l:Q.length?Math.min(...Q):1/0,t:te.length?Math.min(...te):1/0,r:Q.length?Math.max(...Q)+n:-1/0,b:te.length?Math.max(...te)+s:-1/0};c.forEach((ye,xe)=>{if(f[xe]!==B)return;let Re=J[xe];me.l=Math.min(me.l,Re.l),me.t=Math.min(me.t,Re.t),me.r=Math.max(me.r,Re.r),me.b=Math.max(me.b,Re.b)}),J[B]={l:me.l-i,t:me.t-i,r:me.r+i,b:me.b+i+a}}let ae=t.cards.map(B=>N(B.cell[0],B.cell[1])),we=t.cards.map(B=>{let X=k[B.cell[0]][B.cell[1]];return X.length?X[X.length-1]:-1}),j=(B,X)=>{for(let Q=B;Q>=0;Q=f[Q])if(Q===X)return!0;return!1},U=(B,X)=>{t.cards.forEach((Q,te)=>{we[te]>=0&&j(we[te],B)&&(ae[te]=[ae[te][0]+X,ae[te][1]])}),c.forEach((Q,te)=>{j(te,B)&&(J[te]={...J[te],l:J[te].l+X,r:J[te].r+X})})},ee=B=>{let X=[],Q=[],te=[],ne=[];t.cards.forEach((I,re)=>{we[re]===B&&(X.push(ae[re][0]),te.push(ae[re][0]+n),Q.push(ae[re][1]),ne.push(ae[re][1]+s))}),c.forEach((I,re)=>{f[re]===B&&(X.push(J[re].l),te.push(J[re].r),Q.push(J[re].t),ne.push(J[re].b))});let me=J[B],ye=Math.min(...X,me.l+i),xe=Math.max(...te,me.r-i),Re=Math.min(...Q,me.t+i),Ue=Math.max(...ne,me.b-i-a);J[B]={l:ye-i,t:Re-i,r:xe+i,b:Ue+i+a}};for(let B of F)if(f[B]<0&&!f.includes(B))ee(B);else{let Q=[];t.cards.forEach((xe,Re)=>{we[Re]===B&&Q.push({l:ae[Re][0],r:ae[Re][0]+n,t:ae[Re][1],b:ae[Re][1]+s,card:Re})}),c.forEach((xe,Re)=>{f[Re]===B&&Q.push({...J[Re],panel:Re})}),Q.sort((xe,Re)=>xe.l-Re.l||xe.t-Re.t);let te=Math.min(...Q.map(xe=>xe.l)),ne=[];for(let xe of Q){let Re=te;for(let I of ne)I.t<xe.b&&xe.t<I.b&&I.r<=xe.l+1e-6&&(Re=Math.max(Re,I.r+(I.card!==void 0&&xe.card!==void 0?r:l)));let Ue=Re-xe.l;Ue<-1e-6&&(xe.card!==void 0?ae[xe.card]=[ae[xe.card][0]+Ue,ae[xe.card][1]]:U(xe.panel,Ue),xe.l+=Ue,xe.r+=Ue),ne.push(xe)}let me=Q.map(xe=>xe.l),ye=Q.map(xe=>xe.r);J[B]={...J[B],l:Math.min(...me)-i,r:Math.max(...ye)+i}}return{prect:J,parentIx:f,depthOf:p,pos:N,cardAt:B=>ae[B]}}function Fs(t,e,n={}){if(n.wrap){let{wrap:m,...O}=n;return Fs(Kp(t,e,m.aspect,O),e,O)}let s=wa(t);if(s.length)throw new Error(`the board has ${s.length} error${s.length>1?"s":""}:
|
|
276
|
+
`,_a=_c+zc+Vc;var Gc=t=>({data:t,locate:()=>({line:0,col:0}),span:()=>{},diags:[]});function Zu(t,e,n,s=Gc(t),r,o={},i=[]){let a=ca(la(e),t.roles,t.kinds),l=[],c=new Map;return t.scenes.forEach((d,u)=>{let f=`/scenes/${u}`;if(c.has(d.id)){let w=s.locate(f+"/id");i.push({severity:"error",message:`duplicate scene id "${d.id}"`,line:w.line,col:w.col,path:f+"/id"})}c.set(d.id,u);let p={...t.grid,...d.grid,...o.snap?{snap:o.snap}:{}},g=wa(d,f,s,a,n,t.roles,p.snap);i.push(...g.diags);let h=Ea(d,f,g,s,new Set(Object.keys(a.kinds)),p.snap);i.push(...h.diags);let b=Ra(d,f,g,h.routes,s,a);i.push(...b.diags),i.push(...vm(d,f,n,s));let v=Ba({scene:d,layout:g,routes:h.routes,steps:b,theme:a,id:d.id,gridStep:p.step??p.snap??1});for(let w of v.warnings){let k=s.locate(w.path);i.push({severity:"warning",message:w.message,line:k.line,col:k.col,path:w.path})}l.push({id:d.id,raw:d,layout:g,routes:h.routes,steps:b,rendered:v,grid:p,assemble:d.assemble??t.assemble??!1})}),i.sort((d,u)=>d.line-u.line||d.col-u.col),{ok:!i.some(d=>d.severity==="error"),diags:i,doc:t,theme:a,catalog:n,scenes:l,parsed:s,source:r}}function vm(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,d)=>{let u=`${l}/nodes/${d}`;(c.deco??In(n,c.asset).deco??[]).forEach((f,p)=>{typeof f=="object"&&f.icon&&!qo(f.icon)&&o(c.deco?`${u}/deco/${p}/icon`:u,`node "${c.id}": no icon "${f.icon}" is registered here, so it is drawn as a placeholder`)}),c.face!==void 0&&!ga(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,d)=>i(c,`${l}/regions/${d}`))};return i(t,e),r}function Cs(t,e){let n=t/(Kt*yt),s=2*e/yt;return[(n+s)/2,(s-n)/2]}function qr(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 za(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(Xe(n,s,r));return km(e)}function Ur(t){return[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]].map(([e,n])=>Xe(e,n,t.z0))}function km(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 ei=(t,e)=>e?.padding??Dt(t,e?.kind)?.pad??0;function ti(t,e,n,s,r){let o=d=>Math.round(d/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 d=Math.ceil(r.pad/n-1e-9)*n,u=Math.floor((r.w-r.pad-s[0])/n+1e-9)*n,f=Math.floor((r.d-r.pad-s[1])/n+1e-9)*n;i<d&&(i=d,l.left=!0),u>=d&&i>u&&(i=u,l.right=!0),a<d&&(a=d,l.top=!0),f>=d&&a>f&&(a=f,l.bottom=!0)}let c=d=>Math.round(d*1e3)/1e3;return{at:[c(i),c(a)],delta:[c(i-t[0]),c(a-t[1])],clamped:l}}function gr(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 Yc=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}),qc={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}},ef=(t,e)=>Nn(t,qc[e]);function Va(t){let e=[],n=new Map,s=(l,c)=>{if(typeof c!="string"||!c){e.push(`${l} has no id`);return}let d=n.get(c);d?e.push(`duplicate id "${c}": a ${d} 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(d=>Number.isInteger(d)&&d>=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 d=o[l].cells,u=o[c].cells;d[0]<=u[2]&&u[0]<=d[2]&&d[1]<=u[3]&&u[1]<=d[3]&&!Hc(d,u)&&!Hc(u,d)&&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 d=`link ${l.id?`"${l.id}"`:c}`;for(let u of["a","b"])i.has(l[u])||e.push(`${d}: ${u} "${l[u]}" is no card or panel`);for(let u of["aOn","bOn"])l[u]!==void 0&&!a.has(l[u])&&e.push(`${d}: ${u} "${l[u]}" is no panel`);l.id!==void 0&&s("link",l.id)}),e}var Hc=(t,e)=>t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3];function ni(t,e){let{W:n,H:s,GX:r,GY:o,PAD:i,TITLE:a,CH:l}=e,c=t.panels??[],d=V=>(V[2]-V[0]+1)*(V[3]-V[1]+1),u=(V,J)=>{let G=c[V].cells,ne=c[J].cells;return Hc(ne,G)?d(G)>d(ne)||V<J:!1},f=c.map((V,J)=>{let G=-1;return c.forEach((ne,oe)=>{oe!==J&&u(oe,J)&&(G<0||u(G,oe))&&(G=oe)}),G}),p=V=>f[V]<0?0:1+p(f[V]),g=(V,J)=>{let G=-1;c.forEach((oe,ve)=>{let ge=oe.cells;V>=ge[0]&&V<=ge[2]&&J>=ge[1]&&J<=ge[3]&&(G<0||u(G,ve))&&(G=ve)});let ne=[];for(let oe=G;oe>=0;oe=f[oe])ne.unshift(oe);return ne},h=Math.max(1,...t.cards.map(V=>V.cell[0]+1),...c.map(V=>V.cells[2]+1)),b=Math.max(1,...t.cards.map(V=>V.cell[1]+1),...c.map(V=>V.cells[3]+1)),v=[];for(let V=0;V<h;V++){v.push([]);for(let J=0;J<b;J++)v[V].push(g(V,J))}let w=(V,J,G)=>{let ne=V.filter(ve=>!J.includes(ve)),oe=J.filter(ve=>!V.includes(ve));return!ne.length&&!oe.length?0:ne.length*(i+(G?a:0))+oe.length*i+l},k=new Array(h+1).fill(0),y=new Array(b+1).fill(0);for(let V=0;V<b;V++)for(let J=1;J<h;J++){let G=w(v[J-1][V],v[J][V],!1);G&&(k[J]=Math.max(k[J],G-r))}for(let V=0;V<h;V++)for(let J=1;J<b;J++){let G=w(v[V][J-1],v[V][J],!0);G&&(y[J]=Math.max(y[J],G-o))}let M=V=>{let J=V*(n+r);for(let G=1;G<=V;G++)J+=k[G];return J},T=V=>{let J=V*(s+o);for(let G=1;G<=V;G++)J+=y[G];return J},A=(V,J,G,ne)=>G===J?V(J):V(J)+(ne-J)*(V(G)-V(J))/(G-J),I=c.map(()=>new Set),j=(V,J)=>{for(let G=V;G>=0;G=f[G])I[G].add(J)};c.forEach((V,J)=>{j(J,V.cells[1]),j(J,V.cells[3])});for(let V of t.cards){let J=v[V.cell[0]][V.cell[1]];J.length&&j(J[J.length-1],V.cell[1])}let L=c.map(()=>new Map),B=(V,J)=>V.slice(V.indexOf(J)+1);for(let V of c.map((J,G)=>G).sort((J,G)=>p(J)-p(G)||J-G)){let J=c[V].cells,G=[...I[V]].sort((oe,ve)=>oe-ve),ne=f[V]>=0?L[f[V]].get(G[0]):T(G[0]);L[V].set(G[0],ne);for(let oe=1;oe<G.length;oe++){let ve=0;for(let ge=J[0];ge<=J[2];ge++)ve=Math.max(ve,w(B(v[ge][G[oe-1]],V),B(v[ge][G[oe]],V),!0));ne+=s+Math.max(o,ve),L[V].set(G[oe],ne)}}let S=c.map(()=>new Set),E=(V,J)=>{for(let G=V;G>=0;G=f[G])S[G].add(J)};c.forEach((V,J)=>{E(J,V.cells[0]),E(J,V.cells[2])});for(let V of t.cards){let J=v[V.cell[0]][V.cell[1]];J.length&&E(J[J.length-1],V.cell[0])}let x=c.map(()=>new Map);for(let V of c.map((J,G)=>G).sort((J,G)=>p(J)-p(G)||J-G)){let J=c[V].cells,G=[...S[V]].sort((oe,ve)=>oe-ve);if(f[V]<0&&!f.includes(V)&&G.length===J[2]-J[0]+1){for(let oe of G)x[V].set(oe,A(M,J[0],J[2],oe));continue}let ne=f[V]>=0?x[f[V]].get(G[0]):M(G[0]);x[V].set(G[0],ne);for(let oe=1;oe<G.length;oe++){let ve=0;for(let ge=J[1];ge<=J[3];ge++)ve=Math.max(ve,w(B(v[G[oe-1]][ge],V),B(v[G[oe]][ge],V),!1));ne+=n+Math.max(r,ve),x[V].set(G[oe],ne)}}let N=(V,J)=>{let G=v[V][J],ne=G.length?G[G.length-1]:-1;return ne>=0?[x[ne].get(V),L[ne].get(J)]:[M(V),T(J)]},z=c.map((V,J)=>J).sort((V,J)=>p(J)-p(V)||V-J),Q=new Array(c.length);for(let V of z){let J=c[V].cells,G=[],ne=[];for(let ge of t.cards){let ye=v[ge.cell[0]][ge.cell[1]];ye[ye.length-1]===V&&(G.push(x[V].get(ge.cell[0])),ne.push(L[V].get(ge.cell[1])))}let oe=ge=>ge.cell[0]>=J[0]&&ge.cell[0]<=J[2]&&ge.cell[1]>=J[1]&&ge.cell[1]<=J[3];for(let ge of[J[1],J[3]])t.cards.some(ye=>ye.cell[1]===ge&&oe(ye))||ne.push(L[V].get(ge));for(let ge of[J[0],J[2]])t.cards.some(ye=>ye.cell[0]===ge&&oe(ye))||G.push(x[V].get(ge));let ve={l:G.length?Math.min(...G):1/0,t:ne.length?Math.min(...ne):1/0,r:G.length?Math.max(...G)+n:-1/0,b:ne.length?Math.max(...ne)+s:-1/0};c.forEach((ge,ye)=>{if(f[ye]!==V)return;let Ie=Q[ye];ve.l=Math.min(ve.l,Ie.l),ve.t=Math.min(ve.t,Ie.t),ve.r=Math.max(ve.r,Ie.r),ve.b=Math.max(ve.b,Ie.b)}),Q[V]={l:ve.l-i,t:ve.t-i,r:ve.r+i,b:ve.b+i+a}}let re=t.cards.map(V=>N(V.cell[0],V.cell[1])),we=t.cards.map(V=>{let J=v[V.cell[0]][V.cell[1]];return J.length?J[J.length-1]:-1}),F=(V,J)=>{for(let G=V;G>=0;G=f[G])if(G===J)return!0;return!1},X=(V,J)=>{t.cards.forEach((G,ne)=>{we[ne]>=0&&F(we[ne],V)&&(re[ne]=[re[ne][0]+J,re[ne][1]])}),c.forEach((G,ne)=>{F(ne,V)&&(Q[ne]={...Q[ne],l:Q[ne].l+J,r:Q[ne].r+J})})},Z=V=>{let J=[],G=[],ne=[],oe=[];t.cards.forEach((D,se)=>{we[se]===V&&(J.push(re[se][0]),ne.push(re[se][0]+n),G.push(re[se][1]),oe.push(re[se][1]+s))}),c.forEach((D,se)=>{f[se]===V&&(J.push(Q[se].l),ne.push(Q[se].r),G.push(Q[se].t),oe.push(Q[se].b))});let ve=Q[V],ge=Math.min(...J,ve.l+i),ye=Math.max(...ne,ve.r-i),Ie=Math.min(...G,ve.t+i),Ue=Math.max(...oe,ve.b-i-a);Q[V]={l:ge-i,t:Ie-i,r:ye+i,b:Ue+i+a}};for(let V of z)if(f[V]<0&&!f.includes(V))Z(V);else{let G=[];t.cards.forEach((ye,Ie)=>{we[Ie]===V&&G.push({l:re[Ie][0],r:re[Ie][0]+n,t:re[Ie][1],b:re[Ie][1]+s,card:Ie})}),c.forEach((ye,Ie)=>{f[Ie]===V&&G.push({...Q[Ie],panel:Ie})}),G.sort((ye,Ie)=>ye.l-Ie.l||ye.t-Ie.t);let ne=Math.min(...G.map(ye=>ye.l)),oe=[];for(let ye of G){let Ie=ne;for(let D of oe)D.t<ye.b&&ye.t<D.b&&D.r<=ye.l+1e-6&&(Ie=Math.max(Ie,D.r+(D.card!==void 0&&ye.card!==void 0?r:l)));let Ue=Ie-ye.l;Ue<-1e-6&&(ye.card!==void 0?re[ye.card]=[re[ye.card][0]+Ue,re[ye.card][1]]:X(ye.panel,Ue),ye.l+=Ue,ye.r+=Ue),oe.push(ye)}let ve=G.map(ye=>ye.l),ge=G.map(ye=>ye.r);Q[V]={...Q[V],l:Math.min(...ve)-i,r:Math.max(...ge)+i}}return{prect:Q,parentIx:f,depthOf:p,pos:N,cardAt:V=>re[V]}}function Js(t,e,n={}){if(n.wrap){let{wrap:m,...C}=n;return Js(Sm(t,e,m.aspect,C),e,C)}let s=Va(t);if(s.length)throw new Error(`the board has ${s.length} error${s.length>1?"s":""}:
|
|
277
277
|
${s.join(`
|
|
278
|
-
`)}`);let r={...bc,...n},{W:o,H:i}=r,a=m=>Math.round(m*10)/10,l=[],c=t.panels??[],{prect:d,parentIx:u,depthOf:f,cardAt:p}=jo(t,r),g=c.map((m,O)=>{let L=d[O],G=e(m.label??"","title")+(m.sub?e(m.sub,"titleSub"):0);return{...m,rect:L,titleAt:[a(L.l+16),a(L.b-15)],depth:f(O),parent:u[O]>=0?c[u[O]].id:void 0,title:{l:L.l+10,r:L.l+22+G,t:L.b-30,b:L.b-6}}}),h=t.cards.map(m=>{let[O,L]=p(t.cards.indexOf(m));return{...m,rect:{l:O,t:L,r:O+o,b:L+i}}}),b=new Map;g.forEach(m=>b.set(m.id,m.rect)),h.forEach(m=>b.set(m.id,m.rect));let k=h.map(m=>m.rect),v=g.map(m=>m.rect),M=g.filter(m=>m.label).map(m=>m.title),x=(m,O)=>m.l>=O.l&&m.r<=O.r&&m.t>=O.t&&m.b<=O.b,T=(m,O,L,G)=>Math.min(m[0],O[0])<L.r+G&&Math.max(m[0],O[0])>L.l-G&&Math.min(m[1],O[1])<L.b+G&&Math.max(m[1],O[1])>L.t-G,y=(m,O)=>v.reduce((L,G)=>{if(m[0]===O[0]){let Z=Math.min(m[1],O[1]),Se=Math.max(m[1],O[1]);m[0]>G.l&&m[0]<G.r&&(L+=[G.t,G.b].filter(ue=>ue>Z+1&&ue<Se-1).length)}else{let Z=Math.min(m[0],O[0]),Se=Math.max(m[0],O[0]);m[1]>G.t&&m[1]<G.b&&(L+=[G.l,G.r].filter(ue=>ue>Z+1&&ue<Se-1).length)}return L},0),A=(m,O)=>v.some(L=>m[1]===O[1]?[L.t,L.b].some(G=>Math.abs(m[1]-G)<16&&Math.max(m[0],O[0])>L.l&&Math.min(m[0],O[0])<L.r):[L.l,L.r].some(G=>Math.abs(m[0]-G)<16&&Math.max(m[1],O[1])>L.t&&Math.min(m[1],O[1])<L.b)),D=(m,O,L,G)=>v.filter(Z=>Z!==L&&Z!==G&&!x(L,Z)&&!x(G,Z)&&T(m,O,{l:Z.l+3,r:Z.r-3,t:Z.t+3,b:Z.b-3},0)).length,K=[],C=new Map,_=new Map,S=(m,O)=>{K.push([m,O]);let[L,G]=m[1]===O[1]?[C,m[1]]:m[0]===O[0]?[_,m[0]]:[void 0,0];if(!L)return;let Z=Math.floor(G/6);(L.get(Z)??L.set(Z,[]).get(Z)).push([m,O])},$=(m,O)=>{let L=m[1]===O[1];if(!L&&m[0]!==O[0])return 0;let G=L?1:0,Z=L?0:1,Se=L?C:_,ue=Math.floor(m[G]/6),Ke=Math.min(m[Z],O[Z]),Ye=Math.max(m[Z],O[Z]),Ie=0;for(let De=ue-1;De<=ue+1;De++)for(let[Ce,vt]of Se.get(De)??[])Math.abs(m[G]-Ce[G])<6&&Math.min(Ye,Math.max(Ce[Z],vt[Z]))-Math.max(Ke,Math.min(Ce[Z],vt[Z]))>0&&Ie++;return Ie},w=[...b.values()],N=Math.min(...w.map(m=>m.l)),F=Math.max(...w.map(m=>m.r)),J=Math.min(...w.map(m=>m.t)),ae=Math.max(...w.map(m=>m.b)),we=(m,O)=>{let L=(m+O)/2;return[L,L-12,L+12,L-24,L+24]},j=(()=>{let m=[];return k.forEach(O=>k.forEach(L=>{L.t>O.b&&L.l<O.r+400&&L.r>O.l-400&&m.push(...we(O.b,L.t))})),m.push(J-22,J-34,ae+22,ae+34),[...new Set(m.map(Math.round))]})(),U=(()=>{let m=[];return k.forEach(O=>k.forEach(L=>{L.l>O.r&&m.push(...we(O.r,L.l))})),m.push(N-22,N-34,F+22,F+34),[...new Set(m.map(Math.round))]})(),ee=new Map,fe=new Map,B=m=>{let O=ee.get(m);return O||ee.set(m,O=k.filter(L=>m<L.b+6&&m>L.t-6)),O},X=m=>{let O=fe.get(m);return O||fe.set(m,O=k.filter(L=>m<L.r+6&&m>L.l-6)),O},Q=r.crossPanel/r.overlap,te=r.border/r.overlap,ne=r.nearEdge/r.overlap;function me(m,O,L,G,Z=!0){let Se=0;for(let Ie=1;Ie<m.length;Ie++)Se+=Math.abs(m[Ie-1][0]-m[Ie][0])+Math.abs(m[Ie-1][1]-m[Ie][1]);let ue=Se+r.bend*(m.length-2);if(ue>=G)return ue;let Ke=0,Ye=0;for(let Ie=1;Ie<m.length;Ie++){let De=m[Ie-1],Ce=m[Ie];if(Z){if(Pe(De,Ce,O,L)||A(De,Ce))return 1/0;continue}for(let vt of De[1]===Ce[1]?B(De[1]):X(De[0]))vt!==O&&vt!==L&&T(De,Ce,vt,6)&&Ke++;for(let vt of M)T(De,Ce,vt,2)&&Ke++}for(let Ie=1;Ie<m.length;Ie++){let De=m[Ie-1],Ce=m[Ie];if(Ye+=$(De,Ce)+Q*D(De,Ce,O,L)+te*y(De,Ce),A(De,Ce)&&(Ye+=ne),ue+r.overlap*Ye>=G)return ue+r.overlap*Ye}return ue+r.overlap*Ye+Ke*1e5}let ye=m=>(m.l+m.r)/2,xe=m=>(m.t+m.b)/2,Re=[0,-22,22,-44,44],Ue={bc:1/0},I=(m,O,L,G)=>Math.abs(m-L)+Math.abs(O-G),re=(m,O,L,G,Z,Se,ue,Ke)=>{let Ye=0;return Ye+=I(m,O,L,G),Ye+=I(L,G,Z,Se),Ye+=I(Z,Se,ue,Ke),Ye+r.bend*2},$e=(m,O,L,G,Z,Se,ue,Ke,Ye,Ie)=>{let De=0;return De+=I(m,O,L,G),De+=I(L,G,Z,Se),De+=I(Z,Se,ue,Ke),De+=I(ue,Ke,Ye,Ie),De+r.bend*3},Pe=(m,O,L,G)=>{for(let Z of m[1]===O[1]?B(m[1]):X(m[0]))if(Z!==L&&Z!==G&&T(m,O,Z,6))return!0;for(let Z of M)if(T(m,O,Z,2))return!0;return A(m,O)};function be(m,O,L,G){let Z=Math.max(m.l,O.l),Se=Math.min(m.r,O.r);if(Se-Z>24)for(let St of Re){let Et=(Z+Se)/2+St;Et>Z+8&&Et<Se-8&&L(O.t>=m.b?[[Et,m.b],[Et,O.t]]:[[Et,m.t],[Et,O.b]])}let ue=Math.max(m.t,O.t),Ke=Math.min(m.b,O.b);if(Ke-ue>16)for(let St of[0,-10,10]){let Et=(ue+Ke)/2+St;L(O.l>=m.r?[[m.r,Et],[O.l,Et]]:[[m.l,Et],[O.r,Et]])}let Ye=U.length,Ie=j.length,De=new Uint8Array(Re.length*Ie),Ce=new Uint8Array(Re.length*Ie),vt=new Uint8Array(Re.length*Ye),Mn=new Uint8Array(Re.length*Ye),kt=(St,Et,bn,Yt)=>G?(St[Et]||(St[Et]=Pe(bn,Yt,m,O)?2:1),St[Et]===1):!0;Re.forEach((St,Et)=>Re.forEach((bn,Yt)=>{let Pt=ye(m)+St,Ot=ye(O)+bn,_t=xe(m)+St/3,pt=xe(O)+bn/3;j.forEach((rt,fn)=>{let Mt=rt>m.b?m.b:rt<m.t?m.t:null,Jt=rt>O.b?O.b:rt<O.t?O.t:null;Mt!==null&&Jt!==null&&re(Pt,Mt,Pt,rt,Ot,rt,Ot,Jt)<Ue.bc&&kt(De,Et*Ie+fn,[Pt,Mt],[Pt,rt])&&kt(Ce,Yt*Ie+fn,[Ot,rt],[Ot,Jt])&&L([[Pt,Mt],[Pt,rt],[Ot,rt],[Ot,Jt]])}),U.forEach((rt,fn)=>{let Mt=rt>m.r?m.r:rt<m.l?m.l:null,Jt=rt>O.r?O.r:rt<O.l?O.l:null;Mt!==null&&Jt!==null&&re(Mt,_t,rt,_t,rt,pt,Jt,pt)<Ue.bc&&kt(vt,Et*Ye+fn,[Mt,_t],[rt,_t])&&kt(Mn,Yt*Ye+fn,[rt,pt],[Jt,pt])&&L([[Mt,_t],[rt,_t],[rt,pt],[Jt,pt]])}),St===0&&bn===0&&U.forEach((rt,fn)=>j.forEach((Mt,Jt)=>{let H=rt>m.r?m.r:rt<m.l?m.l:null,he=Mt>O.b?O.b:Mt<O.t?O.t:null;H!==null&&he!==null&&$e(H,_t,rt,_t,rt,Mt,Ot,Mt,Ot,he)<Ue.bc&&kt(vt,Et*Ye+fn,[H,_t],[rt,_t])&&kt(Ce,Yt*Ie+Jt,[Ot,Mt],[Ot,he])&&L([[H,_t],[rt,_t],[rt,Mt],[Ot,Mt],[Ot,he]]);let ke=Mt>m.b?m.b:Mt<m.t?m.t:null,Ae=rt>O.r?O.r:rt<O.l?O.l:null;ke!==null&&Ae!==null&&$e(Pt,ke,Pt,Mt,rt,Mt,rt,pt,Ae,pt)<Ue.bc&&kt(De,Et*Ie+Jt,[Pt,ke],[Pt,Mt])&&kt(Mn,Yt*Ye+fn,[rt,pt],[Ae,pt])&&L([[Pt,ke],[Pt,Mt],[rt,Mt],[rt,pt],[Ae,pt]])}));let as=ye(m)<O.l?O.l:ye(m)>O.r?O.r:null,Ht=pt<m.t?m.t:pt>m.b?m.b:null;as!==null&&Ht!==null&&L([[Pt,Ht],[Pt,pt],[as,pt]]);let Yn=xe(m)<O.t?O.t:xe(m)>O.b?O.b:null,ls=Ot<m.l?m.l:Ot>m.r?m.r:null;Yn!==null&&ls!==null&&L([[ls,_t],[Ot,_t],[Ot,Yn]])}))}function ce(m,O,L,G){for(let Z of Re){let Se=ye(m)+Z,ue=xe(m)+Z/3,Ke=[[[Se,m.t],[Se,O.t]],[[m.r,ue],[O.r,ue]],[[Se,m.b],[Se,O.b]],[[m.l,ue],[O.l,ue]]];for(let Ye of Ke)G(L?[Ye[1],Ye[0]]:Ye)}}let ze=(m,O,L,G)=>{let Z=null;return Ue.bc=1/0,m(Se=>{let ue=me(Se,O,L,Ue.bc,G);ue<Ue.bc&&(Ue.bc=ue,Z=Se)},G),Z},Oe=[],Ee=m=>v.some(O=>[O.l,O.r].some(L=>m.l<L+3&&m.r>L-3&&m.b>O.t&&m.t<O.b)||[O.t,O.b].some(L=>m.t<L+3&&m.b>L-3&&m.r>O.l&&m.l<O.r)),Be=m=>K.filter(([O,L])=>T(O,L,m,1)).length,it=m=>M.some(O=>m.l<O.r&&m.r>O.l&&m.t<O.b&&m.b>O.t),We=m=>k.filter(O=>m.l<O.r+3&&m.r>O.l-3&&m.t<O.b+3&&m.b>O.t-3).length,Ne=m=>Oe.filter(O=>m.l<O.r+4&&m.r>O.l-4&&m.t<O.b+2&&m.b>O.t-2).length,gt=m=>50*at(m)+3*Be(m)+(Ee(m)?1:0)+(it(m)?5:0)+5*We(m)+5*Ne(m),Ze=m=>Be(m)>0||Ee(m)||it(m)||We(m)>0||Ne(m)>0,ft=[];(t.links??[]).forEach((m,O)=>{let L=m.id??`link-${O}`,G=b.get(m.aOn??m.a),Z=b.get(m.bOn??m.b);if(G===Z){l.push(`link "${L}" joins "${m.aOn??m.a}" to itself: not drawn`),ft.push({...m,id:L,points:[],routed:!1});return}let Se=x(G,Z)?Ye=>ce(G,Z,!1,Ye):x(Z,G)?Ye=>ce(Z,G,!0,Ye):(Ye,Ie)=>be(G,Z,Ye,Ie),ue=ze(Se,G,Z,!0),Ke=!0;if(ue||(ue=ze(Se,G,Z,!1),Ke=!1,l.push(`link "${L}": no clear route; drawn the least bad way`)),!ue){ft.push({...m,id:L,points:[],routed:!1});return}for(let Ye=1;Ye<ue.length;Ye++)S(ue[Ye-1],ue[Ye]);ft.push({...m,id:L,points:ue,routed:Ke})});let ot=[];for(let m=0;m<K.length;m++)for(let O=m+1;O<K.length;O++){let[L,G]=K[m],[Z,Se]=K[O],ue=L[1]===G[1],Ke=Z[1]===Se[1];if(ue===Ke)continue;let[Ye,Ie]=ue?[[L,G],[Z,Se]]:[[Z,Se],[L,G]],De=Ie[0][0],Ce=Ye[0][1];De>Math.min(Ye[0][0],Ye[1][0])&&De<Math.max(Ye[0][0],Ye[1][0])&&Ce>Math.min(Ie[0][1],Ie[1][1])&&Ce<Math.max(Ie[0][1],Ie[1][1])&&ot.push([De,Ce])}let at=m=>ot.filter(([O,L])=>O>m.l-2&&O<m.r+2&&L>m.t-2&&L<m.b+2).length;for(let m of ft){let O=m,L=m.points;if(!O.label||!L.length)continue;let G=[];for(let Ie=1;Ie<L.length;Ie++)G.push([L[Ie-1],L[Ie]]);let Z=Ie=>Math.abs(Ie[0][0]-Ie[1][0])+Math.abs(Ie[0][1]-Ie[1][1]);G.sort((Ie,De)=>Z(De)-Z(Ie));let Se=e(O.label,"label")+6,ue=null,Ke=null,Ye=1/0;for(let[Ie,De]of G){let Ce=(Ie[0]+De[0])/2,vt=(Ie[1]+De[1])/2,Mn=Ie[1]===De[1]?[0,-.3,.3,-.15,.15].flatMap(kt=>{let St=Ce+kt*Math.abs(Ie[0]-De[0]);return[[St,vt-6,"middle"],[St,vt+15,"middle"]]}):[0,-.3,.3].flatMap(kt=>{let St=vt+4+kt*Math.abs(Ie[1]-De[1]);return[[Ce+7,St,"start"],[Ce-7,St,"end"],[Ce+24,St,"start"],[Ce-24,St,"end"]]});for(let[kt,St,Et]of Mn){let bn=Et==="middle"?kt-Se/2:Et==="end"?kt-Se:kt,Yt={l:bn,r:bn+Se,t:St-11,b:St+3};if(!Ze(Yt)){ue=[kt,St,Et,Yt];break}let Pt=gt(Yt);Pt<Ye&&(Ye=Pt,Ke=[kt,St,Et,Yt])}if(ue)break}if(!ue&&Ke&&(ue=Ke),!ue){let[Ie,De]=G[0],Ce=(Ie[0]+De[0])/2,vt=(Ie[1]+De[1])/2-6;ue=[Ce,vt,"middle",{l:Ce-Se/2,r:Ce+Se/2,t:vt-11,b:vt+3}]}Oe.push(ue[3]),m.at={x:a(ue[0]),y:a(ue[1]),anchor:ue[2],box:ue[3],text:O.label}}let E=[],Y=[];for(let m of[...w,...Oe,...g.map(O=>O.title)])E.push(m.l,m.r),Y.push(m.t,m.b);for(let m of ft)for(let O of m.points)E.push(O[0]),Y.push(O[1]);let q=r.margin,de={l:Math.min(...E)-q,t:Math.min(...Y)-q,r:Math.max(...E)+q,b:Math.max(...Y)+q};return{cards:h,panels:g,links:ft,bounds:de,options:r,warnings:l}}function wu(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 Kp(t,e,n,s={}){let r=a=>{let l=Fs(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 d of _p(o)){if(wa(d).length)continue;let u=r(d);u<c-.5&&(c=u,l=d)}if(!l)break;o=l,i=c}return o}function*_p(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,d)=>{d===a||!n(i,c.cells)||a>=0&&d>a&&s(c.cells,e[a].cells)||(l<0||n(c.cells,e[l].cells)&&(!s(c.cells,e[l].cells)||d>l))&&(l=d)}),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 d=[l.cell[0],l.cell[1],l.cell[0],l.cell[1]];r(d)===i&&a.push({range:d,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((f,p)=>f.range[1]-p.range[1]||f.range[0]-p.range[0])){let f=c.find(p=>p.some(g=>l(g)[0]<=l(u)[1]&&l(u)[0]<=l(g)[1]));f?f.push(u):c.push([u])}let d=Math.max(...a.map(u=>u.range[3]));for(let u of c){u.sort((f,p)=>f.range[0]-p.range[0]);for(let f=1;f<u.length;f++){let p=u.slice(f),g=u[0].range[0],h=d+1,b=Math.min(...p.map(y=>y.range[1])),k=Math.max(...p.map(y=>y.range[3]))-b+1,v=t.cards.map(y=>({...y,cell:[...y.cell]})),M=e.map(y=>({...y,cells:[...y.cells]}));for(let y of v)y.cell[1]>d&&(y.cell[1]+=k);let x=new Set;for(let y=i;y>=0&&!x.has(y);y=r(e[y].cells,y))x.add(y);M.forEach((y,A)=>{y.cells[1]>d?(y.cells[1]+=k,y.cells[3]+=k):(x.has(A)||y.cells[1]<=d&&y.cells[3]>d)&&(y.cells[3]+=k)});let T=g;for(let y of p){let A=T-y.range[0],D=h+(y.range[1]-b)-y.range[1],K=C=>C[0]>=y.range[0]&&C[0]<=y.range[2]&&C[1]>=y.range[1]&&C[1]<=y.range[3];t.cards.forEach((C,_)=>{K([C.cell[0],C.cell[1]])&&(v[_].cell=[C.cell[0]+A,C.cell[1]+D])}),e.forEach((C,_)=>{n(C.cells,y.range)&&(M[_].cells=[C.cells[0]+A,C.cells[1]+D,C.cells[2]+A,C.cells[3]+D])}),T+=y.range[2]-y.range[0]+1}e.forEach((y,A)=>{let D=t.cards.map((K,C)=>n([K.cell[0],K.cell[1],K.cell[0],K.cell[1]],y.cells)?v[C].cell:void 0).filter(K=>!!K);D.length&&(M[A].cells=[Math.min(...D.map(K=>K[0])),Math.min(...D.map(K=>K[1])),Math.max(...D.map(K=>K[0])),Math.max(...D.map(K=>K[1]))])}),yield{cards:v,panels:M,links:t.links}}}}}function or(t,e=()=>!0){let n=t.layout.items.filter(y=>e(y.id)),s=t.layout.catalog,r=y=>y.type==="node"&&!y.children.some(A=>A.type==="node"&&e(A.id)),o=n.filter(r),i=y=>{let A=[];for(let D=y;D;D=D.parent)A.unshift(D);return A},a=new Map(o.map(y=>[y.id,i(y)])),l=(y,A)=>{let D=a.get(y.id),K=a.get(A.id),C=0;for(;C<D.length&&C<K.length&&D[C]===K[C];)C++;return[D[C].box,K[C].box]},c=1e-6,d=(y,A)=>{let[D,K]=l(y,A);return D.y1<=K.y0+c&&D.x0<K.x1-c&&K.x0<D.x1-c},u=(y,A)=>{let[D,K]=l(y,A);return D.x1<=K.x0+c&&D.y0<K.y1-c&&K.y0<D.y1-c},f=(y,A)=>{let D=new Map,K=[];for(let C of[...o].sort((_,S)=>A(_)-A(S))){let _=0;for(let S of K)D.get(S.id)+1>_&&y(S,C)&&(_=D.get(S.id)+1);D.set(C.id,_),K.push(C)}return D},p=f(d,y=>y.box.y0),g=f(u,y=>y.box.x0),h=Math.min(...o.map(y=>y.box.x1-y.box.x0))/2;for(let y of o)if(!y.parent)for(let A of o)A.parent&&A.box.x0<=y.box.x0+h&&g.set(y.id,Math.max(g.get(y.id),g.get(A.id)));let b=new Map;for(let y of o)b.set(y.id,[g.get(y.id),p.get(y.id)]);let k=new Map;for(let y of o){let A=b.get(y.id),D=k.get(String(A));if(D!==void 0&&D!==y.id){for(let[,K]of b)K[0]>A[0]&&K!==A&&K[0]++;A[0]++,k.clear();for(let K of o)k.set(String(b.get(K.id)),K.id)}else k.set(String(A),y.id)}let v=o.map(y=>{let A=y.node,D=Tn(s,A.asset);return{id:y.id,label:A.label??y.id,sub:A.sub,role:A.role??D.role,ghost:A.ghost||void 0,cell:b.get(y.id)}}),M=[];for(let y of n){if(r(y))continue;let A=[],D=$=>{for(let w of $.children){let N=b.get(w.id);N&&A.push(N),D(w)}};if(D(y),!A.length)continue;let K=A.map($=>$[0]),C=A.map($=>$[1]),_=y.type==="region"?y.region.label:y.node.label??y.id,S=y.type==="region"?y.region.role??Ft(s,y.region.kind)?.role:y.node.role??Tn(s,y.node.asset).role;M.push({id:y.id,label:_,sub:y.type==="node"?y.node.sub:void 0,role:S,cells:[Math.min(...K),Math.min(...C),Math.max(...K),Math.max(...C)]})}let x=new Set([...v.map(y=>y.id),...M.map(y=>y.id)]),T=[];for(let y of t.routes){if(!e(y.id))continue;let A=wn(y.raw.from).id,D=wn(y.raw.to).id;if(!x.has(A)||!x.has(D))continue;let K=typeof y.raw.label=="string"?y.raw.label:y.raw.label?.text;T.push({id:y.id,a:A,b:D,kind:y.kind,label:K})}return{cards:v,panels:M,links:T}}var js={W:4,D:2,H:.9,GX:2,GY:2.4,PAD:.6,CH:2.2,PANEL_H:.3},vu=`
|
|
278
|
+
`)}`);let r={...Yc,...n},{W:o,H:i}=r,a=m=>Math.round(m*10)/10,l=[],c=t.panels??[],{prect:d,parentIx:u,depthOf:f,cardAt:p}=ni(t,r),g=c.map((m,C)=>{let R=d[C],H=e(m.label??"","title")+(m.sub?e(m.sub,"titleSub"):0);return{...m,rect:R,titleAt:[a(R.l+16),a(R.b-15)],depth:f(C),parent:u[C]>=0?c[u[C]].id:void 0,title:{l:R.l+10,r:R.l+22+H,t:R.b-30,b:R.b-6}}}),h=t.cards.map(m=>{let[C,R]=p(t.cards.indexOf(m));return{...m,rect:{l:C,t:R,r:C+o,b:R+i}}}),b=new Map;g.forEach(m=>b.set(m.id,m.rect)),h.forEach(m=>b.set(m.id,m.rect));let v=h.map(m=>m.rect),w=g.map(m=>m.rect),k=g.filter(m=>m.label).map(m=>m.title),y=(m,C)=>m.l>=C.l&&m.r<=C.r&&m.t>=C.t&&m.b<=C.b,M=(m,C,R,H)=>Math.min(m[0],C[0])<R.r+H&&Math.max(m[0],C[0])>R.l-H&&Math.min(m[1],C[1])<R.b+H&&Math.max(m[1],C[1])>R.t-H,T=(m,C)=>w.reduce((R,H)=>{if(m[0]===C[0]){let ee=Math.min(m[1],C[1]),$e=Math.max(m[1],C[1]);m[0]>H.l&&m[0]<H.r&&(R+=[H.t,H.b].filter(de=>de>ee+1&&de<$e-1).length)}else{let ee=Math.min(m[0],C[0]),$e=Math.max(m[0],C[0]);m[1]>H.t&&m[1]<H.b&&(R+=[H.l,H.r].filter(de=>de>ee+1&&de<$e-1).length)}return R},0),A=(m,C)=>w.some(R=>m[1]===C[1]?[R.t,R.b].some(H=>Math.abs(m[1]-H)<16&&Math.max(m[0],C[0])>R.l&&Math.min(m[0],C[0])<R.r):[R.l,R.r].some(H=>Math.abs(m[0]-H)<16&&Math.max(m[1],C[1])>R.t&&Math.min(m[1],C[1])<R.b)),I=(m,C,R,H)=>w.filter(ee=>ee!==R&&ee!==H&&!y(R,ee)&&!y(H,ee)&&M(m,C,{l:ee.l+3,r:ee.r-3,t:ee.t+3,b:ee.b-3},0)).length,j=[],L=new Map,B=new Map,S=(m,C)=>{j.push([m,C]);let[R,H]=m[1]===C[1]?[L,m[1]]:m[0]===C[0]?[B,m[0]]:[void 0,0];if(!R)return;let ee=Math.floor(H/6);(R.get(ee)??R.set(ee,[]).get(ee)).push([m,C])},E=(m,C)=>{let R=m[1]===C[1];if(!R&&m[0]!==C[0])return 0;let H=R?1:0,ee=R?0:1,$e=R?L:B,de=Math.floor(m[H]/6),De=Math.min(m[ee],C[ee]),He=Math.max(m[ee],C[ee]),Ne=0;for(let Ye=de-1;Ye<=de+1;Ye++)for(let[ot,Mt]of $e.get(Ye)??[])Math.abs(m[H]-ot[H])<6&&Math.min(He,Math.max(ot[ee],Mt[ee]))-Math.max(De,Math.min(ot[ee],Mt[ee]))>0&&Ne++;return Ne},x=[...b.values()],N=Math.min(...x.map(m=>m.l)),z=Math.max(...x.map(m=>m.r)),Q=Math.min(...x.map(m=>m.t)),re=Math.max(...x.map(m=>m.b)),we=(m,C)=>{let R=(m+C)/2;return[R,R-12,R+12,R-24,R+24]},F=(()=>{let m=[];return v.forEach(C=>v.forEach(R=>{R.t>C.b&&R.l<C.r+400&&R.r>C.l-400&&m.push(...we(C.b,R.t))})),m.push(Q-22,Q-34,re+22,re+34),[...new Set(m.map(Math.round))]})(),X=(()=>{let m=[];return v.forEach(C=>v.forEach(R=>{R.l>C.r&&m.push(...we(C.r,R.l))})),m.push(N-22,N-34,z+22,z+34),[...new Set(m.map(Math.round))]})(),Z=new Map,be=new Map,V=m=>{let C=Z.get(m);return C||Z.set(m,C=v.filter(R=>m<R.b+6&&m>R.t-6)),C},J=m=>{let C=be.get(m);return C||be.set(m,C=v.filter(R=>m<R.r+6&&m>R.l-6)),C},G=r.crossPanel/r.overlap,ne=r.border/r.overlap,oe=r.nearEdge/r.overlap;function ve(m,C,R,H,ee=!0){let $e=0;for(let Ne=1;Ne<m.length;Ne++)$e+=Math.abs(m[Ne-1][0]-m[Ne][0])+Math.abs(m[Ne-1][1]-m[Ne][1]);let de=$e+r.bend*(m.length-2);if(de>=H)return de;let De=0,He=0;for(let Ne=1;Ne<m.length;Ne++){let Ye=m[Ne-1],ot=m[Ne];if(ee){if(Ce(Ye,ot,C,R)||A(Ye,ot))return 1/0;continue}for(let Mt of Ye[1]===ot[1]?V(Ye[1]):J(Ye[0]))Mt!==C&&Mt!==R&&M(Ye,ot,Mt,6)&&De++;for(let Mt of k)M(Ye,ot,Mt,2)&&De++}for(let Ne=1;Ne<m.length;Ne++){let Ye=m[Ne-1],ot=m[Ne];if(He+=E(Ye,ot)+G*I(Ye,ot,C,R)+ne*T(Ye,ot),A(Ye,ot)&&(He+=oe),de+r.overlap*He>=H)return de+r.overlap*He}return de+r.overlap*He+De*1e5}let ge=m=>(m.l+m.r)/2,ye=m=>(m.t+m.b)/2,Ie=[0,-22,22,-44,44],Ue={bc:1/0},D=(m,C,R,H)=>Math.abs(m-R)+Math.abs(C-H),se=(m,C,R,H,ee,$e,de,De)=>{let He=0;return He+=D(m,C,R,H),He+=D(R,H,ee,$e),He+=D(ee,$e,de,De),He+r.bend*2},Me=(m,C,R,H,ee,$e,de,De,He,Ne)=>{let Ye=0;return Ye+=D(m,C,R,H),Ye+=D(R,H,ee,$e),Ye+=D(ee,$e,de,De),Ye+=D(de,De,He,Ne),Ye+r.bend*3},Ce=(m,C,R,H)=>{for(let ee of m[1]===C[1]?V(m[1]):J(m[0]))if(ee!==R&&ee!==H&&M(m,C,ee,6))return!0;for(let ee of k)if(M(m,C,ee,2))return!0;return A(m,C)};function he(m,C,R,H){let ee=Math.max(m.l,C.l),$e=Math.min(m.r,C.r);if($e-ee>24)for(let xt of Ie){let wt=(ee+$e)/2+xt;wt>ee+8&&wt<$e-8&&R(C.t>=m.b?[[wt,m.b],[wt,C.t]]:[[wt,m.t],[wt,C.b]])}let de=Math.max(m.t,C.t),De=Math.min(m.b,C.b);if(De-de>16)for(let xt of[0,-10,10]){let wt=(de+De)/2+xt;R(C.l>=m.r?[[m.r,wt],[C.l,wt]]:[[m.l,wt],[C.r,wt]])}let He=X.length,Ne=F.length,Ye=new Uint8Array(Ie.length*Ne),ot=new Uint8Array(Ie.length*Ne),Mt=new Uint8Array(Ie.length*He),$n=new Uint8Array(Ie.length*He),Ct=(xt,wt,Tt,ze)=>H?(xt[wt]||(xt[wt]=Ce(Tt,ze,m,C)?2:1),xt[wt]===1):!0;Ie.forEach((xt,wt)=>Ie.forEach((Tt,ze)=>{let Ft=ge(m)+xt,Wt=ge(C)+Tt,jt=ye(m)+xt/3,Ot=ye(C)+Tt/3;F.forEach((tt,on)=>{let dt=tt>m.b?m.b:tt<m.t?m.t:null,nn=tt>C.b?C.b:tt<C.t?C.t:null;dt!==null&&nn!==null&&se(Ft,dt,Ft,tt,Wt,tt,Wt,nn)<Ue.bc&&Ct(Ye,wt*Ne+on,[Ft,dt],[Ft,tt])&&Ct(ot,ze*Ne+on,[Wt,tt],[Wt,nn])&&R([[Ft,dt],[Ft,tt],[Wt,tt],[Wt,nn]])}),X.forEach((tt,on)=>{let dt=tt>m.r?m.r:tt<m.l?m.l:null,nn=tt>C.r?C.r:tt<C.l?C.l:null;dt!==null&&nn!==null&&se(dt,jt,tt,jt,tt,Ot,nn,Ot)<Ue.bc&&Ct(Mt,wt*He+on,[dt,jt],[tt,jt])&&Ct($n,ze*He+on,[tt,Ot],[nn,Ot])&&R([[dt,jt],[tt,jt],[tt,Ot],[nn,Ot]])}),xt===0&&Tt===0&&X.forEach((tt,on)=>F.forEach((dt,nn)=>{let Y=tt>m.r?m.r:tt<m.l?m.l:null,pe=dt>C.b?C.b:dt<C.t?C.t:null;Y!==null&&pe!==null&&Me(Y,jt,tt,jt,tt,dt,Wt,dt,Wt,pe)<Ue.bc&&Ct(Mt,wt*He+on,[Y,jt],[tt,jt])&&Ct(ot,ze*Ne+nn,[Wt,dt],[Wt,pe])&&R([[Y,jt],[tt,jt],[tt,dt],[Wt,dt],[Wt,pe]]);let ke=dt>m.b?m.b:dt<m.t?m.t:null,Ae=tt>C.r?C.r:tt<C.l?C.l:null;ke!==null&&Ae!==null&&Me(Ft,ke,Ft,dt,tt,dt,tt,Ot,Ae,Ot)<Ue.bc&&Ct(Ye,wt*Ne+nn,[Ft,ke],[Ft,dt])&&Ct($n,ze*He+on,[tt,Ot],[Ae,Ot])&&R([[Ft,ke],[Ft,dt],[tt,dt],[tt,Ot],[Ae,Ot]])}));let Ks=ge(m)<C.l?C.l:ge(m)>C.r?C.r:null,Zt=Ot<m.t?m.t:Ot>m.b?m.b:null;Ks!==null&&Zt!==null&&R([[Ft,Zt],[Ft,Ot],[Ks,Ot]]);let ys=ye(m)<C.t?C.t:ye(m)>C.b?C.b:null,Ln=Wt<m.l?m.l:Wt>m.r?m.r:null;ys!==null&&Ln!==null&&R([[Ln,jt],[Wt,jt],[Wt,ys]])}))}function ie(m,C,R,H){for(let ee of Ie){let $e=ge(m)+ee,de=ye(m)+ee/3,De=[[[$e,m.t],[$e,C.t]],[[m.r,de],[C.r,de]],[[$e,m.b],[$e,C.b]],[[m.l,de],[C.l,de]]];for(let He of De)H(R?[He[1],He[0]]:He)}}let Ke=(m,C,R,H)=>{let ee=null;return Ue.bc=1/0,m($e=>{let de=ve($e,C,R,Ue.bc,H);de<Ue.bc&&(Ue.bc=de,ee=$e)},H),ee},Oe=[],Te=m=>w.some(C=>[C.l,C.r].some(R=>m.l<R+3&&m.r>R-3&&m.b>C.t&&m.t<C.b)||[C.t,C.b].some(R=>m.t<R+3&&m.b>R-3&&m.r>C.l&&m.l<C.r)),je=m=>j.filter(([C,R])=>M(C,R,m,1)).length,lt=m=>k.some(C=>m.l<C.r&&m.r>C.l&&m.t<C.b&&m.b>C.t),We=m=>v.filter(C=>m.l<C.r+3&&m.r>C.l-3&&m.t<C.b+3&&m.b>C.t-3).length,ft=m=>Oe.filter(C=>m.l<C.r+4&&m.r>C.l-4&&m.t<C.b+2&&m.b>C.t-2).length,ut=m=>50*rt(m)+3*je(m)+(Te(m)?1:0)+(lt(m)?5:0)+5*We(m)+5*ft(m),it=m=>je(m)>0||Te(m)||lt(m)||We(m)>0||ft(m)>0,Pe=[];(t.links??[]).forEach((m,C)=>{let R=m.id??`link-${C}`,H=b.get(m.aOn??m.a),ee=b.get(m.bOn??m.b);if(H===ee){l.push(`link "${R}" joins "${m.aOn??m.a}" to itself: not drawn`),Pe.push({...m,id:R,points:[],routed:!1});return}let $e=y(H,ee)?He=>ie(H,ee,!1,He):y(ee,H)?He=>ie(ee,H,!0,He):(He,Ne)=>he(H,ee,He,Ne),de=Ke($e,H,ee,!0),De=!0;if(de||(de=Ke($e,H,ee,!1),De=!1,l.push(`link "${R}": no clear route; drawn the least bad way`)),!de){Pe.push({...m,id:R,points:[],routed:!1});return}for(let He=1;He<de.length;He++)S(de[He-1],de[He]);Pe.push({...m,id:R,points:de,routed:De})});let mt=[];for(let m=0;m<j.length;m++)for(let C=m+1;C<j.length;C++){let[R,H]=j[m],[ee,$e]=j[C],de=R[1]===H[1],De=ee[1]===$e[1];if(de===De)continue;let[He,Ne]=de?[[R,H],[ee,$e]]:[[ee,$e],[R,H]],Ye=Ne[0][0],ot=He[0][1];Ye>Math.min(He[0][0],He[1][0])&&Ye<Math.max(He[0][0],He[1][0])&&ot>Math.min(Ne[0][1],Ne[1][1])&&ot<Math.max(Ne[0][1],Ne[1][1])&&mt.push([Ye,ot])}let rt=m=>mt.filter(([C,R])=>C>m.l-2&&C<m.r+2&&R>m.t-2&&R<m.b+2).length;for(let m of Pe){let C=m,R=m.points;if(!C.label||!R.length)continue;let H=[];for(let Ne=1;Ne<R.length;Ne++)H.push([R[Ne-1],R[Ne]]);let ee=Ne=>Math.abs(Ne[0][0]-Ne[1][0])+Math.abs(Ne[0][1]-Ne[1][1]);H.sort((Ne,Ye)=>ee(Ye)-ee(Ne));let $e=e(C.label,"label")+6,de=null,De=null,He=1/0;for(let[Ne,Ye]of H){let ot=(Ne[0]+Ye[0])/2,Mt=(Ne[1]+Ye[1])/2,$n=Ne[1]===Ye[1]?[0,-.3,.3,-.15,.15].flatMap(Ct=>{let xt=ot+Ct*Math.abs(Ne[0]-Ye[0]);return[[xt,Mt-6,"middle"],[xt,Mt+15,"middle"]]}):[0,-.3,.3].flatMap(Ct=>{let xt=Mt+4+Ct*Math.abs(Ne[1]-Ye[1]);return[[ot+7,xt,"start"],[ot-7,xt,"end"],[ot+24,xt,"start"],[ot-24,xt,"end"]]});for(let[Ct,xt,wt]of $n){let Tt=wt==="middle"?Ct-$e/2:wt==="end"?Ct-$e:Ct,ze={l:Tt,r:Tt+$e,t:xt-11,b:xt+3};if(!it(ze)){de=[Ct,xt,wt,ze];break}let Ft=ut(ze);Ft<He&&(He=Ft,De=[Ct,xt,wt,ze])}if(de)break}if(!de&&De&&(de=De),!de){let[Ne,Ye]=H[0],ot=(Ne[0]+Ye[0])/2,Mt=(Ne[1]+Ye[1])/2-6;de=[ot,Mt,"middle",{l:ot-$e/2,r:ot+$e/2,t:Mt-11,b:Mt+3}]}Oe.push(de[3]),m.at={x:a(de[0]),y:a(de[1]),anchor:de[2],box:de[3],text:C.label}}let P=[],q=[];for(let m of[...x,...Oe,...g.map(C=>C.title)])P.push(m.l,m.r),q.push(m.t,m.b);for(let m of Pe)for(let C of m.points)P.push(C[0]),q.push(C[1]);let U=r.margin,ae={l:Math.min(...P)-U,t:Math.min(...q)-U,r:Math.max(...P)+U,b:Math.max(...q)+U};return{cards:h,panels:g,links:Pe,bounds:ae,options:r,warnings:l}}function tf(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 Sm(t,e,n,s={}){let r=a=>{let l=Js(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 d of Mm(o)){if(Va(d).length)continue;let u=r(d);u<c-.5&&(c=u,l=d)}if(!l)break;o=l,i=c}return o}function*Mm(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,d)=>{d===a||!n(i,c.cells)||a>=0&&d>a&&s(c.cells,e[a].cells)||(l<0||n(c.cells,e[l].cells)&&(!s(c.cells,e[l].cells)||d>l))&&(l=d)}),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 d=[l.cell[0],l.cell[1],l.cell[0],l.cell[1]];r(d)===i&&a.push({range:d,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((f,p)=>f.range[1]-p.range[1]||f.range[0]-p.range[0])){let f=c.find(p=>p.some(g=>l(g)[0]<=l(u)[1]&&l(u)[0]<=l(g)[1]));f?f.push(u):c.push([u])}let d=Math.max(...a.map(u=>u.range[3]));for(let u of c){u.sort((f,p)=>f.range[0]-p.range[0]);for(let f=1;f<u.length;f++){let p=u.slice(f),g=u[0].range[0],h=d+1,b=Math.min(...p.map(T=>T.range[1])),v=Math.max(...p.map(T=>T.range[3]))-b+1,w=t.cards.map(T=>({...T,cell:[...T.cell]})),k=e.map(T=>({...T,cells:[...T.cells]}));for(let T of w)T.cell[1]>d&&(T.cell[1]+=v);let y=new Set;for(let T=i;T>=0&&!y.has(T);T=r(e[T].cells,T))y.add(T);k.forEach((T,A)=>{T.cells[1]>d?(T.cells[1]+=v,T.cells[3]+=v):(y.has(A)||T.cells[1]<=d&&T.cells[3]>d)&&(T.cells[3]+=v)});let M=g;for(let T of p){let A=M-T.range[0],I=h+(T.range[1]-b)-T.range[1],j=L=>L[0]>=T.range[0]&&L[0]<=T.range[2]&&L[1]>=T.range[1]&&L[1]<=T.range[3];t.cards.forEach((L,B)=>{j([L.cell[0],L.cell[1]])&&(w[B].cell=[L.cell[0]+A,L.cell[1]+I])}),e.forEach((L,B)=>{n(L.cells,T.range)&&(k[B].cells=[L.cells[0]+A,L.cells[1]+I,L.cells[2]+A,L.cells[3]+I])}),M+=T.range[2]-T.range[0]+1}e.forEach((T,A)=>{let I=t.cards.map((j,L)=>n([j.cell[0],j.cell[1],j.cell[0],j.cell[1]],T.cells)?w[L].cell:void 0).filter(j=>!!j);I.length&&(k[A].cells=[Math.min(...I.map(j=>j[0])),Math.min(...I.map(j=>j[1])),Math.max(...I.map(j=>j[0])),Math.max(...I.map(j=>j[1]))])}),yield{cards:w,panels:k,links:t.links}}}}}function br(t,e=()=>!0){let n=t.layout.items.filter(A=>e(A.id)),s=t.layout.catalog,r=!t.layout.items.some(A=>A.type==="node"),o=A=>r?!A.children.some(I=>e(I.id)):A.type==="node"&&!A.children.some(I=>I.type==="node"&&e(I.id)),i=n.filter(o),a=A=>{let I=[];for(let j=A;j;j=j.parent)I.unshift(j);return I},l=new Map(i.map(A=>[A.id,a(A)])),c=(A,I)=>{let j=l.get(A.id),L=l.get(I.id),B=0;for(;B<j.length&&B<L.length&&j[B]===L[B];)B++;return[j[B].box,L[B].box]},d=1e-6,u=(A,I)=>{let[j,L]=c(A,I);return j.y1<=L.y0+d&&j.x0<L.x1-d&&L.x0<j.x1-d},f=(A,I)=>{let[j,L]=c(A,I);return j.x1<=L.x0+d&&j.y0<L.y1-d&&L.y0<j.y1-d},p=(A,I)=>{let j=new Map,L=[];for(let B of[...i].sort((S,E)=>I(S)-I(E))){let S=0;for(let E of L)j.get(E.id)+1>S&&A(E,B)&&(S=j.get(E.id)+1);j.set(B.id,S),L.push(B)}return j},g=p(u,A=>A.box.y0),h=p(f,A=>A.box.x0),b=Math.min(...i.map(A=>A.box.x1-A.box.x0))/2;for(let A of i)if(!A.parent)for(let I of i)I.parent&&I.box.x0<=A.box.x0+b&&h.set(A.id,Math.max(h.get(A.id),h.get(I.id)));let v=new Map;for(let A of i)v.set(A.id,[h.get(A.id),g.get(A.id)]);let w=new Map;for(let A of i){let I=v.get(A.id),j=w.get(String(I));if(j!==void 0&&j!==A.id){for(let[,L]of v)L[0]>I[0]&&L!==I&&L[0]++;I[0]++,w.clear();for(let L of i)w.set(String(v.get(L.id)),L.id)}else w.set(String(I),A.id)}let k=i.map(A=>{if(A.region){let L=A.region;return{id:A.id,label:L.label??A.id,sub:void 0,role:L.role??Dt(s,L.kind)?.role??"grey",ghost:L.ghost||void 0,cell:v.get(A.id)}}let I=A.node,j=In(s,I.asset);return{id:A.id,label:I.label??A.id,sub:I.sub,role:I.role??j.role,ghost:I.ghost||void 0,cell:v.get(A.id)}}),y=[];for(let A of n){if(o(A))continue;let I=[],j=x=>{for(let N of x.children){let z=v.get(N.id);z&&I.push(z),j(N)}};if(j(A),!I.length)continue;let L=I.map(x=>x[0]),B=I.map(x=>x[1]),S=A.type==="region"?A.region.label:A.node.label??A.id,E=A.type==="region"?A.region.role??Dt(s,A.region.kind)?.role:A.node.role??In(s,A.node.asset).role;y.push({id:A.id,label:S,sub:A.type==="node"?A.node.sub:void 0,role:E,cells:[Math.min(...L),Math.min(...B),Math.max(...L),Math.max(...B)]})}let M=new Set([...k.map(A=>A.id),...y.map(A=>A.id)]),T=[];for(let A of t.routes){if(!e(A.id))continue;let I=An(A.raw.from).id,j=An(A.raw.to).id;if(!M.has(I)||!M.has(j))continue;let L=typeof A.raw.label=="string"?A.raw.label:A.raw.label?.text;T.push({id:A.id,a:I,b:j,kind:A.kind,label:L})}return{cards:k,panels:y,links:T}}var Xs={W:4,D:2,H:.9,GX:2,GY:2.4,PAD:.6,CH:2.2,PANEL_H:.3},nf=`
|
|
279
279
|
.blk .card-name{font-size:13px;font-weight:600;fill:var(--ink)}
|
|
280
280
|
.blk .card-sub{font-size:10px;fill:var(--ink);opacity:.75}
|
|
281
281
|
.blk.ghost .card-name,.blk.ghost .card-sub{fill:var(--muted)}
|
|
282
|
-
`;function xc(t){return{name:"card",description:"A card: a slab with its name on its front face",size:[js.W,js.D,js.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",Bt.lbl,"left","start"),r.sub&&(o+=e.faceText(n.x0+.2,n.y1,n.z0+i*.14,r.sub,"card-sub",Bt.sub,"left","start")),o}}}function ku(t){let e=new Map(t.cards.map(n=>[n.id,{label:n.label,sub:n.sub}]));return{regions:{panel:{shape:"slab",pad:js.PAD,z:[js.PANEL_H,0],floor:!0,role:"grey",labelStyle:"floor"}},nodes:{card:xc(n=>e.get(n))},defaultNode:"card"}}function Su(t,e={}){let n=js,{prect:s,parentIx:r,cardAt:o}=jo(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=g=>Math.round(g*1e3)/1e3,l=g=>(g.cells[2]-g.cells[0]+1)*(g.cells[3]-g.cells[1]+1),c=g=>{let h=-1;return i.forEach((b,k)=>{let v=b.cells;g.cell[0]>=v[0]&&g.cell[0]<=v[2]&&g.cell[1]>=v[1]&&g.cell[1]<=v[3]&&(h<0||l(b)<=l(i[h]))&&(h=k)}),h},d=i.map((g,h)=>{let b=s[h],k=r[h]>=0?s[r[h]]:{l:0,t:0};return{id:g.id,kind:"panel",label:g.label,role:g.role,at:[a(b.l-k.l),a(b.t-k.t)],size:[a(b.r-b.l),a(b.b-b.t)],regions:[],nodes:[]}}),u=[],f=[];d.forEach((g,h)=>r[h]>=0?d[r[h]].regions.push(g):u.push(g));for(let g of t.cards){let[h,b]=o(t.cards.indexOf(g)),k=c(g),v=k>=0?s[k]:{l:0,t:0},M={id:g.id,asset:"card",role:g.role,ghost:g.ghost||void 0,at:[a(h-v.l),a(b-v.t)],size:[n.W,n.D,n.H]};(k>=0?d[k].nodes:f).push(M)}for(let g of d)g.regions.length||delete g.regions,g.nodes.length||delete g.nodes;let p=(t.links??[]).map((g,h)=>({id:g.id??`link-${h}`,from:g.aOn??g.a,to:g.bOn??g.b,kind:g.kind,label:g.label}));return{isodiag:1,title:e.title,kinds:e.kinds,roles:e.roles,scenes:[{id:"board",title:e.title??"board",regions:u,nodes:f,routes:p}]}}var uf={};Qo(uf,{APPEARS:()=>Pu,BASE_FIELDS:()=>Nc,BINS:()=>ju,BIN_MS:()=>On,CARD:()=>jt,DUAL_VIEW_CSS:()=>df,IDLES:()=>Ou,MAX_ZOOM:()=>Eu,MIN_ZOOM:()=>$u,P3:()=>ht,SEGMENT_NAME:()=>Ma,SEVERITIES:()=>mn,TIMELINE_VERSION:()=>Fu,activityOf:()=>jc,attr:()=>zn,binNext:()=>Oa,binStart:()=>ir,cardMotion:()=>Cu,cls:()=>Lu,crumbs:()=>jr,dualView:()=>af,escapeName:()=>Ta,extent:()=>ka,findGaps:()=>Ca,fitWithOverlay:()=>Ru,flatCss:()=>nf,flatSvg:()=>_r,formatScope:()=>Bu,gapKey:()=>lr,gapLabel:()=>ar,h:()=>z,hasSegment:()=>zu,highlights:()=>_o,isZone:()=>Hu,isoVars:()=>Iu,join:()=>Ku,kindOf:()=>Dr,legend:()=>Cc,levelOf:()=>Xt,markConnectors:()=>Vr,md:()=>ns,measureIn:()=>zr,memorySource:()=>Ju,modeFor:()=>Fc,morphSvgs:()=>ja,mountTimeline:()=>ef,n:()=>Sc,nameOf:()=>Fr,node:()=>Nu,offsetAt:()=>tn,overlayPaint:()=>Tu,parentOf:()=>_u,prefixAt:()=>vs,prune:()=>$c,pts:()=>Bo,rangeOf:()=>Ko,readTime:()=>Lc,rectOf:()=>sf,renderPage:()=>Du,rewrite:()=>Mc,scope:()=>Tc,scopePattern:()=>$a,scopeRules:()=>Ea,scopeSelector:()=>Ec,searchFor:()=>Br,severities:()=>Vu,stepData:()=>Oc,storedMode:()=>lf,ticks:()=>Na,timeScale:()=>Kr,toCSV:()=>Ra,toJSON:()=>La,unite:()=>Sa,viewToggle:()=>cf,viewport:()=>va,within:()=>hn});var $u=.1,Eu=8;function va(t,e){let n,s,r=!1,o=0,i=0,a=0,l=0,c=0,d=!1,u=()=>{let A=t.getBoundingClientRect();return{w:Math.max(1,A.width),h:Math.max(1,A.height)}},f=(A=n)=>{let D=u();return Math.min(D.w/A.w,D.h/A.h)},p=A=>{o++;try{A()}finally{o--}};function g(){let A=e.svg();if(!A||!n)return;o||(r=!0);let D=u(),K=f(),C=D.w/K,_=D.h/K;n={x:n.x+(n.w-C)/2,y:n.y+(n.h-_)/2,w:C,h:_},A.setAttribute("viewBox",`${n.x.toFixed(2)} ${n.y.toFixed(2)} ${n.w.toFixed(2)} ${n.h.toFixed(2)}`),i=K,e.onApply(K),a&&Math.abs(K/a-1)>.02&&(cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,e.onRezoom()}))}let h=(A,D)=>{let K=t.getBoundingClientRect(),C=f();return{x:n.x+(A-K.left)/C,y:n.y+(D-K.top)/C}};function b(A,D,K){if(!n)return;let C=f(),_=Math.min(8,Math.max(.1,C*A)),S=t.getBoundingClientRect(),$=D??S.left+S.width/2,w=K??S.top+S.height/2,N=h($,w),F=u();n={x:N.x-($-S.left)/_,y:N.y-(w-S.top)/_,w:F.w/_,h:F.h/_},g()}function k(A=s){if(!A)return;let D=u(),K=24,C=Math.min(8,Math.max(.1,Math.min((D.w-K*2)/A.w,(D.h-K*2)/A.h))),_=A.x+A.w/2,S=A.y+A.h/2,$={x:_-D.w/C/2,y:S-D.h/C/2,w:D.w/C,h:D.h/C};if(n&&Math.abs($.w/n.w-1)<.001&&Math.abs($.h/n.h-1)<.001&&Math.abs($.x-n.x)<$.w*.001&&Math.abs($.y-n.y)<$.h*.001){g();return}n=$,g()}function v(){for(let A=0,D="";A<4;A++){let K=e.itemsBox()??s;if(!K)return;let C=[K.x,K.y,K.w,K.h].map(S=>Math.round(S)).join();if(C===D)break;D=C;let _=Math.max(24,Math.min(K.w,K.h)*.06);if(p(()=>k({x:K.x-_,y:K.y-_,w:K.w+_*2,h:K.h+_*2})),!e.marksShowing()||!a||Math.abs(f()/a-1)<=.02)break;cancelAnimationFrame(l),l=0,e.onRezoom()}r=!1}function M(){if(r||!e.svg()||!n)return;let A=t.getBoundingClientRect();A.width<2||A.height<2||v()}function x(){if(!n)return;let A=f();b(1/A)}function T(){return new Promise(A=>{let D=0,K=i,C=()=>{if(d){A();return}let _=!!(l||c)||i!==K;K=i,D=_?0:D+1,D>=2?A():requestAnimationFrame(C)};requestAnimationFrame(C)})}let y=new ResizeObserver(()=>{if(!(!n||d)){if(r&&i){let A=u(),D=n.x+n.w/2,K=n.y+n.h/2;n={x:D-A.w/i/2,y:K-A.h/i/2,w:A.w/i,h:A.h/i}}r||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,d||M()})),p(g)}});return y.observe(t),{get view(){return n},set view(A){n=A},get full(){return s},set full(A){s=A},get moved(){return r},get zoom(){return i},painted(A){a=A},size:u,scale:f,quietly:p,applyView:g,toSvg:h,zoomAt:b,fit:k,fitItems:v,autoFit:M,actual:x,settled:T,dispose(){cancelAnimationFrame(c),cancelAnimationFrame(l),y.disconnect(),d=!0}}}var Kt="http://www.w3.org/2000/svg",jt={half:2.4,h:3.2,t:.25,above:1.4,lift:3.8,fan:.32,gap:.3},ht=(t,e,n)=>[(t-e)*It*xt,(t+e)*.5*xt-n*xt],Bo=t=>t.map(([e,n])=>`${e.toFixed(1)},${n.toFixed(1)}`).join(" ");function Tu(t,e){function n(o,i,a){let l=t.k(),c=(u,f,p,g,h="")=>{let b=o.createElementNS(Kt,"g");b.setAttribute("class",`live-badge ${p.cls} ${h}`.trim());let k=8/l,v=o.createElementNS(Kt,"circle");if(v.setAttribute("cx",String(u)),v.setAttribute("cy",String(f)),v.setAttribute("r",String(k)),b.append(v),"g"in p){let x=o.createElementNS(Kt,"text");x.setAttribute("x",String(u)),x.setAttribute("y",String(f)),x.style.fontSize=`${(10/l).toFixed(2)}px`,x.textContent=p.g,b.append(x)}else{let x=o.createElementNS(Kt,"use");x.setAttribute("href",t.iconHref(p.icon));let T=11/l;x.setAttribute("x",String(u-T/2)),x.setAttribute("y",String(f-T/2)),x.setAttribute("width",String(T)),x.setAttribute("height",String(T)),b.append(x)}let M=o.createElementNS(Kt,"title");M.textContent=g,b.append(M),i(b)},d=(u,f)=>{for(let p of t.outlinesFor(u)){if(p.kind!=="poly")continue;let g=o.createElementNS(Kt,"polygon");g.setAttribute("class",f),g.setAttribute("points",p.points.map(([h,b])=>`${h.toFixed(1)},${b.toFixed(1)}`).join(" ")),i(g)}};for(let u of a){let f=t.boxOf(u.at);if(f){if(u.outline&&d(u.at,u.outline),u.badge)c(f.x,f.y,u.badge,u.title);else if(u.hit){let p=o.createElementNS(Kt,"title");p.textContent=u.title;let g=o.createElementNS(Kt,"rect");g.setAttribute("class","live-hit"),g.setAttribute("x",String(f.x)),g.setAttribute("y",String(f.y)),g.setAttribute("width",String(f.w)),g.setAttribute("height",String(f.h)),g.append(p),i(g)}if((u.beside??[]).forEach((p,g)=>c(f.x+18*(g+1)/l,f.y,p.glyph,p.title)),u.dot&&c(f.x,f.y+f.h,u.dot.glyph,u.dot.title),u.tag){let p=o.createElementNS(Kt,"text");p.setAttribute("class",`live-life ${u.tag.cls}`),p.setAttribute("x",String(f.x+f.w)),p.setAttribute("y",String(f.y+f.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(Kt,"g");c.setAttribute("class",`live-extra${l.cls}`);for(let[M,x]of l.data)c.setAttribute(M,x);let{x:d,y:u,w:f,hgt:p,k:g}=l.rect,h=o.createElementNS(Kt,"rect");h.setAttribute("x",String(d)),h.setAttribute("y",String(u)),h.setAttribute("width",String(f)),h.setAttribute("height",String(p)),h.setAttribute("rx",String(6/g));let b=o.createElementNS(Kt,"text");b.setAttribute("x",String(d+8/g)),b.setAttribute("y",String(u+13/g)),b.style.fontSize=`${(11/g).toFixed(2)}px`,b.textContent=l.line1;let k=o.createElementNS(Kt,"text");k.setAttribute("class","sub"),k.setAttribute("x",String(d+8/g)),k.setAttribute("y",String(u+27/g)),k.style.fontSize=`${(9/g).toFixed(2)}px`,k.textContent=l.line2;let v=o.createElementNS(Kt,"title");v.textContent=l.title,c.append(h,b,k,v),i(c)}}function r(o,i,a){let l=[];for(let c of a){let d=c.over,u=(d.x0+d.x1)/2,f=(d.y0+d.y1)/2,p=0,g={x0:0,y0:0,x1:0,y1:0};for(let j=0;j<6;j++){let U=d.z1+jt.above+p,ee=U+jt.h,fe=[ht(u-jt.half,f+jt.t,U),ht(u+jt.half,f+jt.t,U),ht(u+jt.half,f-jt.t,ee),ht(u-jt.half,f+jt.t,ee)];if(g={x0:Math.min(...fe.map(B=>B[0])),y0:Math.min(...fe.map(B=>B[1])),x1:Math.max(...fe.map(B=>B[0])),y1:Math.max(...fe.map(B=>B[1]))},!rr(g,l))break;p+=jt.lift}l.push(g);let h=d.z1+jt.above+p,b=h+jt.h,k=u-jt.half,v=u+jt.half,M=f+jt.t,x=f-jt.t,T=o.createElementNS(Kt,"g");T.setAttribute("class",`${e}-card${c.cls}`);for(let[j,U]of c.data)T.setAttribute(j,U);let[y,A]=ht(u,f,d.z1+.15),D=`${y.toFixed(1)}px ${A.toFixed(1)}px`;T.style.transformOrigin=D;let K=o.createElementNS(Kt,"g");K.setAttribute("class",`${e}-float`),K.style.transformOrigin=D;let C=[];for(let j=Math.min(c.count-1,3);j>=1;j--){let U=j*jt.fan,ee=x-(j-1)*(2*jt.t+jt.gap)-jt.gap,fe=ee-2*jt.t,B=k+U,X=v+U,Q=h+U,te=b+U,ne=(me,ye)=>{let xe=o.createElementNS(Kt,"polygon");xe.setAttribute("class",`${e}-face stacked ${me}`),xe.setAttribute("points",Bo(ye)),K.append(xe)};ne("s-top",[ht(B,fe,te),ht(X,fe,te),ht(X,ee,te),ht(B,ee,te)]),ne("s-side",[ht(X,fe,Q),ht(X,ee,Q),ht(X,ee,te),ht(X,fe,te)]),ne("s-front",[ht(B,ee,Q),ht(X,ee,Q),ht(X,ee,te),ht(B,ee,te)]),C.push({x0:B,x1:X,y0:fe,y1:ee,z0:Q,z1:te})}let _=o.createElementNS(Kt,"polygon");_.setAttribute("class",`${e}-tail`),_.setAttribute("points",Bo([ht(u-.5,M,h+.05),ht(u+.5,M,h+.05),ht(u,f,d.z1+.15)]));let S=(j,U)=>{let ee=o.createElementNS(Kt,"polygon");return ee.setAttribute("class",j),ee.setAttribute("points",Bo(U)),ee},$=S(`${e}-face front`,[ht(k,M,h),ht(v,M,h),ht(v,M,b),ht(k,M,b)]);K.append(_,S(`${e}-face top`,[ht(k,x,b),ht(v,x,b),ht(v,M,b),ht(k,M,b)]),S(`${e}-face side`,[ht(v,x,h),ht(v,M,h),ht(v,M,b),ht(v,x,b)]),$);let[w,N]=ht(k,M,b),F=40,J=o.createElementNS(Kt,"g");J.setAttribute("transform",`matrix(${(It*xt/F).toFixed(4)} ${(.5*xt/F).toFixed(4)} 0 ${(xt/F).toFixed(4)} ${w.toFixed(1)} ${N.toFixed(1)})`);let ae=(j,U,ee,fe)=>{let B=o.createElementNS(Kt,"text");return B.setAttribute("class",j),B.setAttribute("x",String(U)),B.setAttribute("y",String(ee)),B.textContent=fe,B};if(J.append(ae(`${e}-mark`,34,98,c.mark),ae(`${e}-who`,70,52,c.who),ae(`${e}-age`,70,82,c.age)),c.line!==void 0&&J.append(ae(`${e}-q`,12,118,c.line)),c.count>1){let j=o.createElementNS(Kt,"circle");j.setAttribute("class",`${e}-count-bg`),j.setAttribute("cx","178"),j.setAttribute("cy","14"),j.setAttribute("r","15"),J.append(j,ae(`${e}-count`,178,14,String(c.count)))}K.append(J);let we=o.createElementNS(Kt,"title");we.textContent=c.title,T.append(K,we),t.onCard?.(T,{cx:u,cy:f,tipZ:d.z1+.15,card:{x0:k,x1:v,y0:x,y1:M,z0:h,z1:b},panes:C.reverse()}),i(T)}}return{paintMarks:n,paintGhosts:s,paintCards:r}}var Pu=[["scale","Scale"],["spin","Spin"],["dissolve","Dissolve"],["inflate","Inflate"]],Ou=[["none","None"],["jiggle","Jiggle"],["pirouette","Pirouette"],["glow","Glow"],["breathe","Breathe"]];function zp(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 wc=t=>t<0?0:t>1?1:1-Math.pow(1-t,3),Au=t=>t<0?0:t>1?1:t*t*t,vc=Math.PI*2,kc={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 Cu(t,e,{prefix:n,key:s,alt:r}){let o={...e},i=1,a=new Map,l=new WeakSet,c=0,d=0,u=new WeakMap,f=new WeakMap;function p(_){c=0;for(let[S,$]of a){if(!S.isConnected){a.delete(S);continue}let w;if($.repeat){if(w=(_+($.offset??0))%$.repeat/$.dur,w>1){l.has(S)&&(t.restore(S),l.delete(S),S.style.removeProperty("transform"));continue}}else if(w=(_-$.start)/$.dur,w>=1){g(S,$);continue}let N=$.frame(Math.max(0,w));t.spin(S,N.theta,N.lift),l.add(S),f.set(S,N),N.scale!==1?S.style.transform=`scale(${N.scale.toFixed(4)})`:S.style.removeProperty("transform"),d++}a.size&&(c=requestAnimationFrame(p))}function g(_,S){a.delete(_),l.has(_)&&(t.restore(_),l.delete(_)),_.style.removeProperty("transform"),S.done?.()}function h(_){let S=a.get(_.card);S&&g(_.card,S),a.set(_.card,_),c||(c=requestAnimationFrame(p))}let b=8,k=0,v=_=>(k++,_.finally(()=>{k--}));function M(_){return!o.enabled||k>=b?Promise.resolve():v(T(_))}function x(_){return!o.enabled||k>=b?Promise.resolve():v(y(_))}function T(_){let S=kc.appear[o.appear]/i;if(o.appear==="spin")return new Promise(N=>h({card:_,start:performance.now(),dur:S,frame:F=>({theta:(1-wc(F))*vc,lift:0,scale:Math.max(.001,wc(F))}),done:N}));let $=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 _.animate($,{duration:S,easing:o.appear==="inflate"?"linear":"ease-out"}).finished.then(()=>{},()=>{})}function y(_){let S=kc.disappear[o.appear]/i;if(o.appear==="spin")return new Promise(N=>h({card:_,start:performance.now(),dur:S,frame:F=>({theta:Au(F)*vc,lift:0,scale:Math.max(.001,1-Au(F))}),done:()=>{_.style.transform="scale(0)",N()}}));let $=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 _.animate($,{duration:S,easing:"ease-in",fill:"forwards"}).finished.then(()=>{},()=>{})}function A(_){u.get(_)?.cancel(),u.delete(_);let S=a.get(_);S?.repeat&&g(_,S)}function D(_,S){if(A(_),!o.enabled||o.idle==="none"||_.classList.contains("still"))return;let $=_.getAttribute(s)??_.getAttribute(r)??"",w=(S??kc.period[o.idle])/i,N=zp($)*w;if(o.idle==="pirouette"){let j=(Pn.windup+Pn.turn+Pn.land)/i,U=Pn.windup/(Pn.windup+Pn.turn+Pn.land),ee=(Pn.windup+Pn.turn)/(Pn.windup+Pn.turn+Pn.land);h({card:_,start:0,dur:j,repeat:w,offset:N,frame:fe=>{if(fe<U)return{theta:-.35*Math.sin(fe/U*Math.PI/2),lift:0,scale:1};if(fe<ee){let X=(fe-U)/(ee-U);return{theta:-.35*(1-X)+wc(X)*vc,lift:.9*Math.sin(X*Math.PI),scale:1}}let B=(fe-ee)/(1-ee);return{theta:0,lift:0,scale:1-.04*Math.sin(B*Math.PI)}}});return}let F=_.querySelector(`.${n}-float`)??_,J=t.amber(),ae=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)"}],we=F.animate(ae,{duration:w,iterations:1/0,easing:o.idle==="jiggle"?"linear":"ease-in-out"});we.startTime=(document.timeline.currentTime??0)-((document.timeline.currentTime??0)+N)%w,u.set(_,we)}function K(_,S,$,w,N=!1){N&&(w=!1);for(let[J,ae]of S)!_.has(J)&&!N&&M(ae),!u.has(ae)&&!a.get(ae)?.repeat&&D(ae);if(!o.enabled||!w)return;let F=t.leavingLayer();if(F)for(let[J,ae]of $){let we=_.get(J);!we||S.has(J)||(A(we),we.setAttribute("class",`${n}-leaving${ae?" expired":""}`),we.removeAttribute(r),F.append(we),x(we).then(()=>we.remove()))}}function C(_){for(let[S,$]of[...a])g(S,$);c&&cancelAnimationFrame(c),c=0;for(let S of document.getAnimations())S.effect?.target?.closest?.(`.live-layer, .${n}-leaving-layer`)&&S.cancel();t.leavingLayer()?.replaceChildren()}return{get settings(){return{...o}},set(_,S){let $=o;if(o={...o,..._},(!o.enabled||$.idle!==o.idle||$.enabled!==o.enabled)&&(C(void 0),o.enabled))for(let w of S)D(w)},update:K,appear:M,disappear:x,startIdle:D,stopIdle:A,stopAll:C,async preview(_){o.enabled&&await Promise.all(_.map(async S=>{if(A(S),await M(S),o.idle!=="none"&&!S.classList.contains("still")){let $=o.idle==="pirouette"?1800:1400;D(S,$),await new Promise(w=>setTimeout(w,$*2.2/i)),A(S)}else await new Promise($=>setTimeout($,700/i));await x(S);for(let $ of S.getAnimations())$.cancel();S.style.removeProperty("transform"),D(S)}))},get stats(){return{jobs:a.size,raf:!!c,frames:d,effects:k}},setSpeed(_){i=_},lastFrame:_=>f.get(_)}}var Sc=t=>String(Math.round(t*100)/100),Nu=(t,e={},...n)=>({name:t,attrs:Object.entries(e).map(([s,r])=>[s,typeof r=="number"?Sc(r):r]),children:n});function Mc(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=>Mc(s,e))}}function $c(t,e){if(typeof t=="string")return t;if(!e(t))return{...t,children:t.children.map(n=>$c(n,e)).filter(n=>n!==void 0)}}var Lu=t=>(t.attrs.find(e=>e[0]==="class")?.[1]??"").split(/\s+/),zn=(t,e)=>t.attrs.find(n=>n[0]===e)?.[1];function ka(t){let e=[],n=[],s=i=>{if(typeof i=="string")return;let a=zn(i,"transform");if(a&&/matrix/.test(a))return;let l=zn(i,"points");if(l)for(let c of l.trim().split(/\s+/)){let[d,u]=c.split(",").map(Number);Number.isFinite(d)&&Number.isFinite(u)&&(e.push(d),n.push(u))}if(i.name==="rect"){let c=Number(zn(i,"x")),d=Number(zn(i,"y")),u=Number(zn(i,"width")),f=Number(zn(i,"height"));[c,d,u,f].every(Number.isFinite)&&(e.push(c,c+u),n.push(d,d+f))}if(i.name==="circle"){let c=Number(zn(i,"cx")),d=Number(zn(i,"cy")),u=Number(zn(i,"r"));[c,d,u].every(Number.isFinite)&&(e.push(c-u,c+u),n.push(d-u,d+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 Sa=(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 Ru(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=Sa(t,ka(o));return r=s(i),o=n(r),i=Sa(t,ka(o)),r=s(i),{k:r,box:i,live:o}}var Iu=t=>t.replace(/--([a-zA-Z][\w-]*)/g,"--iso-$1");function Vp(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 Gp(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 Ec(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 Tc(t,e,n){let s="";for(let[r,o]of Vp(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
|
|
282
|
+
`;function Uc(t){return{name:"card",description:"A card: a slab with its name on its front face",size:[Xs.W,Xs.D,Xs.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",It.lbl,"left","start"),r.sub&&(o+=e.faceText(n.x0+.2,n.y1,n.z0+i*.14,r.sub,"card-sub",It.sub,"left","start")),o}}}function sf(t){let e=new Map(t.cards.map(n=>[n.id,{label:n.label,sub:n.sub}]));return{regions:{panel:{shape:"slab",pad:Xs.PAD,z:[Xs.PANEL_H,0],floor:!0,role:"grey",labelStyle:"floor"}},nodes:{card:Uc(n=>e.get(n))},defaultNode:"card"}}function rf(t,e={}){let n=Xs,{prect:s,parentIx:r,cardAt:o}=ni(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=g=>Math.round(g*1e3)/1e3,l=g=>(g.cells[2]-g.cells[0]+1)*(g.cells[3]-g.cells[1]+1),c=g=>{let h=-1;return i.forEach((b,v)=>{let w=b.cells;g.cell[0]>=w[0]&&g.cell[0]<=w[2]&&g.cell[1]>=w[1]&&g.cell[1]<=w[3]&&(h<0||l(b)<=l(i[h]))&&(h=v)}),h},d=i.map((g,h)=>{let b=s[h],v=r[h]>=0?s[r[h]]:{l:0,t:0};return{id:g.id,kind:"panel",label:g.label,role:g.role,at:[a(b.l-v.l),a(b.t-v.t)],size:[a(b.r-b.l),a(b.b-b.t)],regions:[],nodes:[]}}),u=[],f=[];d.forEach((g,h)=>r[h]>=0?d[r[h]].regions.push(g):u.push(g));for(let g of t.cards){let[h,b]=o(t.cards.indexOf(g)),v=c(g),w=v>=0?s[v]:{l:0,t:0},k={id:g.id,asset:"card",role:g.role,ghost:g.ghost||void 0,at:[a(h-w.l),a(b-w.t)],size:[n.W,n.D,n.H]};(v>=0?d[v].nodes:f).push(k)}for(let g of d)g.regions.length||delete g.regions,g.nodes.length||delete g.nodes;let p=(t.links??[]).map((g,h)=>({id:g.id??`link-${h}`,from:g.aOn??g.a,to:g.bOn??g.b,kind:g.kind,label:g.label}));return{isodiag:1,title:e.title,kinds:e.kinds,roles:e.roles,scenes:[{id:"board",title:e.title??"board",regions:u,nodes:f,routes:p}]}}var Gf={};vi(Gf,{APPEARS:()=>cf,BASE_FIELDS:()=>ad,BINS:()=>yf,BIN_MS:()=>jn,CARD:()=>zt,DUAL_VIEW_CSS:()=>Vf,IDLES:()=>df,MAX_ZOOM:()=>Ha,MIN_ZOOM:()=>Ga,P3:()=>bt,SEGMENT_NAME:()=>Wa,SEVERITIES:()=>kn,TIMELINE_VERSION:()=>bf,activityOf:()=>pd,attr:()=>Zn,binNext:()=>tl,binStart:()=>yr,buildLayer:()=>li,cardMotion:()=>uf,clamp:()=>Ls,cls:()=>pf,crumbs:()=>Xr,dualView:()=>Kf,ease:()=>ai,escapeName:()=>Qa,extent:()=>qa,findGaps:()=>nl,fitWithOverlay:()=>mf,flatCss:()=>Df,flatSvg:()=>eo,formatScope:()=>xf,gapKey:()=>wr,gapLabel:()=>xr,h:()=>_,hasSegment:()=>kf,highlights:()=>oi,isZone:()=>$f,isoVars:()=>hf,join:()=>wf,kindOf:()=>Wr,legend:()=>id,levelOf:()=>rn,markConnectors:()=>no,md:()=>fs,measureIn:()=>to,memorySource:()=>Cf,modeFor:()=>fd,morphSvgs:()=>cl,mountTimeline:()=>Rf,n:()=>Qc,nameOf:()=>Jr,node:()=>ff,offsetAt:()=>dn,overlayPaint:()=>af,parentOf:()=>vf,prefixAt:()=>Os,prune:()=>ed,pts:()=>si,rangeOf:()=>ri,readTime:()=>ld,rectOf:()=>Ff,renderPage:()=>gf,rewrite:()=>Zc,scope:()=>nd,scopePattern:()=>Ja,scopeRules:()=>Xa,scopeSelector:()=>td,searchFor:()=>Qr,severities:()=>Sf,stepData:()=>od,storedMode:()=>_f,ticks:()=>sl,timeScale:()=>Zr,toCSV:()=>ol,toJSON:()=>rl,unite:()=>Ua,viewToggle:()=>zf,viewport:()=>Ya,within:()=>Sn});function $m(t,e,n){let r=(a,l,c,d,u)=>Math.min((a-48)/(c-l),...d===void 0||u===void 0?[]:[[u-d,12],[u-l,30],[c-d,30]].map(([f,p])=>f>0?(a-p)/f:1/0)),o=Math.min(Ha,Math.max(Ga,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,d,u)=>{let f=(l+c)/2;if(d===void 0||u===void 0)return f;let p=u-(a/2-6)/o,g=d+(a/2-6)/o;return p>g?(p+g)/2:Math.max(p,Math.min(g,f))};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 Ga=.1,Ha=8;function Ya(t,e){let n,s,r=!1,o=0,i=0,a=0,l=0,c=0,d=!1,u=()=>{let A=t.getBoundingClientRect();return{w:Math.max(1,A.width),h:Math.max(1,A.height)}},f=(A=n)=>{let I=u();return Math.min(I.w/A.w,I.h/A.h)},p=A=>{o++;try{A()}finally{o--}};function g(){let A=e.svg();if(!A||!n)return;o||(r=!0);let I=u(),j=f(),L=I.w/j,B=I.h/j;n={x:n.x+(n.w-L)/2,y:n.y+(n.h-B)/2,w:L,h:B},A.setAttribute("viewBox",`${n.x.toFixed(2)} ${n.y.toFixed(2)} ${n.w.toFixed(2)} ${n.h.toFixed(2)}`),i=j,e.onApply(j),a&&Math.abs(j/a-1)>.02&&(cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,e.onRezoom()}))}let h=(A,I)=>{let j=t.getBoundingClientRect(),L=f();return{x:n.x+(A-j.left)/L,y:n.y+(I-j.top)/L}};function b(A,I,j){if(!n)return;let L=f(),B=Math.min(Ha,Math.max(Ga,L*A)),S=t.getBoundingClientRect(),E=I??S.left+S.width/2,x=j??S.top+S.height/2,N=h(E,x),z=u();n={x:N.x-(E-S.left)/B,y:N.y-(x-S.top)/B,w:z.w/B,h:z.h/B},g()}function v(A=s,I){if(!A)return;let j=u(),{k:L,cx:B,cy:S}=$m(j,A,I),E={x:B-j.w/L/2,y:S-j.h/L/2,w:j.w/L,h:j.h/L};if(n&&Math.abs(E.w/n.w-1)<.001&&Math.abs(E.h/n.h-1)<.001&&Math.abs(E.x-n.x)<E.w*.001&&Math.abs(E.y-n.y)<E.h*.001){g();return}n=E,g()}function w(){for(let A=0,I="";A<4;A++){let j=e.itemsBox()??s;if(!j)return;let L=[j.x,j.y,j.w,j.h].map(S=>Math.round(S)).join();if(L===I)break;I=L;let B=Math.max(24,Math.min(j.w,j.h)*.06);if(p(()=>v({x:j.x-B,y:j.y-B,w:j.w+B*2,h:j.h+B*2},e.alsoBox?.())),!e.marksShowing()||!a||Math.abs(f()/a-1)<=.02)break;cancelAnimationFrame(l),l=0,e.onRezoom()}r=!1}function k(){if(r||!e.svg()||!n)return;let A=t.getBoundingClientRect();A.width<2||A.height<2||w()}function y(){if(!n)return;let A=f();b(1/A)}function M(){return new Promise(A=>{let I=0,j=i,L=()=>{if(d){A();return}let B=!!(l||c)||i!==j;j=i,I=B?0:I+1,I>=2?A():requestAnimationFrame(L)};requestAnimationFrame(L)})}let T=new ResizeObserver(()=>{if(!(!n||d)){if(r&&i){let A=u(),I=n.x+n.w/2,j=n.y+n.h/2;n={x:I-A.w/i/2,y:j-A.h/i/2,w:A.w/i,h:A.h/i}}r||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,d||k()})),p(g)}});return T.observe(t),{get view(){return n},set view(A){n=A},get full(){return s},set full(A){s=A},get moved(){return r},get zoom(){return i},painted(A){a=A},size:u,scale:f,quietly:p,applyView:g,toSvg:h,zoomAt:b,fit:v,fitItems:w,autoFit:k,actual:y,settled:M,dispose(){cancelAnimationFrame(c),cancelAnimationFrame(l),T.disconnect(),d=!0}}}var Vt="http://www.w3.org/2000/svg",zt={half:2.4,h:3.2,t:.25,above:1.4,lift:3.8,fan:.32,gap:.3},bt=(t,e,n)=>[(t-e)*Kt*yt,(t+e)*.5*yt-n*yt],si=t=>t.map(([e,n])=>`${e.toFixed(1)},${n.toFixed(1)}`).join(" ");function af(t,e){function n(o,i,a){let l=t.k(),c=(u,f,p,g,h="")=>{let b=o.createElementNS(Vt,"g");b.setAttribute("class",`live-badge ${p.cls} ${h}`.trim());let v=8/l,w=o.createElementNS(Vt,"circle");if(w.setAttribute("cx",String(u)),w.setAttribute("cy",String(f)),w.setAttribute("r",String(v)),b.append(w),"g"in p){let y=o.createElementNS(Vt,"text");y.setAttribute("x",String(u)),y.setAttribute("y",String(f)),y.style.fontSize=`${(10/l).toFixed(2)}px`,y.textContent=p.g,b.append(y)}else{let y=o.createElementNS(Vt,"use");y.setAttribute("href",t.iconHref(p.icon));let M=11/l;y.setAttribute("x",String(u-M/2)),y.setAttribute("y",String(f-M/2)),y.setAttribute("width",String(M)),y.setAttribute("height",String(M)),b.append(y)}let k=o.createElementNS(Vt,"title");k.textContent=g,b.append(k),i(b)},d=(u,f)=>{for(let p of t.outlinesFor(u)){if(p.kind!=="poly")continue;let g=o.createElementNS(Vt,"polygon");g.setAttribute("class",f),g.setAttribute("points",p.points.map(([h,b])=>`${h.toFixed(1)},${b.toFixed(1)}`).join(" ")),i(g)}};for(let u of a){let f=t.boxOf(u.at);if(f){if(u.outline&&d(u.at,u.outline),u.badge)c(f.x,f.y,u.badge,u.title);else if(u.hit){let p=o.createElementNS(Vt,"title");p.textContent=u.title;let g=o.createElementNS(Vt,"rect");g.setAttribute("class","live-hit"),g.setAttribute("x",String(f.x)),g.setAttribute("y",String(f.y)),g.setAttribute("width",String(f.w)),g.setAttribute("height",String(f.h)),g.append(p),i(g)}if((u.beside??[]).forEach((p,g)=>c(f.x+18*(g+1)/l,f.y,p.glyph,p.title)),u.dot&&c(f.x,f.y+f.h,u.dot.glyph,u.dot.title),u.tag){let p=o.createElementNS(Vt,"text");p.setAttribute("class",`live-life ${u.tag.cls}`),p.setAttribute("x",String(f.x+f.w)),p.setAttribute("y",String(f.y+f.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(Vt,"g");c.setAttribute("class",`live-extra${l.cls}`);for(let[k,y]of l.data)c.setAttribute(k,y);let{x:d,y:u,w:f,hgt:p,k:g}=l.rect,h=o.createElementNS(Vt,"rect");h.setAttribute("x",String(d)),h.setAttribute("y",String(u)),h.setAttribute("width",String(f)),h.setAttribute("height",String(p)),h.setAttribute("rx",String(6/g));let b=o.createElementNS(Vt,"text");b.setAttribute("x",String(d+8/g)),b.setAttribute("y",String(u+13/g)),b.style.fontSize=`${(11/g).toFixed(2)}px`,b.textContent=l.line1;let v=o.createElementNS(Vt,"text");v.setAttribute("class","sub"),v.setAttribute("x",String(d+8/g)),v.setAttribute("y",String(u+27/g)),v.style.fontSize=`${(9/g).toFixed(2)}px`,v.textContent=l.line2;let w=o.createElementNS(Vt,"title");w.textContent=l.title,c.append(h,b,v,w),i(c)}}function r(o,i,a){let l=[];for(let c of a){let d=c.over,u=(d.x0+d.x1)/2,f=(d.y0+d.y1)/2,p=0,g={x0:0,y0:0,x1:0,y1:0};for(let F=0;F<6;F++){let X=d.z1+zt.above+p,Z=X+zt.h,be=[bt(u-zt.half,f+zt.t,X),bt(u+zt.half,f+zt.t,X),bt(u+zt.half,f-zt.t,Z),bt(u-zt.half,f+zt.t,Z)];if(g={x0:Math.min(...be.map(V=>V[0])),y0:Math.min(...be.map(V=>V[1])),x1:Math.max(...be.map(V=>V[0])),y1:Math.max(...be.map(V=>V[1]))},!gr(g,l))break;p+=zt.lift}l.push(g);let h=d.z1+zt.above+p,b=h+zt.h,v=u-zt.half,w=u+zt.half,k=f+zt.t,y=f-zt.t,M=o.createElementNS(Vt,"g");M.setAttribute("class",`${e}-card${c.cls}`);for(let[F,X]of c.data)M.setAttribute(F,X);let[T,A]=bt(u,f,d.z1+.15),I=`${T.toFixed(1)}px ${A.toFixed(1)}px`;M.style.transformOrigin=I;let j=o.createElementNS(Vt,"g");j.setAttribute("class",`${e}-float`),j.style.transformOrigin=I;let L=[];for(let F=Math.min(c.count-1,3);F>=1;F--){let X=F*zt.fan,Z=y-(F-1)*(2*zt.t+zt.gap)-zt.gap,be=Z-2*zt.t,V=v+X,J=w+X,G=h+X,ne=b+X,oe=(ve,ge)=>{let ye=o.createElementNS(Vt,"polygon");ye.setAttribute("class",`${e}-face stacked ${ve}`),ye.setAttribute("points",si(ge)),j.append(ye)};oe("s-top",[bt(V,be,ne),bt(J,be,ne),bt(J,Z,ne),bt(V,Z,ne)]),oe("s-side",[bt(J,be,G),bt(J,Z,G),bt(J,Z,ne),bt(J,be,ne)]),oe("s-front",[bt(V,Z,G),bt(J,Z,G),bt(J,Z,ne),bt(V,Z,ne)]),L.push({x0:V,x1:J,y0:be,y1:Z,z0:G,z1:ne})}let B=o.createElementNS(Vt,"polygon");B.setAttribute("class",`${e}-tail`),B.setAttribute("points",si([bt(u-.5,k,h+.05),bt(u+.5,k,h+.05),bt(u,f,d.z1+.15)]));let S=(F,X)=>{let Z=o.createElementNS(Vt,"polygon");return Z.setAttribute("class",F),Z.setAttribute("points",si(X)),Z},E=S(`${e}-face front`,[bt(v,k,h),bt(w,k,h),bt(w,k,b),bt(v,k,b)]);j.append(B,S(`${e}-face top`,[bt(v,y,b),bt(w,y,b),bt(w,k,b),bt(v,k,b)]),S(`${e}-face side`,[bt(w,y,h),bt(w,k,h),bt(w,k,b),bt(w,y,b)]),E);let[x,N]=bt(v,k,b),z=40,Q=o.createElementNS(Vt,"g");Q.setAttribute("transform",`matrix(${(Kt*yt/z).toFixed(4)} ${(.5*yt/z).toFixed(4)} 0 ${(yt/z).toFixed(4)} ${x.toFixed(1)} ${N.toFixed(1)})`);let re=(F,X,Z,be)=>{let V=o.createElementNS(Vt,"text");return V.setAttribute("class",F),V.setAttribute("x",String(X)),V.setAttribute("y",String(Z)),V.textContent=be,V};if(Q.append(re(`${e}-mark`,34,98,c.mark),re(`${e}-who`,70,52,c.who),re(`${e}-age`,70,82,c.age)),c.line!==void 0&&Q.append(re(`${e}-q`,12,118,c.line)),c.count>1){let F=o.createElementNS(Vt,"circle");F.setAttribute("class",`${e}-count-bg`),F.setAttribute("cx","178"),F.setAttribute("cy","14"),F.setAttribute("r","15"),Q.append(F,re(`${e}-count`,178,14,String(c.count)))}j.append(Q);let we=o.createElementNS(Vt,"title");we.textContent=c.title,M.append(j,we),t.onCard?.(M,{cx:u,cy:f,tipZ:d.z1+.15,card:{x0:v,x1:w,y0:y,y1:k,z0:h,z1:b},panes:L.reverse()}),i(M)}}return{paintMarks:n,paintGhosts:s,paintCards:r}}var cf=[["scale","Scale"],["spin","Spin"],["dissolve","Dissolve"],["inflate","Inflate"]],df=[["none","None"],["jiggle","Jiggle"],["pirouette","Pirouette"],["glow","Glow"],["breathe","Breathe"]];function Em(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 Wc=t=>t<0?0:t>1?1:1-Math.pow(1-t,3),lf=t=>t<0?0:t>1?1:t*t*t,Jc=Math.PI*2,Xc={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}},Fn={windup:220,turn:980,land:260};function uf(t,e,{prefix:n,key:s,alt:r}){let o={...e},i=1,a=new Map,l=new WeakSet,c=0,d=0,u=new WeakMap,f=new WeakMap;function p(B){c=0;for(let[S,E]of a){if(!S.isConnected){a.delete(S);continue}let x;if(E.repeat){if(x=(B+(E.offset??0))%E.repeat/E.dur,x>1){l.has(S)&&(t.restore(S),l.delete(S),S.style.removeProperty("transform"));continue}}else if(x=(B-E.start)/E.dur,x>=1){g(S,E);continue}let N=E.frame(Math.max(0,x));t.spin(S,N.theta,N.lift),l.add(S),f.set(S,N),N.scale!==1?S.style.transform=`scale(${N.scale.toFixed(4)})`:S.style.removeProperty("transform"),d++}a.size&&(c=requestAnimationFrame(p))}function g(B,S){a.delete(B),l.has(B)&&(t.restore(B),l.delete(B)),B.style.removeProperty("transform"),S.done?.()}function h(B){let S=a.get(B.card);S&&g(B.card,S),a.set(B.card,B),c||(c=requestAnimationFrame(p))}let b=8,v=0,w=B=>(v++,B.finally(()=>{v--}));function k(B){return!o.enabled||v>=b?Promise.resolve():w(M(B))}function y(B){return!o.enabled||v>=b?Promise.resolve():w(T(B))}function M(B){let S=Xc.appear[o.appear]/i;if(o.appear==="spin")return new Promise(N=>h({card:B,start:performance.now(),dur:S,frame:z=>({theta:(1-Wc(z))*Jc,lift:0,scale:Math.max(.001,Wc(z))}),done:N}));let E=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 B.animate(E,{duration:S,easing:o.appear==="inflate"?"linear":"ease-out"}).finished.then(()=>{},()=>{})}function T(B){let S=Xc.disappear[o.appear]/i;if(o.appear==="spin")return new Promise(N=>h({card:B,start:performance.now(),dur:S,frame:z=>({theta:lf(z)*Jc,lift:0,scale:Math.max(.001,1-lf(z))}),done:()=>{B.style.transform="scale(0)",N()}}));let E=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 B.animate(E,{duration:S,easing:"ease-in",fill:"forwards"}).finished.then(()=>{},()=>{})}function A(B){u.get(B)?.cancel(),u.delete(B);let S=a.get(B);S?.repeat&&g(B,S)}function I(B,S){if(A(B),!o.enabled||o.idle==="none"||B.classList.contains("still"))return;let E=B.getAttribute(s)??B.getAttribute(r)??"",x=(S??Xc.period[o.idle])/i,N=Em(E)*x;if(o.idle==="pirouette"){let F=(Fn.windup+Fn.turn+Fn.land)/i,X=Fn.windup/(Fn.windup+Fn.turn+Fn.land),Z=(Fn.windup+Fn.turn)/(Fn.windup+Fn.turn+Fn.land);h({card:B,start:0,dur:F,repeat:x,offset:N,frame:be=>{if(be<X)return{theta:-.35*Math.sin(be/X*Math.PI/2),lift:0,scale:1};if(be<Z){let J=(be-X)/(Z-X);return{theta:-.35*(1-J)+Wc(J)*Jc,lift:.9*Math.sin(J*Math.PI),scale:1}}let V=(be-Z)/(1-Z);return{theta:0,lift:0,scale:1-.04*Math.sin(V*Math.PI)}}});return}let z=B.querySelector(`.${n}-float`)??B,Q=t.amber(),re=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 ${Q})`},{filter:`drop-shadow(0 0 7px ${Q})`},{filter:`drop-shadow(0 0 0px ${Q})`}]:[{transform:"scale(1)"},{transform:"scale(1.035)"},{transform:"scale(1)"}],we=z.animate(re,{duration:x,iterations:1/0,easing:o.idle==="jiggle"?"linear":"ease-in-out"});we.startTime=(document.timeline.currentTime??0)-((document.timeline.currentTime??0)+N)%x,u.set(B,we)}function j(B,S,E,x,N=!1){N&&(x=!1);for(let[Q,re]of S)!B.has(Q)&&!N&&k(re),!u.has(re)&&!a.get(re)?.repeat&&I(re);if(!o.enabled||!x)return;let z=t.leavingLayer();if(z)for(let[Q,re]of E){let we=B.get(Q);!we||S.has(Q)||(A(we),we.setAttribute("class",`${n}-leaving${re?" expired":""}`),we.removeAttribute(r),z.append(we),y(we).then(()=>we.remove()))}}function L(B){for(let[S,E]of[...a])g(S,E);c&&cancelAnimationFrame(c),c=0;for(let S of document.getAnimations())S.effect?.target?.closest?.(`.live-layer, .${n}-leaving-layer`)&&S.cancel();t.leavingLayer()?.replaceChildren()}return{get settings(){return{...o}},set(B,S){let E=o;if(o={...o,...B},(!o.enabled||E.idle!==o.idle||E.enabled!==o.enabled)&&(L(void 0),o.enabled))for(let x of S)I(x)},update:j,appear:k,disappear:y,startIdle:I,stopIdle:A,stopAll:L,async preview(B){o.enabled&&await Promise.all(B.map(async S=>{if(A(S),await k(S),o.idle!=="none"&&!S.classList.contains("still")){let E=o.idle==="pirouette"?1800:1400;I(S,E),await new Promise(x=>setTimeout(x,E*2.2/i)),A(S)}else await new Promise(E=>setTimeout(E,700/i));await y(S);for(let E of S.getAnimations())E.cancel();S.style.removeProperty("transform"),I(S)}))},get stats(){return{jobs:a.size,raf:!!c,frames:d,effects:v}},setSpeed(B){i=B},lastFrame:B=>f.get(B)}}var Qc=t=>String(Math.round(t*100)/100),ff=(t,e={},...n)=>({name:t,attrs:Object.entries(e).map(([s,r])=>[s,typeof r=="number"?Qc(r):r]),children:n});function Zc(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=>Zc(s,e))}}function ed(t,e){if(typeof t=="string")return t;if(!e(t))return{...t,children:t.children.map(n=>ed(n,e)).filter(n=>n!==void 0)}}var pf=t=>(t.attrs.find(e=>e[0]==="class")?.[1]??"").split(/\s+/),Zn=(t,e)=>t.attrs.find(n=>n[0]===e)?.[1];function qa(t){let e=[],n=[],s=i=>{if(typeof i=="string")return;let a=Zn(i,"transform");if(a&&/matrix/.test(a))return;let l=Zn(i,"points");if(l)for(let c of l.trim().split(/\s+/)){let[d,u]=c.split(",").map(Number);Number.isFinite(d)&&Number.isFinite(u)&&(e.push(d),n.push(u))}if(i.name==="rect"){let c=Number(Zn(i,"x")),d=Number(Zn(i,"y")),u=Number(Zn(i,"width")),f=Number(Zn(i,"height"));[c,d,u,f].every(Number.isFinite)&&(e.push(c,c+u),n.push(d,d+f))}if(i.name==="circle"){let c=Number(Zn(i,"cx")),d=Number(Zn(i,"cy")),u=Number(Zn(i,"r"));[c,d,u].every(Number.isFinite)&&(e.push(c-u,c+u),n.push(d-u,d+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 Ua=(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 mf(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=Ua(t,qa(o));return r=s(i),o=n(r),i=Ua(t,qa(o)),r=s(i),{k:r,box:i,live:o}}var hf=t=>t.replace(/--([a-zA-Z][\w-]*)/g,"--iso-$1");function Tm(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 Am(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 td(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 nd(t,e,n){let s="";for(let[r,o]of Tm(t)){if(r.startsWith("@keyframes")){s+=`@keyframes iso-${r.slice(10).trim()}{${o}}
|
|
283
|
+
`;continue}if(r.startsWith("@media")||r.startsWith("@supports")){s+=`${r}{${nd(o,e,n)}}
|
|
284
|
+
`;continue}if(r.startsWith("@"))throw new Error(`the canvas's CSS has an at-rule it can't scope: ${r}`);s+=`${Am(r).map(i=>td(i,e,n)).join(",")}{${o.replace(/\banimation:\s*([a-z][\w-]*)/g,"animation:iso-$1")}}
|
|
285
|
+
`}return s}var sd=["<","script"].join("");function fs(t){return t?_t(t).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<b>$1</b>").replace(/(^|[^*])\*([^*\s][^*]*)\*/g,"$1<em>$2</em>").replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,n,s)=>/^(https?:|#|\.{0,2}\/)/.test(s.replace(/&/g,"&"))?`<a href="${s}">${n}</a>`:n):""}var rd=t=>(t??"").split(/\n\s*\n/).filter(Boolean).map(e=>`<p class="sec-sub">${fs(e.trim())}</p>`).join("");function od(t){return JSON.stringify({scenes:t.scenes.map(e=>({id:e.id,loop:e.raw.loop??!0,dim:e.raw.dim??"flows",vis:e.steps.vis,steps:e.steps.steps.map(n=>({...n,caption:fs(n.caption)})),assemble:e.assemble,grid:!!e.grid.show,assembly:e.rendered.assembly}))})}function id(t,e){let n=t.theme,s=e.raw.legend;if(s===!1)return"";let r=Array.isArray(s)?s:e.steps.kindsUsed.filter(a=>e.routes.some(l=>l.kind===a)||e.steps.steps.some(l=>l.phases.some(c=>c.some(d=>d.kind===a)))),o=a=>`<span><i${a.box?' class="box"':""} style="${a.swatch}"></i>${a.label}</span>`,i=r.map(a=>{let l=Dt(t.catalog,a)?.legend;if(l)return o(l);let c=n.kinds[a];return c?`<span><i style="${`border-color:${cs(n,c.color)}${c.dash==="dashed"?";border-top-style:dashed":c.dash==="dotted"?";border-top-style:dotted":""}`}"></i>${fs(c.legend)}</span>`:""});if(!Array.isArray(s)){let a=new Set(e.layout.items.map(l=>l.region?.kind));for(let[l,c]of Object.entries(t.catalog.regions))c.legend?.auto&&a.has(l)&&i.push(o(c.legend))}return i.join("")}function Pm(t){let e=t.steps.steps,n=`<div class="tools">
|
|
286
286
|
<button class="pbtn small" type="button" data-a="grid" aria-pressed="${t.grid.show?"true":"false"}" title="Show the floor grid">Grid</button>
|
|
287
287
|
<button class="pbtn small" type="button" data-a="assemble" title="Draw the diagram again, piece by piece">Assemble</button>
|
|
288
288
|
</div>`;if(!e.length)return`<div class="player">${n}</div>`;let s=e[0];return`<div class="player">
|
|
@@ -293,33 +293,33 @@ svg.pre-assemble > g:not(.g-anim){opacity:0}
|
|
|
293
293
|
</div>
|
|
294
294
|
${n}
|
|
295
295
|
<div class="cap" aria-live="polite">
|
|
296
|
-
<div class="cap-h"><span class="num" style="background:${s.color}">${s.num}</span><span class="h">${
|
|
297
|
-
<p class="cap-t">${
|
|
298
|
-
<pre class="cap-c">${
|
|
296
|
+
<div class="cap-h"><span class="num" style="background:${s.color}">${s.num}</span><span class="h">${_t(s.heading)}</span><span class="cnt">1 / ${e.length}</span></div>
|
|
297
|
+
<p class="cap-t">${fs(s.caption)}</p>
|
|
298
|
+
<pre class="cap-c">${_t(s.command)}</pre>
|
|
299
299
|
<div class="prog"><i></i></div>
|
|
300
300
|
</div>
|
|
301
301
|
<div class="dots"></div>
|
|
302
|
-
</div>`}function
|
|
303
|
-
<section class="scene" id="scene-${
|
|
304
|
-
<h2>${
|
|
305
|
-
${
|
|
302
|
+
</div>`}function Cm(t){let e=t.steps.steps;return e.length?`<details class="steps"><summary>All ${e.length} steps as text</summary><ol>${e.map(n=>`<li value="${n.num}"><b>${_t(n.heading)}.</b> ${fs(n.caption)}${n.command?`<br><code>${_t(n.command)}</code>`:""}</li>`).join("")}</ol></details>`:""}function gf(t,e={}){let n=t.doc,s=n.title??n.scenes[0]?.title??"Diagram",r=(n.pills??[]).map(i=>`<span class="pill">${fs(i)}</span>`).join(""),o=t.scenes.map(i=>`
|
|
303
|
+
<section class="scene" id="scene-${_t(i.id)}">
|
|
304
|
+
<h2>${_t(i.raw.title)}</h2>
|
|
305
|
+
${rd(i.raw.caption)}
|
|
306
306
|
<div class="figure" tabindex="-1">
|
|
307
307
|
<div class="scroller">${i.grid.show?i.rendered.svg.replace("<svg ",'<svg class="show-grid" '):i.rendered.svg}</div>
|
|
308
|
-
${
|
|
309
|
-
<div class="legend">${
|
|
308
|
+
${Pm(i)}
|
|
309
|
+
<div class="legend">${id(t,i)}</div>
|
|
310
310
|
</div>
|
|
311
|
-
${
|
|
312
|
-
${i.raw.after?`<div class="after">${
|
|
311
|
+
${Cm(i)}
|
|
312
|
+
${i.raw.after?`<div class="after">${rd(i.raw.after)}</div>`:""}
|
|
313
313
|
</section>`).join(`
|
|
314
314
|
`);return`<!doctype html>
|
|
315
315
|
<html lang="en">
|
|
316
316
|
<head>
|
|
317
317
|
<meta charset="utf-8">
|
|
318
318
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
319
|
-
<title>${
|
|
320
|
-
${n.lede?`<meta name="description" content="${
|
|
319
|
+
<title>${_t(s)}</title>
|
|
320
|
+
${n.lede?`<meta name="description" content="${_t(n.lede)}">`:""}
|
|
321
321
|
<style>
|
|
322
|
-
${
|
|
322
|
+
${da(t.theme)}${Ka(t.catalog)}${_a}
|
|
323
323
|
</style>
|
|
324
324
|
${e.extraHead??""}
|
|
325
325
|
</head>
|
|
@@ -327,17 +327,17 @@ ${e.extraHead??""}
|
|
|
327
327
|
<div class="wrap">
|
|
328
328
|
<header class="page">
|
|
329
329
|
<div>
|
|
330
|
-
<h1>${
|
|
331
|
-
${n.lede?`<p class="lede">${
|
|
330
|
+
<h1>${_t(s)}</h1>
|
|
331
|
+
${n.lede?`<p class="lede">${fs(n.lede)}</p>`:""}
|
|
332
332
|
</div>
|
|
333
333
|
<div class="pills">${r}<button class="theme" id="themeBtn" type="button">Theme</button></div>
|
|
334
334
|
</header>
|
|
335
335
|
${o}
|
|
336
|
-
${n.after?
|
|
337
|
-
${n.footer?`<footer>${
|
|
336
|
+
${n.after?rd(n.after):""}
|
|
337
|
+
${n.footer?`<footer>${fs(n.footer)}</footer>`:""}
|
|
338
338
|
</div>
|
|
339
|
-
${
|
|
340
|
-
${
|
|
339
|
+
${sd} type="application/json" id="diagram-steps">${od(t).replace(/</g,"\\u003c")}<\/script>
|
|
340
|
+
${sd}>
|
|
341
341
|
(function(){
|
|
342
342
|
var root=document.documentElement, m=/theme=(light|dark)/.exec(location.hash);
|
|
343
343
|
try{var t=localStorage.getItem('diagram-theme'); if(t) root.dataset.theme=t;}catch(e){}
|
|
@@ -349,14 +349,14 @@ ${Ac}>
|
|
|
349
349
|
});
|
|
350
350
|
})();
|
|
351
351
|
<\/script>
|
|
352
|
-
${e.runtime?`${
|
|
352
|
+
${e.runtime?`${sd}>${e.runtime}<\/script>`:""}
|
|
353
353
|
${e.extraBody??""}
|
|
354
354
|
</body>
|
|
355
355
|
</html>
|
|
356
|
-
`}function z(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 Fu=1,Ma="(?:[^/:%\\s]|%[0-9A-F]{2})+",mn=["debug","info","notice","warning","error"],ju=["1m","1h","1d"],On={"1m":6e4,"1h":36e5,"1d":864e5},$a=t=>`^(?:(?:${t.kinds.join("|")}):(?:${Ma})(?:/(?:${t.kinds.join("|")}):(?:${Ma}))*)?$`;function Ea(t){let e=new RegExp($a(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 Ta=t=>t.replace(/[%/:\s]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`),Bu=t=>t.map(e=>`${e.kind}:${Ta(e.name)}`).join("/"),Ku=(t,e,n)=>(t?`${t}/`:"")+`${e}:${Ta(n)}`,Xt=t=>t===""?0:t.split("/").length;function vs(t,e){return e<=0?"":(t===""?[]:t.split("/")).slice(0,e).join("/")}var _u=t=>vs(t,Xt(t)-1),hn=(t,e)=>e===""||t===e||t.startsWith(`${e}/`),zu=(t,e)=>t!==""&&t.split("/").includes(e),Dr=t=>t===""?"fleet":t.slice(t.lastIndexOf("/")+1).split(":")[0],Fr=t=>t===""?"all hosts":decodeURIComponent(t.slice(t.lastIndexOf("/")+1).split(":").slice(1).join(":"));function jr(t){let e=[{scope:"",label:"all hosts",kind:"fleet"}];for(let n=1;n<=Xt(t);n++){let s=vs(t,n);e.push({scope:s,label:Fr(s),kind:Dr(s)})}return e}var Nc=["kind","source","severity","scope","since","before"];function qp(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 Up=/^(\d+)(s|m|h|d|w)$/,Wp={s:1e3,m:6e4,h:36e5,d:864e5,w:7*864e5};function Lc(t,e){let n=Up.exec(t);if(n)return e-Number(n[1])*Wp[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",d="0",u]=s;if(u){let p=Date.parse(t.replace(" ","T"));return Number.isNaN(p)?void 0:p}let f=new Date(+r,+o-1,+i,+a,+l,+c,+d.padEnd(3,"0")).getTime();return Number.isNaN(f)?void 0:f}function Jp(t,e,n=Date.now()){let s=[],r=[];for(let o of qp(e??"")){let i=c=>{let d=o.field?`${o.field}:${o.raw}`:o.raw;c&&r.push(`${JSON.stringify(d)}: ${c}; searched as text`),d&&s.push({neg:o.neg,value:d})};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(!mn.includes(c[2])){i(`no severity ${c[2]} (${mn.join(", ")})`);continue}s.push({neg:o.neg,field:l,op:c[1]??"=",value:c[2]})}else if(l==="since"||l==="before"){let c=Lc(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 Aa=t=>mn.indexOf(t),Xp={"=":"eq",">=":"ge",">":"gt","<=":"le","<":"lt"};function Qp(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:Xp[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 Zp(t,e){let n=[],s=new Map;for(let r of e.terms){let o=Qp(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 em(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=Aa(n.severity),o=Aa(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"?hn(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 Br(t){let e=[...Nc,...t.links],n=(a,l=Date.now())=>Jp(e,a,l),s=a=>Zp(t,a);function r(a,l,c,d){let u=n(a,l);return{where:s(u),...Ko(u,c,d),warnings:u.warnings}}function o(a,l=[]){let c=new Set(l),d=a?.all??[];return d.length?u=>d.every(f=>f.any.some(p=>em(t,p,u,c))!==!!f.not):()=>!0}return{FIELDS:e,parseSearch:n,toAst:s,compileSearch:r,matchAst:o,matcher:(a,l=[])=>o(s(a),l)}}function Ko(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 _o(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 Vu=t=>mn.filter(e=>Aa(e)>=Aa(t));var Gu=new Map,Pa=new Map;function tn(t,e){if(!t||t==="UTC")return 0;let n=`${t}|${Math.floor(e/(15*6e4))}`,s=Pa.get(n);if(s!==void 0)return s;let r=Gu.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}Gu.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 Pa.size>5e4&&Pa.clear(),Pa.set(n,a),a}var Hu=t=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),!0}catch{return!1}};function ir(t,e,n){if(e==="1m")return Math.floor(t/6e4)*6e4;let s=tn(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-tn(n,r-s);return o>t?o=r-864e5-tn(n,r-864e5-s):Oa(o,n)<=t&&(o=Oa(o,n)),o}function Oa(t,e,n="1d"){if(n==="1m")return t+6e4;if(n==="1h")return t+36e5;let s=tn(e,t),r=Math.floor((t+s)/864e5)*864e5+864e5;return r-tn(e,r-s)}var Bs=6e4,Ks=36e5,Cn=864e5;function Ca(t,e,n,s={}){let r=Math.max((s.minFrac??.15)*(n-e),s.minMs??10*Bs),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 ar(t){if(t>=Cn){let e=Math.floor(t/Cn),n=Math.round((t-e*Cn)/Ks);return n?`${e} d ${n} h`:`${e} d`}if(t>=Ks){let e=Math.floor(t/Ks),n=Math.round((t-e*Ks)/Bs);return n&&e<10?`${e} h ${n} min`:`${e} h`}return`${Math.max(1,Math.round(t/Bs))} min`}var lr=t=>`${t.from}-${t.to}`;function Kr(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(lr(M))??0})).sort((M,x)=>M.from-x.from),c=l.reduce((M,x)=>M+(x.to-x.from)*(1-x.w),0),d=l.reduce((M,x)=>M+(1-x.w)*o,0),u=(i-d)/Math.max(1,a-c);if(!(u>0)||d>i*.6)return Kr(t,e,n,[],r);let f=[[t,0]],p=0,g=t,h=[];for(let M of l){p+=(M.from-g)*u,f.push([M.from,p]);let x=(1-M.w)*o+M.w*u*(M.to-M.from);h.push({from:M.from,to:M.to,x0:p,x1:p+x,weight:M.w}),p+=x,f.push([M.to,p]),g=M.to}f.push([e,p+(e-g)*u]);let b=M=>{if(M<=t)return(M-t)*u;if(M>=e)return f[f.length-1][1]+(M-e)*u;let x=0,T=f.length-1;for(;T-x>1;){let C=x+T>>1;f[C][0]<=M?x=C:T=C}let[y,A]=f[x],[D,K]=f[T];return D===y?A:A+(M-y)/(D-y)*(K-A)},k=M=>h.find(x=>x.weight<1&&M>x.x0&&M<x.x1);return{t0:t,t1:e,width:i,cuts:h,x:b,t:M=>{let x=k(M);if(x)return M-x.x0<x.x1-M?x.from:x.to;if(M<=0)return t+M/u;let T=0,y=f.length-1;if(M>=f[y][1])return e+(M-f[y][1])/u;for(;y-T>1;){let _=T+y>>1;f[_][1]<=M?T=_:y=_}let[A,D]=f[T],[K,C]=f[y];return C===D?A:A+(M-D)/(C-D)*(K-A)},cutAt:k,msPerPx:1/u}}var Rc=[1e3,5e3,15e3,3e4,Bs,5*Bs,15*Bs,30*Bs,Ks,3*Ks,6*Ks,12*Ks,Cn,2*Cn,7*Cn,14*Cn,28*Cn];function Na(t,e,n=80){let s=Rc.find(l=>l/t.msPerPx>=n)??Rc[Rc.length-1],r=[],o=l=>{let c=new Date(l+tn(e,l)),d=String(c.getUTCHours()).padStart(2,"0"),u=String(c.getUTCMinutes()).padStart(2,"0"),f=String(c.getUTCSeconds()).padStart(2,"0"),p=`${c.getUTCDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getUTCMonth()]}`,g=d==="00"&&u==="00"&&f==="00";return s>=Cn||g?{label:p,major:!0}:{label:s<Bs?`${d}:${u}:${f}`:`${d}:${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 d=f=>f-tn(e,f-tn(e,f)),u=Math.ceil((l+tn(e,l))/s)*s;s>=7*Cn&&(u=Math.ceil((l+tn(e,l))/Cn)*Cn);for(let f=0,p=d(u);p<c&&f<2e3;f++,u+=s,p=d(u)){if(p<l)continue;let g=t.x(p),h=r[r.length-1];(!h||g-h.x>=n*.6)&&r.push({t:p,x:g,...o(p)})}}return r}var tm=["id","time","t","dur","scope","source","kind","severity","summary"],nm=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},Yu=(t,e)=>e.size?{...t,attrs:Object.fromEntries(Object.entries(t.attrs).filter(([n])=>!e.has(`${t.source}.${n}`)))}:t;function La(t,e=[]){let n=new Set(e);return JSON.stringify(t.map(s=>Yu(s,n)),null,2)+`
|
|
357
|
-
`}function
|
|
356
|
+
`}function _(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 bf=1,Wa="(?:[^/:%\\s]|%[0-9A-F]{2})+",kn=["debug","info","notice","warning","error"],yf=["1m","1h","1d"],jn={"1m":6e4,"1h":36e5,"1d":864e5},Ja=t=>`^(?:(?:${t.kinds.join("|")}):(?:${Wa})(?:/(?:${t.kinds.join("|")}):(?:${Wa}))*)?$`;function Xa(t){let e=new RegExp(Ja(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 Qa=t=>t.replace(/[%/:\s]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`),xf=t=>t.map(e=>`${e.kind}:${Qa(e.name)}`).join("/"),wf=(t,e,n)=>(t?`${t}/`:"")+`${e}:${Qa(n)}`,rn=t=>t===""?0:t.split("/").length;function Os(t,e){return e<=0?"":(t===""?[]:t.split("/")).slice(0,e).join("/")}var vf=t=>Os(t,rn(t)-1),Sn=(t,e)=>e===""||t===e||t.startsWith(`${e}/`),kf=(t,e)=>t!==""&&t.split("/").includes(e),Wr=t=>t===""?"fleet":t.slice(t.lastIndexOf("/")+1).split(":")[0],Jr=t=>t===""?"all hosts":decodeURIComponent(t.slice(t.lastIndexOf("/")+1).split(":").slice(1).join(":"));function Xr(t){let e=[{scope:"",label:"all hosts",kind:"fleet"}];for(let n=1;n<=rn(t);n++){let s=Os(t,n);e.push({scope:s,label:Jr(s),kind:Wr(s)})}return e}var ad=["kind","source","severity","scope","since","before"];function Om(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 Lm=/^(\d+)(s|m|h|d|w)$/,Nm={s:1e3,m:6e4,h:36e5,d:864e5,w:7*864e5};function ld(t,e){let n=Lm.exec(t);if(n)return e-Number(n[1])*Nm[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",d="0",u]=s;if(u){let p=Date.parse(t.replace(" ","T"));return Number.isNaN(p)?void 0:p}let f=new Date(+r,+o-1,+i,+a,+l,+c,+d.padEnd(3,"0")).getTime();return Number.isNaN(f)?void 0:f}function Rm(t,e,n=Date.now()){let s=[],r=[];for(let o of Om(e??"")){let i=c=>{let d=o.field?`${o.field}:${o.raw}`:o.raw;c&&r.push(`${JSON.stringify(d)}: ${c}; searched as text`),d&&s.push({neg:o.neg,value:d})};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(!kn.includes(c[2])){i(`no severity ${c[2]} (${kn.join(", ")})`);continue}s.push({neg:o.neg,field:l,op:c[1]??"=",value:c[2]})}else if(l==="since"||l==="before"){let c=ld(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 Za=t=>kn.indexOf(t),Im={"=":"eq",">=":"ge",">":"gt","<=":"le","<":"lt"};function Dm(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:Im[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 Fm(t,e){let n=[],s=new Map;for(let r of e.terms){let o=Dm(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 jm(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=Za(n.severity),o=Za(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"?Sn(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 Qr(t){let e=[...ad,...t.links],n=(a,l=Date.now())=>Rm(e,a,l),s=a=>Fm(t,a);function r(a,l,c,d){let u=n(a,l);return{where:s(u),...ri(u,c,d),warnings:u.warnings}}function o(a,l=[]){let c=new Set(l),d=a?.all??[];return d.length?u=>d.every(f=>f.any.some(p=>jm(t,p,u,c))!==!!f.not):()=>!0}return{FIELDS:e,parseSearch:n,toAst:s,compileSearch:r,matchAst:o,matcher:(a,l=[])=>o(s(a),l)}}function ri(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 oi(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 Sf=t=>kn.filter(e=>Za(e)>=Za(t));var Mf=new Map,el=new Map;function dn(t,e){if(!t||t==="UTC")return 0;let n=`${t}|${Math.floor(e/(15*6e4))}`,s=el.get(n);if(s!==void 0)return s;let r=Mf.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}Mf.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 el.size>5e4&&el.clear(),el.set(n,a),a}var $f=t=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),!0}catch{return!1}};function yr(t,e,n){if(e==="1m")return Math.floor(t/6e4)*6e4;let s=dn(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-dn(n,r-s);return o>t?o=r-864e5-dn(n,r-864e5-s):tl(o,n)<=t&&(o=tl(o,n)),o}function tl(t,e,n="1d"){if(n==="1m")return t+6e4;if(n==="1h")return t+36e5;let s=dn(e,t),r=Math.floor((t+s)/864e5)*864e5+864e5;return r-dn(e,r-s)}var Qs=6e4,Zs=36e5,Bn=864e5;function nl(t,e,n,s={}){let r=Math.max((s.minFrac??.15)*(n-e),s.minMs??10*Qs),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 xr(t){if(t>=Bn){let e=Math.floor(t/Bn),n=Math.round((t-e*Bn)/Zs);return n?`${e} d ${n} h`:`${e} d`}if(t>=Zs){let e=Math.floor(t/Zs),n=Math.round((t-e*Zs)/Qs);return n&&e<10?`${e} h ${n} min`:`${e} h`}return`${Math.max(1,Math.round(t/Qs))} min`}var wr=t=>`${t.from}-${t.to}`;function Zr(t,e,n,s=[],r={}){let o=r.cut??24,i=Math.max(1,n),a=Math.max(1,e-t),l=s.filter(k=>k.to>t&&k.from<e).map(k=>({from:Math.max(t,k.from),to:Math.min(e,k.to),w:r.weights?.get(wr(k))??0})).sort((k,y)=>k.from-y.from),c=l.reduce((k,y)=>k+(y.to-y.from)*(1-y.w),0),d=l.reduce((k,y)=>k+(1-y.w)*o,0),u=(i-d)/Math.max(1,a-c);if(!(u>0)||d>i*.6)return Zr(t,e,n,[],r);let f=[[t,0]],p=0,g=t,h=[];for(let k of l){p+=(k.from-g)*u,f.push([k.from,p]);let y=(1-k.w)*o+k.w*u*(k.to-k.from);h.push({from:k.from,to:k.to,x0:p,x1:p+y,weight:k.w}),p+=y,f.push([k.to,p]),g=k.to}f.push([e,p+(e-g)*u]);let b=k=>{if(k<=t)return(k-t)*u;if(k>=e)return f[f.length-1][1]+(k-e)*u;let y=0,M=f.length-1;for(;M-y>1;){let L=y+M>>1;f[L][0]<=k?y=L:M=L}let[T,A]=f[y],[I,j]=f[M];return I===T?A:A+(k-T)/(I-T)*(j-A)},v=k=>h.find(y=>y.weight<1&&k>y.x0&&k<y.x1);return{t0:t,t1:e,width:i,cuts:h,x:b,t:k=>{let y=v(k);if(y)return k-y.x0<y.x1-k?y.from:y.to;if(k<=0)return t+k/u;let M=0,T=f.length-1;if(k>=f[T][1])return e+(k-f[T][1])/u;for(;T-M>1;){let B=M+T>>1;f[B][1]<=k?M=B:T=B}let[A,I]=f[M],[j,L]=f[T];return L===I?A:A+(k-I)/(L-I)*(j-A)},cutAt:v,msPerPx:1/u}}var cd=[1e3,5e3,15e3,3e4,Qs,5*Qs,15*Qs,30*Qs,Zs,3*Zs,6*Zs,12*Zs,Bn,2*Bn,7*Bn,14*Bn,28*Bn];function sl(t,e,n=80){let s=cd.find(l=>l/t.msPerPx>=n)??cd[cd.length-1],r=[],o=l=>{let c=new Date(l+dn(e,l)),d=String(c.getUTCHours()).padStart(2,"0"),u=String(c.getUTCMinutes()).padStart(2,"0"),f=String(c.getUTCSeconds()).padStart(2,"0"),p=`${c.getUTCDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getUTCMonth()]}`,g=d==="00"&&u==="00"&&f==="00";return s>=Bn||g?{label:p,major:!0}:{label:s<Qs?`${d}:${u}:${f}`:`${d}:${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 d=f=>f-dn(e,f-dn(e,f)),u=Math.ceil((l+dn(e,l))/s)*s;s>=7*Bn&&(u=Math.ceil((l+dn(e,l))/Bn)*Bn);for(let f=0,p=d(u);p<c&&f<2e3;f++,u+=s,p=d(u)){if(p<l)continue;let g=t.x(p),h=r[r.length-1];(!h||g-h.x>=n*.6)&&r.push({t:p,x:g,...o(p)})}}return r}var Bm=["id","time","t","dur","scope","source","kind","severity","summary"],Km=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},Ef=(t,e)=>e.size?{...t,attrs:Object.fromEntries(Object.entries(t.attrs).filter(([n])=>!e.has(`${t.source}.${n}`)))}:t;function rl(t,e=[]){let n=new Set(e);return JSON.stringify(t.map(s=>Ef(s,n)),null,2)+`
|
|
357
|
+
`}function ol(t,e=[]){let n=new Set(e),s=t.map(l=>Ef(l,n)),r=[...new Set(s.flatMap(l=>Object.keys(l.attrs)))].sort(),o=[...new Set(s.flatMap(l=>Object.keys(l.links)))].sort(),i=[...Bm,...r.map(l=>`attr.${l}`),...o.map(l=>`link.${l}`)],a=s.map(l=>[l.id,new Date(l.t).toISOString(),l.t,l.dur,l.scope,l.source,l.kind,l.severity,l.summary,...r.map(c=>l.attrs[c]),...o.map(c=>l.links[c])].map(Km).join(","));return[i.join(","),...a].join(`\r
|
|
358
358
|
`)+`\r
|
|
359
|
-
`}var sm=864e5,Vn=36e5,Ia=(t,e)=>t.t-e.t||(t.id<e.id?-1:t.id>e.id?1:0);function ss(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 Wu=(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 qu(t,e,n){let s=[];for(let r of t){let o=ir(r.t,e,n),i=s[s.length-1];i&&i.t===o?Wu(i,r):s.push({t:o,min:r.min,max:r.max,sum:r.sum,count:r.count})}return s}function Ic(t,e,n,s){for(let i=ss(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=ss(t,e.t);for(;o<t.length&&s(t[o],e)<0;)o++;t.splice(o,0,e)}function Uu(t,e,n){for(let s=ss(t,e);s<t.length&&t[s].t===e;s++)if(n(t[s])){t.splice(s,1);return}}function Ju(t,e,n={}){let s=t.catalog,{isScope:r}=Ea(e),{parseSearch:o,matchAst:i,toAst:a}=Br(e),l=I=>Object.fromEntries(e.flags.filter(re=>I?.[re]).map(re=>[re,!0])),c=n.now??s.now,d=(s.names??[]).flatMap(I=>(I.aliases??[]).map(re=>[re,I.scope])).sort((I,re)=>re[0].length-I[0].length),u=new Map,f=I=>{if(!d.length)return I;let re=u.get(I);if(re===void 0){let $e=d.find(([Pe])=>hn(I,Pe));re=$e?$e[1]+I.slice($e[0].length):I,u.set(I,re)}return re},p=new Map((s.names??[]).map(I=>[I.scope,I])),g=I=>d.length?{...I,scope:f(I.scope)}:I,h=I=>`${I.source}\0${I.id}`,b=t.events.map(g).sort(Ia),k=new Map;for(let I of b)k.set(h(I),I);let v=b.filter(I=>I.dur!==void 0&&!I.open),M=v.reduce((I,re)=>Math.max(I,re.dur),0),x=new Map;for(let I of b)I.open&&x.set(h(I),I);let T=new Map,y=new Set,A=I=>{for(let re=Xt(I);re>=1;re--){let $e=vs(I,re);if(y.has($e))break;y.add($e)}},D=new Map;for(let I of s.sources)for(let re of I.series)D.set(re.name,re.type);let K=s.sources.flatMap(I=>(I.sensitive??[]).map(re=>`${I.name}.${re}`)),C=new Map;for(let I of s.sources)C.set(I.name,{events:I.defaultRetention.events,rollups:{...I.defaultRetention.rollups},setBy:"default"});for(let I of s.retention)C.set(I.source,{events:I.events,rollups:{...I.rollups},setBy:I.setBy});let _=new Map;for(let I of s.sources)for(let re of I.series)_.set(re.name,I.name);function S(I){let re=f(I.scope),$e=`${I.series}\0${re}`,Pe=T.get($e);Pe||(Pe={series:I.series,scope:re,fine:[],cache:new Map},T.set($e,Pe),A(re));let be="value"in I?{t:I.t,min:I.value,max:I.value,sum:I.value,count:1}:{t:I.t,min:I.min,max:I.max,sum:I.sum,count:I.count};Ic(Pe.fine,be,ce=>ce.t===be.t,(ce,ze)=>ce.t-ze.t),Pe.cache.clear()}for(let I of b)A(I.scope);for(let I of t.metrics)S(I);let $=new Map,w=new Set,N=(I,re)=>{w.add(I.source);let $e=$.get(I.scope);$e||$.set(I.scope,$e=new Map);let Pe=$e.get(I.source);Pe||$e.set(I.source,Pe=new Map);let be=Math.floor(I.t/Vn)*Vn,ce=Pe.get(be);if(ce||Pe.set(be,ce={t:be,count:0,severity:{},kinds:{},first:1/0,last:-1/0}),ce.count+=re,re>0)ce.first=Math.min(ce.first,I.t),ce.last=Math.max(ce.last,I.t);else if(I.t===ce.first||I.t===ce.last){ce.first=1/0,ce.last=-1/0;for(let ze=ss(b,be);ze<b.length&&b[ze].t<be+Vn;ze++){let Oe=b[ze];Oe.scope===I.scope&&Oe.source===I.source&&(ce.first=Math.min(ce.first,Oe.t),ce.last=Math.max(ce.last,Oe.t))}}ce.severity[I.severity]=(ce.severity[I.severity]??0)+re,ce.kinds[I.kind]=(ce.kinds[I.kind]??0)+re,ce.severity[I.severity]===0&&delete ce.severity[I.severity],ce.kinds[I.kind]===0&&delete ce.kinds[I.kind],ce.count||Pe.delete(be)};for(let I of b)N(I,1);let F=(I,re,$e)=>{let Pe=`${re}|${$e??""}`,be=I.cache.get(Pe);return be||(be=re==="1d"?qu(F(I,"1h",$e),"1d",$e):qu(I.fine,re,$e),I.cache.set(Pe,be)),be},J=I=>I===null?-1/0:c-I*sm,ae=I=>J(C.get(I)?.events??null),we=(I,re)=>{let $e=C.get(I);return J($e?re?$e.rollups[re]:$e.events:null)};function j(I){let re=[];for(let $e of new Set(I)){let Pe=C.get($e);if(!Pe)continue;let be=b.find(Ee=>Ee.source===$e&&Ee.t>=ae($e))?.t,ce=Ee=>{let Be=1/0;for(let it of T.values())if(_.get(it.series)===$e){let We=(Ee?F(it,Ee):it.fine).find(Ne=>Ne.t>=we($e,Ee));We&&We.t<Be&&(Be=We.t)}return Be===1/0?void 0:Be},ze=[be,ce()].filter(Ee=>Ee!==void 0),Oe={};for(let Ee of["1m","1h","1d"]){let Be=ce(Ee)??(be!==void 0&&be>=we($e,Ee)?be:void 0);Be!==void 0&&(Oe[Ee]=Math.max(Be,we($e,Ee)))}re.push({source:$e,events:Pe.events,rollups:{...Pe.rollups},setBy:Pe.setBy,keptFrom:{...ze.length?{events:Math.min(...ze)}:{},rollups:Oe}})}return re}function U(I){let re=I.where,$e={from:I.from,to:I.to},Pe=[];if(!re&&I.q){let We=o(I.q,c);re=a(We),$e=Ko(We,I.from,I.to),Pe=We.warnings}let be=i(re,K),ce=I.filters??{},ze=ce.source?.length?new Set(ce.source):void 0,Oe=ce.kind?.length?new Set(ce.kind):void 0,Ee=ce.severity?.length?new Set(ce.severity):void 0,Be=ce.scope?.length?ce.scope:void 0;return{test:We=>hn(We.scope,I.scope)&&(!ze||ze.has(We.source))&&(!Oe||Oe.has(We.kind))&&(!Ee||Ee.has(We.severity))&&(!Be||Be.some(Ne=>hn(We.scope,Ne)))&&We.t>=ae(We.source)&&be(We),range:$e,warnings:Pe}}function ee(I){let re=Xt(I.scope),$e=re+I.depth,Pe=new Map,be=Ee=>{let Be=Pe.get(Ee);return Be===void 0&&!Pe.has(Ee)&&(Be=hn(Ee,I.scope)?Xt(Ee)>=$e?vs(Ee,$e):Ee:void 0,Pe.set(Ee,Be)),Be},ce=Ee=>{let Be=0,it=Xt(Ee)+1;for(let We of y)Xt(We)===it&&hn(We,Ee)&&Be++;return Be},ze=new Map,Oe=Ee=>{let Be=ze.get(Ee);if(!Be){let it=Xt(Ee)-re,We=p.get(Ee);Be={scope:Ee,label:We?.label??Fr(Ee),kind:Dr(Ee),...l(We),depth:it,...it<I.depth?{own:!0}:{},children:ce(Ee),count:0},ze.set(Ee,Be)}return Be};for(let Ee of y)Xt(Ee)===$e&&hn(Ee,I.scope)&&Oe(Ee);return $e===0&&Oe(""),{at:be,add:Oe,rows:ze}}let fe=I=>[...I.values()].sort((re,$e)=>re.scope===$e.scope?0:re.scope<$e.scope?-1:1);function B(I,re){let $e=[];for(let Pe=ss(v,I-M);Pe<v.length&&v[Pe].t<I;Pe++)v[Pe].t+v[Pe].dur>I&&$e.push(v[Pe]);for(let Pe of x.values())Pe.t<I&&c>I&&$e.push(Pe);for(let Pe=ss(b,I);Pe<b.length&&b[Pe].t<re;Pe++)$e.push(b[Pe]);return $e}function X(I,re,$e,Pe){let be=I.series?new Set(I.series):void 0,ce=new Map;for(let Oe of T.values()){if(be&&!be.has(Oe.series))continue;let Ee=re(Oe.scope);if(Ee===void 0)continue;let Be=_.get(Oe.series)??"",it=we(Be,I.bin),We=I.bin?F(Oe,I.bin,I.tz):Oe.fine;for(let Ne=ss(We,I.bin?ir($e,I.bin,I.tz):$e);Ne<We.length&&We[Ne].t<Pe;Ne++){let gt=We[Ne];if(gt.t<it)continue;let Ze=`${Oe.series}\0${Ee}\0${gt.t}`,ft=ce.get(Ze);ft?Wu(ft,gt):ce.set(Ze,{series:Oe.series,scope:Ee,t:gt.t,bin:I.bin??"1m",min:gt.min,max:gt.max,sum:gt.sum,count:gt.count})}}let ze=[...ce.values()].sort((Oe,Ee)=>Oe.t-Ee.t||(Oe.series<Ee.series?-1:1)||(Oe.scope<Ee.scope?-1:1));return I.bin?ze:ze.map(Oe=>({series:Oe.series,scope:Oe.scope,t:Oe.t,value:Oe.count===1||D.get(Oe.series)!=="gauge"?Oe.sum:Oe.sum/Oe.count}))}let Q=I=>`${I.t}:${I.id}`,te=(I,re)=>{let $e=re.indexOf(":"),Pe=Number(re.slice(0,$e)),be=re.slice($e+1);return I.t>Pe||I.t===Pe&&I.id>be};function ne(I){if(I.bin!=="1h"&&I.bin!=="1d"||(I.where?.all.length??0)||I.q||I.filters?.kind?.length||I.filters?.severity?.length||I.filters?.scope?.length||tn(I.tz,I.from)%Vn||tn(I.tz,I.to)%Vn)return;let re=I.filters?.source?.length?new Set(I.filters.source):void 0,$e=E=>Math.max(I.from,ae(E)),{at:Pe,add:be,rows:ce}=ee(I),ze=new Set,Oe=new Map,Ee=0,Be=(E,Y)=>{let q=ir(Y,I.bin,I.tz),de=`${E}\0${q}`,m=Oe.get(de);return m||(m={scope:E,t:q,bin:I.bin,count:0,severity:{},kinds:{}},Oe.set(de,m)),m},it=(E,Y,q)=>{let de=be(E);de.count+=q,Ee+=q,(de.first===void 0||Y<de.first)&&(de.first=Y),(de.last===void 0||Y>de.last)&&(de.last=Y)},We=Math.floor(I.to/Vn)*Vn;for(let[E,Y]of $){let q=Pe(E);if(q!==void 0)for(let[de,m]of Y){if(re&&!re.has(de))continue;let O=Math.ceil($e(de)/Vn)*Vn;for(let[L,G]of m){if(L<O||L>=We)continue;it(q,G.first,G.count),G.last>(ce.get(q).last??-1/0)&&(ce.get(q).last=G.last),ze.add(de);let Z=Be(q,L);Z.count+=G.count;for(let[Se,ue]of Object.entries(G.severity))Z.severity[Se]=(Z.severity[Se]??0)+ue;for(let[Se,ue]of Object.entries(G.kinds))Z.kinds[Se]=(Z.kinds[Se]??0)+ue}}}let Ne=E=>hn(E.scope,I.scope)&&(!re||re.has(E.source))&&E.t>=ae(E.source)&&Pe(E.scope)!==void 0,gt=E=>{let Y=Pe(E.scope);it(Y,E.t,1),ze.add(E.source);let q=Be(Y,E.t);q.count++,q.severity[E.severity]=(q.severity[E.severity]??0)+1,q.kinds[E.kind]=(q.kinds[E.kind]??0)+1};for(let E of w){if(re&&!re.has(E))continue;let Y=$e(E),q=Math.ceil(Y/Vn)*Vn,de=q>=We?[[Y,I.to]]:[[Y,q],[We,I.to]];for(let[m,O]of de)for(let L=ss(b,m);L<b.length&&b[L].t<O;L++){let G=b[L];G.source===E&&Ne(G)&>(G)}}let Ze=On[I.bin],ft=[];for(let E=ss(v,I.from-M);E<v.length&&v[E].t<I.from;E++){let Y=v[E];Y.t+Y.dur>I.from&&Ne(Y)&&(it(Pe(Y.scope),Y.t,1),ze.add(Y.source),Y.dur>=Ze&&ft.length<5e3&&ft.push(Y))}for(let E of x.values())E.t<I.from&&c>I.from&&Ne(E)&&(it(Pe(E.scope),E.t,1),ze.add(E.source),ft.length<5e3&&ft.push(E));for(let E=ss(v,I.from);E<v.length&&v[E].t<I.to&&ft.length<5e3;E++)v[E].dur>=Ze&&Ne(v[E])&&ft.push(v[E]);for(let E of x.values())E.t>=I.from&&E.t<I.to&&ft.length<5e3&&Ne(E)&&ft.push(E);let ot=X(I,Pe,I.from,I.to);for(let E of ot){let Y=_.get(E.series);Y&&ze.add(Y)}let at=[...Oe.values()].sort((E,Y)=>E.t-Y.t||(E.scope<Y.scope?-1:1));return{timeline:1,type:"result",rows:fe(ce),bins:at,spans:ft,metrics:ot,total:Ee,retention:j(ze)}}async function me(I){if(!r(I.scope))throw new Error(`not a scope path: ${JSON.stringify(I.scope)}`);let re=ne(I);if(re)return re;let{test:$e,range:Pe,warnings:be}=U(I),{at:ce,add:ze,rows:Oe}=ee(I),Ee=new Set,Be=[];for(let ot of B(Pe.from,Pe.to)){if(!$e(ot))continue;let at=ce(ot.scope);if(at===void 0)continue;let E=ze(at);E.count++,(E.first===void 0||ot.t<E.first)&&(E.first=ot.t),(E.last===void 0||ot.t>E.last)&&(E.last=ot.t),Ee.add(ot.source),Be.push(ot)}Be.sort(Ia);let it=X(I,ce,Pe.from,Pe.to);for(let ot of it){let at=_.get(ot.series);at&&Ee.add(at)}let We={timeline:1,type:"result",total:Be.length,...be.length?{warnings:be}:{}};if(I.bin){let ot=On[I.bin],at=new Map,E=[];for(let q of Be){if((q.open||q.dur!==void 0&&q.dur>=ot)&&E.length<5e3&&E.push(q),q.t<Pe.from)continue;let de=ce(q.scope),m=ir(q.t,I.bin,I.tz),O=`${de}\0${m}`,L=at.get(O);L||(L={scope:de,t:m,bin:I.bin,count:0,severity:{},kinds:{}},at.set(O,L)),L.count++,L.severity[q.severity]=(L.severity[q.severity]??0)+1,L.kinds[q.kind]=(L.kinds[q.kind]??0)+1}let Y=[...at.values()].sort((q,de)=>q.t-de.t||(q.scope<de.scope?-1:1));return{...We,rows:fe(Oe),bins:Y,spans:E,metrics:it,retention:j(Ee)}}let Ne=Math.min(1e4,Math.max(1,I.limit??2e3)),gt=I.cursor?Be.findIndex(ot=>te(ot,I.cursor)):0,Ze=gt<0?[]:Be.slice(gt,gt+Ne),ft=gt>=0&>+Ne<Be.length;return{...We,rows:fe(Oe),events:Ze,metrics:it,retention:j(Ee),...ft?{next:Q(Ze[Ze.length-1])}:{}}}let ye=new Set,xe=I=>mn.includes(I),Re=0;function Ue(I){let re=h(I),$e=k.get(re);$e&&(Uu(b,$e.t,Pe=>Pe===$e),N($e,-1),$e.dur!==void 0&&!$e.open&&Uu(v,$e.t,Pe=>Pe===$e),x.delete(re)),k.set(re,I),N(I,1),Ic(b,I,()=>!1,Ia),I.open?x.set(re,I):I.dur!==void 0&&(Ic(v,I,()=>!1,Ia),M=Math.max(M,I.dur)),A(I.scope)}return{async catalog(){return{...s,now:c,retention:j(s.sources.map(I=>I.name))}},query:me,subscribe(I,re){let $e={q:I,on:re};return ye.add($e),()=>{ye.delete($e)}},...n.stateAt?{stateAt:(I,re)=>n.stateAt(I,re)}:{},append(I,re=[],$e){$e!==void 0&&(c=Math.max(c,$e));let Pe=new Set(y),be=I.map(g);for(let ce of be){if(!xe(ce.severity))throw new Error(`not a severity: ${ce.severity}`);Ue(ce)}for(let ce of re)S(ce);Re++;for(let ce of ye){let{test:ze}=U(ce.q),{at:Oe}=ee(ce.q),Ee=be.filter(Ze=>ze(Ze)&&Oe(Ze.scope)!==void 0),Be=ce.q.series?new Set(ce.q.series):void 0,it=re.filter(Ze=>hn(f(Ze.scope),ce.q.scope)&&(!Be||Be.has(Ze.series))).map(Ze=>({...Ze,scope:Oe(f(Ze.scope))})),We=[...y].filter(Ze=>!Pe.has(Ze)),Ne=Xt(ce.q.scope)+ce.q.depth,gt=We.filter(Ze=>Xt(Ze)===Ne&&hn(Ze,ce.q.scope)).map(Ze=>({scope:Ze,label:p.get(Ze)?.label??Fr(Ze),kind:Dr(Ze),depth:ce.q.depth,children:0,count:0}));ce.on({timeline:1,type:"batch",events:Ee,metrics:it,...gt.length?{rows:gt}:{},now:c,resume:String(Re)})}},setRetention(I,re){C.set(I,{events:re.events,rollups:{...re.rollups},setBy:"user"})},get now(){return c},get size(){let I=0;for(let re of T.values())I+=re.fine.length;return{events:b.length,samples:I}}}}var Xu="http://www.w3.org/2000/svg",cr=22,Da=38,rs=26,rm=210,om=24,zo=6e4,dr=36e5,kn=864e5,Qu={"15m":15*zo,"1h":dr,"1d":kn,"1w":7*kn},Zu=t=>mn.indexOf(t),im={debug:"dot",info:"circle",notice:"square",warning:"triangle",error:"diamond"},Ct=(t,e,n)=>{let s=document.createElementNS(Xu,t);for(let[r,o]of Object.entries(e))o!==void 0&&s.setAttribute(r,String(o));if(n){let r=document.createElementNS(Xu,"title");r.textContent=n,s.append(r)}return s},nn=(t,e)=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e,dateStyle:"medium",timeStyle:"medium"}).format(t)}catch{return new Date(t).toISOString()}},Dc=t=>t<1e3?`${Math.round(t)} ms`:t<zo?`${(t/1e3).toFixed(1)} s`:ar(t),am=(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 Fc(t,e){if(t<=3*dr)return{kind:"single"};for(let n of["1m","1h","1d"])if(t/On[n]<=e/2)return{kind:"binned",bin:n};return{kind:"binned",bin:"1d"}}function jc(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"?On[e.bin]:zo;for(let i of t.bins??[])i.count&&s.push([i.t,i.t+On[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 ef(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}=Br(e.catalog),a=(H="system")=>{t.style.colorScheme=H==="system"?"light dark":H,H==="system"?delete t.dataset.theme:t.dataset.theme=H};a(e.theme),t.setAttribute("role","region"),t.setAttribute("aria-label","Timeline");let l,c="",d=1,u="",f={},p=!1,g=e.collapseGaps??!0,h={t0:0,t1:kn},b,k="",v={from:0,to:0,mode:{kind:"single"},key:""},M,x,T,y,A=!0,D=0,K=0,C=!1,_,S=[],$=[],w=-1,N=new Set,F=new Map,J=[],ae=Kr(0,kn,800),we=new Map,j=[],U=z("nav",{class:"tlx-crumbs","aria-label":"Scope"}),ee=z("div",{class:"segmented tlx-quick",role:"group","aria-label":"Range"});for(let H of["15m","1h","1d","1w","run"]){let he=z("button",{type:"button",class:"seg","data-v":H,title:H==="run"?"The latest run":`The last ${H}`},H==="run"?"this run":H);he.addEventListener("click",()=>Mn(H)),ee.append(he)}let fe=z("button",{type:"button",class:"btn sm tlx-live","aria-pressed":"false",title:"Follow what happens now"},"Live"),B=z("button",{type:"button",class:"btn sm quiet tlx-now",hidden:!0,title:"Back to the live edge"},"Back to now"),X=z("button",{type:"button",class:"btn sm quiet tlx-fit",title:"Everything in this scope"},"Fit"),Q=z("input",{type:"checkbox",class:"tlx-gaps"});Q.checked=g;let te=!0,ne=z("input",{type:"checkbox",class:"tlx-quiet"});ne.checked=te;let me=z("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"}),ye=z("span",{class:"tlx-hits",role:"status","aria-live":"polite"}),xe=z("button",{type:"button",class:"btn sm quiet tlx-prev",title:"Previous hit (\u21E7N)","aria-label":"Previous hit"},"\u2039"),Re=z("button",{type:"button",class:"btn sm quiet tlx-next",title:"Next hit (N)","aria-label":"Next hit"},"\u203A"),Ue=z("div",{class:"tlx-facets",role:"group","aria-label":"Sources"}),I=z("select",{class:"input tlx-sev","aria-label":"Severity"},z("option",{value:""},"every severity"),...mn.slice(1).map(H=>z("option",{value:H},`${H} and above`))),re=z("select",{class:"input tlx-views","aria-label":"Saved views",hidden:!e.views},z("option",{value:""},"Saved views\u2026")),$e=z("button",{type:"button",class:"btn sm quiet tlx-save",hidden:!e.saveView,title:"Save this view"},"Save view"),Pe=z("div",{class:"tlx-warn",role:"status",hidden:!0}),be=z("div",{class:"tlx-status",role:"status"}),ce=z("span",{class:"tlx-canvas-note"}),ze=z("div",{class:"tlx-labels"}),Oe=z("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"}),Ee=Ct("svg",{class:"tlx-svg"});Oe.append(Ee);let Be=z("div",{class:"tlx-scroll"},z("div",{class:"tlx-grid"},ze,Oe)),it=z("section",{class:"tlx-table",hidden:!0,"aria-label":"The events in the chosen range"}),We=z("aside",{class:"tlx-detail",hidden:!0,"aria-label":"The event"});t.replaceChildren(z("div",{class:"tlx-bar"},U,z("span",{class:"spacer"}),ee,fe,B,X,z("label",{class:"tlx-gaps-label",title:"Draw long empty stretches as narrow breaks"},Q,"Collapse gaps"),z("label",{class:"tlx-gaps-label",title:"Hide the rows with nothing in this range"},ne,"Hide quiet rows")),z("div",{class:"tlx-bar"},me,ye,xe,Re,I,re,$e),Ue,Pe,z("div",{class:"tlx-body"},Be,We),z("div",{class:"tlx-foot"},be,z("span",{class:"spacer"}),ce),it);let Ne=()=>Math.max(200,Oe.clientWidth||800),gt=()=>{let H=(Fe,st)=>(Fe.own?-1:0)-(st.own?-1:0)||Fe.scope.localeCompare(st.scope,void 0,{numeric:!0}),ke=(b?.rows??[]).filter(Fe=>!te||Fe.count>0||Fe.own||(b?.rows.length??0)<=1).sort(H).map(Fe=>({kind:"row",row:Fe})),Ae=new Set(b?.metrics.map(Fe=>Fe.series)??[]);for(let Fe of[...Ae].sort()){let st=we.get(Fe);ke.push({kind:"metric",series:Fe,unit:st?.unit??"count",type:st?.type??"counter",title:st?.title??Fe})}return ke},Ze=(H,he)=>l?.names?.find(ke=>ke.scope===H)?.label??he,ft=H=>H.kind==="metric"?Da:cr,ot=()=>Fc(h.t1-h.t0,Ne()),at=()=>l?.now??Date.now();function E(){return{timeline:1,type:"view",name:"",scope:c,depth:d,range:{from:Math.round(h.t0),to:Math.round(h.t1)},...u?{q:u}:{},...Object.keys(f).length?{filters:f}:{},...p?{live:p}:{},...g?{}:{collapseGaps:!1},...te?{}:{quietRows:!0}}}function Y(H){H.scope!==void 0&&(c=H.scope),H.depth!==void 0&&(d=H.depth),u=H.q??"",me.value=u,f=H.filters??{},I.value=f.severity?.length?f.severity[0]:"",g=H.collapseGaps??e.collapseGaps??!0,Q.checked=g,te=!H.quietRows,ne.checked=te,N.clear(),F.clear();let he=H.range;he&&"last"in he?Mn(he.last,!1):he&&(h={t0:he.from,t1:he.to}),kt(!!H.live,!1)}let q=()=>{let H=E();if(e.onViewChange?.(H),!!e.urlState)try{history.replaceState(null,"",`#timeline=${encodeURIComponent(JSON.stringify(H))}`)}catch{}},de=()=>{if(!e.urlState)return;let H=/#timeline=(.+)$/.exec(location.hash);if(H)try{return JSON.parse(decodeURIComponent(H[1]))}catch{return}};function m(H,he,ke,Ae={}){let Fe=i(u,at(),H,he);S=Fe.warnings;let st=u?[]:f.source?[...we].filter(([,bt])=>f.source.includes(bt.source)).map(([bt])=>bt):void 0;return{timeline:1,type:"query",scope:c,depth:d,from:Fe.from,to:Fe.to,tz:n,...ke.kind==="binned"?{bin:ke.bin}:{},...u?{q:u,where:Fe.where}:{},...Object.keys(f).length?{filters:f}:{},...st?{series:st}:{},...Ae}}let O=()=>JSON.stringify([c,d,u,f,ot()]);async function L(H=!1){let he=ot(),ke=O(),Ae=h.t1-h.t0;if(!H&&b&&ke===v.key&&h.t0>=v.from&&h.t1<=v.to){Z();return}if(K){C=!0;return}K++;let Fe=h.t0-Ae/2,st=Math.min(h.t1+Ae/2,Math.max(h.t1,at()+Ae*.1));try{let bt=await e.source.query(m(Fe,st,he,he.kind==="single"?{limit:1e4}:{}));he.kind==="single"&&bt.next&&(bt=await e.source.query(m(Fe,st,{kind:"binned",bin:"1m"}))),b=bt,k=ke,v={from:Fe,to:st,mode:he,key:ke}}catch(bt){be.textContent=`The history couldn't be read: ${String(bt?.message??bt)}`}finally{K--}Z(),q(),C&&(C=!1,L())}function G(){let H=Ne(),he=ot();if(J=[],g&&b){let ke=new Map([...we].map(([Ae,Fe])=>[Ae,Fe.type]));J=Ca(jc(b,he,ke),h.t0,Math.min(h.t1,Math.max(h.t0,at())),{minFrac:.15,minMs:10*zo}),he.kind==="binned"&&(J=J.filter(Ae=>Ae.to-Ae.from>=2*On[he.bin])),J=J.filter(Ae=>!(N.has(lr(Ae))&&(F.get(lr(Ae))??1)>=1))}ae=Kr(h.t0,h.t1,H,J,{cut:om,weights:F})}let Z=()=>{D||(D=requestAnimationFrame(Se))};function Se(){D=0,G();let H=Ne(),he=gt(),ke=v.mode,Ae=[],Fe=rs;for(let ve of he)Ae.push(Fe),Fe+=ft(ve);let st=Math.max(Fe,rs+cr);Ee.setAttribute("width",String(H)),Ee.setAttribute("height",String(st)),Ee.setAttribute("viewBox",`0 0 ${H} ${st}`);let bt=Be.scrollTop-200,yn=Be.scrollTop+(Be.clientHeight||600)+200,et=[],Qe=ae.x;et.push(Ct("rect",{class:"tlx-axis",x:0,y:0,width:H,height:rs}));let Ut=(b?.retention??[]).map(ve=>({r:ve,from:ke.kind==="binned"?ve.keptFrom.rollups[ke.bin]??ve.keptFrom.events:ve.keptFrom.events,days:ke.kind==="binned"?ve.rollups[ke.bin]:ve.events})).filter(ve=>ve.from!==void 0);if(Ut.length){let ve=Math.min(...Ut.map(je=>je.from));ve>h.t0&&et.push(Ct("rect",{class:"tlx-notkept",x:Math.max(0,Qe(h.t0)),y:rs,width:Math.max(0,Qe(ve)-Math.max(0,Qe(h.t0))),height:st-rs},`Nothing kept before ${nn(ve,n)}: ${Ut.map(je=>`${je.r.source} ${je.days===null?"kept until deleted":`kept ${je.days} days`}`).join(", ")}`))}let an=at();an<h.t1&&et.push(Ct("rect",{class:"tlx-future",x:Qe(an),y:rs,width:H-Qe(an),height:st-rs}));for(let ve of Na(ae,n,90)){et.push(Ct("line",{class:`tlx-tick${ve.major?" major":""}`,x1:ve.x,x2:ve.x,y1:rs-6,y2:st}));let je=Ct("text",{class:"tlx-ticklabel",x:ve.x+3,y:16});je.textContent=ve.label,et.push(je)}y&&et.push(Ct("rect",{class:"tlx-brush",x:Qe(y.from),y:0,width:Math.max(1,Qe(y.to)-Qe(y.from)),height:st}));let br=ke.kind==="single"?(b?.events??[]).filter(ve=>ve.dur!==void 0||ve.open):b?.spans??[],Xo=ke.kind==="single"?(b?.events??[]).filter(ve=>ve.dur===void 0&&!ve.open):[],Ws=new Map;he.forEach((ve,je)=>{ve.kind==="row"&&Ws.set(ve.row.scope,je)});let cs=ve=>{let je=Xt(c)+d,dt=Xt(ve)>=je?vs(ve,je):ve;return Ws.get(dt)},Js=ve=>Ae[ve]+ft(he[ve])>=bt&&Ae[ve]<=yn;if(he.forEach((ve,je)=>{Js(je)&&et.push(Ct("rect",{class:`tlx-lane${je%2?" odd":""}${ve.kind==="metric"?" metric":""}`,x:0,y:Ae[je],width:H,height:ft(ve)}))}),ke.kind==="binned"){let ve=new Map;for(let je of b?.bins??[]){let dt=cs(je.scope);dt!==void 0&&ve.set(dt,Math.max(ve.get(dt)??0,je.count))}for(let je of b?.bins??[]){let dt=cs(je.scope);if(dt===void 0||!Js(dt))continue;let yt=Qe(je.t),ut=Qe(je.t+On[je.bin]);if(ut<0||yt>H)continue;let Tt=[...mn].reverse().find(R=>(je.severity[R]??0)>0)??"info",P=Math.max(2,(cr-8)*Math.sqrt(je.count)/Math.sqrt(ve.get(dt)||1));et.push(Ct("rect",{class:"tlx-countbar",x:yt,y:Ae[dt]+cr-3-P,width:Math.max(1,ut-yt-.5),height:P,"data-t":je.t},`${nn(je.t,n)}: ${je.count} event${je.count===1?"":"s"}${Tt!=="info"&&Tt!=="debug"?`, the worst ${Tt}`:""}`)),(Tt==="warning"||Tt==="error")&&et.push(Ct("rect",{class:`tlx-heat sev-${Tt}`,x:yt,y:Ae[dt]+cr-(Tt==="error"?4:3),width:Math.max(1,ut-yt-.5),height:Tt==="error"?3:2}))}}for(let ve of br){let je=cs(ve.scope);if(je===void 0||!Js(je))continue;let dt=ve.open?an:ve.t+(ve.dur??0),yt=Qe(ve.t),ut=Qe(dt);if(ut<-2||yt>H+2)continue;let Tt=`tlx-span sev-${ve.severity}${ve.open?" open":""}${T?.id===ve.id?" selected":""}`,P=`${ve.summary} \xB7 ${nn(ve.t,n)}${ve.open?", still going":`, ${Dc(dt-ve.t)}`}`,R=Ae[je]+5,V=ke.kind==="binned"?4:8,W=yt;for(let oe of ae.cuts)oe.weight>=1||oe.x1<=yt||oe.x0>=ut||(oe.x0>W&&et.push(Ct("rect",{class:Tt,x:W,y:R,width:Math.max(1,oe.x0-W),height:V,rx:2,"data-id":ve.id},P)),et.push(Ct("path",{class:`${Tt} through`,d:`M${oe.x0} ${R+V/2} H${oe.x1}`,"data-id":ve.id},`${P} (lasted through the break)`)),W=oe.x1);ut>W&&et.push(Ct("rect",{class:Tt,x:Math.max(-2,W),y:R,width:Math.max(2,Math.min(H+2,ut)-Math.max(-2,W)),height:V,rx:2,"data-id":ve.id},P))}let eo=new Map;for(let ve of Xo){let je=cs(ve.scope);if(je===void 0||!Js(je))continue;let dt=Qe(ve.t);if(dt<-6||dt>H+6||dt-(eo.get(je)??-1/0)<3)continue;eo.set(je,dt);let yt=Ae[je]+cr/2+2,ut=4,Tt=im[ve.severity],P=Tt==="diamond"?`M${dt} ${yt-ut-1} l${ut+1} ${ut+1} l${-ut-1} ${ut+1} l${-ut-1} ${-ut-1} z`:Tt==="triangle"?`M${dt} ${yt-ut-1} l${ut+1} ${2*ut+1} h${-2*ut-2} z`:Tt==="square"?`M${dt-ut+.5} ${yt-ut+.5} h${2*ut-1} v${2*ut-1} h${-2*ut+1} z`:"",R=`${nn(ve.t,n)} \xB7 ${ve.summary}`,V=`tlx-mark sev-${ve.severity}${T?.id===ve.id?" selected":""}${w>=0&&$[w]?.id===ve.id?" hit":""}`;et.push(P?Ct("path",{class:V,d:P,"data-id":ve.id},R):Ct("circle",{class:V,cx:dt,cy:yt,r:Tt==="dot"?2.5:ut,"data-id":ve.id},R))}he.forEach((ve,je)=>{if(ve.kind!=="metric"||!Js(je))return;let dt=new Map;for(let se of b?.metrics??[]){if(se.series!==ve.series)continue;let ie="value"in se?{min:se.value,max:se.value,sum:se.value,count:1}:{min:se.min,max:se.max,sum:se.sum,count:se.count},le=dt.get(se.t);le?(le.min=Math.min(le.min,ie.min),le.max=Math.max(le.max,ie.max),le.sum+=ie.sum,le.count+=ie.count):dt.set(se.t,{...ie})}let yt=[...dt].sort((se,ie)=>se[0]-ie[0]);if(!yt.length)return;let ut=ke.kind==="binned"?On[ke.bin]:zo,Tt=se=>ve.type==="gauge"?se.sum/Math.max(1,se.count):se.sum,P=Math.max(1e-9,...yt.map(([,se])=>ve.type==="gauge"?se.max:Tt(se))),R=Ae[je]+Da-4,V=Da-10,W=se=>R-se/P*V;if(ve.type==="gauge"){let se=yt.map(([ie,le])=>`${Qe(ie)},${W(le.max)}`).join(" ")+" "+[...yt].reverse().map(([ie,le])=>`${Qe(ie)},${W(le.min)}`).join(" ");et.push(Ct("polygon",{class:"tlx-band",points:se})),et.push(Ct("polyline",{class:"tlx-line",points:yt.map(([ie,le])=>`${Qe(ie+ut/2)},${W(Tt(le))}`).join(" ")}))}else{let se="",ie=-1/0;for(let[le,pe]of yt){let ge=Qe(le),Te=Qe(le+ut),qe=W(Tt(pe));se+=le>ie?`M${ge} ${R} V${qe} H${Te}`:` V${qe} H${Te}`,ie=le+ut;let Le=yt.find(([ct])=>ct>le);(!Le||Le[0]>ie)&&(se+=` V${R} Z`)}et.push(Ct("path",{class:"tlx-area",d:se}))}let oe=Ct("text",{class:"tlx-peak",x:4,y:Ae[je]+11});oe.textContent=`peak ${am(P,ve.unit)}${ve.type==="counter"?` per ${ke.kind==="binned"?ke.bin:"1m"}`:""}`,et.push(oe)});for(let ve of ae.cuts){if(ve.weight>=1)continue;let je=ut=>{let Tt=`M${ut} 0`;for(let P=0;P<st;P+=8)Tt+=` L${ut+(P/8%2?-3:3)} ${P+8}`;return Tt},dt=Ct("g",{class:"tlx-cut",tabindex:0,role:"button","data-from":ve.from,"data-to":ve.to,"aria-label":`A break of ${ar(ve.to-ve.from)} with nothing shown, from ${nn(ve.from,n)} to ${nn(ve.to,n)}: press to open it`},`${ar(ve.to-ve.from)} with nothing here: ${nn(ve.from,n)} to ${nn(ve.to,n)} (click to open)`);dt.append(Ct("rect",{class:"tlx-cut-bg",x:ve.x0,y:0,width:ve.x1-ve.x0,height:st})),dt.append(Ct("path",{class:"tlx-cut-edge",d:je(ve.x0+3)}),Ct("path",{class:"tlx-cut-edge",d:je(ve.x1-3)}));let yt=Ct("text",{class:"tlx-cut-label",x:(ve.x0+ve.x1)/2,y:15,"text-anchor":"middle"});yt.textContent=ar(ve.to-ve.from),dt.append(yt),et.push(dt)}if(M!==void 0){let ve=Qe(M);et.push(Ct("line",{class:"tlx-playhead",x1:ve,x2:ve,y1:0,y2:st})),et.push(Ct("path",{class:"tlx-handle",d:`M${ve-6} 0 h12 v8 l-6 7 l-6 -7 z`},`the playhead: ${nn(M,n)}`))}Ee.replaceChildren(...et),ze.replaceChildren(z("div",{class:"tlx-labelhead",style:`height:${rs}px`},ot().kind==="single"?"single events":`per ${ot().kind==="binned"?ot().bin:""}`),...he.map(ve=>{if(ve.kind==="metric")return z("div",{class:"tlx-rowlabel metric",style:`height:${Da}px`,title:`${ve.title} (${ve.type==="counter"?"sums":"min, max and mean"})`},ve.title);let je=ve.row,dt=z("div",{class:`tlx-rowlabel${je.own?" own":""}`,style:`height:${cr}px`,"data-scope":je.scope,title:`${je.scope||"all hosts"} \xB7 ${je.count} event${je.count===1?"":"s"}`},z("span",{class:"tlx-kind"},e.catalog.flags.find(yt=>je[yt])??je.kind),z("span",{class:"tlx-name"},je.own?`${je.label} (itself)`:je.label),z("span",{class:"tlx-count"},String(je.count)));if(!je.own&&je.scope!==c){let yt=z("button",{type:"button",class:"tlx-drill",title:je.children?`Into ${je.label}: its ${je.children} part${je.children===1?"":"s"}`:`Into ${je.label}`,"aria-label":`Into ${je.label}`},"\u203A");yt.addEventListener("click",()=>St(je.scope)),dt.append(yt)}return dt})),ze.style.width=`${rm}px`,ue()}function ue(){U.replaceChildren(...jr(c).flatMap((Ae,Fe,st)=>{let bt=z("button",{type:"button",class:`tlx-crumb${Fe===st.length-1?" current":""}`,"aria-current":Fe===st.length-1?"location":void 0},Ze(Ae.scope,Ae.label));return bt.addEventListener("click",()=>{Ae.scope!==c&&(c=Ae.scope,d=1,L(!0))}),Fe?[z("span",{class:"tlx-sep","aria-hidden":"true"},"/"),bt]:[bt]})),fe.setAttribute("aria-pressed",String(p)),fe.classList.toggle("on",p),B.hidden=!p||A;let H=ot(),he=b?.total??0,ke=(b?.retention??[]).filter(Ae=>Ae.events!==null).map(Ae=>`${Ae.source} kept ${Ae.events} d`);be.textContent=`${nn(h.t0,n)} \u2013 ${nn(h.t1,n)} \xB7 ${H.kind==="single"?"single events":`bins of ${H.bin}`} \xB7 ${he} event${he===1?"":"s"}${J.length?` \xB7 ${J.length} break${J.length===1?"":"s"}`:""}${ke.length?` \xB7 ${ke.slice(0,3).join(", ")}`:""}`,Pe.hidden=!S.length,Pe.textContent=S.join(" \xB7 "),ye.textContent=u?$.length?`${w+1>0?`${w+1} of `:""}${$.length}${$.length>=2e3?"+":""} hit${$.length===1?"":"s"}`:`${he?`${he} hit${he===1?"":"s"}`:"no hits"}`:"";for(let Ae of ee.querySelectorAll(".seg"))Ae.classList.remove("on");ce.textContent=M===void 0?"":x?(()=>{let Ae=e.stamp?.(x)??{};return`Canvas: the state recorded at ${nn(Date.parse(Ae.at??"")||M,n)}${Ae.tag?` (${Ae.tag})`:""}`})():"No state recorded here",ce.classList.toggle("none",M!==void 0&&!x)}function Ke(){Ue.replaceChildren();for(let H of l?.sources??[]){let he=!f.source?.length||f.source.includes(H.name),ke=z("button",{type:"button",class:`tlx-chip${he?" on":""}${H.status==="not-yet"?" notyet":""}`,"aria-pressed":String(he&&H.status!=="not-yet"),disabled:H.status==="not-yet",title:H.status==="not-yet"?`${H.title}: not kept yet`:`${H.title}${Ye(H)}`},H.name);H.status!=="not-yet"&&ke.addEventListener("click",()=>Ie(H.name)),Ue.append(ke)}}let Ye=H=>{let he=l?.retention.find(ke=>ke.source===H.name);return he?` (kept ${he.events===null?"until deleted":`${he.events} days`})`:""};function Ie(H){let he=(l?.sources??[]).filter(Ae=>Ae.status==="kept").map(Ae=>Ae.name),ke=f.source?.length?[...f.source]:[...he];ke=ke.includes(H)?ke.filter(Ae=>Ae!==H):[...ke,H],f={...f,...ke.length===he.length?{source:void 0}:{source:ke}},f.source||delete f.source,Ke(),L(!0),Ce()}let De=0;me.addEventListener("input",()=>{clearTimeout(De),De=setTimeout(()=>{u=me.value.trim(),w=-1,L(!0),Ce()},250)}),me.addEventListener("keydown",H=>{H.key==="Enter"&&(H.preventDefault(),clearTimeout(De),u=me.value.trim(),L(!0).then(()=>Ce()).then(()=>vt(H.shiftKey?-1:1)))});async function Ce(){if(!u){$=[],w=-1,ue();return}let H=h.t1-h.t0;$=(await e.source.query(m(h.t0-H*4,Math.max(h.t1+H*4,at()),{kind:"single"},{limit:2e3}))).events??[],w=Math.min(w,$.length-1),ue()}function vt(H){if(!$.length)return;let he=(h.t0+h.t1)/2;w<0?w=H>0?Math.max(0,$.findIndex(Fe=>Fe.t>=he)):Math.max(0,$.length-1-[...$].reverse().findIndex(Fe=>Fe.t<=he)):w=(w+H+$.length)%$.length;let ke=$[w],Ae=Math.min(h.t1-h.t0,2*dr);h={t0:ke.t-Ae/2,t1:ke.t+Ae/2},A=!1,pt(ke),L()}xe.addEventListener("click",()=>vt(-1)),Re.addEventListener("click",()=>vt(1)),I.addEventListener("change",()=>{let H=I.value;f={...f,...H?{severity:mn.filter(he=>Zu(he)>=Zu(H))}:{}},H||delete f.severity,L(!0),Ce()});async function Mn(H,he=!0){let ke=at();if(H==="run"){let Ae=await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:ke-30*kn,to:ke+1,filters:{kind:["run"]},limit:1e4}).catch(()=>{}),Fe=Ae?.events?.[Ae.events.length-1];h=Fe?{t0:Fe.t-(Fe.dur??dr)*.02,t1:(Fe.open?ke:Fe.t+(Fe.dur??dr))+(Fe.dur??dr)*.04}:{t0:ke-kn,t1:ke+kn*.02}}else h={t0:ke-Qu[H],t1:ke+Qu[H]*.02};A=!0,N.clear(),F.clear(),he&&L()}function kt(H,he=!0){if(p=H,_?.(),_=void 0,H&&e.source.subscribe){let ke=0,Ae=0;_=e.source.subscribe(m(at()-dr,at()+365*kn,{kind:"single"}),Fe=>{if(l&&(l.now=Math.max(l.now,Fe.now)),A){let bt=h.t1-h.t0;h={t0:Fe.now-bt*.98,t1:Fe.now+bt*.02}}let st=Date.now();st-ke>500?(ke=st,L(!0)):Ae||(Ae=setTimeout(()=>{Ae=0,ke=Date.now(),L(!0)},500))}),A=!0}he&&(ue(),q())}fe.addEventListener("click",()=>kt(!p)),B.addEventListener("click",()=>{A=!0;let H=h.t1-h.t0,he=at();h={t0:he-H*.98,t1:he+H*.02},L()}),X.addEventListener("click",()=>{Et()}),Q.addEventListener("change",()=>{g=Q.checked,N.clear(),F.clear(),Z(),q()}),ne.addEventListener("change",()=>{te=ne.checked,Z(),q()});function St(H){let he=b?.rows.find(ke=>ke.scope===H);c=H,d=he&&he.children===0?0:1,y=void 0,it.hidden=!0,L(!0)}async function Et(){let H=at(),ke=((await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:H-400*kn,to:H+1,bin:"1d",tz:n}).catch(()=>{}))?.bins??[]).map(Fe=>Fe.t),Ae=ke.length?Math.min(...ke):H-7*kn;h={t0:Ae,t1:H+(H-Ae)*.02},A=!0,L()}let bn=0;async function Yt(H){if(M=H,Z(),H===void 0){x=void 0;return}let he=++bn,ke=e.source.stateAt?await e.source.stateAt(c,H).catch(()=>{}):void 0;he===bn&&(x=ke,e.onPlayhead?.(H,ke),ue())}async function Pt(H,he){y={from:Math.min(H,he),to:Math.max(H,he)},Z();let ke=await e.source.query(m(y.from,y.to,{kind:"single"},{limit:500})),Ae=o(u),Fe=et=>{let Qe=[],Nt=0;for(let[Ut,an]of _o(Ae,et))Qe.push(et.slice(Nt,Ut),z("mark",null,et.slice(Ut,an))),Nt=an;return Qe.push(et.slice(Nt)),Qe},st=(ke.events??[]).map(et=>{let Qe=z("tr",{"data-id":et.id,tabindex:"0"},z("td",null,nn(et.t,n)),z("td",null,et.dur!==void 0?Dc(et.dur):et.open?"still going":""),z("td",null,et.source),z("td",null,et.kind),z("td",{class:`sev-${et.severity}`},et.severity),z("td",{class:"tlx-sum"},...Fe(et.summary)),z("td",{class:"tlx-scope"},et.scope));return Qe.addEventListener("click",()=>pt(et)),Qe.addEventListener("keydown",Nt=>{Nt.key==="Enter"&&pt(et)}),Qe}),bt=z("button",{type:"button",class:"btn sm quiet","aria-label":"Close the table"},"Close");bt.addEventListener("click",()=>{y=void 0,it.hidden=!0,Z()});let yn=et=>{let Qe=z("button",{type:"button",class:"btn sm","data-export":et},et.toUpperCase());return Qe.addEventListener("click",()=>{_t(et)}),Qe};it.replaceChildren(z("div",{class:"tlx-table-head"},z("strong",null,`${ke.total} event${ke.total===1?"":"s"}`),z("span",null,` ${nn(y.from,n)} \u2013 ${nn(y.to,n)}${ke.total>500?" (the first 500 shown; the export has them all)":""}`),z("span",{class:"spacer"}),z("span",null,"Export: "),yn("json"),yn("csv"),bt),z("div",{class:"tlx-table-wrap"},z("table",null,z("thead",null,z("tr",null,...["When","Long","Source","Kind","Severity","What","Scope"].map(et=>z("th",{scope:"col"},et)))),z("tbody",null,...st)))),it.hidden=!1}async function Ot(){if(!y)return[];let H=[],he;do{let ke=await e.source.query(m(y.from,y.to,{kind:"single"},{limit:1e4,...he?{cursor:he}:{}}));H.push(...ke.events??[]),he=ke.next}while(he&&H.length<2e5);return H}async function _t(H){let he=await Ot(),ke=H==="json"?La(he,j):Ra(he,j),Ae=`timeline-${new Date(y.from).toISOString().slice(0,16).replace(/:/g,"")}.${H}`,Fe=H==="json"?"application/json":"text/csv";if(e.onExport){e.onExport(Ae,ke,Fe);return}let st=z("a",{href:`data:${Fe};charset=utf-8,${encodeURIComponent(ke)}`,download:Ae});document.body.append(st),st.click(),st.remove()}function pt(H){if(T=H,Z(),!H){We.hidden=!0;return}let he=l?.sources.find(Qe=>Qe.name===H.source),ke=new Set(he?.sensitive??[]),Ae=o(u),Fe=Qe=>{let Nt=[],Ut=0;for(let[an,br]of _o(Ae,Qe))Nt.push(Qe.slice(Ut,an),z("mark",null,Qe.slice(an,br))),Ut=br;return Nt.push(Qe.slice(Ut)),Nt},st=(Qe,Nt)=>{if(!Nt)return null;let Ut=z("button",{type:"button",class:"btn sm"},Qe);return Ut.addEventListener("click",Nt),Ut},bt=Object.entries(H.attrs).map(([Qe,Nt])=>{if(!ke.has(Qe))return z("tr",null,z("th",{scope:"row"},Qe),z("td",null,...Fe(String(Nt))));let Ut=z("button",{type:"button",class:"btn sm quiet",title:"This can name a remote host, a folder or free text"},"Show"),an=z("td",{class:"tlx-sensitive"},"hidden ",Ut);return Ut.addEventListener("click",()=>an.replaceChildren(String(Nt))),z("tr",null,z("th",{scope:"row"},Qe),an)}),yn=z("button",{type:"button",class:"btn sm quiet tlx-close","aria-label":"Close"},"\xD7");yn.addEventListener("click",()=>pt(void 0));let et=jr(H.scope).slice(1).map(Qe=>{let Nt=z("button",{type:"button",class:"tlx-crumb"},Ze(Qe.scope,Qe.label));return Nt.addEventListener("click",()=>St(Qe.scope)),Nt});We.replaceChildren(z("div",{class:"tlx-detail-head"},z("strong",null,H.kind),yn),z("p",{class:`tlx-sev sev-${H.severity}`},`${H.severity} \xB7 ${he?.title??H.source}`),z("p",{class:"tlx-sum"},...Fe(H.summary)),z("p",null,nn(H.t,n),H.dur!==void 0?` \xB7 ${Dc(H.dur)}${H.open?" so far":""}`:H.open?" \xB7 still going":""),z("p",{class:"tlx-crumbs small"},...et),...bt.length?[z("table",{class:"tlx-attrs"},z("tbody",null,...bt))]:[],z("div",{class:"tlx-links"},...(e.actions?.(H)??[]).map(([Qe,Nt])=>st(Qe,Nt)))),We.hidden=!1}function as(H,he){let ke=lr({from:H,to:he});if(!J.find(bt=>bt.from===H&&bt.to===he))return;if(N.add(ke),!r){F.set(ke,1),Z();return}let Fe=performance.now(),st=bt=>{let yn=Math.min(1,(bt-Fe)/260);F.set(ke,1-(1-yn)**3),Se(),yn<1&&requestAnimationFrame(st)};requestAnimationFrame(st)}let Ht,Yn=H=>H.clientX-Ee.getBoundingClientRect().left;Ee.addEventListener("pointerdown",H=>{let he=Yn(H),ke=H.clientY-Ee.getBoundingClientRect().top,Ae=H.target.closest?.(".tlx-cut");if(Ae){H.preventDefault(),as(Number(Ae.getAttribute("data-from")),Number(Ae.getAttribute("data-to")));return}Ee.setPointerCapture(H.pointerId),Ht={kind:ke<rs||H.shiftKey?"brush":H.target.classList.contains("tlx-handle")?"scrub":"pan",x0:he,t0:ae.t(he),v0:h,moved:!1},H.preventDefault(),Oe.focus({preventScroll:!0})}),Ee.addEventListener("pointermove",H=>{if(!Ht)return;let he=Yn(H);if(Math.abs(he-Ht.x0)>3&&(Ht.moved=!0),!!Ht.moved)if(Ht.kind==="pan"){let ke=(Ht.x0-he)*ae.msPerPx;h={t0:Ht.v0.t0+ke,t1:Ht.v0.t1+ke},A=!1,L()}else Ht.kind==="scrub"?Yt(ae.t(he)):(y={from:Math.min(Ht.t0,ae.t(he)),to:Math.max(Ht.t0,ae.t(he))},Z())}),Ee.addEventListener("pointerup",H=>{let he=Ht;if(Ht=void 0,!he)return;let ke=Yn(H);if(he.kind==="brush"&&he.moved){Pt(he.t0,ae.t(ke));return}if(he.kind==="brush"&&!he.moved){Yt(ae.t(ke));return}if(he.kind==="pan"&&!he.moved){let Ae=H.target.closest?.("[data-id]")?.getAttribute("data-id"),Fe=Ae?[...b?.events??[],...b?.spans??[]].find(st=>st.id===Ae):void 0;Fe?(pt(Fe),Yt(Fe.t)):Yt(ae.t(ke))}}),Ee.addEventListener("keydown",H=>{let he=H.target.closest?.(".tlx-cut");he&&(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),as(Number(he.getAttribute("data-from")),Number(he.getAttribute("data-to"))))}),Ee.addEventListener("wheel",H=>{H.preventDefault();let he=Yn(H);if(H.shiftKey||Math.abs(H.deltaX)>Math.abs(H.deltaY)){let ke=(H.shiftKey?H.deltaY:H.deltaX)*ae.msPerPx;h={t0:h.t0+ke,t1:h.t1+ke},A=!1}else ls(ae.t(he),Math.exp(H.deltaY*.0015),he/Ne());L()},{passive:!1});function ls(H,he,ke=.5){let Ae=Math.min(400*kn,Math.max(1e4,(h.t1-h.t0)*he));h={t0:H-ke*Ae,t1:H+(1-ke)*Ae},N.clear(),F.clear(),he<1&&(A=p&&h.t1>=at())}Oe.addEventListener("keydown",H=>{let he=h.t1-h.t0;if(H.key==="ArrowLeft"||H.key==="ArrowRight"){let ke=he*.15*(H.key==="ArrowLeft"?-1:1);h={t0:h.t0+ke,t1:h.t1+ke},A=!1}else if(H.key==="+"||H.key==="=")ls((h.t0+h.t1)/2,.6);else if(H.key==="-"||H.key==="_")ls((h.t0+h.t1)/2,1/.6);else if(H.key==="n"||H.key==="N"){vt(H.shiftKey?-1:1),H.preventDefault();return}else if(H.key==="Escape")pt(void 0),y=void 0,it.hidden=!0;else return;H.preventDefault(),L()}),t.addEventListener("keydown",H=>{H.key==="/"&&document.activeElement!==me&&!H.target.closest("input, select, textarea")&&(H.preventDefault(),me.focus())}),Be.addEventListener("scroll",()=>Z(),{passive:!0}),$e.addEventListener("click",async()=>{let H=`${jr(c).slice(-1)[0].label}${u?`: ${u}`:""}`.slice(0,80);await e.saveView?.({...E(),name:H}),await fn()});let rt=[];async function fn(){e.views&&(rt=await e.views(),re.replaceChildren(z("option",{value:""},"Saved views\u2026"),...rt.map((H,he)=>z("option",{value:String(he)},H.name))))}re.addEventListener("change",()=>{let H=rt[Number(re.value)];H&&(Y(H),Ke(),L(!0)),re.value=""});let Mt=typeof ResizeObserver=="function"?new ResizeObserver(()=>Z()):void 0;Mt?.observe(Oe);let Jt=(async()=>{l=await e.source.catalog(),j=l.sources.flatMap(Ae=>(Ae.sensitive??[]).map(Fe=>`${Ae.name}.${Fe}`));for(let Ae of l.sources)for(let Fe of Ae.series)we.set(Fe.name,{unit:Fe.unit,type:Fe.type,title:Fe.title,source:Ae.name});c=l.hosts.length===1?`host:${l.hosts[0].replace(/[%/:\s]/g,Ae=>`%${Ae.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}`:"";let he=l.now;h={t0:he-kn,t1:he+kn*.02};let ke=de()??e.view;ke&&Y(ke),Ke(),await fn(),await L(!0),u&&await Ce()})();return{el:t,ready:Jt,get view(){return E()},setView(H){return Y(H),Ke(),L(!0)},setRange(H,he){return h={t0:H,t1:he},A=!1,L()},setPlayhead:Yt,setLive:kt,setTheme:a,refresh:()=>L(!0),internal:{get result(){return b},get mode(){return ot()},get scale(){return ae},get gaps(){return J},get playState(){return x},get hits(){return $},get selected(){return T},get follow(){return A},openCut:as,showTable:Pt,rangeEvents:Ot,exportRange:_t,select:pt,stepHit:vt,drill:St,findHits:Ce,paint:Se,lines:gt},dispose(){_?.(),Mt?.disconnect(),D&&cancelAnimationFrame(D),t.replaceChildren()}}}var lm={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}},sn=t=>(Math.round(t*10)/10).toString(),tf=t=>(t??"link").replace(/[^\w-]/g,"_");function _r(t,e){let{id:n}=e,s=e.styles??{},r=t.options,o=t.bounds,i=new Map,a=(p,g)=>{let h=s[p]??{},b=g==="start"?h.start??"none":h.end??"arrow";if(b!=="none")return(i.get(p)??i.set(p,new Set).get(p)).add(b),`url(#${n}-mk-${p}-${b})`},l="",c="",d="",u="";for(let p of[...t.panels].sort((g,h)=>g.depth-h.depth)){let g=p.rect,h=p.label?Ve("text",{class:"pl",x:p.titleAt[0],y:p.titleAt[1]},Dt(p.label)+(p.sub?Ve("tspan",{class:"pls",dx:10},Dt(p.sub)):"")):"";l+=Ve("g",{class:`panel k-${p.role??"grey"}`,"data-id":p.id},Ve("rect",{class:"face",x:sn(g.l),y:sn(g.t),width:sn(g.r-g.l),height:sn(g.b-g.t),rx:r.panelRx})+h)}for(let p of t.links){if(!p.points.length)continue;let g=tf(p.kind);c+=Ve("path",{class:`conn k-${g}`,d:"M"+p.points.map(h=>`${sn(h[0])},${sn(h[1])}`).join(" L"),"data-id":p.id,"data-a":p.a,"data-b":p.b,"marker-start":a(g,"start"),"marker-end":a(g,"end")}),p.at&&(u+=Ve("text",{class:`cl k-${g}`,x:p.at.x,y:p.at.y,"text-anchor":p.at.anchor==="start"?void 0:p.at.anchor,"data-for":p.id},Dt(p.at.text)))}for(let p of t.cards){let g=p.rect;d+=Ve("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},Ve("rect",{class:"face",x:sn(g.l),y:sn(g.t),width:r.W,height:r.H,rx:r.cardRx})+Ve("text",{class:"lt",x:sn(g.l+14),y:sn(g.t+24)},Dt(p.label))+(p.sub?Ve("text",{class:"st",x:sn(g.l+14),y:sn(g.t+42)},Dt(p.sub)):""))}let f="";for(let[p,g]of i)for(let h of g){let b=lm[h];f+=Ve("marker",{id:`${n}-mk-${p}-${h}`,viewBox:"0 0 10 10",refX:b.refX,refY:5,markerWidth:5.4,markerHeight:5.4,orient:"auto-start-reverse"},Ve("path",{d:b.d,class:`mk k-${p}`}))}return Ve("svg",{xmlns:"http://www.w3.org/2000/svg",class:"flat",viewBox:`${sn(o.l)} ${sn(o.t)} ${sn(o.r-o.l)} ${sn(o.b-o.t)}`,role:"img","aria-label":e.title??"drawing, flat view","data-view":"2d"},(f?Ve("defs",{},f):"")+Ve("g",{class:"panels"},l)+Ve("g",{class:"conns"},c)+Ve("g",{class:"cards"},d)+Ve("g",{class:"labels"},u))}function nf(t={}){let e=s=>s?s.startsWith("#")||s.includes("(")?s:`var(--${s})`:"var(--ink)",n=`
|
|
359
|
+
`}var _m=864e5,es=36e5,il=(t,e)=>t.t-e.t||(t.id<e.id?-1:t.id>e.id?1:0);function ps(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 Pf=(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 Tf(t,e,n){let s=[];for(let r of t){let o=yr(r.t,e,n),i=s[s.length-1];i&&i.t===o?Pf(i,r):s.push({t:o,min:r.min,max:r.max,sum:r.sum,count:r.count})}return s}function dd(t,e,n,s){for(let i=ps(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=ps(t,e.t);for(;o<t.length&&s(t[o],e)<0;)o++;t.splice(o,0,e)}function Af(t,e,n){for(let s=ps(t,e);s<t.length&&t[s].t===e;s++)if(n(t[s])){t.splice(s,1);return}}function Cf(t,e,n={}){let s=t.catalog,{isScope:r}=Xa(e),{parseSearch:o,matchAst:i,toAst:a}=Qr(e),l=D=>Object.fromEntries(e.flags.filter(se=>D?.[se]).map(se=>[se,!0])),c=n.now??s.now,d=(s.names??[]).flatMap(D=>(D.aliases??[]).map(se=>[se,D.scope])).sort((D,se)=>se[0].length-D[0].length),u=new Map,f=D=>{if(!d.length)return D;let se=u.get(D);if(se===void 0){let Me=d.find(([Ce])=>Sn(D,Ce));se=Me?Me[1]+D.slice(Me[0].length):D,u.set(D,se)}return se},p=new Map((s.names??[]).map(D=>[D.scope,D])),g=D=>d.length?{...D,scope:f(D.scope)}:D,h=D=>`${D.source}\0${D.id}`,b=t.events.map(g).sort(il),v=new Map;for(let D of b)v.set(h(D),D);let w=b.filter(D=>D.dur!==void 0&&!D.open),k=w.reduce((D,se)=>Math.max(D,se.dur),0),y=new Map;for(let D of b)D.open&&y.set(h(D),D);let M=new Map,T=new Set,A=D=>{for(let se=rn(D);se>=1;se--){let Me=Os(D,se);if(T.has(Me))break;T.add(Me)}},I=new Map;for(let D of s.sources)for(let se of D.series)I.set(se.name,se.type);let j=s.sources.flatMap(D=>(D.sensitive??[]).map(se=>`${D.name}.${se}`)),L=new Map;for(let D of s.sources)L.set(D.name,{events:D.defaultRetention.events,rollups:{...D.defaultRetention.rollups},setBy:"default"});for(let D of s.retention)L.set(D.source,{events:D.events,rollups:{...D.rollups},setBy:D.setBy});let B=new Map;for(let D of s.sources)for(let se of D.series)B.set(se.name,D.name);function S(D){let se=f(D.scope),Me=`${D.series}\0${se}`,Ce=M.get(Me);Ce||(Ce={series:D.series,scope:se,fine:[],cache:new Map},M.set(Me,Ce),A(se));let he="value"in D?{t:D.t,min:D.value,max:D.value,sum:D.value,count:1}:{t:D.t,min:D.min,max:D.max,sum:D.sum,count:D.count};dd(Ce.fine,he,ie=>ie.t===he.t,(ie,Ke)=>ie.t-Ke.t),Ce.cache.clear()}for(let D of b)A(D.scope);for(let D of t.metrics)S(D);let E=new Map,x=new Set,N=(D,se)=>{x.add(D.source);let Me=E.get(D.scope);Me||E.set(D.scope,Me=new Map);let Ce=Me.get(D.source);Ce||Me.set(D.source,Ce=new Map);let he=Math.floor(D.t/es)*es,ie=Ce.get(he);if(ie||Ce.set(he,ie={t:he,count:0,severity:{},kinds:{},first:1/0,last:-1/0}),ie.count+=se,se>0)ie.first=Math.min(ie.first,D.t),ie.last=Math.max(ie.last,D.t);else if(D.t===ie.first||D.t===ie.last){ie.first=1/0,ie.last=-1/0;for(let Ke=ps(b,he);Ke<b.length&&b[Ke].t<he+es;Ke++){let Oe=b[Ke];Oe.scope===D.scope&&Oe.source===D.source&&(ie.first=Math.min(ie.first,Oe.t),ie.last=Math.max(ie.last,Oe.t))}}ie.severity[D.severity]=(ie.severity[D.severity]??0)+se,ie.kinds[D.kind]=(ie.kinds[D.kind]??0)+se,ie.severity[D.severity]===0&&delete ie.severity[D.severity],ie.kinds[D.kind]===0&&delete ie.kinds[D.kind],ie.count||Ce.delete(he)};for(let D of b)N(D,1);let z=(D,se,Me)=>{let Ce=`${se}|${Me??""}`,he=D.cache.get(Ce);return he||(he=se==="1d"?Tf(z(D,"1h",Me),"1d",Me):Tf(D.fine,se,Me),D.cache.set(Ce,he)),he},Q=D=>D===null?-1/0:c-D*_m,re=D=>Q(L.get(D)?.events??null),we=(D,se)=>{let Me=L.get(D);return Q(Me?se?Me.rollups[se]:Me.events:null)};function F(D){let se=[];for(let Me of new Set(D)){let Ce=L.get(Me);if(!Ce)continue;let he=b.find(Te=>Te.source===Me&&Te.t>=re(Me))?.t,ie=Te=>{let je=1/0;for(let lt of M.values())if(B.get(lt.series)===Me){let We=(Te?z(lt,Te):lt.fine).find(ft=>ft.t>=we(Me,Te));We&&We.t<je&&(je=We.t)}return je===1/0?void 0:je},Ke=[he,ie()].filter(Te=>Te!==void 0),Oe={};for(let Te of["1m","1h","1d"]){let je=ie(Te)??(he!==void 0&&he>=we(Me,Te)?he:void 0);je!==void 0&&(Oe[Te]=Math.max(je,we(Me,Te)))}se.push({source:Me,events:Ce.events,rollups:{...Ce.rollups},setBy:Ce.setBy,keptFrom:{...Ke.length?{events:Math.min(...Ke)}:{},rollups:Oe}})}return se}function X(D){let se=D.where,Me={from:D.from,to:D.to},Ce=[];if(!se&&D.q){let We=o(D.q,c);se=a(We),Me=ri(We,D.from,D.to),Ce=We.warnings}let he=i(se,j),ie=D.filters??{},Ke=ie.source?.length?new Set(ie.source):void 0,Oe=ie.kind?.length?new Set(ie.kind):void 0,Te=ie.severity?.length?new Set(ie.severity):void 0,je=ie.scope?.length?ie.scope:void 0;return{test:We=>Sn(We.scope,D.scope)&&(!Ke||Ke.has(We.source))&&(!Oe||Oe.has(We.kind))&&(!Te||Te.has(We.severity))&&(!je||je.some(ft=>Sn(We.scope,ft)))&&We.t>=re(We.source)&&he(We),range:Me,warnings:Ce}}function Z(D){let se=rn(D.scope),Me=se+D.depth,Ce=new Map,he=Te=>{let je=Ce.get(Te);return je===void 0&&!Ce.has(Te)&&(je=Sn(Te,D.scope)?rn(Te)>=Me?Os(Te,Me):Te:void 0,Ce.set(Te,je)),je},ie=Te=>{let je=0,lt=rn(Te)+1;for(let We of T)rn(We)===lt&&Sn(We,Te)&&je++;return je},Ke=new Map,Oe=Te=>{let je=Ke.get(Te);if(!je){let lt=rn(Te)-se,We=p.get(Te);je={scope:Te,label:We?.label??Jr(Te),kind:Wr(Te),...l(We),depth:lt,...lt<D.depth?{own:!0}:{},children:ie(Te),count:0},Ke.set(Te,je)}return je};for(let Te of T)rn(Te)===Me&&Sn(Te,D.scope)&&Oe(Te);return Me===0&&Oe(""),{at:he,add:Oe,rows:Ke}}let be=D=>[...D.values()].sort((se,Me)=>se.scope===Me.scope?0:se.scope<Me.scope?-1:1);function V(D,se){let Me=[];for(let Ce=ps(w,D-k);Ce<w.length&&w[Ce].t<D;Ce++)w[Ce].t+w[Ce].dur>D&&Me.push(w[Ce]);for(let Ce of y.values())Ce.t<D&&c>D&&Me.push(Ce);for(let Ce=ps(b,D);Ce<b.length&&b[Ce].t<se;Ce++)Me.push(b[Ce]);return Me}function J(D,se,Me,Ce){let he=D.series?new Set(D.series):void 0,ie=new Map;for(let Oe of M.values()){if(he&&!he.has(Oe.series))continue;let Te=se(Oe.scope);if(Te===void 0)continue;let je=B.get(Oe.series)??"",lt=we(je,D.bin),We=D.bin?z(Oe,D.bin,D.tz):Oe.fine;for(let ft=ps(We,D.bin?yr(Me,D.bin,D.tz):Me);ft<We.length&&We[ft].t<Ce;ft++){let ut=We[ft];if(ut.t<lt)continue;let it=`${Oe.series}\0${Te}\0${ut.t}`,Pe=ie.get(it);Pe?Pf(Pe,ut):ie.set(it,{series:Oe.series,scope:Te,t:ut.t,bin:D.bin??"1m",min:ut.min,max:ut.max,sum:ut.sum,count:ut.count})}}let Ke=[...ie.values()].sort((Oe,Te)=>Oe.t-Te.t||(Oe.series<Te.series?-1:1)||(Oe.scope<Te.scope?-1:1));return D.bin?Ke:Ke.map(Oe=>({series:Oe.series,scope:Oe.scope,t:Oe.t,value:Oe.count===1||I.get(Oe.series)!=="gauge"?Oe.sum:Oe.sum/Oe.count}))}let G=D=>`${D.t}:${D.id}`,ne=(D,se)=>{let Me=se.indexOf(":"),Ce=Number(se.slice(0,Me)),he=se.slice(Me+1);return D.t>Ce||D.t===Ce&&D.id>he};function oe(D){if(D.bin!=="1h"&&D.bin!=="1d"||(D.where?.all.length??0)||D.q||D.filters?.kind?.length||D.filters?.severity?.length||D.filters?.scope?.length||dn(D.tz,D.from)%es||dn(D.tz,D.to)%es)return;let se=D.filters?.source?.length?new Set(D.filters.source):void 0,Me=P=>Math.max(D.from,re(P)),{at:Ce,add:he,rows:ie}=Z(D),Ke=new Set,Oe=new Map,Te=0,je=(P,q)=>{let U=yr(q,D.bin,D.tz),ae=`${P}\0${U}`,m=Oe.get(ae);return m||(m={scope:P,t:U,bin:D.bin,count:0,severity:{},kinds:{}},Oe.set(ae,m)),m},lt=(P,q,U)=>{let ae=he(P);ae.count+=U,Te+=U,(ae.first===void 0||q<ae.first)&&(ae.first=q),(ae.last===void 0||q>ae.last)&&(ae.last=q)},We=Math.floor(D.to/es)*es;for(let[P,q]of E){let U=Ce(P);if(U!==void 0)for(let[ae,m]of q){if(se&&!se.has(ae))continue;let C=Math.ceil(Me(ae)/es)*es;for(let[R,H]of m){if(R<C||R>=We)continue;lt(U,H.first,H.count),H.last>(ie.get(U).last??-1/0)&&(ie.get(U).last=H.last),Ke.add(ae);let ee=je(U,R);ee.count+=H.count;for(let[$e,de]of Object.entries(H.severity))ee.severity[$e]=(ee.severity[$e]??0)+de;for(let[$e,de]of Object.entries(H.kinds))ee.kinds[$e]=(ee.kinds[$e]??0)+de}}}let ft=P=>Sn(P.scope,D.scope)&&(!se||se.has(P.source))&&P.t>=re(P.source)&&Ce(P.scope)!==void 0,ut=P=>{let q=Ce(P.scope);lt(q,P.t,1),Ke.add(P.source);let U=je(q,P.t);U.count++,U.severity[P.severity]=(U.severity[P.severity]??0)+1,U.kinds[P.kind]=(U.kinds[P.kind]??0)+1};for(let P of x){if(se&&!se.has(P))continue;let q=Me(P),U=Math.ceil(q/es)*es,ae=U>=We?[[q,D.to]]:[[q,U],[We,D.to]];for(let[m,C]of ae)for(let R=ps(b,m);R<b.length&&b[R].t<C;R++){let H=b[R];H.source===P&&ft(H)&&ut(H)}}let it=jn[D.bin],Pe=[];for(let P=ps(w,D.from-k);P<w.length&&w[P].t<D.from;P++){let q=w[P];q.t+q.dur>D.from&&ft(q)&&(lt(Ce(q.scope),q.t,1),Ke.add(q.source),q.dur>=it&&Pe.length<5e3&&Pe.push(q))}for(let P of y.values())P.t<D.from&&c>D.from&&ft(P)&&(lt(Ce(P.scope),P.t,1),Ke.add(P.source),Pe.length<5e3&&Pe.push(P));for(let P=ps(w,D.from);P<w.length&&w[P].t<D.to&&Pe.length<5e3;P++)w[P].dur>=it&&ft(w[P])&&Pe.push(w[P]);for(let P of y.values())P.t>=D.from&&P.t<D.to&&Pe.length<5e3&&ft(P)&&Pe.push(P);let mt=J(D,Ce,D.from,D.to);for(let P of mt){let q=B.get(P.series);q&&Ke.add(q)}let rt=[...Oe.values()].sort((P,q)=>P.t-q.t||(P.scope<q.scope?-1:1));return{timeline:1,type:"result",rows:be(ie),bins:rt,spans:Pe,metrics:mt,total:Te,retention:F(Ke)}}async function ve(D){if(!r(D.scope))throw new Error(`not a scope path: ${JSON.stringify(D.scope)}`);let se=oe(D);if(se)return se;let{test:Me,range:Ce,warnings:he}=X(D),{at:ie,add:Ke,rows:Oe}=Z(D),Te=new Set,je=[];for(let mt of V(Ce.from,Ce.to)){if(!Me(mt))continue;let rt=ie(mt.scope);if(rt===void 0)continue;let P=Ke(rt);P.count++,(P.first===void 0||mt.t<P.first)&&(P.first=mt.t),(P.last===void 0||mt.t>P.last)&&(P.last=mt.t),Te.add(mt.source),je.push(mt)}je.sort(il);let lt=J(D,ie,Ce.from,Ce.to);for(let mt of lt){let rt=B.get(mt.series);rt&&Te.add(rt)}let We={timeline:1,type:"result",total:je.length,...he.length?{warnings:he}:{}};if(D.bin){let mt=jn[D.bin],rt=new Map,P=[];for(let U of je){if((U.open||U.dur!==void 0&&U.dur>=mt)&&P.length<5e3&&P.push(U),U.t<Ce.from)continue;let ae=ie(U.scope),m=yr(U.t,D.bin,D.tz),C=`${ae}\0${m}`,R=rt.get(C);R||(R={scope:ae,t:m,bin:D.bin,count:0,severity:{},kinds:{}},rt.set(C,R)),R.count++,R.severity[U.severity]=(R.severity[U.severity]??0)+1,R.kinds[U.kind]=(R.kinds[U.kind]??0)+1}let q=[...rt.values()].sort((U,ae)=>U.t-ae.t||(U.scope<ae.scope?-1:1));return{...We,rows:be(Oe),bins:q,spans:P,metrics:lt,retention:F(Te)}}let ft=Math.min(1e4,Math.max(1,D.limit??2e3)),ut=D.cursor?je.findIndex(mt=>ne(mt,D.cursor)):0,it=ut<0?[]:je.slice(ut,ut+ft),Pe=ut>=0&&ut+ft<je.length;return{...We,rows:be(Oe),events:it,metrics:lt,retention:F(Te),...Pe?{next:G(it[it.length-1])}:{}}}let ge=new Set,ye=D=>kn.includes(D),Ie=0;function Ue(D){let se=h(D),Me=v.get(se);Me&&(Af(b,Me.t,Ce=>Ce===Me),N(Me,-1),Me.dur!==void 0&&!Me.open&&Af(w,Me.t,Ce=>Ce===Me),y.delete(se)),v.set(se,D),N(D,1),dd(b,D,()=>!1,il),D.open?y.set(se,D):D.dur!==void 0&&(dd(w,D,()=>!1,il),k=Math.max(k,D.dur)),A(D.scope)}return{async catalog(){return{...s,now:c,retention:F(s.sources.map(D=>D.name))}},query:ve,subscribe(D,se){let Me={q:D,on:se};return ge.add(Me),()=>{ge.delete(Me)}},...n.stateAt?{stateAt:(D,se)=>n.stateAt(D,se)}:{},append(D,se=[],Me){Me!==void 0&&(c=Math.max(c,Me));let Ce=new Set(T),he=D.map(g);for(let ie of he){if(!ye(ie.severity))throw new Error(`not a severity: ${ie.severity}`);Ue(ie)}for(let ie of se)S(ie);Ie++;for(let ie of ge){let{test:Ke}=X(ie.q),{at:Oe}=Z(ie.q),Te=he.filter(it=>Ke(it)&&Oe(it.scope)!==void 0),je=ie.q.series?new Set(ie.q.series):void 0,lt=se.filter(it=>Sn(f(it.scope),ie.q.scope)&&(!je||je.has(it.series))).map(it=>({...it,scope:Oe(f(it.scope))})),We=[...T].filter(it=>!Ce.has(it)),ft=rn(ie.q.scope)+ie.q.depth,ut=We.filter(it=>rn(it)===ft&&Sn(it,ie.q.scope)).map(it=>({scope:it,label:p.get(it)?.label??Jr(it),kind:Wr(it),depth:ie.q.depth,children:0,count:0}));ie.on({timeline:1,type:"batch",events:Te,metrics:lt,...ut.length?{rows:ut}:{},now:c,resume:String(Ie)})}},setRetention(D,se){L.set(D,{events:se.events,rollups:{...se.rollups},setBy:"user"})},get now(){return c},get size(){let D=0;for(let se of M.values())D+=se.fine.length;return{events:b.length,samples:D}}}}var Of="http://www.w3.org/2000/svg",vr=22,al=38,ms=26,zm=210,Vm=24,ii=6e4,kr=36e5,Cn=864e5,Lf={"15m":15*ii,"1h":kr,"1d":Cn,"1w":7*Cn},Nf=t=>kn.indexOf(t),Gm={debug:"dot",info:"circle",notice:"square",warning:"triangle",error:"diamond"},Nt=(t,e,n)=>{let s=document.createElementNS(Of,t);for(let[r,o]of Object.entries(e))o!==void 0&&s.setAttribute(r,String(o));if(n){let r=document.createElementNS(Of,"title");r.textContent=n,s.append(r)}return s},un=(t,e)=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e,dateStyle:"medium",timeStyle:"medium"}).format(t)}catch{return new Date(t).toISOString()}},ud=t=>t<1e3?`${Math.round(t)} ms`:t<ii?`${(t/1e3).toFixed(1)} s`:xr(t),Hm=(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 fd(t,e){if(t<=3*kr)return{kind:"single"};for(let n of["1m","1h","1d"])if(t/jn[n]<=e/2)return{kind:"binned",bin:n};return{kind:"binned",bin:"1d"}}function pd(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"?jn[e.bin]:ii;for(let i of t.bins??[])i.count&&s.push([i.t,i.t+jn[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 Rf(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}=Qr(e.catalog),a=(Y="system")=>{t.style.colorScheme=Y==="system"?"light dark":Y,Y==="system"?delete t.dataset.theme:t.dataset.theme=Y};a(e.theme),t.setAttribute("role","region"),t.setAttribute("aria-label","Timeline");let l,c="",d=1,u="",f={},p=!1,g=e.collapseGaps??!0,h={t0:0,t1:Cn},b,v="",w={from:0,to:0,mode:{kind:"single"},key:""},k,y,M,T,A=!0,I=0,j=0,L=!1,B,S=[],E=[],x=-1,N=new Set,z=new Map,Q=[],re=Zr(0,Cn,800),we=new Map,F=[],X=_("nav",{class:"tlx-crumbs","aria-label":"Scope"}),Z=_("div",{class:"segmented tlx-quick",role:"group","aria-label":"Range"});for(let Y of["15m","1h","1d","1w","run"]){let pe=_("button",{type:"button",class:"seg","data-v":Y,title:Y==="run"?"The latest run":`The last ${Y}`},Y==="run"?"this run":Y);pe.addEventListener("click",()=>$n(Y)),Z.append(pe)}let be=_("button",{type:"button",class:"btn sm tlx-live","aria-pressed":"false",title:"Follow what happens now"},"Live"),V=_("button",{type:"button",class:"btn sm quiet tlx-now",hidden:!0,title:"Back to the live edge"},"Back to now"),J=_("button",{type:"button",class:"btn sm quiet tlx-fit",title:"Everything in this scope"},"Fit"),G=_("input",{type:"checkbox",class:"tlx-gaps"});G.checked=g;let ne=!0,oe=_("input",{type:"checkbox",class:"tlx-quiet"});oe.checked=ne;let ve=_("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"}),ge=_("span",{class:"tlx-hits",role:"status","aria-live":"polite"}),ye=_("button",{type:"button",class:"btn sm quiet tlx-prev",title:"Previous hit (\u21E7N)","aria-label":"Previous hit"},"\u2039"),Ie=_("button",{type:"button",class:"btn sm quiet tlx-next",title:"Next hit (N)","aria-label":"Next hit"},"\u203A"),Ue=_("div",{class:"tlx-facets",role:"group","aria-label":"Sources"}),D=_("select",{class:"input tlx-sev","aria-label":"Severity"},_("option",{value:""},"every severity"),...kn.slice(1).map(Y=>_("option",{value:Y},`${Y} and above`))),se=_("select",{class:"input tlx-views","aria-label":"Saved views",hidden:!e.views},_("option",{value:""},"Saved views\u2026")),Me=_("button",{type:"button",class:"btn sm quiet tlx-save",hidden:!e.saveView,title:"Save this view"},"Save view"),Ce=_("div",{class:"tlx-warn",role:"status",hidden:!0}),he=_("div",{class:"tlx-status",role:"status"}),ie=_("span",{class:"tlx-canvas-note"}),Ke=_("div",{class:"tlx-labels"}),Oe=_("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"}),Te=Nt("svg",{class:"tlx-svg"});Oe.append(Te);let je=_("div",{class:"tlx-scroll"},_("div",{class:"tlx-grid"},Ke,Oe)),lt=_("section",{class:"tlx-table",hidden:!0,"aria-label":"The events in the chosen range"}),We=_("aside",{class:"tlx-detail",hidden:!0,"aria-label":"The event"});t.replaceChildren(_("div",{class:"tlx-bar"},X,_("span",{class:"spacer"}),Z,be,V,J,_("label",{class:"tlx-gaps-label",title:"Draw long empty stretches as narrow breaks"},G,"Collapse gaps"),_("label",{class:"tlx-gaps-label",title:"Hide the rows with nothing in this range"},oe,"Hide quiet rows")),_("div",{class:"tlx-bar"},ve,ge,ye,Ie,D,se,Me),Ue,Ce,_("div",{class:"tlx-body"},je,We),_("div",{class:"tlx-foot"},he,_("span",{class:"spacer"}),ie),lt);let ft=()=>Math.max(200,Oe.clientWidth||800),ut=()=>{let Y=(Re,at)=>(Re.own?-1:0)-(at.own?-1:0)||Re.scope.localeCompare(at.scope,void 0,{numeric:!0}),ke=(b?.rows??[]).filter(Re=>!ne||Re.count>0||Re.own||(b?.rows.length??0)<=1).sort(Y).map(Re=>({kind:"row",row:Re})),Ae=new Set(b?.metrics.map(Re=>Re.series)??[]);for(let Re of[...Ae].sort()){let at=we.get(Re);ke.push({kind:"metric",series:Re,unit:at?.unit??"count",type:at?.type??"counter",title:at?.title??Re})}return ke},it=(Y,pe)=>l?.names?.find(ke=>ke.scope===Y)?.label??pe,Pe=Y=>Y.kind==="metric"?al:vr,mt=()=>fd(h.t1-h.t0,ft()),rt=()=>l?.now??Date.now();function P(){return{timeline:1,type:"view",name:"",scope:c,depth:d,range:{from:Math.round(h.t0),to:Math.round(h.t1)},...u?{q:u}:{},...Object.keys(f).length?{filters:f}:{},...p?{live:p}:{},...g?{}:{collapseGaps:!1},...ne?{}:{quietRows:!0}}}function q(Y){Y.scope!==void 0&&(c=Y.scope),Y.depth!==void 0&&(d=Y.depth),u=Y.q??"",ve.value=u,f=Y.filters??{},D.value=f.severity?.length?f.severity[0]:"",g=Y.collapseGaps??e.collapseGaps??!0,G.checked=g,ne=!Y.quietRows,oe.checked=ne,N.clear(),z.clear();let pe=Y.range;pe&&"last"in pe?$n(pe.last,!1):pe&&(h={t0:pe.from,t1:pe.to}),Ct(!!Y.live,!1)}let U=()=>{let Y=P();if(e.onViewChange?.(Y),!!e.urlState)try{history.replaceState(null,"",`#timeline=${encodeURIComponent(JSON.stringify(Y))}`)}catch{}},ae=()=>{if(!e.urlState)return;let Y=/#timeline=(.+)$/.exec(location.hash);if(Y)try{return JSON.parse(decodeURIComponent(Y[1]))}catch{return}};function m(Y,pe,ke,Ae={}){let Re=i(u,rt(),Y,pe);S=Re.warnings;let at=u?[]:f.source?[...we].filter(([,vt])=>f.source.includes(vt.source)).map(([vt])=>vt):void 0;return{timeline:1,type:"query",scope:c,depth:d,from:Re.from,to:Re.to,tz:n,...ke.kind==="binned"?{bin:ke.bin}:{},...u?{q:u,where:Re.where}:{},...Object.keys(f).length?{filters:f}:{},...at?{series:at}:{},...Ae}}let C=()=>JSON.stringify([c,d,u,f,mt()]);async function R(Y=!1){let pe=mt(),ke=C(),Ae=h.t1-h.t0;if(!Y&&b&&ke===w.key&&h.t0>=w.from&&h.t1<=w.to){ee();return}if(j){L=!0;return}j++;let Re=h.t0-Ae/2,at=Math.min(h.t1+Ae/2,Math.max(h.t1,rt()+Ae*.1));try{let vt=await e.source.query(m(Re,at,pe,pe.kind==="single"?{limit:1e4}:{}));pe.kind==="single"&&vt.next&&(vt=await e.source.query(m(Re,at,{kind:"binned",bin:"1m"}))),b=vt,v=ke,w={from:Re,to:at,mode:pe,key:ke}}catch(vt){he.textContent=`The history couldn't be read: ${String(vt?.message??vt)}`}finally{j--}ee(),U(),L&&(L=!1,R())}function H(){let Y=ft(),pe=mt();if(Q=[],g&&b){let ke=new Map([...we].map(([Ae,Re])=>[Ae,Re.type]));Q=nl(pd(b,pe,ke),h.t0,Math.min(h.t1,Math.max(h.t0,rt())),{minFrac:.15,minMs:10*ii}),pe.kind==="binned"&&(Q=Q.filter(Ae=>Ae.to-Ae.from>=2*jn[pe.bin])),Q=Q.filter(Ae=>!(N.has(wr(Ae))&&(z.get(wr(Ae))??1)>=1))}re=Zr(h.t0,h.t1,Y,Q,{cut:Vm,weights:z})}let ee=()=>{I||(I=requestAnimationFrame($e))};function $e(){I=0,H();let Y=ft(),pe=ut(),ke=w.mode,Ae=[],Re=ms;for(let xe of pe)Ae.push(Re),Re+=Pe(xe);let at=Math.max(Re,ms+vr);Te.setAttribute("width",String(Y)),Te.setAttribute("height",String(at)),Te.setAttribute("viewBox",`0 0 ${Y} ${at}`);let vt=je.scrollTop-200,En=je.scrollTop+(je.clientHeight||600)+200,Ze=[],Qe=re.x;Ze.push(Nt("rect",{class:"tlx-axis",x:0,y:0,width:Y,height:ms}));let sn=(b?.retention??[]).map(xe=>({r:xe,from:ke.kind==="binned"?xe.keptFrom.rollups[ke.bin]??xe.keptFrom.events:xe.keptFrom.events,days:ke.kind==="binned"?xe.rollups[ke.bin]:xe.events})).filter(xe=>xe.from!==void 0);if(sn.length){let xe=Math.min(...sn.map(Fe=>Fe.from));xe>h.t0&&Ze.push(Nt("rect",{class:"tlx-notkept",x:Math.max(0,Qe(h.t0)),y:ms,width:Math.max(0,Qe(xe)-Math.max(0,Qe(h.t0))),height:at-ms},`Nothing kept before ${un(xe,n)}: ${sn.map(Fe=>`${Fe.r.source} ${Fe.days===null?"kept until deleted":`kept ${Fe.days} days`}`).join(", ")}`))}let hn=rt();hn<h.t1&&Ze.push(Nt("rect",{class:"tlx-future",x:Qe(hn),y:ms,width:Y-Qe(hn),height:at-ms}));for(let xe of sl(re,n,90)){Ze.push(Nt("line",{class:`tlx-tick${xe.major?" major":""}`,x1:xe.x,x2:xe.x,y1:ms-6,y2:at}));let Fe=Nt("text",{class:"tlx-ticklabel",x:xe.x+3,y:16});Fe.textContent=xe.label,Ze.push(Fe)}T&&Ze.push(Nt("rect",{class:"tlx-brush",x:Qe(T.from),y:0,width:Math.max(1,Qe(T.to)-Qe(T.from)),height:at}));let Ar=ke.kind==="single"?(b?.events??[]).filter(xe=>xe.dur!==void 0||xe.open):b?.spans??[],bi=ke.kind==="single"?(b?.events??[]).filter(xe=>xe.dur===void 0&&!xe.open):[],Pr=new Map;pe.forEach((xe,Fe)=>{xe.kind==="row"&&Pr.set(xe.row.scope,Fe)});let ar=xe=>{let Fe=rn(c)+d,pt=rn(xe)>=Fe?Os(xe,Fe):xe;return Pr.get(pt)},_s=xe=>Ae[xe]+Pe(pe[xe])>=vt&&Ae[xe]<=En;if(pe.forEach((xe,Fe)=>{_s(Fe)&&Ze.push(Nt("rect",{class:`tlx-lane${Fe%2?" odd":""}${xe.kind==="metric"?" metric":""}`,x:0,y:Ae[Fe],width:Y,height:Pe(xe)}))}),ke.kind==="binned"){let xe=new Map;for(let Fe of b?.bins??[]){let pt=ar(Fe.scope);pt!==void 0&&xe.set(pt,Math.max(xe.get(pt)??0,Fe.count))}for(let Fe of b?.bins??[]){let pt=ar(Fe.scope);if(pt===void 0||!_s(pt))continue;let St=Qe(Fe.t),ht=Qe(Fe.t+jn[Fe.bin]);if(ht<0||St>Y)continue;let At=[...kn].reverse().find(en=>(Fe.severity[en]??0)>0)??"info",Pt=Math.max(2,(vr-8)*Math.sqrt(Fe.count)/Math.sqrt(xe.get(pt)||1));Ze.push(Nt("rect",{class:"tlx-countbar",x:St,y:Ae[pt]+vr-3-Pt,width:Math.max(1,ht-St-.5),height:Pt,"data-t":Fe.t},`${un(Fe.t,n)}: ${Fe.count} event${Fe.count===1?"":"s"}${At!=="info"&&At!=="debug"?`, the worst ${At}`:""}`)),(At==="warning"||At==="error")&&Ze.push(Nt("rect",{class:`tlx-heat sev-${At}`,x:St,y:Ae[pt]+vr-(At==="error"?4:3),width:Math.max(1,ht-St-.5),height:At==="error"?3:2}))}}for(let xe of Ar){let Fe=ar(xe.scope);if(Fe===void 0||!_s(Fe))continue;let pt=xe.open?hn:xe.t+(xe.dur??0),St=Qe(xe.t),ht=Qe(pt);if(ht<-2||St>Y+2)continue;let At=`tlx-span sev-${xe.severity}${xe.open?" open":""}${M?.id===xe.id?" selected":""}`,Pt=`${xe.summary} \xB7 ${un(xe.t,n)}${xe.open?", still going":`, ${ud(pt-xe.t)}`}`,en=Ae[Fe]+5,zn=ke.kind==="binned"?4:8,Qt=St;for(let wn of re.cuts)wn.weight>=1||wn.x1<=St||wn.x0>=ht||(wn.x0>Qt&&Ze.push(Nt("rect",{class:At,x:Qt,y:en,width:Math.max(1,wn.x0-Qt),height:zn,rx:2,"data-id":xe.id},Pt)),Ze.push(Nt("path",{class:`${At} through`,d:`M${wn.x0} ${en+zn/2} H${wn.x1}`,"data-id":xe.id},`${Pt} (lasted through the break)`)),Qt=wn.x1);ht>Qt&&Ze.push(Nt("rect",{class:At,x:Math.max(-2,Qt),y:en,width:Math.max(2,Math.min(Y+2,ht)-Math.max(-2,Qt)),height:zn,rx:2,"data-id":xe.id},Pt))}let mo=new Map;for(let xe of bi){let Fe=ar(xe.scope);if(Fe===void 0||!_s(Fe))continue;let pt=Qe(xe.t);if(pt<-6||pt>Y+6||pt-(mo.get(Fe)??-1/0)<3)continue;mo.set(Fe,pt);let St=Ae[Fe]+vr/2+2,ht=4,At=Gm[xe.severity],Pt=At==="diamond"?`M${pt} ${St-ht-1} l${ht+1} ${ht+1} l${-ht-1} ${ht+1} l${-ht-1} ${-ht-1} z`:At==="triangle"?`M${pt} ${St-ht-1} l${ht+1} ${2*ht+1} h${-2*ht-2} z`:At==="square"?`M${pt-ht+.5} ${St-ht+.5} h${2*ht-1} v${2*ht-1} h${-2*ht+1} z`:"",en=`${un(xe.t,n)} \xB7 ${xe.summary}`,zn=`tlx-mark sev-${xe.severity}${M?.id===xe.id?" selected":""}${x>=0&&E[x]?.id===xe.id?" hit":""}`;Ze.push(Pt?Nt("path",{class:zn,d:Pt,"data-id":xe.id},en):Nt("circle",{class:zn,cx:pt,cy:St,r:At==="dot"?2.5:ht,"data-id":xe.id},en))}pe.forEach((xe,Fe)=>{if(xe.kind!=="metric"||!_s(Fe))return;let pt=new Map;for(let $t of b?.metrics??[]){if($t.series!==xe.series)continue;let Ht="value"in $t?{min:$t.value,max:$t.value,sum:$t.value,count:1}:{min:$t.min,max:$t.max,sum:$t.sum,count:$t.count},Jt=pt.get($t.t);Jt?(Jt.min=Math.min(Jt.min,Ht.min),Jt.max=Math.max(Jt.max,Ht.max),Jt.sum+=Ht.sum,Jt.count+=Ht.count):pt.set($t.t,{...Ht})}let St=[...pt].sort(($t,Ht)=>$t[0]-Ht[0]);if(!St.length)return;let ht=ke.kind==="binned"?jn[ke.bin]:ii,At=$t=>xe.type==="gauge"?$t.sum/Math.max(1,$t.count):$t.sum,Pt=Math.max(1e-9,...St.map(([,$t])=>xe.type==="gauge"?$t.max:At($t))),en=Ae[Fe]+al-4,zn=al-10,Qt=$t=>en-$t/Pt*zn;if(xe.type==="gauge"){let $t=St.map(([Ht,Jt])=>`${Qe(Ht)},${Qt(Jt.max)}`).join(" ")+" "+[...St].reverse().map(([Ht,Jt])=>`${Qe(Ht)},${Qt(Jt.min)}`).join(" ");Ze.push(Nt("polygon",{class:"tlx-band",points:$t})),Ze.push(Nt("polyline",{class:"tlx-line",points:St.map(([Ht,Jt])=>`${Qe(Ht+ht/2)},${Qt(At(Jt))}`).join(" ")}))}else{let $t="",Ht=-1/0;for(let[Jt,yi]of St){let ns=Qe(Jt),ho=Qe(Jt+ht),go=Qt(At(yi));$t+=Jt>Ht?`M${ns} ${en} V${go} H${ho}`:` V${go} H${ho}`,Ht=Jt+ht;let bo=St.find(([lr])=>lr>Jt);(!bo||bo[0]>Ht)&&($t+=` V${en} Z`)}Ze.push(Nt("path",{class:"tlx-area",d:$t}))}let wn=Nt("text",{class:"tlx-peak",x:4,y:Ae[Fe]+11});wn.textContent=`peak ${Hm(Pt,xe.unit)}${xe.type==="counter"?` per ${ke.kind==="binned"?ke.bin:"1m"}`:""}`,Ze.push(wn)});for(let xe of re.cuts){if(xe.weight>=1)continue;let Fe=ht=>{let At=`M${ht} 0`;for(let Pt=0;Pt<at;Pt+=8)At+=` L${ht+(Pt/8%2?-3:3)} ${Pt+8}`;return At},pt=Nt("g",{class:"tlx-cut",tabindex:0,role:"button","data-from":xe.from,"data-to":xe.to,"aria-label":`A break of ${xr(xe.to-xe.from)} with nothing shown, from ${un(xe.from,n)} to ${un(xe.to,n)}: press to open it`},`${xr(xe.to-xe.from)} with nothing here: ${un(xe.from,n)} to ${un(xe.to,n)} (click to open)`);pt.append(Nt("rect",{class:"tlx-cut-bg",x:xe.x0,y:0,width:xe.x1-xe.x0,height:at})),pt.append(Nt("path",{class:"tlx-cut-edge",d:Fe(xe.x0+3)}),Nt("path",{class:"tlx-cut-edge",d:Fe(xe.x1-3)}));let St=Nt("text",{class:"tlx-cut-label",x:(xe.x0+xe.x1)/2,y:15,"text-anchor":"middle"});St.textContent=xr(xe.to-xe.from),pt.append(St),Ze.push(pt)}if(k!==void 0){let xe=Qe(k);Ze.push(Nt("line",{class:"tlx-playhead",x1:xe,x2:xe,y1:0,y2:at})),Ze.push(Nt("path",{class:"tlx-handle",d:`M${xe-6} 0 h12 v8 l-6 7 l-6 -7 z`},`the playhead: ${un(k,n)}`))}Te.replaceChildren(...Ze),Ke.replaceChildren(_("div",{class:"tlx-labelhead",style:`height:${ms}px`},mt().kind==="single"?"single events":`per ${mt().kind==="binned"?mt().bin:""}`),...pe.map(xe=>{if(xe.kind==="metric")return _("div",{class:"tlx-rowlabel metric",style:`height:${al}px`,title:`${xe.title} (${xe.type==="counter"?"sums":"min, max and mean"})`},xe.title);let Fe=xe.row,pt=_("div",{class:`tlx-rowlabel${Fe.own?" own":""}`,style:`height:${vr}px`,"data-scope":Fe.scope,title:`${Fe.scope||"all hosts"} \xB7 ${Fe.count} event${Fe.count===1?"":"s"}`},_("span",{class:"tlx-kind"},e.catalog.flags.find(St=>Fe[St])??Fe.kind),_("span",{class:"tlx-name"},Fe.own?`${Fe.label} (itself)`:Fe.label),_("span",{class:"tlx-count"},String(Fe.count)));if(!Fe.own&&Fe.scope!==c){let St=_("button",{type:"button",class:"tlx-drill",title:Fe.children?`Into ${Fe.label}: its ${Fe.children} part${Fe.children===1?"":"s"}`:`Into ${Fe.label}`,"aria-label":`Into ${Fe.label}`},"\u203A");St.addEventListener("click",()=>xt(Fe.scope)),pt.append(St)}return pt})),Ke.style.width=`${zm}px`,de()}function de(){X.replaceChildren(...Xr(c).flatMap((Ae,Re,at)=>{let vt=_("button",{type:"button",class:`tlx-crumb${Re===at.length-1?" current":""}`,"aria-current":Re===at.length-1?"location":void 0},it(Ae.scope,Ae.label));return vt.addEventListener("click",()=>{Ae.scope!==c&&(c=Ae.scope,d=1,R(!0))}),Re?[_("span",{class:"tlx-sep","aria-hidden":"true"},"/"),vt]:[vt]})),be.setAttribute("aria-pressed",String(p)),be.classList.toggle("on",p),V.hidden=!p||A;let Y=mt(),pe=b?.total??0,ke=(b?.retention??[]).filter(Ae=>Ae.events!==null).map(Ae=>`${Ae.source} kept ${Ae.events} d`);he.textContent=`${un(h.t0,n)} \u2013 ${un(h.t1,n)} \xB7 ${Y.kind==="single"?"single events":`bins of ${Y.bin}`} \xB7 ${pe} event${pe===1?"":"s"}${Q.length?` \xB7 ${Q.length} break${Q.length===1?"":"s"}`:""}${ke.length?` \xB7 ${ke.slice(0,3).join(", ")}`:""}`,Ce.hidden=!S.length,Ce.textContent=S.join(" \xB7 "),ge.textContent=u?E.length?`${x+1>0?`${x+1} of `:""}${E.length}${E.length>=2e3?"+":""} hit${E.length===1?"":"s"}`:`${pe?`${pe} hit${pe===1?"":"s"}`:"no hits"}`:"";for(let Ae of Z.querySelectorAll(".seg"))Ae.classList.remove("on");ie.textContent=k===void 0?"":y?(()=>{let Ae=e.stamp?.(y)??{};return`Canvas: the state recorded at ${un(Date.parse(Ae.at??"")||k,n)}${Ae.tag?` (${Ae.tag})`:""}`})():"No state recorded here",ie.classList.toggle("none",k!==void 0&&!y)}function De(){Ue.replaceChildren();for(let Y of l?.sources??[]){let pe=!f.source?.length||f.source.includes(Y.name),ke=_("button",{type:"button",class:`tlx-chip${pe?" on":""}${Y.status==="not-yet"?" notyet":""}`,"aria-pressed":String(pe&&Y.status!=="not-yet"),disabled:Y.status==="not-yet",title:Y.status==="not-yet"?`${Y.title}: not kept yet`:`${Y.title}${He(Y)}`},Y.name);Y.status!=="not-yet"&&ke.addEventListener("click",()=>Ne(Y.name)),Ue.append(ke)}}let He=Y=>{let pe=l?.retention.find(ke=>ke.source===Y.name);return pe?` (kept ${pe.events===null?"until deleted":`${pe.events} days`})`:""};function Ne(Y){let pe=(l?.sources??[]).filter(Ae=>Ae.status==="kept").map(Ae=>Ae.name),ke=f.source?.length?[...f.source]:[...pe];ke=ke.includes(Y)?ke.filter(Ae=>Ae!==Y):[...ke,Y],f={...f,...ke.length===pe.length?{source:void 0}:{source:ke}},f.source||delete f.source,De(),R(!0),ot()}let Ye=0;ve.addEventListener("input",()=>{clearTimeout(Ye),Ye=setTimeout(()=>{u=ve.value.trim(),x=-1,R(!0),ot()},250)}),ve.addEventListener("keydown",Y=>{Y.key==="Enter"&&(Y.preventDefault(),clearTimeout(Ye),u=ve.value.trim(),R(!0).then(()=>ot()).then(()=>Mt(Y.shiftKey?-1:1)))});async function ot(){if(!u){E=[],x=-1,de();return}let Y=h.t1-h.t0;E=(await e.source.query(m(h.t0-Y*4,Math.max(h.t1+Y*4,rt()),{kind:"single"},{limit:2e3}))).events??[],x=Math.min(x,E.length-1),de()}function Mt(Y){if(!E.length)return;let pe=(h.t0+h.t1)/2;x<0?x=Y>0?Math.max(0,E.findIndex(Re=>Re.t>=pe)):Math.max(0,E.length-1-[...E].reverse().findIndex(Re=>Re.t<=pe)):x=(x+Y+E.length)%E.length;let ke=E[x],Ae=Math.min(h.t1-h.t0,2*kr);h={t0:ke.t-Ae/2,t1:ke.t+Ae/2},A=!1,Ot(ke),R()}ye.addEventListener("click",()=>Mt(-1)),Ie.addEventListener("click",()=>Mt(1)),D.addEventListener("change",()=>{let Y=D.value;f={...f,...Y?{severity:kn.filter(pe=>Nf(pe)>=Nf(Y))}:{}},Y||delete f.severity,R(!0),ot()});async function $n(Y,pe=!0){let ke=rt();if(Y==="run"){let Ae=await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:ke-30*Cn,to:ke+1,filters:{kind:["run"]},limit:1e4}).catch(()=>{}),Re=Ae?.events?.[Ae.events.length-1];h=Re?{t0:Re.t-(Re.dur??kr)*.02,t1:(Re.open?ke:Re.t+(Re.dur??kr))+(Re.dur??kr)*.04}:{t0:ke-Cn,t1:ke+Cn*.02}}else h={t0:ke-Lf[Y],t1:ke+Lf[Y]*.02};A=!0,N.clear(),z.clear(),pe&&R()}function Ct(Y,pe=!0){if(p=Y,B?.(),B=void 0,Y&&e.source.subscribe){let ke=0,Ae=0;B=e.source.subscribe(m(rt()-kr,rt()+365*Cn,{kind:"single"}),Re=>{if(l&&(l.now=Math.max(l.now,Re.now)),A){let vt=h.t1-h.t0;h={t0:Re.now-vt*.98,t1:Re.now+vt*.02}}let at=Date.now();at-ke>500?(ke=at,R(!0)):Ae||(Ae=setTimeout(()=>{Ae=0,ke=Date.now(),R(!0)},500))}),A=!0}pe&&(de(),U())}be.addEventListener("click",()=>Ct(!p)),V.addEventListener("click",()=>{A=!0;let Y=h.t1-h.t0,pe=rt();h={t0:pe-Y*.98,t1:pe+Y*.02},R()}),J.addEventListener("click",()=>{wt()}),G.addEventListener("change",()=>{g=G.checked,N.clear(),z.clear(),ee(),U()}),oe.addEventListener("change",()=>{ne=oe.checked,ee(),U()});function xt(Y){let pe=b?.rows.find(ke=>ke.scope===Y);c=Y,d=pe&&pe.children===0?0:1,T=void 0,lt.hidden=!0,R(!0)}async function wt(){let Y=rt(),ke=((await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:Y-400*Cn,to:Y+1,bin:"1d",tz:n}).catch(()=>{}))?.bins??[]).map(Re=>Re.t),Ae=ke.length?Math.min(...ke):Y-7*Cn;h={t0:Ae,t1:Y+(Y-Ae)*.02},A=!0,R()}let Tt=0;async function ze(Y){if(k=Y,ee(),Y===void 0){y=void 0;return}let pe=++Tt,ke=e.source.stateAt?await e.source.stateAt(c,Y).catch(()=>{}):void 0;pe===Tt&&(y=ke,e.onPlayhead?.(Y,ke),de())}async function Ft(Y,pe){T={from:Math.min(Y,pe),to:Math.max(Y,pe)},ee();let ke=await e.source.query(m(T.from,T.to,{kind:"single"},{limit:500})),Ae=o(u),Re=Ze=>{let Qe=[],Gt=0;for(let[sn,hn]of oi(Ae,Ze))Qe.push(Ze.slice(Gt,sn),_("mark",null,Ze.slice(sn,hn))),Gt=hn;return Qe.push(Ze.slice(Gt)),Qe},at=(ke.events??[]).map(Ze=>{let Qe=_("tr",{"data-id":Ze.id,tabindex:"0"},_("td",null,un(Ze.t,n)),_("td",null,Ze.dur!==void 0?ud(Ze.dur):Ze.open?"still going":""),_("td",null,Ze.source),_("td",null,Ze.kind),_("td",{class:`sev-${Ze.severity}`},Ze.severity),_("td",{class:"tlx-sum"},...Re(Ze.summary)),_("td",{class:"tlx-scope"},Ze.scope));return Qe.addEventListener("click",()=>Ot(Ze)),Qe.addEventListener("keydown",Gt=>{Gt.key==="Enter"&&Ot(Ze)}),Qe}),vt=_("button",{type:"button",class:"btn sm quiet","aria-label":"Close the table"},"Close");vt.addEventListener("click",()=>{T=void 0,lt.hidden=!0,ee()});let En=Ze=>{let Qe=_("button",{type:"button",class:"btn sm","data-export":Ze},Ze.toUpperCase());return Qe.addEventListener("click",()=>{jt(Ze)}),Qe};lt.replaceChildren(_("div",{class:"tlx-table-head"},_("strong",null,`${ke.total} event${ke.total===1?"":"s"}`),_("span",null,` ${un(T.from,n)} \u2013 ${un(T.to,n)}${ke.total>500?" (the first 500 shown; the export has them all)":""}`),_("span",{class:"spacer"}),_("span",null,"Export: "),En("json"),En("csv"),vt),_("div",{class:"tlx-table-wrap"},_("table",null,_("thead",null,_("tr",null,...["When","Long","Source","Kind","Severity","What","Scope"].map(Ze=>_("th",{scope:"col"},Ze)))),_("tbody",null,...at)))),lt.hidden=!1}async function Wt(){if(!T)return[];let Y=[],pe;do{let ke=await e.source.query(m(T.from,T.to,{kind:"single"},{limit:1e4,...pe?{cursor:pe}:{}}));Y.push(...ke.events??[]),pe=ke.next}while(pe&&Y.length<2e5);return Y}async function jt(Y){let pe=await Wt(),ke=Y==="json"?rl(pe,F):ol(pe,F),Ae=`timeline-${new Date(T.from).toISOString().slice(0,16).replace(/:/g,"")}.${Y}`,Re=Y==="json"?"application/json":"text/csv";if(e.onExport){e.onExport(Ae,ke,Re);return}let at=_("a",{href:`data:${Re};charset=utf-8,${encodeURIComponent(ke)}`,download:Ae});document.body.append(at),at.click(),at.remove()}function Ot(Y){if(M=Y,ee(),!Y){We.hidden=!0;return}let pe=l?.sources.find(Qe=>Qe.name===Y.source),ke=new Set(pe?.sensitive??[]),Ae=o(u),Re=Qe=>{let Gt=[],sn=0;for(let[hn,Ar]of oi(Ae,Qe))Gt.push(Qe.slice(sn,hn),_("mark",null,Qe.slice(hn,Ar))),sn=Ar;return Gt.push(Qe.slice(sn)),Gt},at=(Qe,Gt)=>{if(!Gt)return null;let sn=_("button",{type:"button",class:"btn sm"},Qe);return sn.addEventListener("click",Gt),sn},vt=Object.entries(Y.attrs).map(([Qe,Gt])=>{if(!ke.has(Qe))return _("tr",null,_("th",{scope:"row"},Qe),_("td",null,...Re(String(Gt))));let sn=_("button",{type:"button",class:"btn sm quiet",title:"This can name a remote host, a folder or free text"},"Show"),hn=_("td",{class:"tlx-sensitive"},"hidden ",sn);return sn.addEventListener("click",()=>hn.replaceChildren(String(Gt))),_("tr",null,_("th",{scope:"row"},Qe),hn)}),En=_("button",{type:"button",class:"btn sm quiet tlx-close","aria-label":"Close"},"\xD7");En.addEventListener("click",()=>Ot(void 0));let Ze=Xr(Y.scope).slice(1).map(Qe=>{let Gt=_("button",{type:"button",class:"tlx-crumb"},it(Qe.scope,Qe.label));return Gt.addEventListener("click",()=>xt(Qe.scope)),Gt});We.replaceChildren(_("div",{class:"tlx-detail-head"},_("strong",null,Y.kind),En),_("p",{class:`tlx-sev sev-${Y.severity}`},`${Y.severity} \xB7 ${pe?.title??Y.source}`),_("p",{class:"tlx-sum"},...Re(Y.summary)),_("p",null,un(Y.t,n),Y.dur!==void 0?` \xB7 ${ud(Y.dur)}${Y.open?" so far":""}`:Y.open?" \xB7 still going":""),_("p",{class:"tlx-crumbs small"},...Ze),...vt.length?[_("table",{class:"tlx-attrs"},_("tbody",null,...vt))]:[],_("div",{class:"tlx-links"},...(e.actions?.(Y)??[]).map(([Qe,Gt])=>at(Qe,Gt)))),We.hidden=!1}function Ks(Y,pe){let ke=wr({from:Y,to:pe});if(!Q.find(vt=>vt.from===Y&&vt.to===pe))return;if(N.add(ke),!r){z.set(ke,1),ee();return}let Re=performance.now(),at=vt=>{let En=Math.min(1,(vt-Re)/260);z.set(ke,1-(1-En)**3),$e(),En<1&&requestAnimationFrame(at)};requestAnimationFrame(at)}let Zt,ys=Y=>Y.clientX-Te.getBoundingClientRect().left;Te.addEventListener("pointerdown",Y=>{let pe=ys(Y),ke=Y.clientY-Te.getBoundingClientRect().top,Ae=Y.target.closest?.(".tlx-cut");if(Ae){Y.preventDefault(),Ks(Number(Ae.getAttribute("data-from")),Number(Ae.getAttribute("data-to")));return}Te.setPointerCapture(Y.pointerId),Zt={kind:ke<ms||Y.shiftKey?"brush":Y.target.classList.contains("tlx-handle")?"scrub":"pan",x0:pe,t0:re.t(pe),v0:h,moved:!1},Y.preventDefault(),Oe.focus({preventScroll:!0})}),Te.addEventListener("pointermove",Y=>{if(!Zt)return;let pe=ys(Y);if(Math.abs(pe-Zt.x0)>3&&(Zt.moved=!0),!!Zt.moved)if(Zt.kind==="pan"){let ke=(Zt.x0-pe)*re.msPerPx;h={t0:Zt.v0.t0+ke,t1:Zt.v0.t1+ke},A=!1,R()}else Zt.kind==="scrub"?ze(re.t(pe)):(T={from:Math.min(Zt.t0,re.t(pe)),to:Math.max(Zt.t0,re.t(pe))},ee())}),Te.addEventListener("pointerup",Y=>{let pe=Zt;if(Zt=void 0,!pe)return;let ke=ys(Y);if(pe.kind==="brush"&&pe.moved){Ft(pe.t0,re.t(ke));return}if(pe.kind==="brush"&&!pe.moved){ze(re.t(ke));return}if(pe.kind==="pan"&&!pe.moved){let Ae=Y.target.closest?.("[data-id]")?.getAttribute("data-id"),Re=Ae?[...b?.events??[],...b?.spans??[]].find(at=>at.id===Ae):void 0;Re?(Ot(Re),ze(Re.t)):ze(re.t(ke))}}),Te.addEventListener("keydown",Y=>{let pe=Y.target.closest?.(".tlx-cut");pe&&(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),Ks(Number(pe.getAttribute("data-from")),Number(pe.getAttribute("data-to"))))}),Te.addEventListener("wheel",Y=>{Y.preventDefault();let pe=ys(Y);if(Y.shiftKey||Math.abs(Y.deltaX)>Math.abs(Y.deltaY)){let ke=(Y.shiftKey?Y.deltaY:Y.deltaX)*re.msPerPx;h={t0:h.t0+ke,t1:h.t1+ke},A=!1}else Ln(re.t(pe),Math.exp(Y.deltaY*.0015),pe/ft());R()},{passive:!1});function Ln(Y,pe,ke=.5){let Ae=Math.min(400*Cn,Math.max(1e4,(h.t1-h.t0)*pe));h={t0:Y-ke*Ae,t1:Y+(1-ke)*Ae},N.clear(),z.clear(),pe<1&&(A=p&&h.t1>=rt())}Oe.addEventListener("keydown",Y=>{let pe=h.t1-h.t0;if(Y.key==="ArrowLeft"||Y.key==="ArrowRight"){let ke=pe*.15*(Y.key==="ArrowLeft"?-1:1);h={t0:h.t0+ke,t1:h.t1+ke},A=!1}else if(Y.key==="+"||Y.key==="=")Ln((h.t0+h.t1)/2,.6);else if(Y.key==="-"||Y.key==="_")Ln((h.t0+h.t1)/2,1/.6);else if(Y.key==="n"||Y.key==="N"){Mt(Y.shiftKey?-1:1),Y.preventDefault();return}else if(Y.key==="Escape")Ot(void 0),T=void 0,lt.hidden=!0;else return;Y.preventDefault(),R()}),t.addEventListener("keydown",Y=>{Y.key==="/"&&document.activeElement!==ve&&!Y.target.closest("input, select, textarea")&&(Y.preventDefault(),ve.focus())}),je.addEventListener("scroll",()=>ee(),{passive:!0}),Me.addEventListener("click",async()=>{let Y=`${Xr(c).slice(-1)[0].label}${u?`: ${u}`:""}`.slice(0,80);await e.saveView?.({...P(),name:Y}),await on()});let tt=[];async function on(){e.views&&(tt=await e.views(),se.replaceChildren(_("option",{value:""},"Saved views\u2026"),...tt.map((Y,pe)=>_("option",{value:String(pe)},Y.name))))}se.addEventListener("change",()=>{let Y=tt[Number(se.value)];Y&&(q(Y),De(),R(!0)),se.value=""});let dt=typeof ResizeObserver=="function"?new ResizeObserver(()=>ee()):void 0;dt?.observe(Oe);let nn=(async()=>{l=await e.source.catalog(),F=l.sources.flatMap(Ae=>(Ae.sensitive??[]).map(Re=>`${Ae.name}.${Re}`));for(let Ae of l.sources)for(let Re of Ae.series)we.set(Re.name,{unit:Re.unit,type:Re.type,title:Re.title,source:Ae.name});c=l.hosts.length===1?`host:${l.hosts[0].replace(/[%/:\s]/g,Ae=>`%${Ae.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}`:"";let pe=l.now;h={t0:pe-Cn,t1:pe+Cn*.02};let ke=ae()??e.view;ke&&q(ke),De(),await on(),await R(!0),u&&await ot()})();return{el:t,ready:nn,get view(){return P()},setView(Y){return q(Y),De(),R(!0)},setRange(Y,pe){return h={t0:Y,t1:pe},A=!1,R()},setPlayhead:ze,setLive:Ct,setTheme:a,refresh:()=>R(!0),internal:{get result(){return b},get mode(){return mt()},get scale(){return re},get gaps(){return Q},get playState(){return y},get hits(){return E},get selected(){return M},get follow(){return A},openCut:Ks,showTable:Ft,rangeEvents:Wt,exportRange:jt,select:Ot,stepHit:Mt,drill:xt,findHits:ot,paint:$e,lines:ut},dispose(){B?.(),dt?.disconnect(),I&&cancelAnimationFrame(I),t.replaceChildren()}}}var Ym={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}},fn=t=>(Math.round(t*10)/10).toString(),If=t=>(t??"link").replace(/[^\w-]/g,"_");function eo(t,e){let{id:n}=e,s=e.styles??{},r=t.options,o=t.bounds,i=new Map,a=(p,g)=>{let h=s[p]??{},b=g==="start"?h.start??"none":h.end??"arrow";if(b!=="none")return(i.get(p)??i.set(p,new Set).get(p)).add(b),`url(#${n}-mk-${p}-${b})`},l="",c="",d="",u="";for(let p of[...t.panels].sort((g,h)=>g.depth-h.depth)){let g=p.rect,h=p.label?_e("text",{class:"pl",x:p.titleAt[0],y:p.titleAt[1]},_t(p.label)+(p.sub?_e("tspan",{class:"pls",dx:10},_t(p.sub)):"")):"";l+=_e("g",{class:`panel k-${p.role??"grey"}`,"data-id":p.id},_e("rect",{class:"face",x:fn(g.l),y:fn(g.t),width:fn(g.r-g.l),height:fn(g.b-g.t),rx:r.panelRx})+h)}for(let p of t.links){if(!p.points.length)continue;let g=If(p.kind);c+=_e("path",{class:`conn k-${g}`,d:"M"+p.points.map(h=>`${fn(h[0])},${fn(h[1])}`).join(" L"),"data-id":p.id,"data-a":p.a,"data-b":p.b,"marker-start":a(g,"start"),"marker-end":a(g,"end")}),p.at&&(u+=_e("text",{class:`cl k-${g}`,x:p.at.x,y:p.at.y,"text-anchor":p.at.anchor==="start"?void 0:p.at.anchor,"data-for":p.id},_t(p.at.text)))}for(let p of t.cards){let g=p.rect;d+=_e("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},_e("rect",{class:"face",x:fn(g.l),y:fn(g.t),width:r.W,height:r.H,rx:r.cardRx})+_e("text",{class:"lt",x:fn(g.l+14),y:fn(g.t+24)},_t(p.label))+(p.sub?_e("text",{class:"st",x:fn(g.l+14),y:fn(g.t+42)},_t(p.sub)):""))}let f="";for(let[p,g]of i)for(let h of g){let b=Ym[h];f+=_e("marker",{id:`${n}-mk-${p}-${h}`,viewBox:"0 0 10 10",refX:b.refX,refY:5,markerWidth:5.4,markerHeight:5.4,orient:"auto-start-reverse"},_e("path",{d:b.d,class:`mk k-${p}`}))}return _e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"flat",viewBox:`${fn(o.l)} ${fn(o.t)} ${fn(o.r-o.l)} ${fn(o.b-o.t)}`,role:"img","aria-label":e.title??"drawing, flat view","data-view":"2d"},(f?_e("defs",{},f):"")+_e("g",{class:"panels"},l)+_e("g",{class:"conns"},c)+_e("g",{class:"cards"},d)+_e("g",{class:"labels"},u))}function Df(t={}){let e=s=>s?s.startsWith("#")||s.includes("(")?s:`var(--${s})`:"var(--ink)",n=`
|
|
360
360
|
.flat{font-family:inherit}
|
|
361
361
|
.flat .card{cursor:pointer;outline:none}
|
|
362
362
|
.flat .card .face{fill:hsl(var(--h) var(--s) var(--l-top));stroke:hsl(var(--h) var(--s) var(--l-edge) / .55);stroke-width:1}
|
|
@@ -374,8 +374,8 @@ ${e.extraBody??""}
|
|
|
374
374
|
.flat .panel.sel .face{stroke:var(--accent,#2f6fd6);stroke-width:2}
|
|
375
375
|
.flat .conn.hot{stroke-width:3}
|
|
376
376
|
.flat .conn.dim,.flat .cl.dim{opacity:.3}
|
|
377
|
-
`;for(let[s,r]of Object.entries(t)){let o=
|
|
378
|
-
`}return n}var cm={name:["card","lt"],sub:["card","st"],title:["panel","pl"],titleSub:["panel","pls"],label:["","cl"]};function zr(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(cm)){let c=document.createElementNS(e,"g");a&&c.setAttribute("class",a);let d=document.createElementNS(e,"text");d.setAttribute("class",l),c.appendChild(d),n.appendChild(c),s[i]=d}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 sf=(t,e)=>t.cards.find(n=>n.id===e)?.rect??t.panels.find(n=>n.id===e)?.rect;var _s="http://www.w3.org/2000/svg";function Vr(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??wn(r.raw.from).id,a=o?.b??wn(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 dm=(t="auto")=>t==="always"||t==="auto"&&!(typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);function ja(t,e,n,s,r={}){let o=r.duration??600;if(!o||!dm(r.motion))return;let i=_c(t,e,n,s);t.appendChild(i.svg),i.at(0);let a=0,l=!1,c,d=new Promise(g=>c=g),u=()=>{l||(l=!0,cancelAnimationFrame(a),i.svg.remove(),c())},f=performance.now(),p=g=>{if(l)return;let h=Math.min(1,(g-f)/o);i.at(h),h<1?a=requestAnimationFrame(p):u()};return a=requestAnimationFrame(p),{done:d,finish:u}}var ur=t=>Math.max(0,Math.min(1,t)),Kc=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;function Fa(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 Bc=(t,e)=>{let n=t.getBoundingClientRect();return{x:n.left-e.left,y:n.top-e.top,w:n.width,h:n.height}},rf=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}},um=(t,e)=>{let n=t.getScreenCTM();return`matrix(${n.a} ${n.b} ${n.c} ${n.d} ${n.e-e.left} ${n.f-e.top})`},of=(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 fm(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 _c(t,e,n,s){let r=t.getBoundingClientRect(),o=document.createElementNS(_s,"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=T=>{let y=document.createElementNS(_s,"g");return y.setAttribute("transform",um(T,r)),y},a=T=>T.hasAttribute("data-a")||T.hasAttribute("data-for"),l=T=>{let y=new Map;for(let A of T.querySelectorAll("[data-id]")){if(a(A)||A.parentElement?.closest("[data-id]")||A.closest(".overlay"))continue;let D=A.getAttribute("data-id");(y.get(D)??y.set(D,[]).get(D)).push(A)}return y},c=l(e),d=l(n),u=document.createElementNS(_s,"g"),f=document.createElementNS(_s,"g"),p=i(e),g=i(n);for(let T of e.querySelectorAll("[data-a],[data-for]"))T.closest(".overlay")||p.appendChild(Fa(T));for(let T of n.querySelectorAll("[data-a],[data-for]"))T.closest(".overlay")||g.appendChild(Fa(T));u.appendChild(p),f.appendChild(g);let h=[...g.querySelectorAll("path")].map(T=>{let y=T.getTotalLength?.()??0;return{p:T,len:y}}),b=[...g.children].filter(T=>T.tagName.toLowerCase()==="text"),k=[...(s==="2d"?c:d).keys()],v=[],M=document.createElementNS(_s,"g");for(let T of new Set([...k,...c.keys(),...d.keys()])){let y=c.get(T),A=d.get(T),D={};if(y){D.a=rf(y.map(N=>Bc(N,r)));let $=document.createElementNS(_s,"g"),w=i(e);for(let N of y)w.appendChild(Fa(N));$.appendChild(w),D.src=$}if(A){D.b=rf(A.map(N=>Bc(N,r)));let $=document.createElementNS(_s,"g"),w=i(n);for(let N of A)w.appendChild(Fa(N));$.appendChild(w),D.dst=$}let K=s==="3d"?y?.[0]:A?.[0],C=s==="3d"?A?.[0]:y?.[0],_=K?fm(K,r):void 0,S=C?.querySelector("rect.face");if(_&&S){let $=Bc(S,r),w=[[$.x,$.y],[$.x+$.w,$.y],[$.x+$.w,$.y+$.h],[$.x,$.y+$.h]],N=_.pts.reduce((j,U,ee)=>U[0]<_.pts[j][0]?ee:j,0),F=[..._.pts.slice(N),..._.pts.slice(0,N)],J=[F[0],F[1],F[2],F[3]],ae=getComputedStyle(S).fill,we=document.createElementNS(_s,"polygon");D.face=we,D.faceFrom=s==="3d"?J:w,D.faceTo=s==="3d"?w:J,D.faceFill=s==="3d"?[_.fill,ae]:[ae,_.fill]}D.src&&M.appendChild(D.src),D.face&&M.appendChild(D.face),D.dst&&M.appendChild(D.dst),v.push(D)}o.append(u,M,f);let x=(T,y,A)=>`color-mix(in srgb, ${T} ${Math.round((1-A)*100)}%, ${y})`;return{svg:o,at(T){let y=ur(T/.2),A=Kc(ur((T-.2)/.6)),D=ur((T-.8)/.2);u.setAttribute("opacity",String(1-y));for(let{p:K,len:C}of h)K.style.strokeDasharray=`${C} ${C}`,K.style.strokeDashoffset=String(C*(1-D));f.setAttribute("opacity",String(D>0?1:0));for(let K of b)K.style.opacity=String(D);for(let K of v)if(K.src&&(K.src.setAttribute("transform",K.a&&K.b?of(K.a,K.b,A):""),K.src.setAttribute("opacity",String(K.b?1-ur(A/(K.face?.35:.6)):1-A))),K.dst&&(K.dst.setAttribute("transform",K.a&&K.b?of(K.b,K.a,1-A):""),K.dst.setAttribute("opacity",String(K.a?ur((A-(K.face?.65:.4))/(K.face?.35:.6)):A))),K.face){let C=K.faceFrom.map((_,S)=>[_[0]+(K.faceTo[S][0]-_[0])*A,_[1]+(K.faceTo[S][1]-_[1])*A]);K.face.setAttribute("points",C.map(_=>_.join(",")).join(" ")),K.face.style.fill=x(K.faceFill[0],K.faceFill[1],A),K.face.setAttribute("opacity",String(A<.08?A/.08:A>.92?(1-A)/.08:1))}}}}var pm=0;function af(t,e,n={}){let s=`dv${++pm}`,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??or(e);Vr(a,e,l);let c=new Set(e.routes.map(C=>C.id));for(let C of a.querySelectorAll("g[data-id]")){let _=C.getAttribute("data-id");c.has(_)||C.hasAttribute("tabindex")||!C.querySelector("polygon")||(C.setAttribute("tabindex","0"),C.setAttribute("role","button"),C.setAttribute("aria-label",_))}let d=zr(i),u=Fs(l,d,n.flat);d.dispose(),i.innerHTML=_r(u,{id:s,title:n.title,styles:n.styles});let f=i.querySelector("svg");for(let C of[a,f])C.style.display="block",C.style.width="100%",C.style.height="auto";n.title&&a.setAttribute("aria-label",n.title);let p=n.mode??"3d",g,h=C=>C==="3d"?o:i,b=C=>C==="3d"?a:f,k=C=>{o.hidden=C!=="3d",i.hidden=C!=="2d";for(let _ of[o,i])_.style.cssText="";r.style.height="",r.dataset.mode=C};k(p);let v=()=>{for(let C of[a,f]){for(let _ of C.querySelectorAll("[data-id]"))_.classList.toggle("sel",!!g&&_.getAttribute("data-id")===g);for(let _ of C.querySelectorAll("[data-a]")){let S=!!g&&(_.getAttribute("data-a")===g||_.getAttribute("data-b")===g);_.classList.toggle("hot",S),_.classList.toggle("dim",!!g&&!S),C.querySelector(`[data-for="${CSS.escape(_.getAttribute("data-id")??"")}"]`)?.classList.toggle("dim",!!g&&!S)}}},M=C=>{g=C,v()},x=C=>{let _=C.target.closest?.("[data-id]");if(!_||!r.contains(_)||_.hasAttribute("data-a"))return;let S=_.getAttribute("data-id");M(S),n.onSelect?.(S)},T=C=>{(C.key==="Enter"||C.key===" ")&&C.target.matches?.("[data-id][tabindex]")&&(C.preventDefault(),x(C))};r.addEventListener("click",x),r.addEventListener("keydown",T);let y,A=()=>{if(!y)return;cancelAnimationFrame(y.frame),y.layer.remove();let C=y;y=void 0,p=C.to,k(p),v(),C.done()},D=C=>{!C||!g||b(p).querySelector(`[data-id="${CSS.escape(g)}"][tabindex]`)?.focus({preventScroll:!0})};return{get mode(){return y?y.to:p},layout:u,root:r,morph:C=>{let _=r.contains(document.activeElement);if(y&&A(),C===p)return D(_),Promise.resolve();let S=n.motion??"auto";return S==="never"||S==="auto"&&typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches||!(n.duration??600)?(p=C,k(p),v(),D(_),Promise.resolve()):new Promise(w=>{let N=p,F=r.getBoundingClientRect().height;o.hidden=!1,i.hidden=!1;for(let fe of[o,i])fe.style.cssText="position:absolute;left:0;top:0;right:0;visibility:hidden";let J=h(C).getBoundingClientRect().height;r.style.height=`${F}px`;let ae=_c(r,b(N),b(C),N);r.appendChild(ae.svg);let we=n.duration??600,j=performance.now(),U={frame:0,layer:ae.svg,to:C,done:()=>{D(_),w()}},ee=fe=>{if(y!==U)return;let B=Math.min(1,(fe-j)/we);ae.at(B),r.style.height=`${F+(J-F)*Kc(ur((B-.2)/.6))}px`,B<1?U.frame=requestAnimationFrame(ee):A()};y=U,U.frame=requestAnimationFrame(ee)})},select:M,get selected(){return g},svgOf:b,destroy(){y&&A(),r.removeEventListener("click",x),r.removeEventListener("keydown",T),r.remove()}}}function lf(t="iso-view"){try{let e=localStorage.getItem(t);return e==="2d"||e==="3d"?e:void 0}catch{return}}function cf(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 d=document.createElement("button");return d.type="button",d.dataset.mode=l,d.textContent=(n.labels??["3D","2D"])[c],d.addEventListener("click",()=>{try{localStorage.setItem(s,l)}catch{}a(l);for(let u of r)u.morph(l)}),o.appendChild(d),d}),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 df=`
|
|
377
|
+
`;for(let[s,r]of Object.entries(t)){let o=If(s),i=e(r.color);n+=`.flat .conn.k-${o}{stroke:${i}${r.dash?`;stroke-dasharray:${r.dash}`:""}${r.width?`;stroke-width:${r.width}`:""}} .flat .mk.k-${o}{fill:${i}} .flat .cl.k-${o}{fill:${i}}
|
|
378
|
+
`}return n}var qm={name:["card","lt"],sub:["card","st"],title:["panel","pl"],titleSub:["panel","pls"],label:["","cl"]};function to(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(qm)){let c=document.createElementNS(e,"g");a&&c.setAttribute("class",a);let d=document.createElementNS(e,"text");d.setAttribute("class",l),c.appendChild(d),n.appendChild(c),s[i]=d}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 Ff=(t,e)=>t.cards.find(n=>n.id===e)?.rect??t.panels.find(n=>n.id===e)?.rect;var er="http://www.w3.org/2000/svg";function no(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??An(r.raw.from).id,a=o?.b??An(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 Um=(t="auto")=>t==="always"||t==="auto"&&!(typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);function cl(t,e,n,s,r={}){let o=r.duration??600;if(!o||!Um(r.motion))return;let i=li(t,e,n,s);t.appendChild(i.svg),i.at(0);let a=0,l=!1,c,d=new Promise(g=>c=g),u=()=>{l||(l=!0,cancelAnimationFrame(a),i.svg.remove(),c())},f=performance.now(),p=g=>{if(l)return;let h=Math.min(1,(g-f)/o);i.at(h),h<1?a=requestAnimationFrame(p):u()};return a=requestAnimationFrame(p),{done:d,finish:u}}var Ls=t=>Math.max(0,Math.min(1,t)),ai=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;function ll(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 md=(t,e)=>{let n=t.getBoundingClientRect();return{x:n.left-e.left,y:n.top-e.top,w:n.width,h:n.height}},jf=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}},Wm=(t,e)=>{let n=t.getScreenCTM();return`matrix(${n.a} ${n.b} ${n.c} ${n.d} ${n.e-e.left} ${n.f-e.top})`},Bf=(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 Jm(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 li(t,e,n,s){let r=t.getBoundingClientRect(),o=document.createElementNS(er,"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=M=>{let T=document.createElementNS(er,"g");return T.setAttribute("transform",Wm(M,r)),T},a=M=>M.hasAttribute("data-a")||M.hasAttribute("data-for"),l=M=>{let T=new Map;for(let A of M.querySelectorAll("[data-id]")){if(a(A)||A.parentElement?.closest("[data-id]")||A.closest(".overlay"))continue;let I=A.getAttribute("data-id");(T.get(I)??T.set(I,[]).get(I)).push(A)}return T},c=l(e),d=l(n),u=document.createElementNS(er,"g"),f=document.createElementNS(er,"g"),p=i(e),g=i(n);for(let M of e.querySelectorAll("[data-a],[data-for]"))M.closest(".overlay")||p.appendChild(ll(M));for(let M of n.querySelectorAll("[data-a],[data-for]"))M.closest(".overlay")||g.appendChild(ll(M));u.appendChild(p),f.appendChild(g);let h=[...g.querySelectorAll("path")].map(M=>{let T=M.getTotalLength?.()??0;return{p:M,len:T}}),b=[...g.children].filter(M=>M.tagName.toLowerCase()==="text"),v=[...(s==="2d"?c:d).keys()],w=[],k=document.createElementNS(er,"g");for(let M of new Set([...v,...c.keys(),...d.keys()])){let T=c.get(M),A=d.get(M),I={};if(T){I.a=jf(T.map(N=>md(N,r)));let E=document.createElementNS(er,"g"),x=i(e);for(let N of T)x.appendChild(ll(N));E.appendChild(x),I.src=E}if(A){I.b=jf(A.map(N=>md(N,r)));let E=document.createElementNS(er,"g"),x=i(n);for(let N of A)x.appendChild(ll(N));E.appendChild(x),I.dst=E}let j=s==="3d"?T?.[0]:A?.[0],L=s==="3d"?A?.[0]:T?.[0],B=j?Jm(j,r):void 0,S=L?.querySelector("rect.face");if(B&&S){let E=md(S,r),x=[[E.x,E.y],[E.x+E.w,E.y],[E.x+E.w,E.y+E.h],[E.x,E.y+E.h]],N=B.pts.reduce((F,X,Z)=>X[0]<B.pts[F][0]?Z:F,0),z=[...B.pts.slice(N),...B.pts.slice(0,N)],Q=[z[0],z[1],z[2],z[3]],re=getComputedStyle(S).fill,we=document.createElementNS(er,"polygon");I.face=we,I.faceFrom=s==="3d"?Q:x,I.faceTo=s==="3d"?x:Q,I.faceFill=s==="3d"?[B.fill,re]:[re,B.fill]}I.src&&k.appendChild(I.src),I.face&&k.appendChild(I.face),I.dst&&k.appendChild(I.dst),w.push(I)}o.append(u,k,f);let y=(M,T,A)=>`color-mix(in srgb, ${M} ${Math.round((1-A)*100)}%, ${T})`;return{svg:o,at(M){let T=Ls(M/.2),A=ai(Ls((M-.2)/.6)),I=Ls((M-.8)/.2);u.setAttribute("opacity",String(1-T));for(let{p:j,len:L}of h)j.style.strokeDasharray=`${L} ${L}`,j.style.strokeDashoffset=String(L*(1-I));f.setAttribute("opacity",String(I>0?1:0));for(let j of b)j.style.opacity=String(I);for(let j of w)if(j.src&&(j.src.setAttribute("transform",j.a&&j.b?Bf(j.a,j.b,A):""),j.src.setAttribute("opacity",String(j.b?1-Ls(A/(j.face?.35:.6)):1-A))),j.dst&&(j.dst.setAttribute("transform",j.a&&j.b?Bf(j.b,j.a,1-A):""),j.dst.setAttribute("opacity",String(j.a?Ls((A-(j.face?.65:.4))/(j.face?.35:.6)):A))),j.face){let L=j.faceFrom.map((B,S)=>[B[0]+(j.faceTo[S][0]-B[0])*A,B[1]+(j.faceTo[S][1]-B[1])*A]);j.face.setAttribute("points",L.map(B=>B.join(",")).join(" ")),j.face.style.fill=y(j.faceFill[0],j.faceFill[1],A),j.face.setAttribute("opacity",String(A<.08?A/.08:A>.92?(1-A)/.08:1))}}}}var Xm=0;function Kf(t,e,n={}){let s=`dv${++Xm}`,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??br(e);no(a,e,l);let c=new Set(e.routes.map(L=>L.id));for(let L of a.querySelectorAll("g[data-id]")){let B=L.getAttribute("data-id");c.has(B)||L.hasAttribute("tabindex")||!L.querySelector("polygon")||(L.setAttribute("tabindex","0"),L.setAttribute("role","button"),L.setAttribute("aria-label",B))}let d=to(i),u=Js(l,d,n.flat);d.dispose(),i.innerHTML=eo(u,{id:s,title:n.title,styles:n.styles});let f=i.querySelector("svg");for(let L of[a,f])L.style.display="block",L.style.width="100%",L.style.height="auto";n.title&&a.setAttribute("aria-label",n.title);let p=n.mode??"3d",g,h=L=>L==="3d"?o:i,b=L=>L==="3d"?a:f,v=L=>{o.hidden=L!=="3d",i.hidden=L!=="2d";for(let B of[o,i])B.style.cssText="";r.style.height="",r.dataset.mode=L};v(p);let w=()=>{for(let L of[a,f]){for(let B of L.querySelectorAll("[data-id]"))B.classList.toggle("sel",!!g&&B.getAttribute("data-id")===g);for(let B of L.querySelectorAll("[data-a]")){let S=!!g&&(B.getAttribute("data-a")===g||B.getAttribute("data-b")===g);B.classList.toggle("hot",S),B.classList.toggle("dim",!!g&&!S),L.querySelector(`[data-for="${CSS.escape(B.getAttribute("data-id")??"")}"]`)?.classList.toggle("dim",!!g&&!S)}}},k=L=>{g=L,w()},y=L=>{let B=L.target.closest?.("[data-id]");if(!B||!r.contains(B)||B.hasAttribute("data-a"))return;let S=B.getAttribute("data-id");k(S),n.onSelect?.(S)},M=L=>{(L.key==="Enter"||L.key===" ")&&L.target.matches?.("[data-id][tabindex]")&&(L.preventDefault(),y(L))};r.addEventListener("click",y),r.addEventListener("keydown",M);let T,A=()=>{if(!T)return;cancelAnimationFrame(T.frame),T.layer.remove();let L=T;T=void 0,p=L.to,v(p),w(),L.done()},I=L=>{!L||!g||b(p).querySelector(`[data-id="${CSS.escape(g)}"][tabindex]`)?.focus({preventScroll:!0})};return{get mode(){return T?T.to:p},layout:u,root:r,morph:L=>{let B=r.contains(document.activeElement);if(T&&A(),L===p)return I(B),Promise.resolve();let S=n.motion??"auto";return S==="never"||S==="auto"&&typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches||!(n.duration??600)?(p=L,v(p),w(),I(B),Promise.resolve()):new Promise(x=>{let N=p,z=r.getBoundingClientRect().height;o.hidden=!1,i.hidden=!1;for(let be of[o,i])be.style.cssText="position:absolute;left:0;top:0;right:0;visibility:hidden";let Q=h(L).getBoundingClientRect().height;r.style.height=`${z}px`;let re=li(r,b(N),b(L),N);r.appendChild(re.svg);let we=n.duration??600,F=performance.now(),X={frame:0,layer:re.svg,to:L,done:()=>{I(B),x()}},Z=be=>{if(T!==X)return;let V=Math.min(1,(be-F)/we);re.at(V),r.style.height=`${z+(Q-z)*ai(Ls((V-.2)/.6))}px`,V<1?X.frame=requestAnimationFrame(Z):A()};T=X,X.frame=requestAnimationFrame(Z)})},select:k,get selected(){return g},svgOf:b,destroy(){T&&A(),r.removeEventListener("click",y),r.removeEventListener("keydown",M),r.remove()}}}function _f(t="iso-view"){try{let e=localStorage.getItem(t);return e==="2d"||e==="3d"?e:void 0}catch{return}}function zf(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 d=document.createElement("button");return d.type="button",d.dataset.mode=l,d.textContent=(n.labels??["3D","2D"])[c],d.addEventListener("click",()=>{try{localStorage.setItem(s,l)}catch{}a(l);for(let u of r)u.morph(l)}),o.appendChild(d),d}),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 Vf=`
|
|
379
379
|
.view-switch{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface);font:600 12px/1 system-ui,sans-serif;box-shadow:0 1px 4px rgba(0,0,0,.12)}
|
|
380
380
|
.view-switch button{font:inherit;border:0;background:none;color:var(--ink);padding:6px 10px;cursor:pointer}
|
|
381
381
|
.view-switch button+button{border-left:1px solid var(--line)}
|
|
@@ -385,14 +385,14 @@ ${e.extraBody??""}
|
|
|
385
385
|
.dual-view .blk.sel polygon{stroke:var(--accent,#2f6fd6);stroke-width:2.4}
|
|
386
386
|
.dual-view [data-a].dim{opacity:.3}
|
|
387
387
|
.dual-view [data-a].hot path{stroke-width:3.4}
|
|
388
|
-
`;var
|
|
389
|
-
`))return{path:[...r,
|
|
390
|
-
`,e-1)+1,r=n.slice(s,e),o=/[A-Za-z0-9_.:\/{}*~$-]*$/.exec(r)[0].replace(/^[{[,]/,""),i=e-o.length,a=
|
|
391
|
-
`,o-1)+1,a=r.slice(i,o);if(o=i-1,!a.trim()||/^\s*#/.test(a))continue;let l=/^\s*/.exec(a)[0].length;if(l===n&&!s){let c=i+l+(a.slice(l).startsWith("- ")?2:0),d=t.at(c);if(d.where==="key"||a.slice(l).startsWith("- "))return d.path.slice(0,-1)}if(l<n||s&&l<=n&&/:\s*$/.test(a)){let c=/^(\s*)(- )?([^\s:#][^:#]*?)\s*:/.exec(a);if(c){let d=t.at(i+c[1].length+(c[2]?2:0));if(d.where==="key")return d.path}if(/^\s*- /.test(a)){let d=t.at(i+l+2),u=d.path.length-1;for(;u>=0&&typeof d.path[u]!="number";)u--;return u>=0?d.path.slice(0,u+1):d.path}if(l<n)return[]}if(l===0&&n===0)return[]}return[]}function
|
|
392
|
-
`,e-1)+1,
|
|
393
|
-
`,e);return n<0?t.length:n},
|
|
394
|
-
`,e);return n<0?t.length:n+1},
|
|
395
|
-
`?r-1:r;return
|
|
388
|
+
`;var fp={};vi(fp,{EditorDoc:()=>On,EditorModel:()=>ao,HISTORY_DEPTH:()=>xd,PLAIN_ICONS:()=>cp,PLAIN_ICON_SVG:()=>po,PLAIN_KEYMAP:()=>Fl,PLAIN_SPRITE:()=>dp,PLAIN_WORDS:()=>$d,PREF:()=>fi,PROTOCOL:()=>ap,SchemaNav:()=>lo,SpliceError:()=>bn,TYPING_PAUSE_MS:()=>tp,VIEWS:()=>qf,actionsFor:()=>Nl,analyse:()=>vl,applyStep:()=>yn,ask:()=>fo,canvasView:()=>Dl,chain:()=>ts,clipboard:()=>Cl,clipboardFor:()=>yl,closeMenu:()=>Tl,cmSnippet:()=>Xf,commandsFor:()=>co,complete:()=>xl,completionContext:()=>dl,composite:()=>Er,deleteAt:()=>Fs,docFor:()=>kl,flatCanvas:()=>op,flatten:()=>vd,flowText:()=>pn,fromPointer:()=>et,icon:()=>Ut,iconSymbols:()=>hi,insertItem:()=>ui,insertKey:()=>Mn,insertRawPair:()=>bl,invertStep:()=>pl,isMessage:()=>lp,isPrefix:()=>qt,isTyping:()=>rr,keySheet:()=>Pl,keymapWith:()=>Al,later:()=>or,layer:()=>gs,mdRuns:()=>Qf,menuOpen:()=>ep,mountEditor:()=>ip,moveKey:()=>gl,namesIn:()=>wd,openMenu:()=>bs,outline:()=>wl,pairText:()=>io,parentOf:()=>Hf,place:()=>kd,problemRange:()=>$l,propsPanel:()=>Il,providersFor:()=>Sl,rangeOfPath:()=>Ml,renameKey:()=>sr,run:()=>xn,samePath:()=>Yf,scalarText:()=>_n,scopeCss:()=>Td,scopeOne:()=>Ed,seqCmd:()=>pi,setLayer:()=>$r,setValue:()=>Ds,setupFor:()=>up,spriteOf:()=>gi,toPointer:()=>Se,treeView:()=>Ol});var Qm=t=>String(t).replace(/~/g,"~0").replace(/\//g,"~1"),Se=t=>t.map(e=>"/"+Qm(e)).join("");function et(t){return t?t.split("/").slice(1).map(e=>{let n=e.replace(/~1/g,"/").replace(/~0/g,"~");return/^\d+$/.test(n)?Number(n):n}):[]}var Hf=t=>t.length?t.slice(0,-1):void 0,qt=(t,e)=>t.length<=e.length&&t.every((n,s)=>String(n)===String(e[s])),Yf=(t,e)=>t.length===e.length&&qt(t,e);var On=class{text;doc;lines;constructor(e){this.text=e,this.lines=new Es,this.doc=cn(e,{keepSourceTokens:!0,lineCounter:this.lines,prettyErrors:!1,uniqueKeys:!1})}get ok(){return this.doc.errors.length===0}get data(){try{return this.doc.toJS()}catch{return}}pos(e){return this.lines.linePos(e)}offset(e,n){return(this.lines.lineStarts[e-1]??this.text.length)+n-1}rangeOf(e,n="value"){let s=this.doc.contents,r;for(let i of e)if(r=void 0,ct(s)){let a=s.items.find(l=>st(l)&&Ge(l.key)&&String(l.key.value)===String(i));if(!a)return;r=a,s=a.value}else if(Lt(s)&&typeof i=="number")s=s.items[i];else return;if(n==="key"&&r&&Ge(r.key)&&r.key.range)return[r.key.range[0],r.key.range[1]];let o=s?.range;if(n==="pair"&&r&&Ge(r.key)&&r.key.range)return[r.key.range[0],o?o[1]:r.key.range[1]];if(o)return[o[0],o[1]];if(r&&Ge(r.key)&&r.key.range)return[r.key.range[0],r.key.range[1]]}at(e){let n=(s,r)=>{if(ct(s)){for(let o of s.items){let i=o.key;if(i?.range&&e>=i.range[0]&&e<=i.range[1])return{path:[...r,so(o)],where:"key",node:i};let a=o.value;if(a?.range&&e>=a.range[0]&&(Ge(a)?e<=a.range[1]:e<a.range[1]))return n(a,[...r,so(o)])??{path:[...r,so(o)],where:"value",node:a};if(i?.range&&(!a||!a.range||Ge(a)&&a.value===null)&&e>i.range[1]&&!this.text.slice(i.range[1],e).includes(`
|
|
389
|
+
`))return{path:[...r,so(o)],where:"value",node:a??void 0}}return s.range&&e>=s.range[0]&&e<=s.range[1]?{path:r,where:"inside",node:s}:void 0}if(Lt(s)){for(let[o,i]of s.items.entries()){let a=i?.range;if(a&&e>=a[0]&&(Ge(i)?e<=a[1]:e<a[1]))return n(i,[...r,o])??{path:[...r,o],where:"value",node:i}}return s.range&&e>=s.range[0]&&e<=s.range[1]?{path:r,where:"inside",node:s}:void 0}if(Ge(s)&&s.range&&e>=s.range[0]&&e<=s.range[1])return{path:r,where:"value",node:s}};return n(this.doc.contents,[])??{path:[],where:"inside"}}nodeAt(e){let n=this.doc.contents;for(let s of e)if(ct(n))n=n.items.find(r=>Ge(r.key)&&String(r.key.value)===String(s))?.value;else if(Lt(n)&&typeof s=="number")n=n.items[s];else return;return n??void 0}paths(){let e=[],n=(s,r)=>{let o=s?.range;if(o&&r.length&&e.push({path:r,range:[o[0],o[1]]}),ct(s))for(let i of s.items)n(i.value,[...r,so(i)]);else Lt(s)&&s.items.forEach((i,a)=>n(i,[...r,a]))};return n(this.doc.contents,[]),e}};function so(t){return Ge(t.key)?String(t.key.value):String(t.key)}function dl(t,e){let n=t.text,s=n.lastIndexOf(`
|
|
390
|
+
`,e-1)+1,r=n.slice(s,e),o=/[A-Za-z0-9_.:\/{}*~$-]*$/.exec(r)[0].replace(/^[{[,]/,""),i=e-o.length,a=Zm(t,i);if(a){let u=n.slice(a.range[0],i),f=/([A-Za-z0-9_-]+)\s*:\s*$/.exec(u.slice(Math.max(u.lastIndexOf(","),u.lastIndexOf("{"))+1));return a.kind==="map"&&f?{path:[...a.path,f[1]],kind:"value",prefix:o,start:i,flow:!0}:{path:a.path,kind:a.kind==="map"?"key":"item",prefix:o,start:i,flow:!0}}let l=/^(\s*)(?:- )?([^\s:#][^:#]*?)\s*:\s+$/.exec(r.slice(0,r.length-o.length));if(l){let u=s+r.indexOf(l[2],l[1].length),f=t.at(u);return f.where==="key"?{path:f.path,kind:"value",prefix:o,start:i,flow:!1}:{path:[...hd(t,s,l[1].length),l[2]],kind:"value",prefix:o,start:i,flow:!1}}let c=/^(\s*)- $/.exec(r.slice(0,r.length-o.length));if(c)return{path:hd(t,s,c[1].length,!0),kind:"item",prefix:o,start:i,flow:!1};let d=/^\s*/.exec(r)[0].length;return{path:hd(t,s,d),kind:"key",prefix:o,start:i,flow:!1}}function hd(t,e,n,s=!1){let r=t.text,o=e-1;for(;o>0;){let i=r.lastIndexOf(`
|
|
391
|
+
`,o-1)+1,a=r.slice(i,o);if(o=i-1,!a.trim()||/^\s*#/.test(a))continue;let l=/^\s*/.exec(a)[0].length;if(l===n&&!s){let c=i+l+(a.slice(l).startsWith("- ")?2:0),d=t.at(c);if(d.where==="key"||a.slice(l).startsWith("- "))return d.path.slice(0,-1)}if(!s&&/^- /.test(a.slice(l))&&l+2===n){let c=t.at(i+l+2);if(c.where==="key")return c.path.slice(0,-1)}if(l<n||s&&l<=n&&/:\s*$/.test(a)){let c=/^(\s*)(- )?([^\s:#][^:#]*?)\s*:/.exec(a);if(c){let d=t.at(i+c[1].length+(c[2]?2:0));if(d.where==="key")return d.path}if(/^\s*- /.test(a)){let d=t.at(i+l+2),u=d.path.length-1;for(;u>=0&&typeof d.path[u]!="number";)u--;return u>=0?d.path.slice(0,u+1):d.path}if(l<n)return[]}if(l===0&&n===0)return[]}return[]}function Zm(t,e){let n,s=(r,o)=>{if(!kt(r))return;let i=r.range;if(r.flow&&i&&e>i[0]&&e<i[1]&&(n={path:o,kind:ct(r)?"map":"list",range:[i[0],i[1]]}),ct(r))for(let l of r.items)s(l.value,[...o,so(l)]);else Lt(r)&&r.items.forEach((l,c)=>s(l,[...o,c]))};return s(t.doc.contents,[]),n}var bn=class extends Error{};function yn(t,e){let n=t;for(let s of[...e].sort((r,o)=>o.start-r.start))n=n.slice(0,s.start)+s.text+n.slice(s.end);return n}function pl(t,e){let n=[...e].sort((r,o)=>r.start-o.start),s=0;return n.map(r=>{let o=r.start+s;return s+=r.text.length-(r.end-r.start),{start:o,end:o+r.text.length,text:t.slice(r.start,r.end)}})}var Rs=t=>({text:t,doc:cn(t,{keepSourceTokens:!0,uniqueKeys:!1})});function hs(t){return Ge(t.key)?String(t.key.value):String(t.key)}function Is(t,e){let n=t.doc.contents,s,r,o=[n];for(let i of e){if(s=void 0,ct(n)){r=n;let a=n.items.find(l=>st(l)&&hs(l)===String(i));if(!a)return{node:void 0,parent:r,chain:o};s=a,n=a.value}else if(Lt(n)&&typeof i=="number"){if(r=n,n=n.items[i],n===void 0)return{node:void 0,parent:r,chain:o}}else return{node:void 0,chain:o};o.push(n)}return{node:n,pair:s,parent:r,chain:o}}var di=t=>t.some(e=>(ct(e)||Lt(e))&&e.flow),Ns=(t,e)=>t.lastIndexOf(`
|
|
392
|
+
`,e-1)+1,gd=(t,e)=>{let n=t.indexOf(`
|
|
393
|
+
`,e);return n<0?t.length:n},bd=(t,e)=>{let n=t.indexOf(`
|
|
394
|
+
`,e);return n<0?t.length:n+1},ci=(t,e)=>e-Ns(t,e);function tr(t,e){let n=e.key,s=e.value,r=s?.range?Math.max(s.range[1],n.range[1]):n.range[1],o=r>0&&t.text[r-1]===`
|
|
395
|
+
`?r-1:r;return bd(t.text,o)}function ro(t,e){let n=e.key.range[0],s=Ns(t.text,n),r=n-s;if(Sr(t.text,n))return n;for(;s!==0;){let o=Ns(t.text,s-1),i=t.text.slice(o,s-1);if(/^\s*#/.test(i)&&i.length-i.trimStart().length===r)s=o;else break}return s}var ml=(t,e)=>/^\s*(-\s+)*$/.test(t.slice(Ns(t,e),e)),Sr=(t,e)=>/-\s+$/.test(t.slice(Ns(t,e),e)),eh=/[,[\]{}]/;function _n(t,e){if(t==null)return"null";if(typeof t!="string")return String(t);if(e.style===Be.QUOTE_DOUBLE)return JSON.stringify(t);if(e.style===Be.QUOTE_SINGLE&&!t.includes(`
|
|
396
396
|
`))return`'${t.replace(/'/g,"''")}'`;if(t.includes(`
|
|
397
397
|
`)){if(e.flow)return JSON.stringify(t);let s=t.endsWith(`
|
|
398
398
|
`)?t.slice(0,-1):t;return/(^|\n)\s/.test(s.split(`
|
|
@@ -400,74 +400,74 @@ ${e.extraBody??""}
|
|
|
400
400
|
`)?"|":"|-")+`
|
|
401
401
|
`+s.split(`
|
|
402
402
|
`).map(r=>r?" ".repeat(e.indent)+r:"").join(`
|
|
403
|
-
`)}let n=
|
|
404
|
-
`)))&&
|
|
405
|
-
`))||Array.isArray(n)&&
|
|
403
|
+
`)}let n=bc(t,{lineWidth:0}).replace(/\n$/,"");return e.flow&&eh.test(n)&&!/^["']/.test(n)?JSON.stringify(t):n}function pn(t){if(Array.isArray(t))return t.length?`[${t.map(pn).join(", ")}]`:"[]";if(t&&typeof t=="object"){let e=Object.entries(t);return e.length?`{ ${e.map(([n,s])=>`${nr(n)}: ${pn(s)}`).join(", ")} }`:"{}"}return _n(t,{flow:!0,indent:0})}var nr=t=>_n(t,{flow:!0,indent:0}),Kn=t=>!!t&&typeof t=="object",yd=t=>{if(Array.isArray(t))return t.every(e=>!Kn(e)&&!(typeof e=="string"&&e.includes(`
|
|
404
|
+
`)))&&pn(t).length<=60;if(Kn(t)){let e=Object.entries(t);return e.length>0&&e.length<=2&&e.every(([,n])=>!Kn(n)&&!(typeof n=="string"&&n.includes(`
|
|
405
|
+
`))||Array.isArray(n)&&yd(n))&&pn(t).length<=40}return!1};function ul(t,e=0){let n=" ".repeat(e),s=r=>Kn(r)?(Array.isArray(r)?!r.length:!Object.keys(r).length)?Array.isArray(r)?"[]":"{}":yd(r)?pn(r):void 0:_n(r,{flow:!1,indent:e+2});return Array.isArray(t)?t.map(r=>{let o=s(r);if(o!==void 0)return`${n}- ${o}`;let i=ul(r,e+2);return Array.isArray(r)?`${n}-
|
|
406
406
|
${i}`:`${n}- ${i.slice(e+2)}`}).join(`
|
|
407
|
-
`):Object.entries(t).map(([r,o])=>{let i=s(o);return i!==void 0?`${n}${
|
|
408
|
-
${
|
|
409
|
-
`)}function
|
|
410
|
-
`+
|
|
407
|
+
`):Object.entries(t).map(([r,o])=>{let i=s(o);return i!==void 0?`${n}${nr(r)}: ${i}`:`${n}${nr(r)}:
|
|
408
|
+
${ul(o,e+2)}`}).join(`
|
|
409
|
+
`)}function fl(t,e){return Kn(t)?(Array.isArray(t)?!t.length:!Object.keys(t).length)?Array.isArray(t)?" []":" {}":yd(t)?" "+pn(t):`
|
|
410
|
+
`+hl(ul(t),e+2):" "+_n(t,{flow:!1,indent:e+2})}var hl=(t,e)=>t.split(`
|
|
411
411
|
`).map(n=>n&&" ".repeat(e)+n).join(`
|
|
412
|
-
`);function
|
|
413
|
-
`&&!
|
|
414
|
-
`))for(
|
|
415
|
-
`;)
|
|
416
|
-
`)){let
|
|
417
|
-
`;)
|
|
418
|
-
`?d-1:d,f=
|
|
412
|
+
`);function Ds(t,e,n){let s=Rs(t),r=Is(s,e);if(r.node===void 0)throw new bn(`no value at ${e.join(".")}`);let o=di(r.chain.slice(0,-1)),i=r.node,a=r.pair?.key,l=a?.range?ci(t,a.range[0]):i?.range?ci(t,i.range[0]):0;if(Ge(i)&&i.range&&!Kn(n)&&i.range[1]>i.range[0]){let v=i.type===Be.BLOCK_LITERAL||i.type===Be.BLOCK_FOLDED?void 0:i.type,w=_n(n,{flow:o,indent:l+2,style:v}),k=i.range[1];if(t[k-1]===`
|
|
413
|
+
`&&!w.endsWith(`
|
|
414
|
+
`))for(k-=1;k>i.range[0]&&t[k-1]===`
|
|
415
|
+
`;)k-=1;if(w.startsWith("|")&&!t.slice(i.range[0],k).includes(`
|
|
416
|
+
`)){let y=gd(t,k),M=t.slice(k,y);/^\s*#/.test(M)&&(w=w.replace(/^(\|-?)/,`$1${M}`),k=y)}return{steps:[[{start:i.range[0],end:k,text:w}]]}}if((o||Kn(i)&&i.flow||!r.pair)&&i?.range&&i.range[1]>i.range[0]){let v=o||!Kn(n)||!r.pair?Kn(n)?pn(n):_n(n,{flow:o,indent:l+2}):null;if(v!==null){let w=i.range[1];for(;w>i.range[0]&&t[w-1]===`
|
|
417
|
+
`;)w-=1;return{steps:[[{start:i.range[0],end:w,text:v}]]}}}if(!r.pair||!a?.range)return oo(t,e.slice(0,-1),v=>v.setIn(e,n));let c=t.indexOf(":",a.range[1]),d=i?.range?i.range[1]:c+1,u=t[d-1]===`
|
|
418
|
+
`?d-1:d,f=gd(t,c),p=i?.range&&i.range[0]>f?t.slice(c+1,f):"",g=/^\s*#/.test(p)?p:"",h=fl(n,l),b=u;if(g&&h.startsWith(`
|
|
419
419
|
`))h=g+h;else if(g)h=h+g;else if(h.startsWith(`
|
|
420
|
-
`)&&u<=f){let
|
|
420
|
+
`)&&u<=f){let v=t.slice(u,f);/^\s*#/.test(v)&&(h=v+h,b=f)}return{steps:[[{start:c+1,end:b,text:h}]]}}function Mn(t,e,n,s,r={}){let o=r.order??[],i=Rs(t),a=Is(i,e);if(a.node===void 0||a.node===null||Ge(a.node)&&a.node.value===null){if(!e.length){let w=`${nr(n)}:${fl(s,0)}
|
|
421
421
|
`;return{steps:[[{start:t.length,end:t.length,text:(t&&!t.endsWith(`
|
|
422
422
|
`)?`
|
|
423
|
-
`:"")+
|
|
424
|
-
`,h=!e.length&&
|
|
425
|
-
`:"";if(u===0&&d.length&&
|
|
426
|
-
`:g}]]}}let b=
|
|
423
|
+
`:"")+w}]]}}return a.node===void 0?Mn(t,e.slice(0,-1),String(e[e.length-1]),{[n]:s},{order:r.order}):Ds(t,e,{[n]:s})}let l=a.node;if(!ct(l))throw new bn(`${e.join(".")||"the file"} is not a map`);if(l.items.some(w=>hs(w)===n))throw new bn(`"${n}" is already in ${e.join(".")||"the file"}`);let c=l.flow||di(a.chain.slice(0,-1)),d=l.items,u=d.length;if(r.after!==void 0)u=d.findIndex(w=>hs(w)===r.after)+1||d.length;else if(r.before!==void 0){let w=d.findIndex(k=>hs(k)===r.before);w>=0&&(u=w)}else if(!e.length&&o.includes(n)){let w=o.indexOf(n),k=d.findIndex(y=>o.indexOf(hs(y))>w||hs(y).startsWith("x-"));k>=0&&(u=k)}if(c&&l.range&&t[l.range[0]]!=="{"){let w=i.doc.getIn(e,!0).toJSON();return{steps:[[{start:l.range[0],end:l.range[1],text:pn({...w,[n]:s})}]]}}if(c){let w=`${nr(n)}: ${pn(s)}`;if(!d.length){let M=l.range;return{steps:[[{start:M[0],end:t.lastIndexOf("}",M[1])+1,text:`{ ${w} }`}]]}}if(u<d.length){let M=d[u].key.range[0];return{steps:[[{start:M,end:M,text:`${w}, `}]]}}let k=d[d.length-1],y=k.value?.range?.[1]??k.key.range[1];return{steps:[[{start:y,end:y,text:`, ${w}`}]]}}let f=d[0]?.key;if(!f?.range)return oo(t,e,w=>w.setIn([...e,n],s),!0);let p=ci(t,f.range[0]);if(d.some(w=>!ml(t,w.key.range[0])))return oo(t,e,w=>w.setIn([...e,n],s),!0);let g=`${" ".repeat(p)}${nr(n)}:${fl(s,p)}
|
|
424
|
+
`,h=!e.length&&Kn(s)?`
|
|
425
|
+
`:"";if(u===0&&d.length&&Sr(t,f.range[0])){let w=f.range[0];return{steps:[[{start:w,end:w,text:g.slice(p)+" ".repeat(p)}]]}}if(u<d.length){let w=ro(i,d[u]);return{steps:[[{start:w,end:w,text:h&&u>0?g+`
|
|
426
|
+
`:g}]]}}let b=tr(i,d[d.length-1]),v=b===t.length&&t.length&&!t.endsWith(`
|
|
427
427
|
`)?`
|
|
428
|
-
`:"";return{steps:[[{start:b,end:b,text:
|
|
429
|
-
`?g-1:g);return{steps:[[{start:p,end:h,text:""}]]}}function
|
|
430
|
-
`;if(c<l.length){let
|
|
431
|
-
`?
|
|
428
|
+
`:"";return{steps:[[{start:b,end:b,text:v+h+g}]]}}function Fs(t,e){if(!e.length)throw new bn("can't delete the whole file");let n=Rs(t),s=e.slice(0,-1),o=Is(n,s).node,i=e[e.length-1];if(!ct(o)&&!Lt(o))throw new bn(`no entry at ${e.join(".")}`);let a=o.items,l=ct(o)?a.findIndex(b=>hs(b)===String(i)):Number(i);if(l<0||l>=a.length)throw new bn(`no entry at ${e.join(".")}`);let c=o.flow,d=b=>st(b)?b.key.range[0]:b.range[0],u=b=>st(b)?b.value?.range?.[1]??b.key.range[1]:b.range[1];if(a.length===1)return!s.length&&ct(o)&&!o.flow?{steps:[[{start:ro(n,a[0]),end:tr(n,a[0]),text:""}]]}:s.length?Ds(t,s,ct(o)?{}:[]):{steps:[[{start:0,end:t.length,text:""}]]};if(c)return l<a.length-1?{steps:[[{start:d(a[l]),end:d(a[l+1]),text:""}]]}:{steps:[[{start:u(a[l-1]),end:u(a[l]),text:""}]]};if(ct(o)){let b=a[l],v=b.key.range[0];return ml(t,v)?Sr(t,v)?{steps:[[{start:v,end:a[l+1]?a[l+1].key.range[0]:tr(n,b),text:""}]]}:{steps:[[{start:ro(n,b),end:tr(n,b),text:""}]]}:oo(t,s,w=>w.deleteIn(e),!0)}let f=a[l],p=Ns(t,f.range[0]);if(!/^\s*-/.test(t.slice(p,f.range[0])))return oo(t,s,b=>b.deleteIn(e),!0);let g=f.range[1],h=bd(t,t[g-1]===`
|
|
429
|
+
`?g-1:g);return{steps:[[{start:p,end:h,text:""}]]}}function ui(t,e,n,s,r){let o=Rs(t),i=Is(o,e);if(i.node===void 0||i.node===null||Ge(i.node)&&i.node.value===null)return i.node===void 0?Mn(t,e.slice(0,-1),String(e[e.length-1]),[n],{order:r}):Ds(t,e,[n]);let a=i.node;if(!Lt(a))throw new bn(`${e.join(".")} is not a list`);let l=a.items,c=s===void 0?l.length:Math.max(0,Math.min(s,l.length));if(a.flow||di(i.chain.slice(0,-1))){let y=pn(n);if(!l.length){let T=a.range,A=t.lastIndexOf("]",T[1]);return{steps:[[{start:T[0],end:A+1,text:`[${y}]`}]]}}if(c<l.length){let T=l[c].range[0];return{steps:[[{start:T,end:T,text:`${y}, `}]]}}let M=l[l.length-1].range[1];return{steps:[[{start:M,end:M,text:`, ${y}`}]]}}let d=l[0],u=Ns(t,d.range[0]),f=t.slice(u,d.range[0]);if(!/^\s*- $/.test(f))return oo(t,e,y=>{y.getIn(e).items.splice(c,0,y.createNode(n))},!0);let p=f.indexOf("-"),g=l[Math.min(c,l.length-1)],h=Kn(n)&&ct(g)&&g.flow,b=" ".repeat(p)+"- "+(h?pn(n):Kn(n)&&Object.keys(n).length?hl(ul(n),p+2).slice(p+2):_n(n,{flow:!1,indent:p+2}))+`
|
|
430
|
+
`;if(c<l.length){let y=Ns(t,l[c].range[0]);return{steps:[[{start:y,end:y,text:b}]]}}let v=l[l.length-1].range[1],w=bd(t,t[v-1]===`
|
|
431
|
+
`?v-1:v),k=w===t.length&&!t.endsWith(`
|
|
432
432
|
`)?`
|
|
433
|
-
`:"";return{steps:[[{start:
|
|
433
|
+
`:"";return{steps:[[{start:w,end:w,text:k+b}]]}}function sr(t,e,n){let s=Rs(t),r=Is(s,e);if(!r.pair)throw new bn(`no key at ${e.join(".")}`);if(r.parent.items.some(i=>hs(i)===n))throw new bn(`"${n}" is already there`);let o=r.pair.key;return{steps:[[{start:o.range[0],end:o.range[1],text:nr(n)}]]}}function gl(t,e,n,s){let r=Rs(t),o=Is(r,e);if(!o.pair||!ct(o.parent))throw new bn(`no key at ${e.join(".")}`);let i=o.parent,a=Sr(t,o.pair.key.range[0])||i.items.some(g=>Sr(t,g.key.range[0]));if(i.flow||a){let h=o.pair.value?r.doc.getIn(e)?.toJSON?.()??r.doc.getIn(e):null,b=Fs(t,e),v=yn(t,b.steps[0]),w=Mn(v,e.slice(0,-1),String(e[e.length-1]),h,n?{before:n,order:s}:{order:s});return{steps:[...b.steps,...w.steps]}}let l=ro(r,o.pair),c=tr(r,o.pair),d=t.slice(l,c),u=n?i.items.find(g=>hs(g)===n):void 0;if(u===o.pair)return{steps:[]};let f=u?ro(r,u):tr(r,i.items[i.items.length-1]),p=d.endsWith(`
|
|
434
434
|
`)?d:d+`
|
|
435
435
|
`;return{steps:[[{start:l,end:c,text:""},{start:f,end:f,text:f===t.length&&!t.endsWith(`
|
|
436
436
|
`)?`
|
|
437
|
-
`+p:p}]]}}function
|
|
438
|
-
`?u[1]-1:
|
|
439
|
-
`,p=
|
|
437
|
+
`+p:p}]]}}function oo(t,e,n,s=!1){let r=Rs(t),i=Is(r,e).node;if(n(r.doc),!e.length||!i?.range)return{steps:[[{start:0,end:t.length,text:r.doc.toString({lineWidth:0})}]],fallback:!0};let a=r.doc.getIn(e,!0),l=i.flow,c=new Jn;c.contents=a;let d=c.toString({lineWidth:0,indent:2}).replace(/\n$/,""),u=i.range;if(l)return{steps:[[{start:u[0],end:u[1],text:d.replace(/\n\s*/g," ")}]],fallback:!0};let f=Ns(t,u[0]),p=u[0]-f,g=u[1]>0&&t[u[1]-1]===`
|
|
438
|
+
`?u[1]-1:gd(t,u[1]);return d=hl(d,p).slice(t.slice(f,u[0]).trim()?p:0),{steps:[[{start:t.slice(f,u[0]).trim()?u[0]:f,end:g,text:d}]],fallback:!0}}function bl(t,e,n,s,r){let o=Rs(t),i=Is(o,e),a=i.node,l=cn(s).toJS()?.[n];if(!ct(a)||a.flow||di(i.chain.slice(0,-1))||!a.items.length)return Mn(t,e,n,l,{order:r});let c=a.items,d=c[0].key;if(!d.range||c.some(h=>!ml(t,h.key.range[0])||Sr(t,h.key.range[0])))return Mn(t,e,n,l,{order:r});if(c.some(h=>hs(h)===n))throw new bn(`"${n}" is already in ${e.join(".")||"the file"}`);let u=ci(t,d.range[0]),f=hl(s.replace(/\n+$/,""),u)+`
|
|
439
|
+
`,p=tr(o,c[c.length-1]),g=p===t.length&&t.length&&!t.endsWith(`
|
|
440
440
|
`)?`
|
|
441
|
-
`:"";return{steps:[[{start:p,end:p,text:g+f}]]}}function
|
|
442
|
-
`}let o=
|
|
441
|
+
`:"";return{steps:[[{start:p,end:p,text:g+f}]]}}function io(t,e){let n=Rs(t),s=Is(n,e);if(!s.pair||!ct(s.parent))return;let r=s.pair.key.range[0];if(s.parent.flow||di(s.chain.slice(0,-1))||!ml(t,r)||Sr(t,r)){let l=n.doc.getIn(e,!0),c=l&&typeof l=="object"&&l.toJSON?l.toJSON():n.doc.getIn(e);return`${nr(String(e[e.length-1]))}:${fl(c,0)}
|
|
442
|
+
`}let o=ro(n,s.pair),i=tr(n,s.pair),a=ci(t,r);return t.slice(o,i).split(`
|
|
443
443
|
`).map(l=>l.slice(0,a).trim()===""?l.slice(a):l.trimStart()).join(`
|
|
444
444
|
`).replace(/\n*$/,`
|
|
445
|
-
`)}var
|
|
446
|
-
`)&&!(/[\w-]/.test(d)&&/^[^\w-]/.test(i.text))}l&&a==="delete"&&(l=i.end===o.caret);let{inverse:c}=this.run([e]);l?(o.steps.push(e),o.inverse.unshift(...c),o.time=r,o.after={paths:this.selection,text:n.after},o.caret=a==="insert"?i.start+i.text.length:i.start):(this.seal(),this.push({id:this.nextId++,label:"Typing",origin:"text",steps:[e],inverse:c,before:{paths:this.selection,text:n.before??this.textSel},after:{paths:this.selection,text:n.after},time:r,fallback:!1,open:!!a,caret:i?a==="insert"?i.start+i.text.length:i.start:void 0,typing:a,source:s})),n.after!==void 0&&(this.textSel=n.after),this.emit({kind:"do",origin:"text",label:"Typing",steps:[e],version:this._version,source:s})}seal(){let e=this.undoStack[this.undoStack.length-1];e&&(e.open=!1)}run(e){let n=[],s=this._text;for(let r of e){let o=
|
|
445
|
+
`)}var xd=500,th=1e3,ao=class{_text="";_doc;_version=0;undoStack=[];redoStack=[];nextId=1;cleanId=0;listeners=new Set;selListeners=new Set;_good;selection=[];textSel;fallbacks=0;depth=xd;now=()=>Date.now();constructor(e=""){this._text=e}get text(){return this._text}get version(){return this._version}get doc(){return this._doc??=new On(this._text)}get goodDoc(){return this.doc.ok&&(this._good=this.doc),this._good??this.doc}select(e,n){this.selection=e;for(let s of this.selListeners)s({paths:e,origin:n})}onSelect(e){return this.selListeners.add(e),()=>this.selListeners.delete(e)}on(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e){for(let n of this.listeners)n(e)}load(e,n="file"){let s=this._text;this.undoStack=[],this.redoStack=[],this.selection=[],this._good=void 0,this.set(e),this.cleanId=0,this.emit({kind:"load",origin:n,label:"Open",steps:[[{start:0,end:s.length,text:e}]],version:this._version})}set(e){this._text=e,this._doc=void 0,this._version++}apply(e,n="api",s){this.seal();let r=e.build(this._text);if(!r.steps.some(c=>c.length))return!1;let o={paths:this.selection,text:this.textSel},{inverse:i}=this.run(r.steps),a=e.remap??(c=>c);this.selection=e.select??this.selection.map(a).filter(c=>c!==null),r.fallback&&this.fallbacks++;let l=this.undoStack[this.undoStack.length-1];l&&s!==void 0&&l.id===s&&!this.redoStack.length&&l.id!==this.cleanId?(l.label=e.joined?.(l.label)??l.label,l.steps.push(...r.steps),l.inverse.unshift(...i),l.after={paths:this.selection,text:this.textSel},l.time=this.now(),l.fallback||=!!r.fallback):this.push({id:this.nextId++,label:e.label,origin:n,steps:r.steps,inverse:i,before:o,after:{paths:this.selection,text:this.textSel},time:this.now(),fallback:!!r.fallback,open:!1}),this.emit({kind:"do",origin:n,label:e.label,steps:r.steps,version:this._version,remap:e.remap});for(let c of this.selListeners)c({paths:this.selection,origin:n});return!0}typed(e,n={},s){if(!e.length)return;let r=this.now(),o=this.undoStack[this.undoStack.length-1],i=e.length===1?e[0]:void 0,a=i?i.text&&i.start===i.end?"insert":!i.text&&i.end>i.start?"delete":void 0:void 0,l=!!(o&&o.open&&o.origin==="text"&&o.source===s&&this.redoStack.length===0&&r-o.time<th&&i&&a&&a===o.typing);if(l&&a==="insert"){let d=this._text[i.start-1]??"";l=i.start===o.caret&&!i.text.includes(`
|
|
446
|
+
`)&&!(/[\w-]/.test(d)&&/^[^\w-]/.test(i.text))}l&&a==="delete"&&(l=i.end===o.caret);let{inverse:c}=this.run([e]);l?(o.steps.push(e),o.inverse.unshift(...c),o.time=r,o.after={paths:this.selection,text:n.after},o.caret=a==="insert"?i.start+i.text.length:i.start):(this.seal(),this.push({id:this.nextId++,label:"Typing",origin:"text",steps:[e],inverse:c,before:{paths:this.selection,text:n.before??this.textSel},after:{paths:this.selection,text:n.after},time:r,fallback:!1,open:!!a,caret:i?a==="insert"?i.start+i.text.length:i.start:void 0,typing:a,source:s})),n.after!==void 0&&(this.textSel=n.after),this.emit({kind:"do",origin:"text",label:"Typing",steps:[e],version:this._version,source:s})}seal(){let e=this.undoStack[this.undoStack.length-1];e&&(e.open=!1)}run(e){let n=[],s=this._text;for(let r of e){let o=yn(s,r);n.unshift(pl(s,r)),s=o}return this.set(s),{inverse:n}}push(e){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>this.depth&&this.undoStack.shift().id===this.cleanId&&(this.cleanId=-1)}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}get undoId(){return this.undoStack[this.undoStack.length-1]?.id}get undoLabel(){return this.undoStack[this.undoStack.length-1]?.label}get redoLabel(){return this.redoStack[this.redoStack.length-1]?.label}undo(){this.seal();let e=this.undoStack.pop();if(!e)return!1;this.run(e.inverse),this.redoStack.push(e),this.selection=e.before.paths,this.textSel=e.before.text,this.emit({kind:"undo",origin:"history",label:e.label,steps:e.inverse,version:this._version,textSel:e.before.text});for(let n of this.selListeners)n({paths:this.selection,origin:"history"});return!0}redo(){let e=this.redoStack.pop();if(!e)return!1;this.run(e.steps),this.undoStack.push(e),this.selection=e.after.paths,this.textSel=e.after.text,this.emit({kind:"redo",origin:"history",label:e.label,steps:e.steps,version:this._version,textSel:e.after.text});for(let n of this.selListeners)n({paths:this.selection,origin:"history"});return!0}markClean(){this.seal(),this.cleanId=this.undoStack[this.undoStack.length-1]?.id??0}get dirty(){return(this.undoStack[this.undoStack.length-1]?.id??0)!==this.cleanId}get history(){return this.undoStack.map(e=>e.label)}};var lo=class{root;defs;constructor(e){this.root=e,this.defs=e.$defs??{}}spread(e,n=new Set){if(!e||typeof e!="object"||n.has(e))return[];n.add(e);let s=e,r=[s];typeof s.$ref=="string"&&s.$ref.startsWith("#/$defs/")&&r.push(...this.spread(this.defs[s.$ref.slice(8)],n));for(let o of["anyOf","oneOf","allOf"])for(let i of s[o]??[])r.push(...this.spread(i,n));return r}at(e){let n=this.spread(this.root);for(let s of e){let r=[];for(let o of n){if(typeof s=="number"){o.items&&r.push(...this.spread(o.items));continue}let i=o.properties??{};if(i[s]!==void 0){r.push(...this.spread(i[s]));continue}let a=Object.entries(o.patternProperties??{}).find(([l])=>new RegExp(l).test(s));if(a){r.push(...this.spread(a[1]));continue}o.additionalProperties&&typeof o.additionalProperties=="object"&&r.push(...this.spread(o.additionalProperties))}if(n=r,!n.length)break}return n}keys(e,n={}){let s=this.at(e),r=new Set;for(let i of s)for(let[a,l]of Object.entries(i.dependentSchemas??{})){let c=Object.entries(l.properties??{}).filter(([,d])=>d===!1).map(([d])=>d);n[a]!==void 0?c.forEach(d=>r.add(d)):c.some(d=>n[d]!==void 0)&&r.add(a)}let o=new Map;for(let i of s)for(let[a,l]of Object.entries(i.properties??{})){if(r.has(a)||l===!1)continue;let c=o.get(a),d=this.info(a,e,l);(!c||!c.doc&&d.doc)&&o.set(a,d)}return[...o.values()]}info(e,n,s){let r=this.at([...n,e]).length?this.at([...n,e]):this.spread(s),o=r.map(c=>c.markdownDescription??c.description).find(Boolean),i=new Set(r.flatMap(c=>Array.isArray(c.type)?c.type:c.type?[c.type]:[])),a=r.some(c=>c.properties||c.additionalProperties||c.patternProperties),l=i.has("array")&&!i.has("string")?"list":(i.has("object")||a)&&!i.has("string")&&!r.some(c=>c.const!==void 0||c.enum)?"map":"scalar";return{name:e,doc:o,shape:l,enumValues:this.values([...n,e],r),examples:r.flatMap(c=>c.examples??[])}}values(e,n=this.at(e)){let s=new Set;for(let r of n){for(let o of r.enum??[])s.add(String(o));r.const!==void 0&&typeof r.const!="object"&&s.add(String(r.const)),r.type==="boolean"&&(s.add("true"),s.add("false"))}return[...s]}hover(e){let n=this.at(e),s=n.map(o=>o.markdownDescription??o.description).find(Boolean);if(!s)return;let r=this.values(e,n);return s+(r.length&&r.length<=12?`
|
|
447
447
|
|
|
448
|
-
One of: ${r.map(o=>"`"+o+"`").join(", ")}`:"")}defaultFor(e){let n=this.at(e),s=this.values(e,n);if(s.length)return s[0]==="true"||s[0]==="false"?!1:s[0];let r=n.flatMap(i=>i.examples??[]).find(i=>typeof i=="string"),o=new Set(n.flatMap(i=>Array.isArray(i.type)?i.type:i.type?[i.type]:[]));return o.has("array")?[]:o.has("object")||n.some(i=>i.properties||i.additionalProperties)?{}:o.has("integer")||o.has("number")?1:r??""}types(e){return new Set(this.at(e).flatMap(n=>Array.isArray(n.type)?n.type:n.type?[n.type]:[]))}isNameMap(e){return this.at(e).some(n=>n.additionalProperties&&typeof n.additionalProperties=="object"&&!n.properties)}};var
|
|
448
|
+
One of: ${r.map(o=>"`"+o+"`").join(", ")}`:"")}defaultFor(e){let n=this.at(e),s=this.values(e,n);if(s.length)return s[0]==="true"||s[0]==="false"?!1:s[0];let r=n.flatMap(i=>i.examples??[]).find(i=>typeof i=="string"),o=new Set(n.flatMap(i=>Array.isArray(i.type)?i.type:i.type?[i.type]:[]));return o.has("array")?[]:o.has("object")||n.some(i=>i.properties||i.additionalProperties)?{}:o.has("integer")||o.has("number")?1:r??""}types(e){return new Set(this.at(e).flatMap(n=>Array.isArray(n.type)?n.type:n.type?[n.type]:[]))}isNameMap(e){return this.at(e).some(n=>n.additionalProperties&&typeof n.additionalProperties=="object"&&!n.properties)}};var fi={view:"view",live:"live"},qf=["text","both","canvas"];var Mr=t=>cn(t,{uniqueKeys:!1}).toJS();function ts(t,e){let n=[],s=t,r=!1;for(let o of e){let i=o(s);for(let a of i.steps)n.push(a),s=yn(s,a);r||=!!i.fallback}return{steps:n,fallback:r}}function pi(t,e){return{label:t,touched:e.flatMap(n=>n.touched??[]),select:e.find(n=>n.select)?.select,build:n=>ts(n,e.map(s=>r=>s.build(r)))}}var nh=(t,e)=>{let n=Mr(t),s=e.slice(0,-1).reduce((r,o)=>r?.[o],n);return!!s&&typeof s=="object"&&String(e[e.length-1])in s},Uf=t=>t.split("/").slice(1).map(e=>{let n=e.replace(/~1/g,"/").replace(/~0/g,"~");return/^\d+$/.test(n)?Number(n):n});function co(t){let e=v=>t.describe(v),n=t.topOrder,s=v=>{let w=new Set;for(let k of t.kinds){let y=k.section.reduce((M,T)=>M?.[T],v);if(y&&typeof y=="object")for(let M of Object.keys(y))w.add(M)}return w};function r(v,w,k=`Set ${e(v)}`){return{label:k,touched:[v],build:y=>{let M=new On(y);return M.rangeOf(v)||M.nodeAt(v)!==void 0||nh(y,v)?Ds(y,v,w):Mn(y,v.slice(0,-1),String(v[v.length-1]),w,{order:n})}}}function o(v,w){let k=v.map(([y])=>[t.pins.key,"layout",y]);return i({label:w,touched:k,build:y=>ts(y,v.map(([,M],T)=>A=>r(k[T],{at:M}).build(A)))})}function i(v){return{...v,build:w=>t.pins.legacyOnly(Mr(w))?ts(w,[k=>sr(k,[t.pins.legacyKey],t.pins.key),k=>v.build(k)]):v.build(w)}}function a(v,w,k,y={}){return{label:y.label??`Add ${e([...v,w])}`,touched:[[...v,w]],select:[[...v,w]],build:M=>Mn(M,v,w,k,{...y,order:n})}}function l(v,w,k,y=`Add to ${e(v)}`){return{label:y,touched:[v],build:M=>ui(M,v,w,k,n)}}function c(v,w){return{label:`Move ${e(v)}`,touched:[v],build:k=>gl(k,v,w,n)}}function d(v,w,k){return t.refs(Mr(v)).filter(y=>(y.slot.key?y.value===k:y.name===k)&&y.slot.targets.includes(w))}function u(v,w={}){let k=t.objectOf(Se(v)),y=k&&k.path===Se(v);return{label:`Delete ${e(v)}`,touched:[v],remap:M=>qt(v,M)?null:M,build:M=>{if(!y||!w.withRefs)return Fs(M,v);let A=d(M,k.kind,k.name).map(E=>{let x=Uf(E.path);return typeof x.at(-1)=="number"?x:t.refDeletePath(x)}),I=[...new Map(A.map(E=>[Se(E),E])).values()],j=I.filter(E=>typeof E.at(-1)=="number").sort((E,x)=>x.at(-1)-E.at(-1)),L=I.filter(E=>typeof E.at(-1)!="number"),B=[...j,...L,v],S=B.filter((E,x)=>!B.some((N,z)=>z!==x&&N.length<E.length&&qt(N,E)));return ts(M,S.map(E=>x=>Fs(x,E)))}}}function f(v,w){let k=t.objectOf(Se(v)),y=String(v[v.length-1]),M=v.slice(0,-1);return{label:`Rename ${e(v)} to ${w}`,touched:[[...M,w]],remap:T=>qt(v,T)?[...M,w,...T.slice(v.length)]:T,build:T=>{let A=sr(T,v,w);if(!k||k.path!==Se(v))return A;let I=new On(T),j=[...A.steps[0]];for(let B of d(T,k.kind,y)){let S=Uf(B.path),E=t.renameRef(B,w);if(E===void 0)continue;let x=I.rangeOf(S,B.slot.key?"key":"value");if(!x)continue;let N=T.slice(x[0],x[1]),z=N[0]==='"'||N[0]==="'"?N[0]:void 0;j.push({start:x[0],end:x[1],text:z==='"'?JSON.stringify(E):z==="'"?`'${E}'`:_n(E,{flow:!0,indent:0})})}let L=Mr(T);for(let B of[t.pins.key,t.pins.legacyKey]){let S=B===void 0?void 0:L?.[B]?.layout;if(!S||typeof S!="object"||!Object.hasOwn(S,y)||Object.hasOwn(S,w))continue;let E=I.rangeOf([B,"layout",y],"key");E&&!j.some(x=>x.start<E[1]&&E[0]<x.end)&&j.push({start:E[0],end:E[1],text:_n(w,{flow:!0,indent:0})})}return{steps:[j]}}}}function p(v){let w=String(v[v.length-1]),k=v.slice(0,-1),y="";return{label:`Duplicate ${e(v)}`,get select(){return y?[[...k,y]]:void 0},build:M=>{let T=Mr(M),A=s(T),I=w.replace(/-\d+$/,""),j=2;for(;A.has(`${I}-${j}`);)j++;y=`${I}-${j}`;let L=t.objectOf(Se(v))?.kind??"",B=t.copyValue(L,v.reduce((S,E)=>S?.[E],T));return Mn(M,k,y,B,{after:w,order:n})}}}function g(v,w){let k=v.slice(0,-1);return{label:`Rename ${e(v)} to ${w}`,touched:[[...k,w]],remap:y=>qt(v,y)?[...k,w,...y.slice(v.length)]:y,build:y=>sr(y,v,w)}}function h(v,w,k){return{label:`Move ${e([...v,w])}`,touched:[v],remap:y=>qt(v,y)&&y.length>v.length&&y[v.length]===w?[...v,k,...y.slice(v.length+1)]:y,build:y=>{if(w===k)return{steps:[]};let M=[...v,w].reduce((T,A)=>T?.[A],Mr(y));return ts(y,[T=>Fs(T,[...v,w]),T=>ui(T,v,M,k,n)])}}}function b(v,w){let k=s(Mr(v)),y=1;for(;k.has(`${w}-${y}`);)y++;return`${w}-${y}`}return{describe:e,setCmd:r,pinsCmd:o,withPinsMoved:i,insertCmd:a,insertItemCmd:l,moveCmd:c,referencesTo:d,deleteCmd:u,renameCmd:f,duplicateCmd:p,renameKeyCmd:g,moveItemCmd:h,freshName:b}}var uo=t=>!!t&&typeof t=="object"&&!Array.isArray(t);function yl(t){let{deleteCmd:e,describe:n,setCmd:s}=co(t),r=t.topOrder,o=t.kinds.map(p=>Se(p.section)),i=new Map(t.kinds.map(p=>[Se(p.section),p])),a=t.entryGroups.map(p=>Se(p));function l(p){let g=t.objectOf(Se(p));if(g&&g.path===Se(p))return t.kinds.find(b=>b.kind===g.kind).section;let h=t.entryGroups.find(b=>p.length===b.length+1&&qt(b,p));if(h)return h}function c(p,g){let h=g.filter(w=>w.length&&!g.some(k=>k!==w&&k.length<w.length&&qt(k,w)));if(!h.length)return;let b=h.filter(w=>l(w));if(b.length===h.length){let w=new Map;for(let T of b){let A=Se(l(T));w.set(A,[...w.get(A)??[],T])}let k=[],y=[...o,...a];for(let T of[...w.keys()].sort((A,I)=>y.indexOf(A)-y.indexOf(I))){let A=et(T),I=w.get(T).map(L=>io(p,L)).filter(L=>!!L),j=" ".repeat(A.length);k.push(A.map((L,B)=>`${" ".repeat(B)}${L}:`).join(`
|
|
449
449
|
`)+`
|
|
450
|
-
`+
|
|
451
|
-
`).map(
|
|
450
|
+
`+I.map(L=>L.replace(/\n$/,"").split(`
|
|
451
|
+
`).map(B=>B&&j+B).join(`
|
|
452
452
|
`)).join(`
|
|
453
453
|
`)+`
|
|
454
|
-
`)}let
|
|
455
|
-
`)[0]}`};let
|
|
454
|
+
`)}let M=b.length;return{text:k.join(""),what:M===1?n(b[0]):`${M} items`}}let v=h.map(w=>typeof w[w.length-1]=="string"?io(p,w):void 0).filter(w=>!!w);if(v.length)return{text:v.join(""),what:h.length===1?n(h[0]):`${h.length} keys`}}function d(p,g,h=[]){let b=cn(g);if(b.errors.length)return{what:"nothing",error:`the clipboard isn't YAML: ${b.errors[0].message.split(`
|
|
455
|
+
`)[0]}`};let v=b.toJS();if(!uo(v)||!Object.keys(v).length)return{what:"nothing",error:"the clipboard holds no YAML map"};let w=new Set([...t.kinds.map(A=>String(A.section[0])),...t.entryGroups.map(A=>String(A[0]))]);if(Object.keys(v).every(A=>w.has(A)))return u(p,g,v);let y=[...new Map(h.map(A=>t.objectOf(Se(A))).filter(A=>!!A).map(A=>[A.path,et(A.path)])).values()];if(!y.length)return{what:"nothing",error:`select a ${t.noun} to paste these keys onto`};let M=Object.entries(v),T=`Paste ${M.map(([A])=>A).join(", ")} onto ${y.length===1?n(y[0]):`${y.length} items`}`;return{what:T,cmd:{label:T,touched:y,build:A=>ts(A,y.flatMap(I=>M.map(([j,L])=>B=>s([...I,j],L).build(B))))}}}function u(p,g,h){let b=cn(p).toJS(),v=new Set;for(let E of t.kinds){let x=js(b,E.section);if(uo(x))for(let N of Object.keys(x))v.add(N)}let w=new Map(t.entryGroups.map(E=>{let x=js(b,E);return[Se(E),new Set(Object.keys(uo(x)?x:{}))]})),k=[];for(let E of[...o,...a]){let x=js(h,et(E));if(uo(x))for(let N of Object.keys(x)){let z=w.get(E)??v,Q=N;if(z.has(Q)){let re=N.replace(/-\d+$/,""),we=2;for(;z.has(`${re}-${we}`);)we++;Q=`${re}-${we}`}z.add(Q),k.push({holder:et(E),name:N,to:Q})}}if(!k.length)return{what:"nothing",error:"nothing to paste"};let y=new Map(k.filter(E=>!w.has(Se(E.holder))&&E.name!==E.to).map(E=>[E.name,E.to])),M=g,T=E=>{for(let x of E.steps)M=yn(M,x)},A=E=>t.kinds.find(x=>x.kind===E)?.section??[];for(let E of t.refs(h)){if(E.slot.key)continue;let x=E.name!==void 0?y.get(E.name):void 0;!x||!E.slot.targets.some(N=>uo(js(h,A(N)))&&E.name in js(h,A(N)))||T(Ds(M,et(E.path),E.slot.rename?E.slot.rename(E.value,x):x))}let I=[],j="";for(let E of k){let x=i.get(Se(E.holder)),N=x&&t.pasteDrops?.(b,{kind:x.kind,path:[...E.holder,E.name],value:js(h,[...E.holder,E.name])});N&&(T(Fs(M,N.path)),I.push(E.to),j=N.why)}for(let E of k)E.name!==E.to&&T(sr(M,[...E.holder,E.name],E.to));let L=cn(M).toJS(),B=k.length,S=B===1?`Paste ${i.get(Se(k[0].holder))?.singular??t.kinds[0]?.singular??"entry"} ${k[0].to}`:`Paste ${B} items`;return{what:S+(I.length?` (${I.join(", ")}: ${j})`:""),names:new Map(k.map(E=>[E.name,E.to])),cmd:{label:w.has(Se(k[0].holder))&&B===1?`Paste ${k[0].holder.join(".")} entry ${k[0].to}`:S,select:k.map(E=>[...E.holder,E.to]),build:E=>ts(E,k.map(x=>N=>{let z=x.holder;if(!uo(js(cn(N).toJS(),z)))return Mn(N,z.slice(0,-1),String(z[z.length-1]),{[x.to]:js(L,[...z,x.to])},{order:r});let re=io(M,[...z,x.to]);return re?bl(N,z,x.to,re,r):Mn(N,z,x.to,js(L,[...z,x.to]),{order:r})}))}}}function f(p,g){let h=c(p,g);if(!h)return;let b=g.filter(w=>w.length&&!g.some(k=>k!==w&&k.length<w.length&&qt(k,w))),v=[...b].sort((w,k)=>typeof w.at(-1)=="number"&&typeof k.at(-1)=="number"?k.at(-1)-w.at(-1):0);return{text:h.text,cmd:{label:`Cut ${h.what}`,remap:w=>b.some(k=>qt(k,w))?null:w,build:w=>ts(w,v.map(k=>y=>e(k).build(y)))}}}return{copyText:c,pasteCmd:d,cutCmd:f}}var js=(t,e)=>e.reduce((n,s)=>n&&typeof n=="object"?n[s]:void 0,t);var Wf=t=>{let e=t.data;return e&&typeof e=="object"&&!Array.isArray(e)?e:{}},Jf=(t,e)=>e.reduce((n,s)=>n&&typeof n=="object"?n[s]:void 0,t);function wd(t,e){let n=Jf(Wf(t),e.section);return n&&typeof n=="object"&&!Array.isArray(n)?Object.keys(n).filter(s=>!s.startsWith("x-")):[]}function xl(t,e,n,s){let r=dl(t,e),o=[],i=Wf(t);if(r.kind==="key"){let a=Jf(i,r.path),l=a&&typeof a=="object"&&!Array.isArray(a)?a:{};if(n.isNameMap(r.path)){let c=Se(r.path);for(let[d,u]of Object.entries(s.snippets))d.split("#")[0]===c&&o.push({label:u.label,insert:u.body,kind:"snippet",snippet:!0,doc:u.doc,preferred:!0})}else{let c=" ".repeat(Math.max(0,r.start-(t.text.lastIndexOf(`
|
|
456
456
|
`,r.start-1)+1)));for(let d of n.keys(r.path,l)){if(d.name in l)continue;let u=r.flow||d.shape==="scalar"?": ":d.shape==="list"?`:
|
|
457
457
|
`+c+" - ":`:
|
|
458
|
-
`+c+" ",f=d.enumValues.length>1&&d.shape==="scalar"?`${d.name}: \${1|${d.enumValues.join(",")}|}`:d.name+u;o.push({label:d.name,insert:f,snippet:f.includes("${"),kind:"key",doc:d.doc,detail:d.enumValues.length?d.enumValues.join(" | "):d.shape==="map"?"map":d.shape==="list"?"list":void 0})}}}else{let a=r.kind==="item"?[...r.path,0]:r.path,l=
|
|
459
|
-
`)[0]??"")+" \u2026":b}return
|
|
460
|
-
`,a[0]),p=f>=0&&f<a[1]?f:a[1],g=e.pos(a[0]),h=e.pos(Math.max(p,a[0]+1));return{...r,startLine:g.line,startCol:g.col,endLine:h.line,endCol:h.col}}let l=Math.max(1,n.line),c=Math.max(1,n.col),d=e.offset(l,c),u=/^[^\s,:{}[\]]+/.exec(e.text.slice(d));return{...r,startLine:l,startCol:c,endLine:l,endCol:c+Math.max(1,u?u[0].length:1)}}var
|
|
458
|
+
`+c+" ",f=d.enumValues.length>1&&d.shape==="scalar"?`${d.name}: \${1|${d.enumValues.join(",")}|}`:d.name+u;o.push({label:d.name,insert:f,snippet:f.includes("${"),kind:"key",doc:d.doc,detail:d.enumValues.length?d.enumValues.join(" | "):d.shape==="map"?"map":d.shape==="list"?"list":void 0})}}}else{let a=r.kind==="item"?[...r.path,0]:r.path,l=Se(a),c=s.slotAt(l);if(c){for(let d of c.targets){let u=s.kinds.find(f=>f.kind===d);if(u)for(let f of wd(t,u))o.push({label:c.write?c.write(f):f,insert:c.write?c.write(f):f,kind:"ref",detail:`${u.singular} \xB7 declared`,preferred:!0})}for(let d of c.extra??[])o.push({label:d,insert:/[{*]/.test(d)?JSON.stringify(d):d,kind:"value",detail:s.extraDetail?.(d,i)})}for(let d of n.values(a))o.some(u=>u.label===d)||o.push({label:d,insert:d,kind:"value"});if(!o.length){let d=n.keys(r.path.slice(0,-1)).find(u=>u.name===String(r.path[r.path.length-1]));for(let u of d?.examples??[])typeof u=="string"&&o.push({label:u,insert:u,kind:"value",detail:"example"})}}return{items:o,start:r.start,path:r.path,context:r.kind}}var Bs=t=>Ge(t.key)?String(t.key.value):String(t.key);function wl(t,e,n="main",s){let r=t.text,o=t.data??{},i=g=>{if(!g)return"";let h=g.range;if(h&&h[1]>h[0]){let b=r.slice(h[0],h[1]).replace(/\s+$/,"");return/^[|>]/.test(b)?(String(g.value??"").split(`
|
|
459
|
+
`)[0]??"")+" \u2026":b}return Ge(g)?String(g.value??""):""},a=(g,h,b,v,w)=>{let k=Se(h),y=typeof h[h.length-1]=="string"&&String(h[h.length-1]).startsWith("x-");if(ct(g))return{id:k,path:h,kind:v,label:b,shape:"map",section:w,ext:y,children:g.items.map(T=>a(T.value,[...h,Bs(T)],Bs(T),"key"))};if(Lt(g))return{id:k,path:h,kind:v,label:b,shape:"list",section:w,ext:y,value:g.items.length?void 0:"[]",children:g.items.map((T,A)=>a(T,[...h,A],Ge(T)?i(T):`${A+1}`,"item"))};let M={id:k,path:h,kind:v,label:b,shape:"scalar",value:i(g),section:w,ext:y,children:[]};return v==="item"&&(M.label=M.value??"",delete M.value),M},l=t.doc.contents,c=ct(l)?l.items:[],d=g=>c.find(h=>Bs(h)===g),u=[],f=new Set;for(let g of e.outline.first){let h=d(g);h&&(u.push(a(h.value,[g],g,"key")),f.add(g))}let p=new Set;if(n==="main"){for(let g of e.outline.kinds){let h=e.kinds.find(y=>y.kind===g),b=h.section.map(String),v=d(b[0]);b.length===1?f.add(b[0]):p.add(b[0]);let w=v?.value;b.length>1&&(w=ct(w)?w.items.find(y=>Bs(y)===b[1])?.value:void 0);let k={id:Se(b),path:b,kind:"group",label:h.group,section:h.kind,shape:ct(w)?"map":"missing",children:[]};if(ct(w))for(let y of w.items){let M=Bs(y);if(M.startsWith("x-")){k.children.push(a(y.value,[...b,M],M,"key"));continue}let T=a(y.value,[...b,M],M,"resource",h.kind),A=s?.get(M)??e.outline.tag?.(h.kind,M,sh(o,[...b,M]),o);A!==void 0&&(T.lifetime=A),k.children.push(T)}u.push(k)}for(let g of p){let h=d(g),b=new Set(e.kinds.filter(v=>String(v.section[0])===g).map(v=>String(v.section[1])));if(h&&ct(h.value)){f.add(g);for(let v of h.value.items)b.has(Bs(v))||u.push(a(v.value,[g,Bs(v)],`${g}.${Bs(v)}`,"key"))}else h&&f.add(g)}}for(let{key:g,label:h,when:b}of e.outline.groups){let v=d(g);f.add(g),v?u.push({...a(v.value,[g],h,"group"),kind:"group"}):n!=="other"&&(!b||b(o))&&u.push({id:"/"+g,path:[g],kind:"group",label:h,shape:"missing",children:[]})}for(let g of c){let h=Bs(g);!f.has(h)&&st(g)&&u.push(a(g.value,[h],h,"key"))}return{id:"",path:[],kind:"root",label:e.outline.rootLabel(o,n),shape:"map",children:u}}var sh=(t,e)=>e.reduce((n,s)=>n&&typeof n=="object"?n[s]:void 0,t);function vd(t,e=[]){e.push(t);for(let n of t.children)vd(n,e);return e}function vl(t,e,n){let s=new On(e),r=t.read(e,{fileName:n.fileName,defaults:n.defaults,profiles:n.profiles,role:t.role(e)});return{problems:[...n.extendsDiags??[],...r.diags].map(i=>kd(t,s,i,n.fileName)),tags:r.tags??new Map,read:r.read}}function kd(t,e,n,s){let r={severity:n.severity,message:n.message,hint:n.hint,path:n.path};if(n.file&&n.file!==s){let f=e.rangeOf(["extends"])??[0,0],p=e.pos(f[0]),g=e.pos(f[1]);return{...r,message:`${n.file}:${n.line}: ${n.message}`,file:n.file,startLine:p.line,startCol:p.col,endLine:g.line,endCol:g.col}}let o=et(n.path),i=t.objectOf(n.path)?.path===n.path,a=o.length?e.rangeOf(o,i||t.keyMessage.test(n.message)?"key":"value"):void 0;if(a&&a[1]>a[0]){let f=e.text.indexOf(`
|
|
460
|
+
`,a[0]),p=f>=0&&f<a[1]?f:a[1],g=e.pos(a[0]),h=e.pos(Math.max(p,a[0]+1));return{...r,startLine:g.line,startCol:g.col,endLine:h.line,endCol:h.col}}let l=Math.max(1,n.line),c=Math.max(1,n.col),d=e.offset(l,c),u=/^[^\s,:{}[\]]+/.exec(e.text.slice(d));return{...r,startLine:l,startCol:c,endLine:l,endCol:c+Math.max(1,u?u[0].length:1)}}var Sd;function kl(t){return Sd?.text!==t&&(Sd=new On(t)),Sd}function Sl(t){let e=new Map,n=c=>{let d=e.get(c);return d||e.set(c,d=new lo(c)),d},s=c=>{let d=t.role(c)==="base"?"base":"main";return n(t.schema(d,c))},r=c=>t.kinds.find(d=>d.kind===c)?.section??[];function o(c,d){let u=xl(c,d,s(c.text),t),f=u.items.map((p,g)=>({it:p,i:g})).sort((p,g)=>+!!g.it.preferred-+!!p.it.preferred||p.i-g.i).map(p=>p.it);return{from:u.start,items:f}}function i(c,d){let u=c.at(d);if(!u.path.length||u.where==="inside")return null;let f=[],p=s(c.text).hover(u.path);p&&f.push(`**${u.path.join(".")}**
|
|
461
461
|
|
|
462
|
-
${p}`);let g=l.refs(c.data).find(b=>b.path===
|
|
462
|
+
${p}`);let g=l.refs(c.data).find(b=>b.path===Se(u.path));if(g?.name){let b=g.slot.targets.map(v=>[...r(v),g.name]).find(v=>c.rangeOf(v));f.push(b?`\u2192 \`${b.join(".")}\` (line ${c.pos(c.rangeOf(b,"key")[0]).line}; \u2318-click to go there)`:`\u2192 no ${g.slot.targets.join("/")} named \`${g.name}\``)}if(!f.length)return null;let h=c.rangeOf(u.path,u.where==="key"?"key":"value")??[d,d];return{from:h[0],to:h[1],parts:f}}function a(c,d){let u=c.at(d);if(u.path[0]==="extends"&&u.where!=="key"){let p=c.nodeAt(u.path);if(typeof p?.value=="string")return{open:p.value}}let f=l.refs(c.data).find(p=>p.path===Se(u.path));if(!f?.name)return null;for(let p of f.slot.targets){let g=c.rangeOf([...r(p),f.name],"key");if(g)return{from:g[0],to:g[1]}}return null}let l=t;return{navFor:s,completionAt:o,hoverAt:i,definitionAt:a}}function Ml(t,e){return t.rangeOf(e,"pair")??t.rangeOf(e)}function $l(t,e){let n=[0];for(let o=t.indexOf(`
|
|
463
463
|
`);o>=0;o=t.indexOf(`
|
|
464
|
-
`,o+1))n.push(o+1);let s=(o,i)=>{let a=Math.min(Math.max(o,1),n.length),l=a<n.length?n[a]-1:t.length;return Math.min(n[a-1]+Math.max(i,1)-1,l)},r=s(e.startLine,e.startCol);return[r,Math.max(r,s(e.endLine,e.endCol))]}function yf(t){return t.replace(/\$\{(\d+)\|([^|}]*)\|\}/g,(e,n,s)=>`\${${n}:${s.split(",")[0]}}`).replace(/\$\{0\}/g,"${}")}function xf(t){return t.split(/\n{2,}/).map(e=>{let n=[];for(let s of e.matchAll(/\*\*([^*]+)\*\*|`([^`]+)`|([^*`]+|[*`])/g))s[1]!==void 0?n.push({kind:"bold",text:s[1]}):s[2]!==void 0?n.push({kind:"code",text:s[2]}):n.push({kind:"text",text:s[3]});return n})}var tl=null;function pr(t){tl=t}function Hs(){return tl&&tl.isConnected?tl:document.body}var wf="http://www.w3.org/2000/svg";function Wt(t,e=""){let n=document.createElementNS(wf,"svg");n.setAttribute("class",`icon${e?" "+e:""}`),n.setAttribute("aria-hidden","true");let s=document.createElementNS(wf,"use");return s.setAttribute("href",`#se-i-${t}`),n.append(s),n}function mr(t,e,n){return new Promise(s=>{let r=z("dialog",{class:"dlg","aria-label":t}),o=z("form",{method:"dialog"}),i=z("div",{class:"dlg-foot"});for(let a of n){let l=z("button",{type:"submit",value:a.value,class:`btn${a.primary?" primary":""}${a.danger?" danger":""}`},a.label);i.append(l)}o.append(z("div",{class:"dlg-head"},z("h2",{class:"h-title"},t)),z("div",{class:"dlg-body"},...e),i),r.append(o),Hs().append(r),r.addEventListener("close",()=>{let a=r.returnValue;r.remove(),s(a&&a!=="cancel"?a:null)}),r.showModal(),i.querySelector(".primary")?.focus()})}var Uo,vf=()=>!!Uo;function is(t,e,n="Actions"){Uo?.close(!1);let s=document.activeElement,r=z("div",{class:"menu",role:"menu","aria-label":n,tabindex:"-1"}),o=[];for(let g of t){if("sep"in g){r.append(z("div",{class:"menu-sep",role:"separator"}));continue}if("heading"in g){r.append(z("div",{class:"menu-label"},g.heading));continue}let h=(g.disabled?g.why:void 0)??g.desc,b=z("button",{type:"button",role:"menuitem",tabindex:"-1",class:"menu-item"+(g.danger?" danger":""),"data-desc":h,"aria-description":h},g.icon?Wt(g.icon):z("span"),z("span",{class:"mi-label"},g.label),g.keys?z("span",{class:"menu-trail"},g.keys):null);g.disabled&&(b.disabled=!0),b.addEventListener("click",k=>{k.stopPropagation(),!b.disabled&&(p(!0),g.onSelect())}),o.push(b),r.append(b)}Hs().append(r);let i=r.getBoundingClientRect(),a,l;if(e instanceof HTMLElement){let g=e.getBoundingClientRect();a=g.left,l=g.bottom+4,l+i.height>innerHeight-8&&(l=g.top-i.height-4)}else a=e.x,l=e.y,l+i.height>innerHeight-8&&(l=Math.max(8,e.y-i.height));r.style.left=`${Math.max(8,Math.min(a,innerWidth-i.width-8))}px`,r.style.top=`${Math.max(8,l)}px`;let c=()=>o.filter(g=>!g.disabled),d=g=>{let h=c();h.length&&h[(g+h.length)%h.length].focus()};d(0),r.addEventListener("keydown",g=>{let b=c().indexOf(document.activeElement);g.key==="ArrowDown"?(d(b+1),g.preventDefault()):g.key==="ArrowUp"?(d(b-1),g.preventDefault()):g.key==="Home"?(d(0),g.preventDefault()):g.key==="End"?(d(-1),g.preventDefault()):(g.key==="Escape"||g.key==="Tab")&&(p(!0),g.preventDefault()),g.stopPropagation()});let u=g=>{r.contains(g.target)||p(!1)};setTimeout(()=>{addEventListener("pointerdown",u,!0),addEventListener("blur",f)},0);let f=()=>p(!1);function p(g){r.isConnected&&(r.remove(),removeEventListener("pointerdown",u,!0),removeEventListener("blur",f),Uo=void 0,g&&s?.focus())}return Uo={el:r,close:p},r}function nl(){Uo?.close(!1)}var kf=150,Ys=t=>t.kind==="do"&&t.origin==="text";function qs(t,e=150){let n=0,s=()=>{n=0,t()},r=()=>{clearTimeout(n),n=window.setTimeout(s,e)};return r.now=()=>{clearTimeout(n),s()},r.pending=()=>n!==0,r.cancel=()=>{clearTimeout(n),n=0},r}function sl(t,e){return t.map((n,s)=>s===0?{...n,keys:[...n.keys.slice(0,1),...e,...n.keys.slice(1)]}:n)}function rl(t){let e=z("dialog",{class:"dlg keys-dlg","aria-label":"Keyboard"}),n=z("form",{method:"dialog"}),s=z("div",{class:"dlg-body keys"});for(let r of t){s.append(z("h3",{class:"keys-h"},r.where));let o=z("dl",{class:"keys-list"});for(let[i,a]of r.keys)o.append(z("dt",null,...i.split(/(\s+or\s+|,\s*)/).map(l=>/^\s+or\s+$|^,\s*$/.test(l)?l:z("kbd",null,l))),z("dd",null,a));s.append(o)}return n.append(z("div",{class:"dlg-head"},z("h2",{class:"h-title"},"Keyboard")),s,z("div",{class:"dlg-foot"},z("button",{type:"submit",class:"btn primary",value:"close"},"Close"))),e.append(n),e.addEventListener("close",()=>e.remove()),Hs().append(e),e.showModal(),e}function ol(t,e,n){let{copyText:s,cutCmd:r,pasteCmd:o}=n,i="",a=()=>!t.doc.ok,l=f=>!!f?.closest?.("input, textarea, select, .monaco-editor, [contenteditable]"),c=()=>{let f=s(t.text,t.selection);if(!f){e("Select something to copy");return}return i=f.text,e(`Copied ${f.what}`),f.text},d=()=>{if(a()){e("Fix the YAML first","warn");return}let f=r(t.text,t.selection);if(!f){e("Select something to cut");return}return i=f.text,t.apply(f.cmd,"menu"),t.select([],"menu"),f.text},u=f=>{if(a())return e("Fix the YAML first","warn"),!1;let p=o(t.text,f,t.selection);if(!p.cmd)return e(`Can't paste: ${p.error}`,"warn"),!1;try{if(!t.apply(p.cmd,"menu"))return!1}catch(h){return e(`Can't paste: ${h.message}`,"bad"),!1}p.cmd.select&&t.select(p.cmd.select,"menu");let g=p.names?[...p.names].filter(([h,b])=>h!==b):[];return e(g.length?`${p.what}: ${g.map(([h,b])=>`${h} \u2192 ${b}`).join(", ")}`:p.what),!0};return{items(){let f=t.selection.length>0;return[{label:"Cut",icon:"clipboard",keys:"\u2318X",disabled:!f||a(),why:f?"Fix the YAML first":"Nothing selected",onSelect:()=>{this.cut()}},{label:"Copy",icon:"copy",keys:"\u2318C",disabled:!f,why:"Nothing selected",onSelect:()=>{this.copy()}},{label:"Paste",icon:"clipboard-paste",keys:"\u2318V",disabled:a(),why:"Fix the YAML first",onSelect:()=>{this.paste()}}]},attach(f,p){let g=k=>{let v=k;if(l(v.target)||!p(v.target))return;let M=c();M!==void 0&&(v.clipboardData?.setData("text/plain",M),v.preventDefault())},h=k=>{let v=k;if(l(v.target)||!p(v.target))return;let M=d();M!==void 0&&(v.clipboardData?.setData("text/plain",M),v.preventDefault())},b=k=>{let v=k;if(l(v.target)||!p(v.target))return;let M=v.clipboardData?.getData("text/plain")??"";v.preventDefault(),u(M||i)};return f.addEventListener("copy",g),f.addEventListener("cut",h),f.addEventListener("paste",b),()=>{f.removeEventListener("copy",g),f.removeEventListener("cut",h),f.removeEventListener("paste",b)}},async copy(){let f=c();if(f===void 0)return!1;try{await navigator.clipboard.writeText(f)}catch{}return!0},async cut(){let f=d();if(f===void 0)return!1;try{await navigator.clipboard.writeText(f)}catch{}return!0},async paste(f){let p=f;if(p===void 0)try{p=await navigator.clipboard.readText()}catch{p=i}return p?u(p):(e("The clipboard is empty"),!1)}}}function il(t,e,n){let s=n.kit,r=s.ui,{setCmd:o,insertCmd:i,insertItemCmd:a,deleteCmd:l,renameCmd:c,renameKeyCmd:d,duplicateCmd:u,moveCmd:f,moveItemCmd:p,referencesTo:g,describe:h,freshName:b}=s.commands,k=E=>s.kinds.find(Y=>Y.kind===E),v=E=>E.id==="",M=E=>s.entryGroups.some(Y=>E.length===Y.length+1&&Vt(Y,E)),x=E=>s.entryGroups.some(Y=>Y.length===E.length&&Vt(Y,E)),T=new Set(["",...s.kinds.map(E=>Me(E.section)),...s.entryGroups.map(E=>Me(E))]),y="",A="",D,K=[],C=new Map,_="",S=0,$=()=>new Set(e.selection.map(Me)),w=()=>!e.doc.ok;t.setAttribute("role","tree"),t.setAttribute("aria-label",r.label),t.setAttribute("aria-multiselectable","true"),t.classList.add("tree");function N(){let E=s.outline(e.goodDoc,n.role(),n.lifetimes());K=[];let Y=(Z,Se,ue)=>{if(K.push({n:Z,depth:Se,parent:ue}),T.has(Z.id))for(let Ke of Z.children)Y(Ke,Se+1,Z);D?.mode==="new"&&Me(D.mapPath)===Z.id&&T.has(Z.id)&&K.push({n:{id:D.id,path:[...D.mapPath,""],kind:"resource",label:"",shape:"scalar",children:[]},depth:Se+1,parent:Z})};Y(E,0),C=new Map(K.map(Z=>[Z.n.id,Z])),C.has(y)||(y=K[0]?.n.id??"");let q=$(),de=F(),m=document.createDocumentFragment();w()&&m.append(z("div",{class:"callout compact warn tree-note",role:"status"},z("span",{class:"c-body"},`Fix the YAML at line ${e.doc.doc.errors[0]?e.doc.pos(e.doc.doc.errors[0].pos[0]).line:"?"} to edit here; the tree shows the last version that read cleanly.`)));for(let{n:Z,depth:Se}of K)m.append(ae(Z,Se,q.has(Z.id),de.get(Z.id)));let O=t.contains(document.activeElement);t.replaceChildren(m);let L=t.querySelector(`[data-id="${CSS.escape(y)}"]`);L&&(L.tabIndex=0);let G=t.querySelector(".tedit");G?(G.focus(),G instanceof HTMLInputElement&&G.select()):O&&L&&!t.contains(document.activeElement)&&L.focus({preventScroll:!0})}function F(){let E=new Map;for(let Y of n.problems()){if(Y.file)continue;let q=nt(Y.path);for(let de=1;de<=q.length;de++){let m=Me(q.slice(0,de)),O=E.get(m)??{e:0,w:0};Y.severity==="error"?O.e++:O.w++,E.set(m,O)}}return E}function J(E){if(v(E))return r.rootIcon;if(E.section)return r.kindIcon(E.section);let Y=String(E.path[E.path.length-1]??"");return E.path.length===1&&r.keyIcon(Y)?r.keyIcon(Y):M(E.path)?r.entryIcon(String(E.path[0])):E.shape==="list"?"list":E.shape==="map"?"list-tree":"circle-dot"}function ae(E,Y,q,de){let m=T.has(E.id),O=E.children.length>0||E.shape==="missing"&&!1,L=z("div",{class:`trow k-${E.kind}${q?" selected":""}${E.shape==="missing"?" missing":""}${E.ext?" ext":""}`,role:"treeitem","aria-level":Y+1,"aria-selected":String(q),"aria-expanded":E.children.length?String(m):void 0,tabindex:"-1","data-id":E.id,draggable:X(E)?"true":void 0,"aria-label":we(E)});L.style.setProperty("--depth",String(Y));let G=z("span",{class:"twisty","aria-hidden":"true"},O?Wt(m?"chevron-down":"chevron-right"):"");G.addEventListener("click",ue=>{ue.stopPropagation(),j(E.id)}),L.append(G,Wt(J(E),"ticon"));let Z=D&&D.id===E.id?D:void 0;Z&&(Z.mode==="rename"||Z.mode==="new")?L.append(ze(E,Z)):L.append(z("span",{class:"tlabel"},E.label||(E.kind==="item"?'""':""))),Z?.mode==="value"?L.append(Ee(E)):E.value!==void 0&&E.kind!=="item"?L.append(z("span",{class:"tval"},E.value)):E.shape==="missing"?L.append(z("span",{class:"tval none"},"none")):E.kind==="group"&&E.children.length&&L.append(z("span",{class:"tcount"},String(E.children.length)));let Se=E.lifetime?r.tagPill(E.lifetime):void 0;if(Se&&L.append(z("span",{class:`tpill l-${E.lifetime}`,title:Se.title},E.lifetime)),de?.e?L.append(z("span",{class:"count bad",title:`${de.e} error${de.e>1?"s":""}`},String(de.e))):de?.w&&L.append(z("span",{class:"count warn",title:`${de.w} warning${de.w>1?"s":""}`},String(de.w))),!w()&&ne(E).length){let ue=z("button",{type:"button",class:"tadd btn sm quiet icon-only",tabindex:"-1","aria-label":`Add to ${E.label||r.text.rootAdd}`,title:"Add\u2026"},Wt("plus"));ue.addEventListener("click",Ke=>{Ke.stopPropagation(),U(E.id),is(ne(E),ue,`Add to ${E.label}`)}),L.append(ue)}return L}let we=E=>[E.kind==="group"?`${E.label}, ${E.shape==="missing"?"none":E.children.length}`:E.label,E.value!==void 0&&E.kind!=="item"?`: ${E.value}`:"",E.lifetime&&E.lifetime!=="run"?`, ${E.lifetime}`:""].join("");function j(E,Y){Y??!T.has(E)?T.add(E):T.delete(E),N()}function U(E){y=E;for(let q of t.querySelectorAll(".trow"))q.tabIndex=q.dataset.id===E?0:-1;let Y=t.querySelector(`[data-id="${CSS.escape(E)}"]`);Y?.focus({preventScroll:!0}),Y?.scrollIntoView({block:"nearest"})}function ee(E,Y=E[E.length-1]){Y!==void 0&&(y=Y,U(y)),e.select(E.map(nt),"tree"),N(),U(y)}function fe(E,Y){if(Y.shiftKey&&A){let q=K.map(O=>O.n.id),de=q.indexOf(A),m=q.indexOf(E);if(de>=0&&m>=0){ee(q.slice(Math.min(de,m),Math.max(de,m)+1),E);return}}if(Y.metaKey||Y.ctrlKey){let q=$();q.has(E)?q.delete(E):q.add(E),A=E,ee([...q],E);return}A=E,ee([E])}function B(E){for(let Y of E)for(let q=0;q<Y.length;q++)T.add(Me(Y.slice(0,q)));if(E[0]){let Y=Me(E[0]);for(N();!C.has(Y)&&Y;)Y=Y.replace(/\/[^/]*$/,"");y=Y}N(),t.querySelector(`[data-id="${CSS.escape(y)}"]`)?.scrollIntoView({block:"nearest"})}let X=E=>!w()&&!v(E)&&E.kind!=="group"&&E.path.length>1||E.kind==="item",Q=E=>E.kind==="resource"&&!!E.section,te=E=>E.kind==="group"&&(!!E.section||x(E.path));function ne(E){if(w())return[];let Y=n.nav(),q=[],de=e.goodDoc.data;if(v(E)){for(let G of s.kinds){if(n.role()!=="main")break;q.push({label:`New ${G.singular}`,icon:r.kindIcon(G.kind),onSelect:()=>Pe(G.kind)})}let m=new Set(E.children.filter(G=>G.shape!=="missing").map(G=>String(G.path[0]))),O=new Set(s.kinds.map(G=>String(G.section[0]))),L=Y.keys([],de??{}).filter(G=>!m.has(G.name)&&!O.has(G.name)&&!(de&&G.name in de));return L.length&&q.push({sep:!0},{heading:"Settings"},...L.map(G=>({label:G.name,desc:ye(G.doc),onSelect:()=>$e([],G.name)}))),q}if(E.kind==="group"&&E.section){let m=E.section;for(let O of r.newItems(m))q.push({label:O.label,icon:O.icon,desc:O.desc,onSelect:()=>Pe(m,O.template,O.stem)});return q}if(x(E.path)&&r.entryItems)return me(E.path);if(E.shape==="missing")return[{label:`Add ${E.label}`,icon:"plus",onSelect:()=>$e([],String(E.path[0]),!0)}];if(E.shape==="list"){let m=s.slotAt(Me([...E.path,0])),O=new Set(E.children.map(L=>L.label));if(m){for(let L of m.targets)for(let G of Re(L))O.has(m.write?m.write(G):G)||q.push({label:m.write?m.write(G):G,icon:r.kindIcon(L),desc:`${k(L).singular}`,onSelect:()=>re(a(E.path,m.write?m.write(G):G,void 0,`Add ${G} to ${h(E.path)}`))});for(let L of m.extra??[])O.has(L)||q.push({label:L,onSelect:()=>re(a(E.path,L,void 0,`Add ${L} to ${h(E.path)}`))})}for(let L of Y.values([...E.path,0]))O.has(L)||q.push({label:L,onSelect:()=>re(a(E.path,L))});return q.push({label:"New item",icon:"plus",onSelect:()=>{re(a(E.path,""));let L=[...E.path,E.children.length];be(Me(L),"value")}}),q}if(E.shape==="map"||E.kind==="resource"){let m=xe(de,E.path),O=m&&typeof m=="object"&&!Array.isArray(m)?m:{};for(let L of Y.keys(E.path,O))L.name in O||q.push({label:L.name,desc:ye(L.doc),onSelect:()=>$e(E.path,L.name)});return q}return q}function me(E){let Y=e.goodDoc.data??{},q=xe(Y,E)??{};return r.entryItems(E,Y,Ue).filter(de=>!de.when||de.when(Y)).map(de=>({label:de.label,icon:de.icon,onSelect:()=>{re(i(E,I(Object.keys(q),de.entry),de.value,de.cmdLabel?{label:de.cmdLabel}:{}))}}))}let ye=E=>E?.split(/(?<=\.)\s/)[0]?.replace(/`/g,""),xe=(E,Y)=>Y.reduce((q,de)=>q&&typeof q=="object"?q[de]:void 0,E),Re=E=>{let Y=xe(e.goodDoc.data,k(E).section);return Y&&typeof Y=="object"?Object.keys(Y).filter(q=>!q.startsWith("x-")):[]},Ue=E=>{let Y=xe(e.goodDoc.data,k(E).section);return Y?Object.keys(Y).filter(q=>!q.startsWith("x-")&&!(Y[q]&&typeof Y[q]=="object"&&"external"in Y[q])):[]},I=(E,Y)=>{if(!E.includes(Y))return Y;let q=2;for(;E.includes(`${Y}-${q}`);)q++;return`${Y}-${q}`};function re(E){try{return e.apply(E,"tree")}catch(Y){return n.note(String(Y.message),"bad"),!1}}function $e(E,Y,q=!1){let de=n.nav(),m=q?{}:de.defaultFor([...E,Y]);if(re(i(E,Y,m))){T.add(Me(E));let O=Me([...E,Y]);y=O,m===""||typeof m=="number"?be(O,"value"):(N(),U(O))}}function Pe(E,Y=k(E).template,q=k(E).singular){let de=k(E).section;T.add(Me(de)),D={id:"#new",mode:"new",section:E,mapPath:de,template:Y,value:b(e.text,q)},N()}function be(E,Y){if(w())return;let q=C.get(E);if(!q){N();return}Y==="rename"&&(q.n.kind==="group"||v(q.n)||q.n.kind==="item")||Y==="value"&&q.n.shape!=="scalar"||(D={id:E,mode:Y},y=E,N())}function ce(E=!0){D=void 0,N(),E&&U(y)}function ze(E,Y){let q=Y.mode==="new"?String(Y.value??""):String(E.path[E.path.length-1]),de=z("input",{class:"tedit tname",value:q,"aria-label":Y.mode==="new"?`Name of the new ${Y.section?k(Y.section).singular:"entry"}`:`Rename ${E.label}`,spellcheck:"false",autocomplete:"off"});de.value=q;let m=()=>{let G=de.value.trim(),Z=Y.mode==="new"||Q(E)||M(E.path),Se=G?Z&&!s.nameRule.test(G)?r.nameHint:G!==q&&Oe(Y.mode==="new"?Y.mapPath:E.path.slice(0,-1),G,Z)?`"${G}" is already used`:"":"a name is needed";return de.setAttribute("aria-invalid",String(!!Se)),de.title=Se,Se?void 0:G};de.addEventListener("input",m),de.addEventListener("keydown",G=>{G.stopPropagation(),G.key==="Escape"&&(G.preventDefault(),ce()),G.key==="Enter"&&(G.preventDefault(),L())});let O=!1,L=()=>{if(O)return;let G=m();if(G===void 0){de.value.trim()||(O=!0,ce());return}if(O=!0,D=void 0,Y.mode==="new"){let Z=[...Y.mapPath,G];re(i(Y.mapPath,G,Y.template(),{label:`Add ${Y.section?k(Y.section).singular:"entry"} ${G}`}))&&(y=Me(Z),e.select([Z],"tree"),T.add(y))}else if(G!==q){let Z=E.path;if(re(Q(E)?c(Z,G):d(Z,G))){let Se=[...Z.slice(0,-1),G];T.has(E.id)&&(T.delete(E.id),T.add(Me(Se))),y=Me(Se)}}N(),U(y)};return de.addEventListener("blur",()=>{O||(de.value.trim()&&m()!==void 0?L():(O=!0,D=void 0,N()))}),de}function Oe(E,Y,q){if(q&&!x(E))return s.kinds.some(m=>Re(m.kind).includes(Y));let de=xe(e.goodDoc.data,E);return!!de&&typeof de=="object"&&Y in de}function Ee(E){let Y=n.nav(),q=xe(e.goodDoc.data,E.path),de=Y.values(E.path),m=s.slotAt(Me(E.path)),O=m?m.targets.flatMap(Z=>Re(Z).map(Se=>m.write?m.write(Se):Se)).concat(m.extra??[]):[],L=[...new Set([...de,...O])],G;return L.length&&(de.length||m)?(G=z("select",{class:"tedit tvalue","aria-label":`Value of ${E.label}`},...L.map(Z=>z("option",{value:Z},Z))),L.includes(String(q))||G.prepend(z("option",{value:String(q??"")},String(q??""))),G.value=String(q??""),G.addEventListener("change",()=>Be(E,G.value))):(G=z("input",{class:"tedit tvalue","aria-label":`Value of ${E.label}`,spellcheck:"false",autocomplete:"off"}),G.value=q==null?"":String(q)),G.addEventListener("keydown",Z=>{Z.stopPropagation(),Z.key==="Escape"&&(Z.preventDefault(),ce()),Z.key==="Enter"&&(Z.preventDefault(),Be(E,G.value))}),G.addEventListener("blur",()=>{D?.id===E.id&&Be(E,G.value,!1)}),G}function Be(E,Y,q=!0){if(D?.id!==E.id)return;D=void 0;let de=n.nav().types(E.path),m=xe(e.goodDoc.data,E.path),O=Y;(de.has("integer")||de.has("number")||typeof m=="number")&&/^-?\d+(\.\d+)?$/.test(Y.trim())?O=Number(Y):(de.has("boolean")||typeof m=="boolean")&&/^(true|false)$/.test(Y.trim())&&(O=Y.trim()==="true"),O!==m&&re(o(E.path,O)),N(),q&&U(y)}async function it(E){if(w()||!E.length)return;let Y=E.map(ue=>C.get(ue)?.n).filter(ue=>!!ue&&!v(ue)&&ue.shape!=="missing"),q=Y.filter(ue=>!Y.some(Ke=>Ke!==ue&&Ke.path.length<ue.path.length&&Vt(Ke.path,ue.path)));if(!q.length)return;let de=!1,m=q.filter(Q).flatMap(ue=>g(e.text,ue.section,String(ue.path[ue.path.length-1])).filter(Ke=>!q.some(Ye=>Vt(Ye.path,nt(Ke.path)))).map(Ke=>({n:ue,r:Ke})));if(m.length){let ue=z("ul",{class:"ref-list"},...m.map(({n:Ie,r:De})=>z("li",null,z("code",null,De.path.slice(1).replace(/\//g,".")),` \u2014 ${De.slot.what} (${Ie.label})`))),Ke=q.length===1?h(q[0].path):`${q.length} items`,Ye=await mr(`Delete ${Ke}?`,[z("p",{class:"sub"},`${m.length===1?"One place refers":`${m.length} places refer`} to ${q.length===1?"it":"them"}:`),ue,z("p",{class:"sub"},"Delete the references too, or leave them (the problems list will show them). Either way, Undo brings everything back.")],[{label:"Cancel",value:"cancel"},{label:"Delete only",value:"only",danger:!0},{label:"Delete with references",value:"with",danger:!0,primary:!0}]);if(!Ye){U(y);return}de=Ye==="with"}let L=[...q].sort((ue,Ke)=>typeof ue.path.at(-1)=="number"&&typeof Ke.path.at(-1)=="number"?Ke.path.at(-1)-ue.path.at(-1):0).map(ue=>l(ue.path,{withRefs:de&&Q(ue)})),G=K.findIndex(ue=>ue.n.id===q[0].id),Z=K[G+1]?.n.id&&!q.some(ue=>K[G+1].n.id.startsWith(ue.id))?K[G+1].n.id:K[G-1]?.n.id??"";re(L.length===1?L[0]:We(`Delete ${q.length} items`,L))&&(y=Z,e.select(Z?[nt(Z)]:[],"tree"),N(),U(y))}function We(E,Y){return{label:E,remap:q=>Y.reduce((de,m)=>de&&m.remap?m.remap(de):de,q),build:q=>{let de=[],m=!1;for(let O of Y){let L=O.build(q);for(let G of L.steps)de.push(G),q=dn(q,G);m||=!!L.fallback}return{steps:de,fallback:m}}}}function Ne(E){let Y=C.get(E)?.n;if(!Y||w())return;if(!Q(Y)){n.note(r.text.duplicateNote,"info");return}let q=u(Y.path);if(re(q)){let de=q.select?.[0];de&&(y=Me(de),e.select([de],"tree")),N(),U(y)}}function gt(E,Y){let q=$().has(E.id)?[...$()]:[E.id],de=q.length>1,m=ne(E),O=w(),L=[];m.length&&!de&&L.push({heading:"Add"},...m.slice(0,12),...m.length>12?[{label:"More\u2026",icon:"plus",onSelect:()=>is(m,Y,"Add")}]:[],{sep:!0}),de||(L.push({label:"Rename",icon:"pencil",keys:"F2",disabled:O||E.kind==="group"||v(E)||E.kind==="item",why:r.text.renameWhy,onSelect:()=>be(E.id,"rename")}),E.shape==="scalar"&&L.push({label:"Edit value",icon:"pencil",keys:"Enter",disabled:O,onSelect:()=>be(E.id,"value")}),L.push({label:"Duplicate",icon:"copy",keys:"\u2318D",disabled:O||!Q(E),why:r.text.duplicateWhy,onSelect:()=>Ne(E.id)})),E.path.length&&L.push({label:"Select parent",icon:"arrow-up-right",keys:"\u2318\u2191",onSelect:()=>Ze()}),L.push({label:"Show in text",icon:"code-xml",onSelect:()=>n.showInText(E.path)}),n.clipItems&&L.push({sep:!0},...n.clipItems()),L.push({sep:!0},{label:de?`Delete ${q.length} items`:"Delete",icon:"trash-2",keys:"\u232B",danger:!0,disabled:O||v(E)||E.shape==="missing",why:v(E)?r.text.deleteWhy:"Nothing to delete",onSelect:()=>it(q)}),is(L,Y,`${E.label||r.text.root} actions`)}function Ze(){let E=e.selection.length?e.selection:[nt(y)],Y=[...new Set(E.map(q=>{let de=q.slice(0,-1);for(;de.length&&!C.has(Me(de));)de=de.slice(0,-1);return Me(de)}))];ee(Y)}t.addEventListener("click",E=>{let Y=E.target.closest(".trow");!Y||E.target.closest(".tedit")||fe(Y.dataset.id,E)}),t.addEventListener("dblclick",E=>{let Y=E.target.closest(".trow");if(!Y||E.target.closest(".tedit, .twisty, .tadd"))return;let q=C.get(Y.dataset.id)?.n;q&&(q.shape==="scalar"&&E.target.closest(".tval")?be(q.id,"value"):q.kind==="resource"||q.kind==="key"?be(q.id,"rename"):j(q.id))}),t.addEventListener("contextmenu",E=>{let Y=E.target.closest(".trow");if(!Y)return;E.preventDefault();let q=Y.dataset.id;$().has(q)||fe(q,{shiftKey:!1,metaKey:!1,ctrlKey:!1});let de=C.get(q)?.n;de&>(de,{x:E.clientX,y:E.clientY})}),t.addEventListener("focusin",E=>{let Y=E.target.closest(".trow");Y&&!E.target.closest(".tedit")&&(y=Y.dataset.id)}),t.addEventListener("keydown",E=>{if(E.target.closest(".tedit"))return;let Y=K.map(G=>G.n.id),q=Math.max(0,Y.indexOf(y)),de=C.get(y),m=de?.n,O=E.metaKey||E.ctrlKey,L=G=>{let Z=Y[Math.max(0,Math.min(Y.length-1,G))];E.shiftKey?(A||(A=y),fe(Z,{shiftKey:!0,metaKey:!1,ctrlKey:!1})):(A=Z,ee([Z]))};switch(E.key){case"ArrowDown":if(O)return;L(q+1);break;case"ArrowUp":if(O){Ze();break}L(q-1);break;case"Home":L(0);break;case"End":L(Y.length-1);break;case"ArrowRight":m&&m.children.length&&!T.has(m.id)?j(m.id,!0):m&&m.children.length&&L(q+1);break;case"ArrowLeft":m&&T.has(m.id)&&m.children.length?j(m.id,!1):de?.parent&&(A=de.parent.id,ee([de.parent.id]));break;case"Enter":if(!m)return;if(m.shape==="scalar"&&m.kind!=="group"){let G=xe(e.goodDoc.data,m.path);typeof G=="boolean"&&!w()?re(o(m.path,!G)):be(m.id,"value")}else m.children.length&&j(m.id);break;case"F2":m&&be(m.id,"rename");break;case"Delete":case"Backspace":it(e.selection.length?e.selection.map(Me):[y]);break;case"ContextMenu":m&>(m,t.querySelector(`[data-id="${CSS.escape(y)}"]`));break;case"F10":if(E.shiftKey&&m)gt(m,t.querySelector(`[data-id="${CSS.escape(y)}"]`));else return;break;case"+":case"Insert":m&&ne(m).length&&is(ne(m),t.querySelector(`[data-id="${CSS.escape(y)}"]`),"Add");break;default:if(O&&E.key.toLowerCase()==="d"){Ne(y);break}if(O&&E.key.toLowerCase()==="a"){ee(Y.filter(G=>G),y);break}if(E.key.length===1&&!O&&/\S/.test(E.key)){let G=Date.now();_=G-S>700?E.key.toLowerCase():_+E.key.toLowerCase(),S=G;let Se=[...Y.slice(q+(_.length===1?1:0)),...Y.slice(0,q+1)].find(ue=>(C.get(ue)?.n.label??"").toLowerCase().startsWith(_));Se!==void 0&&(A=Se,ee([Se]));break}return}E.preventDefault()});let ft;t.addEventListener("dragstart",E=>{let Y=E.target.closest(".trow");Y&&(ft=Y.dataset.id,E.dataTransfer?.setData("text/plain",nt(ft).join(".")),E.dataTransfer&&(E.dataTransfer.effectAllowed="move"))});let ot=E=>{let Y=E.target.closest(".trow");if(!Y||!ft||Y.dataset.id===ft)return;let q=C.get(ft)?.n,de=C.get(Y.dataset.id)?.n;if(!q||!de||Me(q.path.slice(0,-1))!==Me(de.path.slice(0,-1)))return;let m=Y.getBoundingClientRect();return{r:Y,a:q,b:de,after:E.clientY>m.top+m.height/2}};t.addEventListener("dragover",E=>{for(let q of t.querySelectorAll(".drop-before, .drop-after"))q.classList.remove("drop-before","drop-after");let Y=ot(E);Y&&(E.preventDefault(),Y.r.classList.add(Y.after?"drop-after":"drop-before"))}),t.addEventListener("dragleave",E=>{if(E.target===t)for(let Y of t.querySelectorAll(".drop-before, .drop-after"))Y.classList.remove("drop-before","drop-after")}),t.addEventListener("drop",E=>{let Y=ot(E);for(let G of t.querySelectorAll(".drop-before, .drop-after"))G.classList.remove("drop-before","drop-after");if(ft=void 0,!Y)return;E.preventDefault();let{a:q,b:de,after:m}=Y,O=q.path.slice(0,-1),L=G=>G[G.length-1];if(typeof L(q.path)=="number"){let G=L(q.path),Z=L(de.path)+(m?1:0);Z>G&&(Z-=1),re(p(O,G,Z))&&(y=Me([...O,Z]),e.select([[...O,Z]],"tree"))}else{let G=(C.get(Me(O))?.n.children??[]).map(ue=>String(L(ue.path))),Z=G.indexOf(String(L(de.path))),Se=m?G[Z+1]:G[Z];Se!==String(L(q.path))&&re(f(q.path,Se===void 0?void 0:Se)),y=q.id}N(),U(y)}),e.on(E=>{if(E.remap){for(let q of[...T]){let de=E.remap(nt(q));de&&Me(de)!==q&&(T.delete(q),T.add(Me(de)))}let Y=E.remap(nt(y));Y&&(y=Me(Y))}E.kind==="load"&&(D=void 0,y=""),Ys(E)?at():at.now()});let at=qs(()=>N());return e.onSelect(E=>{E.origin!=="tree"?B(E.paths):N()}),N(),{paint:N,dispose:()=>at.cancel(),focus:()=>U(y),rows:()=>K.map(E=>({id:E.n.id,label:E.n.label,depth:E.depth,kind:E.n.kind,value:E.n.value,lifetime:E.n.lifetime})),startEdit:be,remove:it,duplicate:Ne,expand:E=>j(E,!0)}}var Xc=(t,e)=>e.reduce((n,s)=>n&&typeof n=="object"?n[s]:void 0,t);function un(t,e,n,s){try{return t.apply(e,n)}catch(r){return s?.(String(r.message),"bad"),!1}}function hr(t,e){return{label:t,remap:n=>e.reduce((s,r)=>s&&r.remap?r.remap(s):s,n),build:n=>{let s=[],r=!1;for(let o of e){let i=o.build(n);for(let a of i.steps)s.push(a),n=dn(n,a);r||=!!i.fallback}return{steps:s,fallback:r}}}}function al(t){let{deleteCmd:e,renameCmd:n,renameKeyCmd:s,referencesTo:r,describe:o,duplicateCmd:i}=t.commands,a=f=>{let p=t.objectOf(Me(f));return!!p&&p.path===Me(f)};async function l(f,p,g,h){let b=p.filter(y=>y.length&&!p.some(A=>A!==y&&A.length<y.length&&Vt(A,y)));if(!b.length)return!1;let k=b.filter(a).flatMap(y=>{let A=t.objectOf(Me(y));return r(f.text,A.kind,A.name).filter(D=>!b.some(K=>Vt(K,nt(D.path)))).map(D=>({p:y,x:D}))}),v=!1;if(k.length){let y=await mr(`Delete ${b.length===1?o(b[0]):`${b.length} items`}?`,[z("p",{class:"sub"},`${k.length===1?"One place refers":`${k.length} places refer`} to ${b.length===1?"it":"them"}:`),z("ul",{class:"ref-list"},...k.map(({x:A})=>z("li",null,z("code",null,A.path.slice(1).replace(/\//g,".")),` \u2014 ${A.slot.what}`))),z("p",{class:"sub"},"Delete the references too, or leave them (the problems list will show them). Either way, Undo brings everything back.")],[{label:"Cancel",value:"cancel"},{label:"Delete only",value:"only",danger:!0},{label:"Delete with references",value:"with",danger:!0,primary:!0}]);if(!y)return!1;v=y==="with"}let x=[...b].sort((y,A)=>typeof y.at(-1)=="number"&&typeof A.at(-1)=="number"?A.at(-1)-y.at(-1):0).map(y=>e(y,{withRefs:v&&a(y)})),T=un(f,x.length===1?x[0]:hr(`Delete ${b.length} items`,x),g,h);return T&&f.select([],g),T}async function c(f,p,g,h){let b=String(p[p.length-1]),k=z("input",{type:"text",value:b,"aria-label":"New name",spellcheck:"false",autocomplete:"off",class:"mono-input"});k.value=b;let v=z("p",{class:"dlg-error",role:"alert"}),M=()=>t.kinds.flatMap(A=>Object.keys(Xc(f.goodDoc.data,A.section)??{})),x=()=>{let A=k.value.trim(),D=!t.nameRule.test(A)&&a(p)?t.nameHint:A!==b&&M().includes(A)?`"${A}" is already used`:"";return v.textContent=D,D?void 0:A};k.addEventListener("input",x);let T=mr(`Rename ${o(p)}`,[z("label",{class:"field"},z("span",null,"Name"),k),v,a(p)?z("p",{class:"sub"},"Every reference to it is renamed too."):""],[{label:"Cancel",value:"cancel"},{label:"Rename",value:"ok",primary:!0}]);if(setTimeout(()=>{k.focus(),k.select()},0),await T!=="ok")return!1;let y=x();return!y||y===b?!1:un(f,a(p)?n(p,y):s(p,y),g,h)}let d=(f,p,g,h)=>{let b=i(p);un(f,b,g,h)&&b.select&&f.select(b.select,g)};function u(f,p){let g=new Map;for(let h of p){let b=t.objectOf(Me(h));if(!b)continue;g.set(b.path,nt(b.path));for(let M of r(f.text,b.kind,b.name)){let x=t.objectOf(M.path);g.set(x?x.path:M.path,nt(x?x.path:M.path))}let k=Xc(f.goodDoc.data,nt(b.path)),v=JSON.stringify(k??{}).match(/[a-z][a-z0-9-]*/g)??[];for(let M of t.kinds)for(let x of Object.keys(Xc(f.goodDoc.data,M.section)??{}))if(v.includes(x)&&x!==b.name){let T=Me([...M.section,x]);g.set(T,nt(T))}}return[...g.values()]}return{deletePaths:l,renameDialog:c,duplicate:d,connected:u}}var ll=(t,e)=>e.reduce((n,s)=>n&&typeof n=="object"?n[s]:void 0,t),gr=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Us=Symbol("mixed");function cl(t,e,n){let s,r=!1,o=n.kit,i=o.ui,{setCmd:a,deleteCmd:l,insertItemCmd:c,referencesTo:d,describe:u}=o.commands,{deletePaths:f,renameDialog:p}=o.actions,g=S=>o.kinds.find($=>$.kind===S),h=S=>g(S)?.singular??"item",b=S=>Object.keys(ll(e.goodDoc.data,g(S)?.section??[])??{}).filter($=>!$.startsWith("x-")),k=S=>un(e,S,"props",n.note);function v(){if(t.contains(document.activeElement)&&document.activeElement.matches("input, textarea"))return;t.replaceChildren();let S=e.selection;if(!S.length){t.append(z("p",{class:"hint"},"Select something in the canvas, the tree or the text."));return}let $=S.map(we=>o.objectOf(Me(we)));if(S.length>1){if(new Set($.map(j=>j?.kind)).size===1&&$.every(j=>j&&j.path===Me(nt(j.path)))){let j=[...new Set($.map(U=>U.path))].map(nt);t.append(z("div",{class:"sel-title"},`${j.length} ${h($[0].kind)}s`),z("div",{class:"sel-path"},j.map(U=>U[U.length-1]).join(", "))),M(j,$[0].kind)}else t.append(z("div",{class:"sel-title"},`${S.length} items`),z("ul",{class:"plain"},...S.map(j=>z("li",null,z("code",null,j.join(".")||i.rootItem)))));K();return}let w=S[0],N=$[0],F=N?nt(N.path):w.length?w:[];if(!N){C(w);return}let J=z("div",{class:"sel-headrow"},z("div",{class:"sel-title"},u(F))),ae=z("button",{type:"button",class:"btn sm quiet icon-only","aria-label":`Rename ${u(F)}`,title:"Rename (F2)"},Wt("pencil"));ae.addEventListener("click",()=>p(e,F,"props",n.note)),J.append(ae),t.append(J),Me(w)!==N.path&&(s=Me(w)),M([F],N.kind),A(N.kind,N.name),D(N.path),K()}function M(S,$){let w=n.nav(),N=e.goodDoc.data,F=S.map(ne=>ll(N,ne)??{}),J=F[0]&&gr(F[0])?F[0]:{},ae=F.some(ne=>i.isExternal(ne)),we=w.keys(S[0],ae?{external:!0}:J),j=Object.keys(J),U=we.filter(ne=>F.some(me=>gr(me)&&ne.name in me)).sort((ne,me)=>(j.indexOf(ne.name)+1||999)-(j.indexOf(me.name)+1||999)),ee=n.read(),fe=new Set([...U.map(ne=>ne.name),...i.important($,F[0]??{},ae),...S.length===1&&ee!==void 0&&i.inheritedKeys?i.inheritedKeys(S[0],ee):[]]),B=we.filter(ne=>!U.includes(ne)&&fe.has(ne.name)),X=we.filter(ne=>!fe.has(ne.name)),Q=z("div",{class:"props"});for(let ne of[...U,...B])Q.append(x(S,$,ne,F,ee));if(X.length&&e.doc.ok){let ne=z("select",{class:"padd","aria-label":"Add a property"},z("option",{value:""},"+ Add property"),...X.map(me=>z("option",{value:me.name,title:(me.doc??"").replace(/`/g,"")},me.name)));ne.addEventListener("change",()=>{let me=ne.value;if(!me)return;let ye=w.defaultFor([...S[0],me]);s=Me([...S[0],me]),r=!0,k(S.length===1?a([...S[0],me],ye,`Add ${u([...S[0],me])}`):hr(`Add ${me} to ${S.length} ${h($)}s`,S.map(xe=>a([...xe,me],ye))))}),Q.append(ne)}let te=new Set(we.map(ne=>ne.name));for(let ne of new Set(F.flatMap(me=>gr(me)?Object.keys(me):[])))te.has(ne)||Q.append(x(S,$,{name:ne,shape:"scalar",enumValues:[],examples:[],doc:ne.startsWith("x-")?i.extensionDoc:"Not a key the schema knows."},F,ee));if(t.append(Q),s){let ne=Q.querySelector(`[data-path="${CSS.escape(s)}"]`);ne?.classList.add("focus-row"),ne?.scrollIntoView({block:"nearest"}),r&&ne?.querySelector("input, select, textarea")?.focus({preventScroll:!0}),s=void 0,r=!1}}function x(S,$,w,N,F){let J=n.nav(),ae=N.map(be=>gr(be)?be[w.name]:void 0),j=ae.every(be=>JSON.stringify(be)===JSON.stringify(ae[0]))?ae[0]:Us,U=ae.some(be=>be!==void 0),ee=$&&S.length===1&&F!==void 0?i.inherited?.(S[0],w.name,F):void 0,fe=S.map(be=>Me([...be,w.name])),B=z("div",{class:`prow${U?"":" unset"}`,"data-path":fe[0]}),X=z("label",{class:"plabel",title:w.doc?.replace(/`/g,"")??""},w.name),Q=`pf-${Math.random().toString(36).slice(2,8)}`;X.setAttribute("for",Q),B.append(X);let te=(be,ce)=>k(S.length===1?a([...S[0],w.name],be,ce):hr(ce??`Set ${w.name} on ${S.length} ${h($)}s`,S.map(ze=>a([...ze,w.name],be)))),ne=()=>{let be=S.filter((ce,ze)=>ae[ze]!==void 0);k(be.length===1?{...l([...be[0],w.name]),label:`Remove ${u([...be[0],w.name])}`}:hr(`Remove ${w.name} from ${be.length} ${h($)}s`,be.map(ce=>l([...ce,w.name]))))},me=o.slotAt(Me([...S[0],w.name])),ye=o.slotAt(Me([...S[0],w.name,0])),xe=J.values([...S[0],w.name]),Re=J.types([...S[0],w.name]),Ue,I=j===Us?"(mixed)":"";if(me||xe.length){let be=[...new Set([...xe,...me?me.targets.flatMap(ze=>b(ze).map(Oe=>me.write?me.write(Oe):Oe)).concat(me.extra??[]):[]])],ce=z("select",{id:Q,class:"pinput"});ce.append(z("option",{value:"\0"},I||"\u2014"));for(let ze of be)ce.append(z("option",{value:ze},ze));j!==Us&&j!==void 0&&!be.includes(String(j))&&ce.append(z("option",{value:String(j)},String(j))),ce.value=j===Us||j===void 0?"\0":String(j),ce.addEventListener("change",()=>{if(ce.value==="\0"){U&&ne();return}te(xe.includes("true")&&(ce.value==="true"||ce.value==="false")?ce.value==="true":ce.value)}),Ue=ce}else if(ye&&S.length===1){let be=Array.isArray(j)?j:[],ce=z("div",{class:"chips"});be.forEach((Oe,Ee)=>{let Be=z("button",{type:"button",class:"chip-x","aria-label":`Remove ${Oe}`},"\xD7");Be.addEventListener("click",()=>k({...l([...S[0],w.name,Ee]),label:`Remove ${Oe} from ${u([...S[0],w.name])}`})),ce.append(z("span",{class:"chip"},String(Oe),Be))});let ze=[...new Set(ye.targets.flatMap(Oe=>b(Oe)).concat(ye.extra??[]))].filter(Oe=>!be.includes(Oe));if(ze.length){let Oe=z("select",{id:Q,class:"pinput chip-add","aria-label":`Add to ${w.name}`},z("option",{value:""},"+ add"),...ze.map(Ee=>z("option",{value:Ee},Ee)));Oe.addEventListener("change",()=>{Oe.value&&k(c([...S[0],w.name],Oe.value,void 0,`Add ${Oe.value} to ${u([...S[0],w.name])}`))}),ce.append(Oe)}Ue=ce}else if(w.name==="prompt"||typeof j=="string"&&j.includes(`
|
|
465
|
-
`)){let
|
|
466
|
-
`)||!
|
|
467
|
-
`)?
|
|
468
|
-
`)}),Ue=
|
|
464
|
+
`,o+1))n.push(o+1);let s=(o,i)=>{let a=Math.min(Math.max(o,1),n.length),l=a<n.length?n[a]-1:t.length;return Math.min(n[a-1]+Math.max(i,1)-1,l)},r=s(e.startLine,e.startCol);return[r,Math.max(r,s(e.endLine,e.endCol))]}function Xf(t){return t.replace(/\$\{(\d+)\|([^|}]*)\|\}/g,(e,n,s)=>`\${${n}:${s.split(",")[0]}}`).replace(/\$\{0\}/g,"${}")}function Qf(t){return t.split(/\n{2,}/).map(e=>{let n=[];for(let s of e.matchAll(/\*\*([^*]+)\*\*|`([^`]+)`|([^*`]+|[*`])/g))s[1]!==void 0?n.push({kind:"bold",text:s[1]}):s[2]!==void 0?n.push({kind:"code",text:s[2]}):n.push({kind:"text",text:s[3]});return n})}var El=null;function $r(t){El=t}function gs(){return El&&El.isConnected?El:document.body}var Zf="http://www.w3.org/2000/svg";function Ut(t,e=""){let n=document.createElementNS(Zf,"svg");n.setAttribute("class",`icon${e?" "+e:""}`),n.setAttribute("aria-hidden","true");let s=document.createElementNS(Zf,"use");return s.setAttribute("href",`#se-i-${t}`),n.append(s),n}function fo(t,e,n){return new Promise(s=>{let r=_("dialog",{class:"dlg","aria-label":t}),o=_("form",{method:"dialog"}),i=_("div",{class:"dlg-foot"});for(let a of n){let l=_("button",{type:"submit",value:a.value,class:`btn${a.primary?" primary":""}${a.danger?" danger":""}`},a.label);i.append(l)}o.append(_("div",{class:"dlg-head"},_("h2",{class:"h-title"},t)),_("div",{class:"dlg-body"},...e),i),r.append(o),gs().append(r),r.addEventListener("close",()=>{let a=r.returnValue;r.remove(),s(a&&a!=="cancel"?a:null)}),r.showModal(),i.querySelector(".primary")?.focus()})}var mi,ep=()=>!!mi;function bs(t,e,n="Actions"){mi?.close(!1);let s=document.activeElement,r=_("div",{class:"menu",role:"menu","aria-label":n,tabindex:"-1"}),o=[];for(let g of t){if("sep"in g){r.append(_("div",{class:"menu-sep",role:"separator"}));continue}if("heading"in g){r.append(_("div",{class:"menu-label"},g.heading));continue}let h=(g.disabled?g.why:void 0)??g.desc,b=_("button",{type:"button",role:"menuitem",tabindex:"-1",class:"menu-item"+(g.danger?" danger":""),"data-desc":h,"aria-description":h},g.icon?Ut(g.icon):_("span"),_("span",{class:"mi-label"},g.label),g.keys?_("span",{class:"menu-trail"},g.keys):null);g.disabled&&(b.disabled=!0),b.addEventListener("click",v=>{v.stopPropagation(),!b.disabled&&(p(!0),g.onSelect())}),o.push(b),r.append(b)}gs().append(r);let i=r.getBoundingClientRect(),a,l;if(e instanceof HTMLElement){let g=e.getBoundingClientRect();a=g.left,l=g.bottom+4,l+i.height>innerHeight-8&&(l=g.top-i.height-4)}else a=e.x,l=e.y,l+i.height>innerHeight-8&&(l=Math.max(8,e.y-i.height));r.style.left=`${Math.max(8,Math.min(a,innerWidth-i.width-8))}px`,r.style.top=`${Math.max(8,l)}px`;let c=()=>o.filter(g=>!g.disabled),d=g=>{let h=c();h.length&&h[(g+h.length)%h.length].focus()};d(0),r.addEventListener("keydown",g=>{let b=c().indexOf(document.activeElement);g.key==="ArrowDown"?(d(b+1),g.preventDefault()):g.key==="ArrowUp"?(d(b-1),g.preventDefault()):g.key==="Home"?(d(0),g.preventDefault()):g.key==="End"?(d(-1),g.preventDefault()):(g.key==="Escape"||g.key==="Tab")&&(p(!0),g.preventDefault()),g.stopPropagation()});let u=g=>{r.contains(g.target)||p(!1)};setTimeout(()=>{addEventListener("pointerdown",u,!0),addEventListener("blur",f)},0);let f=()=>p(!1);function p(g){r.isConnected&&(r.remove(),removeEventListener("pointerdown",u,!0),removeEventListener("blur",f),mi=void 0,g&&s?.focus())}return mi={el:r,close:p},r}function Tl(){mi?.close(!1)}var tp=150,rr=t=>t.kind==="do"&&t.origin==="text";function or(t,e=150){let n=0,s=()=>{n=0,t()},r=()=>{clearTimeout(n),n=window.setTimeout(s,e)};return r.now=()=>{clearTimeout(n),s()},r.pending=()=>n!==0,r.cancel=()=>{clearTimeout(n),n=0},r}function Al(t,e){return t.map((n,s)=>s===0?{...n,keys:[...n.keys.slice(0,1),...e,...n.keys.slice(1)]}:n)}function Pl(t){let e=_("dialog",{class:"dlg keys-dlg","aria-label":"Keyboard"}),n=_("form",{method:"dialog"}),s=_("div",{class:"dlg-body keys"});for(let r of t){s.append(_("h3",{class:"keys-h"},r.where));let o=_("dl",{class:"keys-list"});for(let[i,a]of r.keys)o.append(_("dt",null,...i.split(/(\s+or\s+|,\s*)/).map(l=>/^\s+or\s+$|^,\s*$/.test(l)?l:_("kbd",null,l))),_("dd",null,a));s.append(o)}return n.append(_("div",{class:"dlg-head"},_("h2",{class:"h-title"},"Keyboard")),s,_("div",{class:"dlg-foot"},_("button",{type:"submit",class:"btn primary",value:"close"},"Close"))),e.append(n),e.addEventListener("close",()=>e.remove()),gs().append(e),e.showModal(),e}function Cl(t,e,n){let{copyText:s,cutCmd:r,pasteCmd:o}=n,i="",a=()=>!t.doc.ok,l=f=>!!f?.closest?.("input, textarea, select, .monaco-editor, [contenteditable]"),c=()=>{let f=s(t.text,t.selection);if(!f){e("Select something to copy");return}return i=f.text,e(`Copied ${f.what}`),f.text},d=()=>{if(a()){e("Fix the YAML first","warn");return}let f=r(t.text,t.selection);if(!f){e("Select something to cut");return}return i=f.text,t.apply(f.cmd,"menu"),t.select([],"menu"),f.text},u=f=>{if(a())return e("Fix the YAML first","warn"),!1;let p=o(t.text,f,t.selection);if(!p.cmd)return e(`Can't paste: ${p.error}`,"warn"),!1;try{if(!t.apply(p.cmd,"menu"))return!1}catch(h){return e(`Can't paste: ${h.message}`,"bad"),!1}p.cmd.select&&t.select(p.cmd.select,"menu");let g=p.names?[...p.names].filter(([h,b])=>h!==b):[];return e(g.length?`${p.what}: ${g.map(([h,b])=>`${h} \u2192 ${b}`).join(", ")}`:p.what),!0};return{items(){let f=t.selection.length>0;return[{label:"Cut",icon:"clipboard",keys:"\u2318X",disabled:!f||a(),why:f?"Fix the YAML first":"Nothing selected",onSelect:()=>{this.cut()}},{label:"Copy",icon:"copy",keys:"\u2318C",disabled:!f,why:"Nothing selected",onSelect:()=>{this.copy()}},{label:"Paste",icon:"clipboard-paste",keys:"\u2318V",disabled:a(),why:"Fix the YAML first",onSelect:()=>{this.paste()}}]},attach(f,p){let g=v=>{let w=v;if(l(w.target)||!p(w.target))return;let k=c();k!==void 0&&(w.clipboardData?.setData("text/plain",k),w.preventDefault())},h=v=>{let w=v;if(l(w.target)||!p(w.target))return;let k=d();k!==void 0&&(w.clipboardData?.setData("text/plain",k),w.preventDefault())},b=v=>{let w=v;if(l(w.target)||!p(w.target))return;let k=w.clipboardData?.getData("text/plain")??"";w.preventDefault(),u(k||i)};return f.addEventListener("copy",g),f.addEventListener("cut",h),f.addEventListener("paste",b),()=>{f.removeEventListener("copy",g),f.removeEventListener("cut",h),f.removeEventListener("paste",b)}},async copy(){let f=c();if(f===void 0)return!1;try{await navigator.clipboard.writeText(f)}catch{}return!0},async cut(){let f=d();if(f===void 0)return!1;try{await navigator.clipboard.writeText(f)}catch{}return!0},async paste(f){let p=f;if(p===void 0)try{p=await navigator.clipboard.readText()}catch{p=i}return p?u(p):(e("The clipboard is empty"),!1)}}}function Ol(t,e,n){let s=n.kit,r=s.ui,{setCmd:o,insertCmd:i,insertItemCmd:a,deleteCmd:l,renameCmd:c,renameKeyCmd:d,duplicateCmd:u,moveCmd:f,moveItemCmd:p,referencesTo:g,describe:h,freshName:b}=s.commands,v=P=>s.kinds.find(q=>q.kind===P),w=P=>P.id==="",k=P=>s.entryGroups.some(q=>P.length===q.length+1&&qt(q,P)),y=P=>s.entryGroups.some(q=>q.length===P.length&&qt(q,P)),M=new Set(["",...s.kinds.map(P=>Se(P.section)),...s.entryGroups.map(P=>Se(P))]),T="",A="",I,j=[],L=new Map,B="",S=0,E=()=>new Set(e.selection.map(Se)),x=()=>!e.doc.ok;t.setAttribute("role","tree"),t.setAttribute("aria-label",r.label),t.setAttribute("aria-multiselectable","true"),t.classList.add("tree");function N(){let P=s.outline(e.goodDoc,n.role(),n.lifetimes());j=[];let q=(ee,$e,de)=>{if(j.push({n:ee,depth:$e,parent:de}),M.has(ee.id))for(let De of ee.children)q(De,$e+1,ee);I?.mode==="new"&&Se(I.mapPath)===ee.id&&M.has(ee.id)&&j.push({n:{id:I.id,path:[...I.mapPath,""],kind:"resource",label:"",shape:"scalar",children:[]},depth:$e+1,parent:ee})};q(P,0),L=new Map(j.map(ee=>[ee.n.id,ee])),L.has(T)||(T=j[0]?.n.id??"");let U=E(),ae=z(),m=document.createDocumentFragment();x()&&m.append(_("div",{class:"callout compact warn tree-note",role:"status"},_("span",{class:"c-body"},`Fix the YAML at line ${e.doc.doc.errors[0]?e.doc.pos(e.doc.doc.errors[0].pos[0]).line:"?"} to edit here; the tree shows the last version that read cleanly.`)));for(let{n:ee,depth:$e}of j)m.append(re(ee,$e,U.has(ee.id),ae.get(ee.id)));let C=t.contains(document.activeElement);t.replaceChildren(m);let R=t.querySelector(`[data-id="${CSS.escape(T)}"]`);R&&(R.tabIndex=0);let H=t.querySelector(".tedit");H?(H.focus(),H instanceof HTMLInputElement&&H.select()):C&&R&&!t.contains(document.activeElement)&&R.focus({preventScroll:!0})}function z(){let P=new Map;for(let q of n.problems()){if(q.file)continue;let U=et(q.path);for(let ae=1;ae<=U.length;ae++){let m=Se(U.slice(0,ae)),C=P.get(m)??{e:0,w:0};q.severity==="error"?C.e++:C.w++,P.set(m,C)}}return P}function Q(P){if(w(P))return r.rootIcon;if(P.section)return r.kindIcon(P.section);let q=String(P.path[P.path.length-1]??"");return P.path.length===1&&r.keyIcon(q)?r.keyIcon(q):k(P.path)?r.entryIcon(String(P.path[0])):P.shape==="list"?"list":P.shape==="map"?"list-tree":"circle-dot"}function re(P,q,U,ae){let m=M.has(P.id),C=P.children.length>0||P.shape==="missing"&&!1,R=_("div",{class:`trow k-${P.kind}${U?" selected":""}${P.shape==="missing"?" missing":""}${P.ext?" ext":""}`,role:"treeitem","aria-level":q+1,"aria-selected":String(U),"aria-expanded":P.children.length?String(m):void 0,tabindex:"-1","data-id":P.id,draggable:J(P)?"true":void 0,"aria-label":we(P)});R.style.setProperty("--depth",String(q));let H=_("span",{class:"twisty","aria-hidden":"true"},C?Ut(m?"chevron-down":"chevron-right"):"");H.addEventListener("click",de=>{de.stopPropagation(),F(P.id)}),R.append(H,Ut(Q(P),"ticon"));let ee=I&&I.id===P.id?I:void 0;ee&&(ee.mode==="rename"||ee.mode==="new")?R.append(Ke(P,ee)):R.append(_("span",{class:"tlabel"},P.label||(P.kind==="item"?'""':""))),ee?.mode==="value"?R.append(Te(P)):P.value!==void 0&&P.kind!=="item"?R.append(_("span",{class:"tval"},P.value)):P.shape==="missing"?R.append(_("span",{class:"tval none"},"none")):P.kind==="group"&&P.children.length&&R.append(_("span",{class:"tcount"},String(P.children.length)));let $e=P.lifetime?r.tagPill(P.lifetime):void 0;if($e&&R.append(_("span",{class:`tpill l-${P.lifetime}`,title:$e.title},P.lifetime)),ae?.e?R.append(_("span",{class:"count bad",title:`${ae.e} error${ae.e>1?"s":""}`},String(ae.e))):ae?.w&&R.append(_("span",{class:"count warn",title:`${ae.w} warning${ae.w>1?"s":""}`},String(ae.w))),!x()&&oe(P).length){let de=_("button",{type:"button",class:"tadd btn sm quiet icon-only",tabindex:"-1","aria-label":`Add to ${P.label||r.text.rootAdd}`,title:"Add\u2026"},Ut("plus"));de.addEventListener("click",De=>{De.stopPropagation(),X(P.id),bs(oe(P),de,`Add to ${P.label}`)}),R.append(de)}return R}let we=P=>[P.kind==="group"?`${P.label}, ${P.shape==="missing"?"none":P.children.length}`:P.label,P.value!==void 0&&P.kind!=="item"?`: ${P.value}`:"",P.lifetime&&P.lifetime!=="run"?`, ${P.lifetime}`:""].join("");function F(P,q){q??!M.has(P)?M.add(P):M.delete(P),N()}function X(P){T=P;for(let U of t.querySelectorAll(".trow"))U.tabIndex=U.dataset.id===P?0:-1;let q=t.querySelector(`[data-id="${CSS.escape(P)}"]`);q?.focus({preventScroll:!0}),q?.scrollIntoView({block:"nearest"})}function Z(P,q=P[P.length-1]){q!==void 0&&(T=q,X(T)),e.select(P.map(et),"tree"),N(),X(T)}function be(P,q){if(q.shiftKey&&A){let U=j.map(C=>C.n.id),ae=U.indexOf(A),m=U.indexOf(P);if(ae>=0&&m>=0){Z(U.slice(Math.min(ae,m),Math.max(ae,m)+1),P);return}}if(q.metaKey||q.ctrlKey){let U=E();U.has(P)?U.delete(P):U.add(P),A=P,Z([...U],P);return}A=P,Z([P])}function V(P){for(let q of P)for(let U=0;U<q.length;U++)M.add(Se(q.slice(0,U)));if(P[0]){let q=Se(P[0]);for(N();!L.has(q)&&q;)q=q.replace(/\/[^/]*$/,"");T=q}N(),t.querySelector(`[data-id="${CSS.escape(T)}"]`)?.scrollIntoView({block:"nearest"})}let J=P=>!x()&&!w(P)&&P.kind!=="group"&&P.path.length>1||P.kind==="item",G=P=>P.kind==="resource"&&!!P.section,ne=P=>P.kind==="group"&&(!!P.section||y(P.path));function oe(P){if(x())return[];let q=n.nav(),U=[],ae=e.goodDoc.data;if(w(P)){for(let H of s.kinds){if(n.role()!=="main")break;U.push({label:`New ${H.singular}`,icon:r.kindIcon(H.kind),onSelect:()=>Ce(H.kind)})}let m=new Set(P.children.filter(H=>H.shape!=="missing").map(H=>String(H.path[0]))),C=new Set(s.kinds.map(H=>String(H.section[0]))),R=q.keys([],ae??{}).filter(H=>!m.has(H.name)&&!C.has(H.name)&&!(ae&&H.name in ae));return R.length&&U.push({sep:!0},{heading:"Settings"},...R.map(H=>({label:H.name,desc:ge(H.doc),onSelect:()=>Me([],H.name)}))),U}if(P.kind==="group"&&P.section){let m=P.section;for(let C of r.newItems(m))U.push({label:C.label,icon:C.icon,desc:C.desc,onSelect:()=>Ce(m,C.template,C.stem)});return U}if(y(P.path)&&r.entryItems)return ve(P.path);if(P.shape==="missing")return[{label:`Add ${P.label}`,icon:"plus",onSelect:()=>Me([],String(P.path[0]),!0)}];if(P.shape==="list"){let m=s.slotAt(Se([...P.path,0])),C=new Set(P.children.map(R=>R.label));if(m){for(let R of m.targets)for(let H of Ie(R))C.has(m.write?m.write(H):H)||U.push({label:m.write?m.write(H):H,icon:r.kindIcon(R),desc:`${v(R).singular}`,onSelect:()=>se(a(P.path,m.write?m.write(H):H,void 0,`Add ${H} to ${h(P.path)}`))});for(let R of m.extra??[])C.has(R)||U.push({label:R,onSelect:()=>se(a(P.path,R,void 0,`Add ${R} to ${h(P.path)}`))})}for(let R of q.values([...P.path,0]))C.has(R)||U.push({label:R,onSelect:()=>se(a(P.path,R))});return U.push({label:"New item",icon:"plus",onSelect:()=>{se(a(P.path,""));let R=[...P.path,P.children.length];he(Se(R),"value")}}),U}if(P.shape==="map"||P.kind==="resource"){let m=ye(ae,P.path),C=m&&typeof m=="object"&&!Array.isArray(m)?m:{};for(let R of q.keys(P.path,C))R.name in C||U.push({label:R.name,desc:ge(R.doc),onSelect:()=>Me(P.path,R.name)});return U}return U}function ve(P){let q=e.goodDoc.data??{},U=ye(q,P)??{};return r.entryItems(P,q,Ue).filter(ae=>!ae.when||ae.when(q)).map(ae=>({label:ae.label,icon:ae.icon,onSelect:()=>{se(i(P,D(Object.keys(U),ae.entry),ae.value,ae.cmdLabel?{label:ae.cmdLabel}:{}))}}))}let ge=P=>P?.split(/(?<=\.)\s/)[0]?.replace(/`/g,""),ye=(P,q)=>q.reduce((U,ae)=>U&&typeof U=="object"?U[ae]:void 0,P),Ie=P=>{let q=ye(e.goodDoc.data,v(P).section);return q&&typeof q=="object"?Object.keys(q).filter(U=>!U.startsWith("x-")):[]},Ue=P=>{let q=ye(e.goodDoc.data,v(P).section);return q?Object.keys(q).filter(U=>!U.startsWith("x-")&&!(q[U]&&typeof q[U]=="object"&&"external"in q[U])):[]},D=(P,q)=>{if(!P.includes(q))return q;let U=2;for(;P.includes(`${q}-${U}`);)U++;return`${q}-${U}`};function se(P){try{return e.apply(P,"tree")}catch(q){return n.note(String(q.message),"bad"),!1}}function Me(P,q,U=!1){let ae=n.nav(),m=U?{}:ae.defaultFor([...P,q]);if(se(i(P,q,m))){M.add(Se(P));let C=Se([...P,q]);T=C,m===""||typeof m=="number"?he(C,"value"):(N(),X(C))}}function Ce(P,q=v(P).template,U=v(P).singular){let ae=v(P).section;M.add(Se(ae)),I={id:"#new",mode:"new",section:P,mapPath:ae,template:q,value:b(e.text,U)},N()}function he(P,q){if(x())return;let U=L.get(P);if(!U){N();return}q==="rename"&&(U.n.kind==="group"||w(U.n)||U.n.kind==="item")||q==="value"&&U.n.shape!=="scalar"||(I={id:P,mode:q},T=P,N())}function ie(P=!0){I=void 0,N(),P&&X(T)}function Ke(P,q){let U=q.mode==="new"?String(q.value??""):String(P.path[P.path.length-1]),ae=_("input",{class:"tedit tname",value:U,"aria-label":q.mode==="new"?`Name of the new ${q.section?v(q.section).singular:"entry"}`:`Rename ${P.label}`,spellcheck:"false",autocomplete:"off"});ae.value=U;let m=()=>{let H=ae.value.trim(),ee=q.mode==="new"||G(P)||k(P.path),$e=H?ee&&!s.nameRule.test(H)?r.nameHint:H!==U&&Oe(q.mode==="new"?q.mapPath:P.path.slice(0,-1),H,ee)?`"${H}" is already used`:"":"a name is needed";return ae.setAttribute("aria-invalid",String(!!$e)),ae.title=$e,$e?void 0:H};ae.addEventListener("input",m),ae.addEventListener("keydown",H=>{H.stopPropagation(),H.key==="Escape"&&(H.preventDefault(),ie()),H.key==="Enter"&&(H.preventDefault(),R())});let C=!1,R=()=>{if(C)return;let H=m();if(H===void 0){ae.value.trim()||(C=!0,ie());return}if(C=!0,I=void 0,q.mode==="new"){let ee=[...q.mapPath,H];se(i(q.mapPath,H,q.template(),{label:`Add ${q.section?v(q.section).singular:"entry"} ${H}`}))&&(T=Se(ee),e.select([ee],"tree"),M.add(T))}else if(H!==U){let ee=P.path;if(se(G(P)?c(ee,H):d(ee,H))){let $e=[...ee.slice(0,-1),H];M.has(P.id)&&(M.delete(P.id),M.add(Se($e))),T=Se($e)}}N(),X(T)};return ae.addEventListener("blur",()=>{C||(ae.value.trim()&&m()!==void 0?R():(C=!0,I=void 0,N()))}),ae}function Oe(P,q,U){if(U&&!y(P))return s.kinds.some(m=>Ie(m.kind).includes(q));let ae=ye(e.goodDoc.data,P);return!!ae&&typeof ae=="object"&&q in ae}function Te(P){let q=n.nav(),U=ye(e.goodDoc.data,P.path),ae=q.values(P.path),m=s.slotAt(Se(P.path)),C=m?m.targets.flatMap(ee=>Ie(ee).map($e=>m.write?m.write($e):$e)).concat(m.extra??[]):[],R=[...new Set([...ae,...C])],H;return R.length&&(ae.length||m)?(H=_("select",{class:"tedit tvalue","aria-label":`Value of ${P.label}`},...R.map(ee=>_("option",{value:ee},ee))),R.includes(String(U))||H.prepend(_("option",{value:String(U??"")},String(U??""))),H.value=String(U??""),H.addEventListener("change",()=>je(P,H.value))):(H=_("input",{class:"tedit tvalue","aria-label":`Value of ${P.label}`,spellcheck:"false",autocomplete:"off"}),H.value=U==null?"":String(U)),H.addEventListener("keydown",ee=>{ee.stopPropagation(),ee.key==="Escape"&&(ee.preventDefault(),ie()),ee.key==="Enter"&&(ee.preventDefault(),je(P,H.value))}),H.addEventListener("blur",()=>{I?.id===P.id&&je(P,H.value,!1)}),H}function je(P,q,U=!0){if(I?.id!==P.id)return;I=void 0;let ae=n.nav().types(P.path),m=ye(e.goodDoc.data,P.path),C=q;(ae.has("integer")||ae.has("number")||typeof m=="number")&&/^-?\d+(\.\d+)?$/.test(q.trim())?C=Number(q):(ae.has("boolean")||typeof m=="boolean")&&/^(true|false)$/.test(q.trim())&&(C=q.trim()==="true"),C!==m&&se(o(P.path,C)),N(),U&&X(T)}async function lt(P){if(x()||!P.length)return;let q=P.map(de=>L.get(de)?.n).filter(de=>!!de&&!w(de)&&de.shape!=="missing"),U=q.filter(de=>!q.some(De=>De!==de&&De.path.length<de.path.length&&qt(De.path,de.path)));if(!U.length)return;let ae=!1,m=U.filter(G).flatMap(de=>g(e.text,de.section,String(de.path[de.path.length-1])).filter(De=>!U.some(He=>qt(He.path,et(De.path)))).map(De=>({n:de,r:De})));if(m.length){let de=_("ul",{class:"ref-list"},...m.map(({n:Ne,r:Ye})=>_("li",null,_("code",null,Ye.path.slice(1).replace(/\//g,".")),` \u2014 ${Ye.slot.what} (${Ne.label})`))),De=U.length===1?h(U[0].path):`${U.length} items`,He=await fo(`Delete ${De}?`,[_("p",{class:"sub"},`${m.length===1?"One place refers":`${m.length} places refer`} to ${U.length===1?"it":"them"}:`),de,_("p",{class:"sub"},"Delete the references too, or leave them (the problems list will show them). Either way, Undo brings everything back.")],[{label:"Cancel",value:"cancel"},{label:"Delete only",value:"only",danger:!0},{label:"Delete with references",value:"with",danger:!0,primary:!0}]);if(!He){X(T);return}ae=He==="with"}let R=[...U].sort((de,De)=>typeof de.path.at(-1)=="number"&&typeof De.path.at(-1)=="number"?De.path.at(-1)-de.path.at(-1):0).map(de=>l(de.path,{withRefs:ae&&G(de)})),H=j.findIndex(de=>de.n.id===U[0].id),ee=j[H+1]?.n.id&&!U.some(de=>j[H+1].n.id.startsWith(de.id))?j[H+1].n.id:j[H-1]?.n.id??"";se(R.length===1?R[0]:We(`Delete ${U.length} items`,R))&&(T=ee,e.select(ee?[et(ee)]:[],"tree"),N(),X(T))}function We(P,q){return{label:P,remap:U=>q.reduce((ae,m)=>ae&&m.remap?m.remap(ae):ae,U),build:U=>{let ae=[],m=!1;for(let C of q){let R=C.build(U);for(let H of R.steps)ae.push(H),U=yn(U,H);m||=!!R.fallback}return{steps:ae,fallback:m}}}}function ft(P){let q=L.get(P)?.n;if(!q||x())return;if(!G(q)){n.note(r.text.duplicateNote,"info");return}let U=u(q.path);if(se(U)){let ae=U.select?.[0];ae&&(T=Se(ae),e.select([ae],"tree")),N(),X(T)}}function ut(P,q){let U=E().has(P.id)?[...E()]:[P.id],ae=U.length>1,m=oe(P),C=x(),R=[];m.length&&!ae&&R.push({heading:"Add"},...m.slice(0,12),...m.length>12?[{label:"More\u2026",icon:"plus",onSelect:()=>bs(m,q,"Add")}]:[],{sep:!0}),ae||(R.push({label:"Rename",icon:"pencil",keys:"F2",disabled:C||P.kind==="group"||w(P)||P.kind==="item",why:r.text.renameWhy,onSelect:()=>he(P.id,"rename")}),P.shape==="scalar"&&R.push({label:"Edit value",icon:"pencil",keys:"Enter",disabled:C,onSelect:()=>he(P.id,"value")}),R.push({label:"Duplicate",icon:"copy",keys:"\u2318D",disabled:C||!G(P),why:r.text.duplicateWhy,onSelect:()=>ft(P.id)})),P.path.length&&R.push({label:"Select parent",icon:"arrow-up-right",keys:"\u2318\u2191",onSelect:()=>it()}),R.push({label:"Show in text",icon:"code-xml",onSelect:()=>n.showInText(P.path)}),n.clipItems&&R.push({sep:!0},...n.clipItems()),R.push({sep:!0},{label:ae?`Delete ${U.length} items`:"Delete",icon:"trash-2",keys:"\u232B",danger:!0,disabled:C||w(P)||P.shape==="missing",why:w(P)?r.text.deleteWhy:"Nothing to delete",onSelect:()=>lt(U)}),bs(R,q,`${P.label||r.text.root} actions`)}function it(){let P=e.selection.length?e.selection:[et(T)],q=[...new Set(P.map(U=>{let ae=U.slice(0,-1);for(;ae.length&&!L.has(Se(ae));)ae=ae.slice(0,-1);return Se(ae)}))];Z(q)}t.addEventListener("click",P=>{let q=P.target.closest(".trow");!q||P.target.closest(".tedit")||be(q.dataset.id,P)}),t.addEventListener("dblclick",P=>{let q=P.target.closest(".trow");if(!q||P.target.closest(".tedit, .twisty, .tadd"))return;let U=L.get(q.dataset.id)?.n;U&&(U.shape==="scalar"&&P.target.closest(".tval")?he(U.id,"value"):U.kind==="resource"||U.kind==="key"?he(U.id,"rename"):F(U.id))}),t.addEventListener("contextmenu",P=>{let q=P.target.closest(".trow");if(!q)return;P.preventDefault();let U=q.dataset.id;E().has(U)||be(U,{shiftKey:!1,metaKey:!1,ctrlKey:!1});let ae=L.get(U)?.n;ae&&ut(ae,{x:P.clientX,y:P.clientY})}),t.addEventListener("focusin",P=>{let q=P.target.closest(".trow");q&&!P.target.closest(".tedit")&&(T=q.dataset.id)}),t.addEventListener("keydown",P=>{if(P.target.closest(".tedit"))return;let q=j.map(H=>H.n.id),U=Math.max(0,q.indexOf(T)),ae=L.get(T),m=ae?.n,C=P.metaKey||P.ctrlKey,R=H=>{let ee=q[Math.max(0,Math.min(q.length-1,H))];P.shiftKey?(A||(A=T),be(ee,{shiftKey:!0,metaKey:!1,ctrlKey:!1})):(A=ee,Z([ee]))};switch(P.key){case"ArrowDown":if(C)return;R(U+1);break;case"ArrowUp":if(C){it();break}R(U-1);break;case"Home":R(0);break;case"End":R(q.length-1);break;case"ArrowRight":m&&m.children.length&&!M.has(m.id)?F(m.id,!0):m&&m.children.length&&R(U+1);break;case"ArrowLeft":m&&M.has(m.id)&&m.children.length?F(m.id,!1):ae?.parent&&(A=ae.parent.id,Z([ae.parent.id]));break;case"Enter":if(!m)return;if(m.shape==="scalar"&&m.kind!=="group"){let H=ye(e.goodDoc.data,m.path);typeof H=="boolean"&&!x()?se(o(m.path,!H)):he(m.id,"value")}else m.children.length&&F(m.id);break;case"F2":m&&he(m.id,"rename");break;case"Delete":case"Backspace":lt(e.selection.length?e.selection.map(Se):[T]);break;case"ContextMenu":m&&ut(m,t.querySelector(`[data-id="${CSS.escape(T)}"]`));break;case"F10":if(P.shiftKey&&m)ut(m,t.querySelector(`[data-id="${CSS.escape(T)}"]`));else return;break;case"+":case"Insert":m&&oe(m).length&&bs(oe(m),t.querySelector(`[data-id="${CSS.escape(T)}"]`),"Add");break;default:if(C&&P.key.toLowerCase()==="d"){ft(T);break}if(C&&P.key.toLowerCase()==="a"){Z(q.filter(H=>H),T);break}if(P.key.length===1&&!C&&/\S/.test(P.key)){let H=Date.now();B=H-S>700?P.key.toLowerCase():B+P.key.toLowerCase(),S=H;let $e=[...q.slice(U+(B.length===1?1:0)),...q.slice(0,U+1)].find(de=>(L.get(de)?.n.label??"").toLowerCase().startsWith(B));$e!==void 0&&(A=$e,Z([$e]));break}return}P.preventDefault()});let Pe;t.addEventListener("dragstart",P=>{let q=P.target.closest(".trow");q&&(Pe=q.dataset.id,P.dataTransfer?.setData("text/plain",et(Pe).join(".")),P.dataTransfer&&(P.dataTransfer.effectAllowed="move"))});let mt=P=>{let q=P.target.closest(".trow");if(!q||!Pe||q.dataset.id===Pe)return;let U=L.get(Pe)?.n,ae=L.get(q.dataset.id)?.n;if(!U||!ae||Se(U.path.slice(0,-1))!==Se(ae.path.slice(0,-1)))return;let m=q.getBoundingClientRect();return{r:q,a:U,b:ae,after:P.clientY>m.top+m.height/2}};t.addEventListener("dragover",P=>{for(let U of t.querySelectorAll(".drop-before, .drop-after"))U.classList.remove("drop-before","drop-after");let q=mt(P);q&&(P.preventDefault(),q.r.classList.add(q.after?"drop-after":"drop-before"))}),t.addEventListener("dragleave",P=>{if(P.target===t)for(let q of t.querySelectorAll(".drop-before, .drop-after"))q.classList.remove("drop-before","drop-after")}),t.addEventListener("drop",P=>{let q=mt(P);for(let H of t.querySelectorAll(".drop-before, .drop-after"))H.classList.remove("drop-before","drop-after");if(Pe=void 0,!q)return;P.preventDefault();let{a:U,b:ae,after:m}=q,C=U.path.slice(0,-1),R=H=>H[H.length-1];if(typeof R(U.path)=="number"){let H=R(U.path),ee=R(ae.path)+(m?1:0);ee>H&&(ee-=1),se(p(C,H,ee))&&(T=Se([...C,ee]),e.select([[...C,ee]],"tree"))}else{let H=(L.get(Se(C))?.n.children??[]).map(de=>String(R(de.path))),ee=H.indexOf(String(R(ae.path))),$e=m?H[ee+1]:H[ee];$e!==String(R(U.path))&&se(f(U.path,$e===void 0?void 0:$e)),T=U.id}N(),X(T)}),e.on(P=>{if(P.remap){for(let U of[...M]){let ae=P.remap(et(U));ae&&Se(ae)!==U&&(M.delete(U),M.add(Se(ae)))}let q=P.remap(et(T));q&&(T=Se(q))}P.kind==="load"&&(I=void 0,T=""),rr(P)?rt():rt.now()});let rt=or(()=>N());return e.onSelect(P=>{P.origin!=="tree"?V(P.paths):N()}),N(),{paint:N,dispose:()=>rt.cancel(),focus:()=>X(T),rows:()=>j.map(P=>({id:P.n.id,label:P.n.label,depth:P.depth,kind:P.n.kind,value:P.n.value,lifetime:P.n.lifetime})),startEdit:he,remove:lt,duplicate:ft,expand:P=>F(P,!0)}}var Md;function np(t,e){return Md?.close(),new Promise(n=>{let s=e.back??document.activeElement,r=`rename-${Math.random().toString(36).slice(2,8)}`,o=_("input",{type:"text",class:"rename-input","aria-label":t.label,"aria-describedby":r,spellcheck:"false",autocomplete:"off",autocapitalize:"off"}),i=_("p",{class:"rename-error",role:"alert",id:r}),a=_("div",{class:`rename-field${e.over?" over":""}`},o,i);o.value=t.value;let l=()=>{o.size=Math.max(8,Math.min(40,o.value.length+1))};l(),gs().append(a);let c=!1,d=0,u=e.at?{left:e.at.x,top:e.at.y,width:0,height:0}:void 0,f=()=>{let w=e.place();w&&(u=w);let k=e.bounds?.()??{left:0,top:0,right:innerWidth,bottom:innerHeight},y=o.getBoundingClientRect(),M=u??{left:(k.left+k.right)/2,top:k.top+48,width:0,height:0},T=(A,I,j)=>Math.max(I,Math.min(A,Math.max(I,j)));a.style.left=`${T(e.over?M.left-8:M.left+M.width/2-y.width/2,k.left+4,k.right-y.width-4)}px`,a.style.top=`${T(e.over?M.top+M.height/2-y.height/2:M.top-y.height-8,k.top+4,k.bottom-y.height-4)}px`},p=()=>{if(!c){if(t.alive&&!t.alive()){b(void 0,!1);return}f(),d=requestAnimationFrame(p)}},g=()=>{let w=t.wrong(o.value.trim());return i.textContent=w,o.setAttribute("aria-invalid",String(!!w)),w},h=()=>{let w=o.value.trim();return w!==t.value&&!t.wrong(w)?w:void 0};function b(w,k,y=!1){if(c)return;c=!0,cancelAnimationFrame(d),removeEventListener("pointerdown",v,!0),a.remove(),Md=void 0,k&&s?.isConnected&&s.focus({preventScroll:!0});let M=()=>{w!==void 0&&(!t.alive||t.alive())&&t.commit(w),n(w)};if(!y||w===void 0){M();return}let T=()=>{removeEventListener("pointerup",T,!0),removeEventListener("pointercancel",T,!0),setTimeout(A,0)},A=()=>{e.busy?.()?setTimeout(A,20):M()};addEventListener("pointerup",T,!0),addEventListener("pointercancel",T,!0)}let v=w=>{a.contains(w.target)||b(h(),!1,!!e.late?.contains(w.target))};addEventListener("pointerdown",v,!0),o.addEventListener("input",()=>{l(),g()}),o.addEventListener("keydown",w=>{if((w.metaKey||w.ctrlKey)&&w.key.toLowerCase()==="s"){b(h(),!0);return}if(w.stopPropagation(),!w.isComposing&&(w.key==="Escape"&&(w.preventDefault(),b(void 0,!0)),w.key==="Enter")){w.preventDefault();let k=o.value.trim();g()||b(k===t.value?void 0:k,!0)}}),o.addEventListener("keyup",w=>w.stopPropagation()),o.addEventListener("blur",()=>setTimeout(()=>{!c&&document.hasFocus()&&document.activeElement!==o&&document.activeElement!==document.body&&b(h(),!1)},0)),Md={close:()=>b(void 0,!1)},p(),o.focus({preventScroll:!0}),o.select()})}var Ll=(t,e)=>e.reduce((n,s)=>n&&typeof n=="object"?n[s]:void 0,t);function xn(t,e,n,s,r){try{return t.apply(e,n,r)}catch(o){return s?.(String(o.message),"bad"),!1}}function Er(t,e){return{label:t,remap:n=>e.reduce((s,r)=>s&&r.remap?r.remap(s):s,n),build:n=>{let s=[],r=!1;for(let o of e){let i=o.build(n);for(let a of i.steps)s.push(a),n=yn(n,a);r||=!!i.fallback}return{steps:s,fallback:r}}}}function Nl(t){let{deleteCmd:e,renameCmd:n,renameKeyCmd:s,referencesTo:r,describe:o,duplicateCmd:i}=t.commands,a=f=>{let p=t.objectOf(Se(f));return!!p&&p.path===Se(f)};async function l(f,p,g,h){let b=p.filter(T=>T.length&&!p.some(A=>A!==T&&A.length<T.length&&qt(A,T)));if(!b.length)return!1;let v=b.filter(a).flatMap(T=>{let A=t.objectOf(Se(T));return r(f.text,A.kind,A.name).filter(I=>!b.some(j=>qt(j,et(I.path)))).map(I=>({p:T,x:I}))}),w=!1;if(v.length){let T=await fo(`Delete ${b.length===1?o(b[0]):`${b.length} items`}?`,[_("p",{class:"sub"},`${v.length===1?"One place refers":`${v.length} places refer`} to ${b.length===1?"it":"them"}:`),_("ul",{class:"ref-list"},...v.map(({x:A})=>_("li",null,_("code",null,A.path.slice(1).replace(/\//g,".")),` \u2014 ${A.slot.what}`))),_("p",{class:"sub"},"Delete the references too, or leave them (the problems list will show them). Either way, Undo brings everything back.")],[{label:"Cancel",value:"cancel"},{label:"Delete only",value:"only",danger:!0},{label:"Delete with references",value:"with",danger:!0,primary:!0}]);if(!T)return!1;w=T==="with"}let y=[...b].sort((T,A)=>typeof T.at(-1)=="number"&&typeof A.at(-1)=="number"?A.at(-1)-T.at(-1):0).map(T=>e(T,{withRefs:w&&a(T)})),M=xn(f,y.length===1?y[0]:Er(`Delete ${b.length} items`,y),g,h);return M&&f.select([],g),M}async function c(f,p,g,h,b){let v=String(p[p.length-1]),w=a(p),k=p,y=f.on(A=>{k&&A.remap&&(k=A.remap(k))}),M=()=>t.kinds.flatMap(A=>Object.keys(Ll(f.goodDoc.data,A.section)??{})),T=!1;return await np({label:`Rename ${o(p)}`,value:v,wrong:A=>A?A===v?"":w&&!t.nameRule.test(A)?t.nameHint:M().includes(A)?`"${A}" is already used`:"":"A name is needed",alive:()=>!!k&&Ll(f.goodDoc.data,k)!==void 0,commit:A=>{k&&(T=xn(f,{...w?n(k,A):s(k,A),joined:I=>I.replace(` ${v}`,` ${A}`)},g,h,b.joins))}},b),y(),T}let d=(f,p,g,h)=>{let b=i(p);xn(f,b,g,h)&&b.select&&f.select(b.select,g)};function u(f,p){let g=new Map;for(let h of p){let b=t.objectOf(Se(h));if(!b)continue;g.set(b.path,et(b.path));for(let k of r(f.text,b.kind,b.name)){let y=t.objectOf(k.path);g.set(y?y.path:k.path,et(y?y.path:k.path))}let v=Ll(f.goodDoc.data,et(b.path)),w=JSON.stringify(v??{}).match(/[a-z][a-z0-9-]*/g)??[];for(let k of t.kinds)for(let y of Object.keys(Ll(f.goodDoc.data,k.section)??{}))if(w.includes(y)&&y!==b.name){let M=Se([...k.section,y]);g.set(M,et(M))}}return[...g.values()]}return{deletePaths:l,rename:c,duplicate:d,connected:u}}var Rl=(t,e)=>e.reduce((n,s)=>n&&typeof n=="object"?n[s]:void 0,t),Tr=t=>!!t&&typeof t=="object"&&!Array.isArray(t),ir=Symbol("mixed");function Il(t,e,n){let s,r=!1,o=n.kit,i=o.ui,{setCmd:a,deleteCmd:l,insertItemCmd:c,referencesTo:d,describe:u}=o.commands,{deletePaths:f,rename:p}=o.actions,g=S=>o.kinds.find(E=>E.kind===S),h=S=>g(S)?.singular??"item",b=S=>Object.keys(Rl(e.goodDoc.data,g(S)?.section??[])??{}).filter(E=>!E.startsWith("x-")),v=S=>xn(e,S,"props",n.note);function w(){if(t.contains(document.activeElement)&&document.activeElement.matches("input, textarea"))return;t.replaceChildren();let S=e.selection;if(!S.length){t.append(_("p",{class:"hint"},"Select something in the canvas, the tree or the text."));return}let E=S.map(we=>o.objectOf(Se(we)));if(S.length>1){if(new Set(E.map(F=>F?.kind)).size===1&&E.every(F=>F&&F.path===Se(et(F.path)))){let F=[...new Set(E.map(X=>X.path))].map(et);t.append(_("div",{class:"sel-title"},`${F.length} ${h(E[0].kind)}s`),_("div",{class:"sel-path"},F.map(X=>X[X.length-1]).join(", "))),k(F,E[0].kind)}else t.append(_("div",{class:"sel-title"},`${S.length} items`),_("ul",{class:"plain"},...S.map(F=>_("li",null,_("code",null,F.join(".")||i.rootItem)))));j();return}let x=S[0],N=E[0],z=N?et(N.path):x.length?x:[];if(!N){L(x);return}let Q=_("div",{class:"sel-headrow"},_("div",{class:"sel-title"},u(z))),re=_("button",{type:"button",class:"btn sm quiet icon-only","aria-label":`Rename ${u(z)}`,title:"Rename (F2)"},Ut("pencil"));re.addEventListener("click",()=>{p(e,z,"props",n.note,{over:!0,place:()=>Q.isConnected?Q.firstElementChild.getBoundingClientRect():void 0})}),Q.append(re),t.append(Q),Se(x)!==N.path&&(s=Se(x)),k([z],N.kind),A(N.kind,N.name),I(N.path),j()}function k(S,E){let x=n.nav(),N=e.goodDoc.data,z=S.map(oe=>Rl(N,oe)??{}),Q=z[0]&&Tr(z[0])?z[0]:{},re=z.some(oe=>i.isExternal(oe)),we=x.keys(S[0],re?{external:!0}:Q),F=Object.keys(Q),X=we.filter(oe=>z.some(ve=>Tr(ve)&&oe.name in ve)).sort((oe,ve)=>(F.indexOf(oe.name)+1||999)-(F.indexOf(ve.name)+1||999)),Z=n.read(),be=new Set([...X.map(oe=>oe.name),...i.important(E,z[0]??{},re),...S.length===1&&Z!==void 0&&i.inheritedKeys?i.inheritedKeys(S[0],Z):[]]),V=we.filter(oe=>!X.includes(oe)&&be.has(oe.name)),J=we.filter(oe=>!be.has(oe.name)),G=_("div",{class:"props"});for(let oe of[...X,...V])G.append(y(S,E,oe,z,Z));if(J.length&&e.doc.ok){let oe=_("select",{class:"padd","aria-label":"Add a property"},_("option",{value:""},"+ Add property"),...J.map(ve=>_("option",{value:ve.name,title:(ve.doc??"").replace(/`/g,"")},ve.name)));oe.addEventListener("change",()=>{let ve=oe.value;if(!ve)return;let ge=x.defaultFor([...S[0],ve]);s=Se([...S[0],ve]),r=!0,v(S.length===1?a([...S[0],ve],ge,`Add ${u([...S[0],ve])}`):Er(`Add ${ve} to ${S.length} ${h(E)}s`,S.map(ye=>a([...ye,ve],ge))))}),G.append(oe)}let ne=new Set(we.map(oe=>oe.name));for(let oe of new Set(z.flatMap(ve=>Tr(ve)?Object.keys(ve):[])))ne.has(oe)||G.append(y(S,E,{name:oe,shape:"scalar",enumValues:[],examples:[],doc:oe.startsWith("x-")?i.extensionDoc:"Not a key the schema knows."},z,Z));if(t.append(G),s){let oe=G.querySelector(`[data-path="${CSS.escape(s)}"]`);oe?.classList.add("focus-row"),oe?.scrollIntoView({block:"nearest"}),r&&oe?.querySelector("input, select, textarea")?.focus({preventScroll:!0}),s=void 0,r=!1}}function y(S,E,x,N,z){let Q=n.nav(),re=N.map(he=>Tr(he)?he[x.name]:void 0),F=re.every(he=>JSON.stringify(he)===JSON.stringify(re[0]))?re[0]:ir,X=re.some(he=>he!==void 0),Z=E&&S.length===1&&z!==void 0?i.inherited?.(S[0],x.name,z):void 0,be=S.map(he=>Se([...he,x.name])),V=_("div",{class:`prow${X?"":" unset"}`,"data-path":be[0]}),J=_("label",{class:"plabel",title:x.doc?.replace(/`/g,"")??""},x.name),G=`pf-${Math.random().toString(36).slice(2,8)}`;J.setAttribute("for",G),V.append(J);let ne=(he,ie)=>v(S.length===1?a([...S[0],x.name],he,ie):Er(ie??`Set ${x.name} on ${S.length} ${h(E)}s`,S.map(Ke=>a([...Ke,x.name],he)))),oe=()=>{let he=S.filter((ie,Ke)=>re[Ke]!==void 0);v(he.length===1?{...l([...he[0],x.name]),label:`Remove ${u([...he[0],x.name])}`}:Er(`Remove ${x.name} from ${he.length} ${h(E)}s`,he.map(ie=>l([...ie,x.name]))))},ve=o.slotAt(Se([...S[0],x.name])),ge=o.slotAt(Se([...S[0],x.name,0])),ye=Q.values([...S[0],x.name]),Ie=Q.types([...S[0],x.name]),Ue,D=F===ir?"(mixed)":"";if(ve||ye.length){let he=[...new Set([...ye,...ve?ve.targets.flatMap(Ke=>b(Ke).map(Oe=>ve.write?ve.write(Oe):Oe)).concat(ve.extra??[]):[]])],ie=_("select",{id:G,class:"pinput"});ie.append(_("option",{value:"\0"},D||"\u2014"));for(let Ke of he)ie.append(_("option",{value:Ke},Ke));F!==ir&&F!==void 0&&!he.includes(String(F))&&ie.append(_("option",{value:String(F)},String(F))),ie.value=F===ir||F===void 0?"\0":String(F),ie.addEventListener("change",()=>{if(ie.value==="\0"){X&&oe();return}ne(ye.includes("true")&&(ie.value==="true"||ie.value==="false")?ie.value==="true":ie.value)}),Ue=ie}else if(ge&&S.length===1){let he=Array.isArray(F)?F:[],ie=_("div",{class:"chips"});he.forEach((Oe,Te)=>{let je=_("button",{type:"button",class:"chip-x","aria-label":`Remove ${Oe}`},"\xD7");je.addEventListener("click",()=>v({...l([...S[0],x.name,Te]),label:`Remove ${Oe} from ${u([...S[0],x.name])}`})),ie.append(_("span",{class:"chip"},String(Oe),je))});let Ke=[...new Set(ge.targets.flatMap(Oe=>b(Oe)).concat(ge.extra??[]))].filter(Oe=>!he.includes(Oe));if(Ke.length){let Oe=_("select",{id:G,class:"pinput chip-add","aria-label":`Add to ${x.name}`},_("option",{value:""},"+ add"),...Ke.map(Te=>_("option",{value:Te},Te)));Oe.addEventListener("change",()=>{Oe.value&&v(c([...S[0],x.name],Oe.value,void 0,`Add ${Oe.value} to ${u([...S[0],x.name])}`))}),ie.append(Oe)}Ue=ie}else if(x.name==="prompt"||typeof F=="string"&&F.includes(`
|
|
465
|
+
`)){let he=_("textarea",{id:G,class:"pinput",rows:"5",spellcheck:"false",placeholder:D});he.value=typeof F=="string"?F:"",he.addEventListener("change",()=>{let ie=he.value;ie===""&&X?oe():ie!==F&&ne(ie.endsWith(`
|
|
466
|
+
`)||!ie.includes(`
|
|
467
|
+
`)?ie:ie+`
|
|
468
|
+
`)}),Ue=he}else if(x.shape==="scalar"&&(F===void 0||F===ir||typeof F!="object")){let he=_("input",{id:G,class:"pinput",type:Ie.has("integer")||Ie.has("number")?"number":"text",spellcheck:"false",autocomplete:"off",placeholder:D});he.value=F===void 0||F===ir?"":String(F),he.addEventListener("change",()=>{let ie=he.value;if(ie===""){X&&oe();return}let Ke=(Ie.has("integer")||Ie.has("number"))&&/^-?\d+(\.\d+)?$/.test(ie)?Number(ie):ie;Ke!==F&&ne(Ke)}),he.addEventListener("keydown",ie=>{ie.key==="Enter"&&he.blur()}),Ue=he}else{let he=_("input",{id:G,class:"pinput mono",spellcheck:"false",autocomplete:"off",placeholder:D||(x.shape==="list"?"[a, b]":"{ key: value }")});he.value=F===void 0||F===ir?"":pn(F),he.addEventListener("change",()=>{if(he.value.trim()===""){X&&oe();return}let ie;try{ie=Go(he.value)}catch(Ke){he.setAttribute("aria-invalid","true"),he.title=`Not YAML: ${Ke.message}`;return}he.removeAttribute("aria-invalid"),JSON.stringify(ie)!==JSON.stringify(F)&&ne(ie)}),he.addEventListener("keydown",ie=>{ie.key==="Enter"&&he.blur()}),Ue=he}let se=F===void 0||F===ir?"":M(F);if(se&&(Ue.title=se),Z&&!X){V.classList.add("inherited"),V.append(_("div",{class:"pinherit",title:M(Z.value)},M(Z.value)));let he=_("div",{class:"pfrom"},`inherited from ${Z.from??i.inheritedFrom}`),ie=_("button",{type:"button",class:"btn sm quiet poverride",title:`Write ${x.name}: ${M(Z.value)} in this file, to change it here`},"Override");ie.addEventListener("click",()=>{s=be[0],r=!0,ne(Z.value,`Override ${u([...S[0],x.name])}`)}),V.append(he,ie);let Ke=n.problems().filter(Oe=>be.some(Te=>Oe.path===Te||Oe.path.startsWith(Te+"/")));for(let Oe of Ke)V.append(_("div",{class:`pprob ${Oe.severity}`},Ut(Oe.severity==="error"?"circle-x":"triangle-alert"),Oe.message));return V}V.append(Ue);let Me=_("span",{class:"pacts"});if(Z&&X){let he=_("button",{type:"button",class:"btn sm quiet",title:`Remove this file's value: ${M(Z.value)} applies again`},"Reset");he.addEventListener("click",oe),Me.append(he)}else if(X&&Ue.tagName!=="SELECT"){let he=_("button",{type:"button",class:"btn sm quiet icon-only","aria-label":`Remove ${x.name}`,title:`Remove ${x.name}`},Ut("x"));he.addEventListener("click",oe),Me.append(he)}V.append(Me),Z&&V.append(_("div",{class:"pfrom"},`overrides ${M(Z.value)} from ${Z.from??i.inheritedFrom}`));let Ce=n.problems().filter(he=>be.some(ie=>he.path===ie||he.path.startsWith(ie+"/")));for(let he of Ce)V.append(_("div",{class:`pprob ${he.severity}`},Ut(he.severity==="error"?"circle-x":"triangle-alert"),he.message));return V}let M=S=>S===null||typeof S!="object"?String(S):pn(S);function T(S){let E=n.now&&i.facts?i.facts(n.now(S)):void 0;if(!E)return;if(t.append(_("div",{class:"sel-head"},"Now")),!E.length){t.append(_("p",{class:"hint now-unknown"},"Not known: the host has said nothing about it."));return}let x=_("dl",{class:"now"});for(let N of E)x.append(_("dt",null,N.term),_("dd",N.cls?{class:N.cls}:null,N.def));t.append(x)}function A(S,E){T(Se([...g(S)?.section??[],E]));let x=d(e.text,S,E);if(t.append(_("div",{class:"sel-head"},x.length?`Used in ${x.length} place${x.length>1?"s":""}`:"Not referenced")),!x.length)return;let N=_("ul",{class:"plain sel-refs"});for(let z of x){let Q=_("button",{type:"button",class:"linkish"},z.path.slice(1).replace(/\//g,"."));Q.addEventListener("click",()=>e.select([et(z.path)],"props")),N.append(_("li",null,Q,_("span",{class:"hint"},` ${z.slot.what}`)))}t.append(N)}function I(S){let E=n.problems().filter(x=>x.path===S&&!x.file);E.length&&t.append(_("div",{class:"sel-head"},"Problems"),...E.map(x=>_("div",{class:`sel-prob ${x.severity}`},Ut(x.severity==="error"?"circle-x":"triangle-alert"),_("span",null,x.message))))}function j(){if(!e.doc.ok||!e.selection.some(E=>E.length))return;let S=_("button",{type:"button",class:"btn sm danger props-delete"},Ut("trash-2"),e.selection.length>1?`Delete ${e.selection.length} items`:"Delete");S.addEventListener("click",()=>f(e,e.selection,"props",n.note)),t.append(S)}function L(S){let E=n.nav();t.append(_("div",{class:"sel-title"},S.length?u(S):i.rootTitle),_("code",{class:"sel-path"},S.join(".")||"(the whole file)"));let x=E.hover(S);x&&S.length&&t.append(_("p",{class:"sel-doc"},x.split(`
|
|
469
469
|
|
|
470
|
-
`)[0].replace(/`/g,"")));let N=ll(e.goodDoc.data,S);if(o.kinds.some(ee=>Me(ee.section)===Me(S))){let ee=gr(N)?Object.keys(N).length:0;t.append(z("p",null,`${ee} ${ee===1?"entry":"entries"}. Add one from the tree's +, or the canvas's menu.`));return}let J=S.length?gr(N)?S:S.slice(0,-1):[],ae=ll(e.goodDoc.data,J);if(!gr(ae)&&J.length)return;let we=new Set(o.kinds.map(ee=>String(ee.section[0]))),j=$.keys(J,ae??{}).filter(ee=>!we.has(ee.name)||J.length),U=z("div",{class:"props"});for(let ee of j)U.append(x([J],"",ee,[ae??{}],void 0));if(t.append(U),S.length&&Me(S)!==Me(J)){let ee=U.querySelector(`[data-path="${CSS.escape(Me(S))}"]`);ee?.classList.add("focus-row"),ee?.scrollIntoView({block:"nearest"})}}t.addEventListener("focusout",()=>setTimeout(()=>{t.contains(document.activeElement)||v()},0)),e.onSelect(()=>v());let _=qs(()=>v());return e.on(S=>{Ys(S)?_():_.now()}),{paint:v,dispose:()=>_.cancel()}}var on="http://www.w3.org/2000/svg";function dl(t,e,n){let s=n.kit,r=s.ui,o=r.text,{setCmd:i,deleteCmd:a,insertCmd:l,insertItemCmd:c,pinsCmd:d,withPinsMoved:u,freshName:f,describe:p}=s.commands,{deletePaths:g,renameDialog:h,duplicate:b,connected:k}=s.actions,v=P=>s.objectOf(P),M=P=>s.kinds.find(R=>R.kind===P),x=s.pins.key,T;t.classList.add("canvas");let y=z("div",{class:`${r.rootClass} canvas-stage`,tabindex:"0",role:"application","aria-label":o.stage}),A=z("div",{class:"canvas-tools",role:"toolbar","aria-label":"Canvas"}),D=z("button",{type:"button",class:"btn sm quiet icon-only","aria-label":"Zoom out (\u2212)",title:"Zoom out (\u2212)"},"\u2212"),K=z("button",{type:"button",class:"btn sm quiet zoom-label",title:"Fit (0) \xB7 100% (1)"},"100%"),C=z("button",{type:"button",class:"btn sm quiet icon-only","aria-label":"Zoom in (+)",title:"Zoom in (+)"},"+"),_=z("button",{type:"button",class:"btn sm quiet",title:"Fit (0)"},"Fit"),S=(P,R,V)=>{let W=z("div",{class:"segmented",role:"group","aria-label":P,title:P});for(let[oe,se,ie]of V){let le=z("button",{type:"button",class:"seg","data-v":oe,title:ie},se);le.addEventListener("click",()=>{fe[R]=oe,X(),Q()}),W.append(le)}return W},$=S("The wheel","wheel",[["zoom","Zoom","The wheel zooms around the pointer; \u21E7-wheel pans sideways"],["scroll","Scroll","The wheel pans; \u21E7-wheel pans sideways; a pinch zooms"]]),w=S(o.dragGroup,"drag",[["pan","Pan","Drag pans; \u21E7- or \u2318-drag draws a selection"],["select","Select",o.dragSelectTip]]),N="3d",F,J,ae=async()=>J??=await s.flat.load(),we=z("div",{class:"segmented view-seg",role:"group","aria-label":"The view"});for(let[P,R,V]of[["3d","3D","3D: the drawing; drag a selected thing to move it"],["2d","2D","2D: select, rename, delete, add from the palette and edit here; moving is in 3D"]]){let W=z("button",{type:"button",class:"seg","data-v":P,title:V},R);W.addEventListener("click",()=>B(P)),we.append(W)}let j={host:t,doc:e,cd:()=>te,svg:()=>ne,elementsFor:P=>G(P),boxOf:P=>Z(P),union:P=>Se(P),outlinesFor:P=>Ie(P),scale:()=>Ze(),full:()=>Ne.full,toSvg:(P,R)=>at(P,R),autoFit:()=>de(),paint:()=>De(),reveal:P=>dt(P),note:(P,R)=>n.note(P,R)},U=n.layer?.(j);A.append(...U?.tools??[],...s.flat?[we]:[],$,w,D,K,C,_);let ee=z("div",{class:"canvas-empty",hidden:!0});t.append(y,A,ee,...U?.marks??[]);let fe={wheel:"zoom",drag:"pan"};try{Object.assign(fe,JSON.parse(n.store?.get("canvas-nav")??"{}"))}catch{}s.flat&&n.store?.get("canvas-view")==="2d"&&(N="2d");function B(P){if(!s.flat||P===N)return;ze();let R=N;N=P,n.store?.set("canvas-view",P),Q(),ne&&te&&ne.parentNode===y&&(be={svg:ne,mode:R}),re!==void 0&&(Ne.view=void 0,ye="",I(re,$e))}let X=()=>n.store?.set("canvas-nav",JSON.stringify(fe));function Q(){for(let[P,R]of[[$,fe.wheel],[w,fe.drag],[we,N]])for(let V of P.querySelectorAll(".seg"))V.setAttribute("aria-pressed",String(V.dataset.v===R));if(ne?.classList.toggle("mode-pan",fe.drag==="pan"),ne?.classList.toggle("mode-select",fe.drag==="select"),Ce?.kind==="pin"&&Ce.moved){ne?.classList.add("dragging"),ne?.classList.toggle("drag-bad",!!Ce.invalid);return}n.onHint?.(`${fe.drag==="pan"?"Drag: pan \xB7 \u21E7-drag: select":"Drag: select \xB7 space-drag: pan"} \xB7 Wheel: ${fe.wheel==="zoom"?"zoom":"scroll"}`)}let te,ne,me,ye="",xe,Re=()=>document,Ue=!1;async function I(P,R){if(Ue)return;if(!P){Be(o.unreadable);return}let V=JSON.stringify(R);if(V===ye&&ne){pt()||De();return}if(N==="2d"&&!J)try{await ae()}catch(oe){N="3d",Q(),n.note(`The 2D view couldn't load: ${oe.message}`,"warn")}let W;try{W=s.draw(P,R,n.theme)}catch(oe){Be(`The canvas couldn't draw this: ${oe.message}`);return}if(W.diags.length){Be(`The canvas couldn't draw this: ${W.diags[0]}`);return}if(ye=V,re=P,$e=R,pt()){Pe=!0;return}await Ee(W),te.pinNotes.length&&n.note(`Pins: ${te.pinNotes.join("; ")}`,"warn")}let re,$e,Pe=!1,be,ce;function ze(){if(!ce)return;let P=ce;ce=void 0,P.m.finish(),P.from.remove(),P.to.style.visibility=""}function Oe(P,R){let V=J?.morph?.(y,te.scene,P,R,{motion:s.flat?.motion,duration:s.flat?.duration});if(!V){P.svg.remove();return}P.svg.style.visibility="hidden",R.style.visibility="hidden";let W={m:V,from:P.svg,to:R};ce=W,y.classList.add("morphing"),V.done.then(()=>{ce===W&&ze(),y.classList.remove("morphing")})}async function Ee(P){ze();let R,V=P.scene.rendered.viewBox;try{if(N==="2d"&&J){F=J.draw(P.scene,y,{styles:s.flat?.styles,title:s.flat?.title,options:s.flat?.options}),V=F.full,R=To(F.svg);for(let pe of R.querySelectorAll("[tabindex]"))pe.removeAttribute("tabindex"),pe.removeAttribute("role")}else F=void 0,R=To(P.svg)}catch(pe){Be(`The canvas couldn't draw this: ${pe.message}`);return}te=P,R.classList.add("scene"),R.removeAttribute("width"),R.removeAttribute("height"),R.setAttribute("preserveAspectRatio","xMidYMid meet"),R.setAttribute("aria-hidden","true"),me=document.createElementNS(on,"g"),me.setAttribute("class","overlay"),me.setAttribute("fill","none"),me.setAttribute("stroke","currentColor"),me.setAttribute("pointer-events","none"),R.append(me,...U?.groups?.()??[]);let W=be;be=void 0,W&&ne===W.svg&&ne.parentNode===y?(W.svg.querySelector(".overlay")?.replaceChildren(),W.svg.style.position="absolute",W.svg.style.inset="0",y.append(R)):ne?.parentNode===y?ne.replaceWith(R):y.append(R),ne=R;let[oe,se,ie,le]=V;Ne.full={x:oe,y:se,w:ie,h:le},Ne.view?ft(ot):(Ne.view={...Ne.full},de()),ee.hidden=!0,U?.drawn?.(),ut&&yt(ut)&&(ut=void 0),Q(),De(),W&&W.svg!==R&&(getComputedStyle(y).position==="static"&&(y.style.position="relative"),Oe(W,R))}function Be(P){be=void 0,ee.textContent=P,ee.hidden=!1}function it(P){De()}function We(){if(!te||!ne)return;let P=[...new Set([...te.pathOf.values()].filter(V=>{let W=v(V);return W&&W.path===V}))],R=U?.extent?.()??[];return Se([...P.flatMap(V=>G(V)).filter(V=>V.getBBox().width||V.getBBox().height).map(Z),...R])}let Ne=va(t,{svg:()=>ne,onApply:P=>{ne.classList.toggle("zoom-near",P>=1);let R=Math.round(P*100);K.textContent=`${R}%`,n.onZoom(R)},onRezoom:()=>De(),itemsBox:()=>We(),marksShowing:()=>!!U?.showing?.()}),{size:gt,scale:Ze,quietly:ft,applyView:ot,toSvg:at,zoomAt:E,fit:Y,fitItems:q,autoFit:de,actual:m,settled:O}=Ne;function L(){let P=Ke(e.selection);P&&Y({x:P.x-20,y:P.y-20,w:P.w+40,h:P.h+40})}C.addEventListener("click",()=>E(1.25)),D.addEventListener("click",()=>E(.8)),K.addEventListener("click",()=>q()),_.addEventListener("click",()=>q());let G=P=>!ne||!te?[]:[...te.pathOf.entries()].filter(([,V])=>V===P||P&&V.startsWith(P+"/")&&!1).map(([V])=>V).flatMap(V=>[...ne.querySelectorAll(`[data-id="${CSS.escape(V)}"]`)]).filter(V=>!V.closest(".pre")&&!V.classList.contains("pre")),Z=P=>{let R=P.getBBox(),V=P.getCTM(),W=ne.getCTM();if(!V||!W)return{x:R.x,y:R.y,w:R.width,h:R.height};let oe=W.inverse().multiply(V),se=[[R.x,R.y],[R.x+R.width,R.y],[R.x,R.y+R.height],[R.x+R.width,R.y+R.height]].map(([pe,ge])=>({x:oe.a*pe+oe.c*ge+oe.e,y:oe.b*pe+oe.d*ge+oe.f})),ie=se.map(pe=>pe.x),le=se.map(pe=>pe.y);return{x:Math.min(...ie),y:Math.min(...le),w:Math.max(...ie)-Math.min(...ie),h:Math.max(...le)-Math.min(...le)}},Se=P=>{if(!P.length)return;let R=Math.min(...P.map(se=>se.x)),V=Math.min(...P.map(se=>se.y)),W=Math.max(...P.map(se=>se.x+se.w)),oe=Math.max(...P.map(se=>se.y+se.h));return{x:R,y:V,w:W-R,h:oe-V}},ue=P=>{let R=Me(P),V=G(R),W=v(R);return!V.length&&W&&W.path!==R&&(V=G(W.path)),V.length?Se(V.filter(oe=>oe.getBBox().width||oe.getBBox().height).map(Z)):void 0},Ke=P=>Se(P.map(ue).filter(R=>!!R)),Ye=P=>{let R=P?.closest?.("[data-id]");if(!R||!te)return;let V=R;for(;V;){let W=V.getAttribute("data-id");if(W&&te.pathOf.has(W))return te.pathOf.get(W);V=V.parentElement?.closest("[data-id]")??null}};function Ie(P){if(!te)return[];let R=[],V=new Set([...te.pathOf].filter(([,W])=>W===P).map(([W])=>W));if(F&&ne)return F.outlines(V,ne);for(let[W,oe]of te.pathOf){if(oe!==P)continue;let se=te.scene.layout.byId.get(W),ie=se?.parent;for(;ie&&!V.has(ie.id);)ie=ie.parent;if(!ie)if(se){if(ne?.querySelector(`[data-id="${CSS.escape(W)}"].pre`))continue;let le=Ft(s.catalog,se.region?.kind)?.shape,pe=se.type==="node"||le==="slab"||le==="block";R.push({kind:"poly",id:W,points:pe?xa(se.box):Ir(se.box)})}else te.scene.rendered.paths[W]&&!ne?.querySelector(`[data-id="${CSS.escape(W)}"].pre`)&&R.push({kind:"route",d:te.scene.rendered.paths[W]})}return R}function De(){if(Ne.painted(Ne.view?Ze():0),!me||!ne)return;let P=Re();me.replaceChildren();let R=(le,pe,ge=4)=>{let Te=P.createElementNS(on,"rect");Te.setAttribute("class",pe),Te.setAttribute("x",String(le.x-ge)),Te.setAttribute("y",String(le.y-ge)),Te.setAttribute("width",String(le.w+ge*2)),Te.setAttribute("height",String(le.h+ge*2)),Te.setAttribute("rx","6"),me.append(Te)},V=(le,pe)=>{let ge=v(le),Te=Ie(le);if(!Te.length&&ge&&ge.path!==le&&(Te=Ie(ge.path)),!Te.length){let qe=ue(nt(le));qe&&R(qe,pe,pe==="hover"?3:4);return}for(let qe of Te)if(qe.kind==="route"){let Le=P.createElementNS(on,"path");Le.setAttribute("class",pe==="ring"?"route-ring":"route-hover"),Le.setAttribute("d",qe.d),me.append(Le)}else{let Le=P.createElementNS(on,"polygon");Le.setAttribute("class",pe),Le.setAttribute("points",qe.points.map(([ct,Je])=>`${ct.toFixed(1)},${Je.toFixed(1)}`).join(" ")),Le.setAttribute("data-for",qe.id),me.append(Le)}};xe!==void 0&&!e.selection.some(le=>Me(le)===xe)&&V(xe,"hover");for(let le of e.selection)V(Me(le),"ring");let W=bt(),oe=T?.from??W,se=oe?ue(nt(oe.path)):void 0;if(se&&s.connect){let le=Ze(),pe=se.x+se.w+10/le,ge=se.y+se.h/2;if(T&&T.x!==void 0&&T.y!==void 0){T.over&&V(T.over,"hover");let Te=P.createElementNS(on,"line");Te.setAttribute("class",`connect-line${T.over?" ok":""}`),Te.setAttribute("x1",String(pe)),Te.setAttribute("y1",String(ge)),Te.setAttribute("x2",String(T.x)),Te.setAttribute("y2",String(T.y)),me.append(Te)}if(!T){let Te=P.createElementNS(on,"circle");Te.setAttribute("class","connect-handle"),Te.setAttribute("cx",String(pe)),Te.setAttribute("cy",String(ge)),Te.setAttribute("r",String(7/le)),Te.style.pointerEvents="all",Te.style.cursor="crosshair";let qe=P.createElementNS(on,"title");qe.textContent=`Drag to what ${oe.name} connects to`,Te.append(qe),me.append(Te)}}let ie=new Map;for(let le of n.problems()){if(le.file)continue;let pe=v(le.path);if(!pe)continue;let ge=ie.get(pe.path)??{e:0,w:0};le.severity==="error"?ge.e++:ge.w++,ie.set(pe.path,ge)}for(let[le,pe]of ie){let ge=G(le).filter(ds=>te.scene.layout.byId.has(ds.getAttribute("data-id")??"")),Te=Se(ge.map(Z));if(!Te)continue;let qe=P.createElementNS(on,"g");qe.setAttribute("class",`badge${pe.e?"":" warn"}`);let Le=Ze(),ct=Te.x+Te.w,Je=Te.y,Rt=9/Le,Ge=P.createElementNS(on,"circle");Ge.setAttribute("cx",String(ct)),Ge.setAttribute("cy",String(Je)),Ge.setAttribute("r",String(Rt));let $t=P.createElementNS(on,"text");$t.setAttribute("x",String(ct)),$t.setAttribute("y",String(Je)),$t.style.fontSize=`${(11/Le).toFixed(2)}px`,$t.textContent=String(pe.e||pe.w),qe.append(Ge,$t),me.append(qe)}U?.paint?.(P)}let Ce,vt=!1,Mn=()=>{y.addEventListener("pointerdown",Et),y.addEventListener("pointermove",bn),y.addEventListener("pointerup",fn),y.addEventListener("pointercancel",fn),y.addEventListener("wheel",Ae,{passive:!1}),y.addEventListener("contextmenu",Fe),y.addEventListener("dblclick",P=>{let R=Ye(P.target);R!==void 0&&n.showInText(nt(R))})},kt=P=>({x:P.clientX,y:P.clientY}),St=P=>{try{y.setPointerCapture(P.pointerId)}catch{}};function Et(P){if(y.focus({preventScroll:!0}),U?.down?.(P))return;let{x:R,y:V}=kt(P);if(P.button===0&&T?.pick){P.preventDefault(),et(Ye(P.target));return}if(P.button===0&&P.target?.closest?.(".connect-handle")){let qe=bt();if(qe){St(P),P.preventDefault();let Le=at(R,V);T={from:qe,x:Le.x,y:Le.y},De();return}}(P.button===0||P.button===1)&&St(P);let W=()=>{Ce={kind:"pan",x0:R,y0:V,v0:{...Ne.view}},ne?.classList.add("panning"),P.preventDefault()};if(P.button===1||vt){W();return}if(P.button!==0)return;let oe=Ye(P.target);if(oe===void 0){let qe=P.shiftKey||P.metaKey||P.ctrlKey;if(fe.drag==="pan"&&!qe){Ce={kind:"pan",x0:R,y0:V,v0:{...Ne.view},emptyClick:!0},ne?.classList.add("panning");return}let Le=fe.drag==="select"&&qe;Ce={kind:"marquee",x0:R,y0:V,sel0:Le?e.selection:[],add:Le,touch:P.altKey};return}let se=nt(oe),ie=e.selection.map(Me);if(P.shiftKey||P.metaKey||P.ctrlKey){e.select(ie.includes(oe)?e.selection.filter(qe=>Me(qe)!==oe):[...e.selection,se],"canvas");return}ie.includes(oe)||e.select([se],"canvas");let le=ie.includes(oe)&&ie.length>1?oe:void 0;Ce={kind:"click",x0:R,y0:V,ptr:le};let pe=v(oe),ge=pe&&pe.path===oe?pe.name:void 0,Te=ge&&N==="3d"?te?.pinId.get(ge):void 0;if(Te&&te){let qe=te.scene.layout.byId.get(Te),Le=Rr(te.scene,Te);if(qe&&Le){let ct=qe.box,Je=qe.parent,Rt=(Je?Je.children:te.scene.layout.items.filter(Ge=>!Ge.parent)).filter(Ge=>Ge!==qe).map(Ge=>({x0:Ge.box.x0,y0:Ge.box.y0,x1:Ge.box.x1,y1:Ge.box.y1}));Ce={kind:"pin",x0:R,y0:V,name:ge,id:Te,ptr:oe,narrow:le,start:Le,shown:Le,z0:ct.z0,size:[ct.x1-ct.x0,ct.y1-ct.y0],siblings:Rt,parent:Je?{w:Je.box.x1-Je.box.x0,d:Je.box.y1-Je.box.y0,pad:Do(s.catalog,Je.region),box:Je.box,label:Je.region?.label??Je.id}:void 0,origCd:te}}}}function bn(P){let{x:R,y:V}=kt(P);if(T){let oe=at(R,V),se=Ye(document.elementFromPoint(R,V)),ie=se===void 0?void 0:v(se);T={...T,x:oe.x,y:oe.y,over:ie&&ie.path!==T.from.path?ie.path:void 0},De();return}if(!Ce){let oe=Ye(P.target);oe!==xe&&(xe=oe,De());return}let W=Ze();if(Ce.kind==="click"&&N==="2d"&&!Ce.moved&&Math.hypot(R-Ce.x0,V-Ce.y0)>4){Ce.moved=!0,n.onHint?.("Moving is in 3D: switch to 3D to drag it where it goes");return}if(Ce.kind==="pan")Math.hypot(R-Ce.x0,V-Ce.y0)>3&&(Ce.emptyClick=!1),Ne.view={...Ce.v0,x:Ce.v0.x-(R-Ce.x0)/W,y:Ce.v0.y-(V-Ce.y0)/W},ot();else if(Ce.kind==="marquee"){if(Math.hypot(R-Ce.x0,V-Ce.y0)<3)return;Ce.moved=!0;let oe=at(Ce.x0,Ce.y0),se=at(R,V);if(F){Yt(oe,se);return}let[ie,le]=ws(oe.x,oe.y),[pe,ge]=ws(se.x,se.y),Te={x0:Math.min(ie,pe),y0:Math.min(le,ge),x1:Math.max(ie,pe),y1:Math.max(le,ge)},qe=new Map;for(let[Je,Rt]of Jt()){let Ge=Rt,$t=Ge.x0>=Te.x0&&Ge.y0>=Te.y0&&Ge.x1<=Te.x1&&Ge.y1<=Te.y1,ds=Ge.x0<Te.x1&&Ge.x1>Te.x0&&Ge.y0<Te.y1&&Ge.y1>Te.y0;(Ce.touch?ds:$t)&&qe.set(Je,nt(Je))}let Le=new Map((Ce.sel0??[]).map(Je=>[Me(Je),Je]));for(let[Je,Rt]of qe)Le.set(Je,Rt);e.select([...Le.values()],"canvas"),De();let ct=Re().createElementNS(on,"polygon");ct.setAttribute("class","marquee"),ct.setAttribute("points",[[Te.x0,Te.y0],[Te.x1,Te.y0],[Te.x1,Te.y1],[Te.x0,Te.y1]].map(([Je,Rt])=>Xe(Je,Rt,0).map(Ge=>Ge.toFixed(1)).join(",")).join(" ")),me.append(ct),Mt=Te}else if(Ce.kind==="pin"){if(!Ce.moved&&Math.hypot(R-Ce.x0,V-Ce.y0)<4)return;if(Ce.moved=!0,Ot={x:R,y:V,alt:P.altKey},!Pt){Pt=!0;let oe=()=>{Pt&&(Pt=!1,as())};requestAnimationFrame(oe),setTimeout(oe,32)}}}function Yt(P,R){if(!Ce||!F||!te)return;let V={l:Math.min(P.x,R.x),t:Math.min(P.y,R.y),r:Math.max(P.x,R.x),b:Math.max(P.y,R.y)},W=new Map;for(let ie of F.hits(V,!!Ce.touch)){let le=te.pathOf.get(ie);le!==void 0&&v(le)?.path===le&&W.set(le,nt(le))}let oe=new Map((Ce.sel0??[]).map(ie=>[Me(ie),ie]));for(let[ie,le]of W)oe.set(ie,le);e.select([...oe.values()],"canvas"),De();let se=Re().createElementNS(on,"rect");se.setAttribute("class","marquee"),se.setAttribute("x",String(V.l)),se.setAttribute("y",String(V.t)),se.setAttribute("width",String(V.r-V.l)),se.setAttribute("height",String(V.b-V.t)),me.append(se)}let Pt=!1,Ot,_t=0,pt=()=>Ce?.kind==="pin"&&Ce.moved?Ce:void 0;function as(){let P=pt();if(!P||!Ot||!te)return;let R=Ze(),V=Ot.alt?.5:1;P.step=V;let W=Fo(P.start,ws((Ot.x-P.x0)/R,(Ot.y-P.y0)/R),V,P.size,P.parent),oe=P.parent?P.parent.box.x0:0,se=P.parent?P.parent.box.y0:0,ie={x0:oe+W.at[0],y0:se+W.at[1],x1:oe+W.at[0]+P.size[0],y1:se+W.at[1]+P.size[1]},le=!P.move||P.move.at[0]!==W.at[0]||P.move.at[1]!==W.at[1];P.move=W,P.invalid=rr(ie,P.siblings),ne?.classList.add("dragging"),ne?.classList.toggle("drag-bad",P.invalid),Yn(P.id,[W.at[0]-P.shown[0],W.at[1]-P.shown[1]]),ls(ie);let pe=P.parent?`within ${P.parent.label}`:"on the canvas";n.onHint?.(`Moving ${P.name} ${pe} \xB7 ${V===1?"whole cells (\u2325: half cells)":"half cells"} \xB7 ${P.invalid?"overlaps: it won't drop here":"Esc cancels"}${o.pinHint}`),le&&!P.invalid&&re&&(clearTimeout(_t),_t=window.setTimeout(async()=>{let ge=pt();if(!ge||ge.invalid||!ge.move)return;let Te;try{({next:Te,keep:ge.keep}=Ht(ge))}catch{return}pt()===ge&&(await Ee(Te),pt()===ge&&(ge.shown=ge.move.at,Yn(ge.id,[0,0]),ls(ge.parent?{x0:ge.parent.box.x0+ge.move.at[0],y0:ge.parent.box.y0+ge.move.at[1],x1:ge.parent.box.x0+ge.move.at[0]+ge.size[0],y1:ge.parent.box.y0+ge.move.at[1]+ge.size[1]}:ie)))},0))}function Ht(P){let R=JSON.parse(JSON.stringify($e??{}));s.pins.legacyOnly(R)&&(R[x]=R[s.pins.legacyKey],delete R[s.pins.legacyKey]),R[x]??={},R[x].layout??={};let V=R[x].layout;V[P.name]={at:P.move.at};let W=s.draw(re,R,n.theme),oe=P.origCd,se=new Map([...oe.pinId].map(([ge,Te])=>[Te,ge])),ie=oe.scene.layout.byId.get(P.id),le=ie.parent?ie.parent.children:oe.scene.layout.items.filter(ge=>!ge.parent),pe=[];for(let ge of le){if(ge===ie)continue;let Te=se.get(ge.id),qe=Rr(oe.scene,ge.id),Le=W.scene.layout.byId.get(ge.id)?.box;!Te||!qe||!Le||Te in V||(Math.abs(Le.x0-ge.box.x0)>1e-6||Math.abs(Le.y0-ge.box.y0)>1e-6)&&pe.push([Te,qe])}if(pe.length){for(let[ge,Te]of pe)V[ge]={at:Te};W=s.draw(re,R,n.theme)}return{next:W,keep:pe}}function Yn(P,[R,V]){if(!ne||!te)return;let[W,oe]=[(R-V)*It*xt,(R+V)*.5*xt],se=new Set([P]);for(let ie of te.scene.layout.items){let le=ie.parent;for(;le;){if(le.id===P){se.add(ie.id);break}le=le.parent}}for(let ie of ne.querySelectorAll("[data-id]"))se.has(ie.getAttribute("data-id")??"")&&(ie.parentElement?.closest(`[data-id="${CSS.escape(ie.getAttribute("data-id"))}"]`)||ie.setAttribute("transform",R||V?`translate(${W.toFixed(1)} ${oe.toFixed(1)})`:""))}function ls(P){let R=pt();if(!R||!me)return;De();let V=Re(),W=V.createElementNS(on,"g");W.setAttribute("class",R.gridShown?"gridwrap":"gridwrap fresh"),R.gridShown=!0;let oe=R.z0,se=(Le,ct)=>Xe(Le,ct,oe).map(Je=>Je.toFixed(1)).join(","),ie=R.parent?R.parent.box:{x0:Math.floor(P.x0)-8,y0:Math.floor(P.y0)-8,x1:Math.ceil(P.x1)+8,y1:Math.ceil(P.y1)+8},le=(Le,ct,Je,Rt,Ge)=>{let $t=V.createElementNS(on,"polyline");$t.setAttribute("class",Ge),$t.setAttribute("points",`${se(Le,ct)} ${se(Je,Rt)}`),W.append($t)},pe=R.parent?R.parent.box.x0:0,ge=R.parent?R.parent.box.y0:0,Te=R.step??1;for(let Le=Math.ceil((ie.x0-pe)/Te)*Te;pe+Le<=ie.x1+1e-9;Le+=Te)le(pe+Le,ie.y0,pe+Le,ie.y1,Number.isInteger(Le)?"dgrid":"dgrid sub");for(let Le=Math.ceil((ie.y0-ge)/Te)*Te;ge+Le<=ie.y1+1e-9;Le+=Te)le(ie.x0,ge+Le,ie.x1,ge+Le,Number.isInteger(Le)?"dgrid":"dgrid sub");me.append(W);let qe=V.createElementNS(on,"polygon");if(qe.setAttribute("class",`drop${R.invalid?" bad":""}`),qe.setAttribute("points",[[P.x0,P.y0],[P.x1,P.y0],[P.x1,P.y1],[P.x0,P.y1]].map(([Le,ct])=>se(Le,ct)).join(" ")),me.append(qe),R.parent&&R.move){let Le=R.parent.box,ct=R.move.clamped,Je=R.parent.pad,Rt=(Ge,$t,ds,us)=>{let to=V.createElementNS(on,"polyline");to.setAttribute("class","edge"),to.setAttribute("points",`${se(Ge,$t)} ${se(ds,us)}`),me.append(to)};ct.left&&Rt(Le.x0+Je,Le.y0,Le.x0+Je,Le.y1),ct.right&&Rt(Le.x1-Je,Le.y0,Le.x1-Je,Le.y1),ct.top&&Rt(Le.x0,Le.y0+Je,Le.x1,Le.y0+Je),ct.bottom&&Rt(Le.x0,Le.y1-Je,Le.x1,Le.y1-Je)}}async function rt(P){let R=pt();if(!R)return;Ce=void 0,clearTimeout(_t);let V=me?[...me.querySelectorAll(".gridwrap, .drop, .edge")]:[];if(V.length){for(let se of V)se.classList.add("out");matchMedia("(prefers-reduced-motion: reduce)").matches||await new Promise(se=>setTimeout(se,160))}ye="",ne?.classList.remove("dragging","drag-bad"),Q();let W=R.move,oe=W&&(W.at[0]!==R.start[0]||W.at[1]!==R.start[1]);if(P&&W&&oe&&!R.invalid){let se=`Pin ${p(nt(R.ptr))} at [${W.at.join(", ")}]`,ie=R.keep??[];if(!R.shown||R.shown[0]!==W.at[0]||R.shown[1]!==W.at[1])try{ie=Ht(R).keep}catch{}un(e,ie.length?d([[R.name,W.at],...ie],`${se} (${ie.map(([le])=>le).join(", ")} kept in place)`):u(i([x,"layout",R.name],{at:W.at},se)),"canvas",n.note),Pe&&re&&(Pe=!1,ye="",I(re,$e));return}P&&R.invalid&&n.note(`${R.name} can't go there: it would overlap`,"warn"),await Ee(R.origCd),Pe&&re&&(Pe=!1,ye="",I(re,$e))}function fn(P){if(T&&!T.pick){let{x:se,y:ie}=kt(P);et(Ye(document.elementFromPoint(se,ie)));return}let R=Ce;if(Ce=void 0,ne?.classList.remove("panning"),!R)return;let{x:V,y:W}=kt(P);(R.kind==="marquee"&&!R.moved&&!R.add||R.kind==="pan"&&R.emptyClick)&&e.select([],"canvas");let oe=R.kind==="click"?R.ptr:R.kind==="pin"&&!R.moved?R.narrow:void 0;if(oe&&e.select([nt(oe)],"canvas"),R.kind==="pin"&&R.moved){Ce=R,Ot={x:V,y:W,alt:P.altKey},Pt=!1,as(),rt(!0);return}De()}let Mt;function Jt(){let P=new Map;if(!te)return P;for(let[R,V]of te.pathOf){let W=v(V);if(!W||W.path!==V)continue;let oe=te.scene.layout.byId.get(R);if(!oe||ne?.querySelector(`[data-id="${CSS.escape(R)}"].pre`))continue;let se=oe.box,ie=se.z0,le={x0:se.x0-ie,y0:se.y0-ie,x1:se.x1-ie,y1:se.y1-ie},pe=P.get(V);P.set(V,pe?{x0:Math.min(pe.x0,le.x0),y0:Math.min(pe.y0,le.y0),x1:Math.max(pe.x1,le.x1),y1:Math.max(pe.y1,le.y1)}:le)}return P}let H=P=>Math.round(P*2)/2,he=([P,R])=>[H(P),H(R)],ke=(P,R)=>{let[V,W]=ws(1,0),[oe,se]=ws(0,1),ie=V*se-W*oe;return[(P*se-R*oe)/ie,(R*V-P*W)/ie]};function Ae(P){P.preventDefault();let{x:R,y:V}=kt(P),W=Ze();if(P.ctrlKey||P.metaKey){E(Math.exp(-P.deltaY*.01),R,V);return}if(P.shiftKey){Ne.view={...Ne.view,x:Ne.view.x+(P.deltaX||P.deltaY)/W},ot();return}fe.wheel==="zoom"?E(Math.exp(-P.deltaY*.0025),R,V):(Ne.view={...Ne.view,x:Ne.view.x+P.deltaX/W,y:Ne.view.y+P.deltaY/W},ot())}function Fe(P){P.preventDefault();let{x:R,y:V}=kt(P);if(U?.context?.(P,{x:R,y:V}))return;let W=Ye(P.target);W!==void 0&&!e.selection.some(oe=>Me(oe)===W)&&e.select([nt(W)],"canvas"),is(st(W),{x:R,y:V},"Canvas")}function st(P){let R=e.selection,V=[],W=!e.doc.ok;if(P===void 0||!R.length){for(let le of r.newOrder)V.push({label:`New ${M(le).singular}`,icon:"plus",disabled:W,onSelect:()=>Ut(le)});n.clipItems&&V.push({sep:!0},...n.clipItems().filter(le=>"label"in le&&le.label==="Paste")),V.push({sep:!0},{label:"Fit",keys:"0",onSelect:()=>q()},{label:"Fit the whole drawing",onSelect:()=>Y()},{label:"Zoom 100%",keys:"1",onSelect:()=>m()});let ie=!!s.pins.of(e.goodDoc.data);return V.push({label:"Reset layout",icon:"rotate-ccw",desc:"Remove every pin (x-editor.layout)",disabled:W||!ie,why:"Nothing is pinned",onSelect:Js}),V}let oe=R.length===1?R[0]:void 0,se=oe&&v(Me(oe))?.path===Me(oe);if(oe){V.push(...s.objectItems(e,oe,"canvas",n.note)),V.length&&V.push({sep:!0}),V.push({label:"Rename\u2026",icon:"pencil",keys:"F2",disabled:W||!se,why:o.renameWhy,onSelect:()=>h(e,oe,"canvas",n.note)}),V.push({label:"Duplicate",icon:"copy",keys:"\u2318D",disabled:W||!se,why:o.duplicateWhy,onSelect:()=>b(e,oe,"canvas",n.note)});let ie=se?v(Me(oe)).name:"";s.pins.of(e.goodDoc.data)?.[ie]&&V.push({label:"Unpin",icon:"rotate-ccw",desc:"Let the layout place it again",onSelect:()=>un(e,u({...a([x,"layout",ie]),label:`Unpin ${p(oe)}`}),"canvas",n.note)}),V.push({sep:!0}),V.push({label:"Show in text",icon:"code-xml",onSelect:()=>n.showInText(oe)}),V.push({label:"Show in tree",icon:"list-tree",onSelect:()=>n.showInTree(oe)})}return s.connect&&oe&&se&&V.push({label:"Connect to\u2026",icon:"link",desc:"Then click what it connects to (Esc cancels)",disabled:W,onSelect:()=>yn()}),s.group&&V.push({label:R.length>1?`Group ${R.length} items`:"Group",icon:"box",keys:"\u2318G",desc:"Into a new container, as one step",disabled:W||!Qe().length,why:"Only objects are grouped",onSelect:Nt}),V.push({label:"Select parent",icon:"arrow-up-right",keys:"\u2318\u2191",onSelect:eo}),V.push({label:"Select connected",icon:"link",desc:"What refers to it, and what it refers to",onSelect:()=>e.select(k(e,R),"canvas")}),V.push({label:"Zoom to selection",keys:"\u21E72",onSelect:L}),n.clipItems&&V.push({sep:!0},...n.clipItems()),V.push({sep:!0},{label:R.length>1?`Delete ${R.length} items`:"Delete",icon:"trash-2",keys:"\u232B",danger:!0,disabled:W,onSelect:()=>g(e,R,"canvas",n.note)}),V}function bt(){if(!s.connect||!e.doc.ok||e.selection.length!==1)return;let P=Me(e.selection[0]),R=v(P);return R&&R.path===P?R:void 0}function yn(){let P=bt();P&&(T={from:P,pick:!0},n.note(`Click what ${P.name} connects to (Esc cancels)`),De())}function et(P){let R=T?.from;if(T=void 0,De(),!R||P===void 0)return;let V=v(P);if(!V||V.path===R.path){n.note("Not connected: drop it on another object","warn");return}let W=e.goodDoc.data,oe=s.connect?.(R,V,W);if(!oe){n.note(`${R.name} and ${V.name} can't be connected`,"warn");return}let se=oe.label??`Connect ${R.name} to ${V.name}`,ie,le;if(oe.name!==void 0){let pe=f(e.text,oe.name);ie=l(oe.at,pe,oe.value,{label:se}),le=[...oe.at,pe]}else{let pe=oe.at.reduce((ge,Te)=>ge&&typeof ge=="object"?ge[Te]:void 0,W);le=[...oe.at,Array.isArray(pe)?pe.length:0],ie=c(oe.at,oe.value,void 0,se)}un(e,{...ie,select:[le]},"canvas",n.note)&&e.select([le],"canvas")}function Qe(){let P=new Map;for(let R of e.selection){let V=v(Me(R));V&&P.set(V.path,V)}return[...P.values()]}function Nt(){if(!s.group||!e.doc.ok)return;let P=Qe();if(!P.length){n.note("Only objects are grouped","warn");return}let R=s.group(P,e.goodDoc.data);if(!R){n.note(P.length>1?`These ${P.length} can't be grouped`:`${P[0].name} can't be grouped`,"warn");return}let V=f(e.text,R.name),W=s.pins.of(e.goodDoc.data)??{},oe=P.filter(pe=>W[pe.name]!==void 0).map(pe=>u(a([x,"layout",pe.name]))),se=R.label??`Group ${P.length>1?`${P.length} items`:P[0].name} into ${V}`,ie=[...R.at,V],le=qo(se,[l(R.at,V,R.value,{label:se}),...R.members(V).map(pe=>i(pe.path,pe.value)),...oe]);un(e,{...le,select:[ie]},"canvas",n.note)&&e.select([ie],"canvas")}function Ut(P){let R=M(P),V=f(e.text,R.singular),W=[...R.section,V];un(e,l(W.slice(0,-1),V,R.template(),{label:`Add ${R.singular} ${V}`}),"canvas",n.note)&&(e.select([W],"canvas"),h(e,W,"canvas",n.note))}function an(P,R,V){if(!te||!ne)return;let W=R.build(e.text).steps.reduce((us,to)=>dn(us,to),e.text),oe;try{oe=s.trial(W,n.theme)}catch{return}if(!oe)return;let se=oe.pinId.get(P),ie=se?oe.scene.layout.byId.get(se):void 0,le=se?Rr(oe.scene,se):void 0;if(!ie||!le)return;let pe=ie.box,ge=ie.parent,Te=(pe.x0+pe.x1)/2,qe=(pe.y0+pe.y1)/2,Le=[(Te-qe)*It*xt,(Te+qe)*.5*xt-pe.z0*xt],ct=at(V.x,V.y),Je=Fo(le,ws(ct.x-Le[0],ct.y-Le[1]),1,[pe.x1-pe.x0,pe.y1-pe.y0],ge?{w:ge.box.x1-ge.box.x0,d:ge.box.y1-ge.box.y0,pad:Do(s.catalog,ge.region)}:void 0),Rt=Je.at[0]-le[0],Ge=Je.at[1]-le[1],$t={x0:pe.x0+Rt,y0:pe.y0+Ge,x1:pe.x1+Rt,y1:pe.y1+Ge},ds=(ge?ge.children:oe.scene.layout.items.filter(us=>!us.parent)).filter(us=>us!==ie).map(us=>us.box);return rr($t,ds)?void 0:Je.at}function br(P,R){if(!te)return;let V=at(R.x,R.y);if(F){for(let oe of F.panelsAt(V.x,V.y)){let se=[...te.pinId].find(([,ie])=>ie===oe)?.[0];if(se&&v(te.pathOf.get(oe)??"")?.kind===P)return se}return}let W=oe=>{let se=!1;for(let ie=0,le=oe.length-1;ie<oe.length;le=ie++){let[pe,ge]=oe[ie],[Te,qe]=oe[le];ge>V.y!=qe>V.y&&V.x<(Te-pe)*(V.y-ge)/(qe-ge)+pe&&(se=!se)}return se};for(let[oe,se]of te.pinId){if(v(te.pathOf.get(se)??"")?.kind!==P)continue;let ie=te.scene.layout.byId.get(se);if(ie&&W(Ir(ie.box)))return oe}}function Xo(P){if(!te)return[];let R=at(P.x,P.y),V=le=>{let pe=te.pathOf.get(le),ge=pe===void 0?void 0:v(pe);return ge&&ge.path===pe?ge:void 0};if(F)return F.panelsAt(R.x,R.y).map(V).filter(le=>!!le);let W=le=>{let pe=!1;for(let ge=0,Te=le.length-1;ge<le.length;Te=ge++){let[qe,Le]=le[ge],[ct,Je]=le[Te];Le>R.y!=Je>R.y&&R.x<(ct-qe)*(R.y-Le)/(Je-Le)+qe&&(pe=!pe)}return pe},oe=le=>{let pe=0;for(let ge=le.parent;ge;ge=ge.parent)pe++;return pe},se=new Map;for(let le of Re().elementsFromPoint(P.x,P.y))if(ne?.contains(le))for(let pe=le.closest("[data-id]");pe;pe=pe.parentElement?.closest("[data-id]")??null){let ge=V(pe.getAttribute("data-id")??"");ge&&!se.has(ge.path)&&se.set(ge.path,ge)}let ie=[];for(let[,le]of te.pinId){let pe=te.scene.layout.byId.get(le),ge=V(le);pe&&ge&&!se.has(ge.path)&&W(Ir(pe.box))&&ie.push({r:ge,d:oe(pe),a:(pe.box.x1-pe.box.x0)*(pe.box.y1-pe.box.y0)})}return[...se.values(),...ie.sort((le,pe)=>pe.d-le.d||le.a-pe.a).map(le=>le.r)]}function Ws(P,R,V){if(!e.doc.ok){n.note("Fix the YAML first","warn");return}let W=M(P),oe=V?.value?.(),se=V&&oe!==void 0?V.label.toLowerCase():W.singular,ie=f(e.text,V?.name??W.singular),le=[...W.section,ie],pe=oe??W.template(),ge,Te=R?s.dropInto?.(P):void 0;if(R&&Te){let Ge=br(Te.container,R);Ge&&(ge=Ge,pe={...Te.value(Ge),...oe??{}})}let qe=ge?Te.label(ge):"";if(R&&!ge&&s.dropOnto)for(let Ge of Xo(R)){let $t=s.dropOnto(Ge,pe,P,e.goodDoc.data);if($t){ge=Ge.name,pe=$t.value,qe=$t.label?` ${$t.label}`:` in ${Ge.name}`;break}}let Le=`Add ${se} ${ie}${qe}`,ct=l(le.slice(0,-1),ie,pe,{label:Le}),Je=R&&!ge&&N==="3d"?an(ie,ct,R):void 0,Rt=Je?qo(`${Le} at [${Je.join(", ")}]`,[ct,u(i([x,"layout",ie],{at:Je}))]):ct;if(un(e,{...Rt,select:[le]},"canvas",n.note))return R&&!ge&&!Je&&n.note(N==="2d"?`${W.singular} ${ie} added; the layout placed it (in 3D a drop pins it where it lands)`:`${W.singular} ${ie} added; that spot is taken, so the layout placed it`),e.select([le],"canvas"),y.focus({preventScroll:!0}),h(e,le,"canvas",n.note),le}let cs=z("div",{class:"palette",role:"toolbar","aria-label":o.palette,"aria-orientation":"vertical"});r.palette.forEach((P,R)=>{let{kind:V,icon:W,label:oe}=P,se=z("button",{type:"button",class:"pal-item","data-section":V,"data-entry":String(R),title:`Add ${oe.toLowerCase()} (click), or drag it where it goes`},Wt(W),z("span",{class:"pal-label"},oe));se.addEventListener("pointerdown",ie=>{if(ie.button!==0)return;ie.preventDefault();try{se.setPointerCapture(ie.pointerId)}catch{}let le=ie.clientX,pe=ie.clientY,ge,Te=Ge=>{let $t=y.getBoundingClientRect();return Ge.clientX>=$t.left&&Ge.clientX<=$t.right&&Ge.clientY>=$t.top&&Ge.clientY<=$t.bottom&&!cs.contains(document.elementFromPoint(Ge.clientX,Ge.clientY))},qe=Ge=>{if(!ge&&Math.hypot(Ge.clientX-le,Ge.clientY-pe)<4)return;ge||(ge=z("div",{class:"pal-ghost","aria-hidden":"true"},Wt(W),oe),t.append(ge));let $t=t.getBoundingClientRect();ge.style.left=`${Ge.clientX-$t.left+8}px`,ge.style.top=`${Ge.clientY-$t.top+8}px`,ge.classList.toggle("bad",!Te(Ge))},Le=(Ge,$t)=>{se.removeEventListener("pointermove",qe),se.removeEventListener("pointerup",ct),se.removeEventListener("pointercancel",Je),removeEventListener("keydown",Rt,!0);let ds=!!ge;ge?.remove(),$t&&(ds?Te(Ge)&&Ws(V,{x:Ge.clientX,y:Ge.clientY},P):Ws(V,void 0,P))},ct=Ge=>Le(Ge,!0),Je=Ge=>Le(Ge,!1),Rt=Ge=>{Ge.key==="Escape"&&(Ge.stopPropagation(),Ge.preventDefault(),Le(ie,!1))};se.addEventListener("pointermove",qe),se.addEventListener("pointerup",ct),se.addEventListener("pointercancel",Je),addEventListener("keydown",Rt,!0)}),se.addEventListener("keydown",ie=>{(ie.key==="Enter"||ie.key===" ")&&(ie.preventDefault(),Ws(V,void 0,P))}),cs.append(se)}),t.append(cs);function Js(){let P=s.pins.keyOf(e.goodDoc.data),R=e.goodDoc.data?.[P],V=R&&Object.keys(R).length===1;un(e,{...a(V?[P]:[P,"layout"]),label:"Reset the layout"},"canvas",n.note)}function eo(){let P=new Map;for(let R of e.selection){let V=v(Me(R)),W=V&&V.path!==Me(R)?nt(V.path):V?M(V.kind).section:[];P.set(Me(W),W)}e.select([...P.values()],"canvas")}function ve(P){if(P.type==="keyup"&&P.key!==" ")return;if(P.key===" "){vt=P.type==="keydown",ne?.classList.toggle(r.panKeyClass,vt),P.preventDefault();return}let R=U?.key?.(P);if(R==="ignore")return;if(R==="handled"){P.preventDefault(),P.stopPropagation();return}let V=P.metaKey||P.ctrlKey,W=e.selection,oe=[...new Set([...te?.pathOf.values()??[]].filter(ie=>v(ie)?.path===ie))],se=!e.doc.ok;switch(P.key){case"+":case"=":E(1.25);break;case"-":case"_":E(.8);break;case"0":q();break;case"1":m();break;case"@":case"2":if(P.shiftKey||P.key==="@")L();else return;break;case"Escape":if(T){T=void 0,De(),n.note("Not connected");break}if(pt()){rt(!1);break}e.select([],"canvas");break;case"Delete":case"Backspace":W.length&&!se&&g(e,W,"canvas",n.note);break;case"F2":W.length===1&&!se&&h(e,W[0],"canvas",n.note);break;case"ArrowUp":if(V){eo();break}return;case"Tab":case"ArrowRight":case"ArrowLeft":case"ArrowDown":{if(!oe.length)return;let ie=W.length?oe.indexOf(Me(W[0])):-1,le=P.key==="ArrowLeft"||P.key==="Tab"&&P.shiftKey,pe=ie<0?0:(ie+(le?-1:1)+oe.length)%oe.length;e.select([nt(oe[pe])],"canvas"),dt(nt(oe[pe]));break}case"ContextMenu":case"F10":if(P.key==="F10"&&!P.shiftKey)return;{let ie=Ke(W),le=t.getBoundingClientRect(),pe=Ze();is(st(W.length?Me(W[0]):void 0),ie?{x:le.left+(ie.x+ie.w-Ne.view.x)*pe,y:le.top+(ie.y-Ne.view.y)*pe}:{x:le.left+40,y:le.top+40},"Canvas")}break;default:if(V&&P.key.toLowerCase()==="d"&&W.length===1&&!se){b(e,W[0],"canvas",n.note);break}if(V&&P.key.toLowerCase()==="a"){e.select(oe.map(nt),"canvas");break}if(V&&P.key.toLowerCase()==="g"&&s.group&&W.length&&!se){Nt();break}return}P.preventDefault(),P.stopPropagation()}y.addEventListener("keydown",ve),y.addEventListener("keyup",ve);let je=P=>t.classList.toggle("has-focus",P);y.addEventListener("focus",()=>je(!0)),y.addEventListener("blur",()=>je(!1)),Q();function dt(P){let R=ue(P);!R||!Ne.view||(R.x<Ne.view.x||R.y<Ne.view.y||R.x+R.w>Ne.view.x+Ne.view.w||R.y+R.h>Ne.view.y+Ne.view.h)&&(Ne.view={...Ne.view,x:R.x+R.w/2-Ne.view.w/2,y:R.y+R.h/2-Ne.view.h/2},ot())}function yt(P){if(!Ne.view||!P.length)return!0;let R=P.map(ue);if(R.some(oe=>!oe))return!1;let V=Se(R),W=24/Ze();return V.x-W>=Ne.view.x&&V.y-W>=Ne.view.y&&V.x+V.w+W<=Ne.view.x+Ne.view.w&&V.y+V.h+W<=Ne.view.y+Ne.view.h?!0:V.w+2*W>Ne.view.w||V.h+2*W>Ne.view.h?(Y({x:V.x-W,y:V.y-W,w:V.w+2*W,h:V.h+2*W}),!0):(Ne.view={...Ne.view,x:V.x+V.w/2-Ne.view.w/2,y:V.y+V.h/2-Ne.view.h/2},ot(),!0)}let ut;Mn(),e.onSelect(P=>{De(),!(P.origin==="canvas"||!P.paths.length)&&(ut=yt(P.paths)?void 0:P.paths)});let Tt={addFromPalette:Ws,palette:cs,groupSelection:Nt,startPick:yn,objectsUnder:Xo,get linking(){return T},render:I,setTheme:it,paintOverlay:De,fit:q,fitAll:Y,actual:m,zoomAt:E,itemsBox:We,get moved(){return Ne.moved},settled:O,get zoom(){return Ne.zoom},dispose(){ze(),clearTimeout(_t),Ne.dispose(),Ue=!0},focus:()=>y.focus(),get view(){return Ne.view},get doc(){return te},get mode(){return N},setMode:B,get flat(){return F?.layout},stage:y,key:ve,scale:()=>Ze(),nav:fe,paintNav:Q,outlinesFor:Ie,footprints:Jt,get drag(){return pt()},get lastMarquee(){return Mt},boxFor:ue,pageXYOf:P=>{let R=ue(P),V=t.getBoundingClientRect(),W=Ze();return R&&Ne.view?{x:V.left+(R.x+R.w/2-Ne.view.x)*W,y:V.top+(R.y+R.h/2-Ne.view.y)*W}:void 0}};return U&&Object.defineProperties(Tt,Object.getOwnPropertyDescriptors(U.api)),Tt}var Sf={draw(t,e,n){let s=zr(e),r;try{r=Fs(or(t),s,n.options)}finally{s.dispose()}let o=r.bounds,i=l=>r.cards.find(c=>c.id===l)?.rect??r.panels.find(c=>c.id===l)?.rect;return{svg:_r(r,{id:"canvas-2d",title:n.title,styles:n.styles}),full:[o.l,o.t,o.r-o.l,o.b-o.t],layout:r,outlines(l,c){let d=[];for(let u of l){let f=i(u);if(f){d.push({kind:"poly",id:u,points:[[f.l,f.t],[f.r,f.t],[f.r,f.b],[f.l,f.b]]});continue}let p=c.querySelector(`path.conn[data-id="${CSS.escape(u)}"]`)?.getAttribute("d");p&&d.push({kind:"route",d:p})}return d},hits(l,c){return[...r.cards,...r.panels].filter(d=>{let u=d.rect;return c?u.l<l.r&&u.r>l.l&&u.t<l.b&&u.b>l.t:u.l>=l.l&&u.t>=l.t&&u.r<=l.r&&u.b<=l.b}).map(d=>d.id)},panelsAt(l,c){return[...r.panels].sort((d,u)=>u.depth-d.depth).filter(d=>l>=d.rect.l&&l<=d.rect.r&&c>=d.rect.t&&c<=d.rect.b).map(d=>d.id)}}},morph(t,e,n,s,r){let o=n.mode==="3d"?n.svg:s;return Vr(o,e,or(e)),ja(t,n.svg,s,n.mode,r)}};var wm=t=>`
|
|
470
|
+
`)[0].replace(/`/g,"")));let N=Rl(e.goodDoc.data,S);if(o.kinds.some(Z=>Se(Z.section)===Se(S))){let Z=Tr(N)?Object.keys(N).length:0;t.append(_("p",null,`${Z} ${Z===1?"entry":"entries"}. Add one from the tree's +, or the canvas's menu.`));return}let Q=S.length?Tr(N)?S:S.slice(0,-1):[],re=Rl(e.goodDoc.data,Q);if(!Tr(re)&&Q.length)return;let we=new Set(o.kinds.map(Z=>String(Z.section[0]))),F=E.keys(Q,re??{}).filter(Z=>!we.has(Z.name)||Q.length),X=_("div",{class:"props"});for(let Z of F)X.append(y([Q],"",Z,[re??{}],void 0));if(t.append(X),S.length&&Se(S)!==Se(Q)){let Z=X.querySelector(`[data-path="${CSS.escape(Se(S))}"]`);Z?.classList.add("focus-row"),Z?.scrollIntoView({block:"nearest"})}}t.addEventListener("focusout",()=>setTimeout(()=>{t.contains(document.activeElement)||w()},0)),e.onSelect(()=>w());let B=or(()=>w());return e.on(S=>{rr(S)?B():B.now()}),{paint:w,dispose:()=>B.cancel()}}function sp(t,e,n){let s=new Map;for(let o of t.values())s.set(o,(s.get(o)??0)+1);let r=new Map;for(let[o,i]of t)e(o)&&s.get(i)===1&&et(i).length>=2&&n(i)===void 0&&r.set(i,o);return r}function rp(t,e,n){let s=(t.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[]).map(Number),r=[];for(let i=0;i+1<s.length;i+=2)r.push([s[i],s[i+1]]);let o;for(let i=0;i+1<r.length;i++){let[a,l]=r[i],[c,d]=r[i+1],u=(c-a)**2+(d-l)**2,f=u?Math.max(0,Math.min(1,((e-a)*(c-a)+(n-l)*(d-l))/u)):0,p=a+(c-a)*f,g=l+(d-l)*f,h=Math.hypot(p-e,g-n);(!o||h<o.dist)&&(o={x:p,y:g,dist:h})}return o}var mn="http://www.w3.org/2000/svg";function Dl(t,e,n){let s=n.kit,r=s.ui,o=r.text,{setCmd:i,deleteCmd:a,insertCmd:l,insertItemCmd:c,pinsCmd:d,withPinsMoved:u,freshName:f,describe:p}=s.commands,{deletePaths:g,duplicate:h,connected:b}=s.actions,v=$=>s.objectOf($),w=$=>s.kinds.find(O=>O.kind===$),k=s.pins.key,y;t.classList.add("canvas");let M=_("div",{class:`${r.rootClass} canvas-stage`,tabindex:"0",role:"application","aria-label":o.stage}),T=_("div",{class:"canvas-tools",role:"toolbar","aria-label":"Canvas"}),A=_("button",{type:"button",class:"btn sm quiet icon-only","aria-label":"Zoom out (\u2212)",title:"Zoom out (\u2212)"},"\u2212"),I=_("button",{type:"button",class:"btn sm quiet zoom-label",title:"Fit (0) \xB7 100% (1)"},"100%"),j=_("button",{type:"button",class:"btn sm quiet icon-only","aria-label":"Zoom in (+)",title:"Zoom in (+)"},"+"),L=_("button",{type:"button",class:"btn sm quiet",title:"Fit (0)"},"Fit"),B=($,O,K)=>{let W=_("div",{class:"segmented",role:"group","aria-label":$,title:$});for(let[te,le,ce]of K){let ue=_("button",{type:"button",class:"seg","data-v":te,title:ce},le);ue.addEventListener("click",()=>{Z[O]=te,V(),J()}),W.append(ue)}return W},S=B("The wheel","wheel",[["zoom","Zoom","The wheel zooms around the pointer; \u21E7-wheel pans sideways"],["scroll","Scroll","The wheel pans; \u21E7-wheel pans sideways; a pinch zooms"]]),E=B(o.dragGroup,"drag",[["pan","Pan","Drag pans; \u21E7- or \u2318-drag draws a selection"],["select","Select",o.dragSelectTip]]),x="3d",N,z,Q=async()=>z??=await s.flat.load(),re=_("div",{class:"segmented view-seg",role:"group","aria-label":"The view"});for(let[$,O,K]of[["3d","3D","3D: the drawing; drag a selected thing to move it"],["2d","2D","2D: select, rename, delete, add from the palette and edit here; moving is in 3D"]]){let W=_("button",{type:"button",class:"seg","data-v":$,title:K},O);W.addEventListener("click",()=>be($)),re.append(W)}let we={host:t,doc:e,cd:()=>G,svg:()=>ne,elementsFor:$=>de($),boxOf:$=>De($),union:$=>He($),outlinesFor:$=>wt($),scale:()=>rt(),full:()=>Pe.full,toSvg:($,O)=>U($,O),autoFit:()=>R(),paint:()=>Tt(),reveal:$=>Nd($),note:($,O)=>n.note($,O)},F=n.layer?.(we);T.append(...F?.tools??[],...s.flat?[re]:[],S,E,A,I,j,L);let X=_("div",{class:"canvas-empty",hidden:!0});t.append(M,T,X,...F?.marks??[]);let Z={wheel:"zoom",drag:"pan"};try{Object.assign(Z,JSON.parse(n.store?.get("canvas-nav")??"{}"))}catch{}s.flat&&n.store?.get("canvas-view")==="2d"&&(x="2d");function be($){if(!s.flat||$===x)return;Ke();let O=x;x=$,n.store?.set("canvas-view",$),J(),ne&&G&&ne.parentNode===M&&(he={svg:ne,mode:O}),se!==void 0&&(Pe.view=void 0,ve="",Ue(se,Me))}let V=()=>n.store?.set("canvas-nav",JSON.stringify(Z));function J(){for(let[$,O]of[[S,Z.wheel],[E,Z.drag],[re,x]])for(let K of $.querySelectorAll(".seg"))K.setAttribute("aria-pressed",String(K.dataset.v===O));if(ne?.classList.toggle("mode-pan",Z.drag==="pan"),ne?.classList.toggle("mode-select",Z.drag==="select"),ze?.kind==="pin"&&ze.moved){ne?.classList.add("dragging"),ne?.classList.toggle("drag-bad",!!ze.invalid);return}n.onHint?.(`${Z.drag==="pan"?"Drag: pan \xB7 \u21E7-drag: select":"Drag: select \xB7 space-drag: pan"} \xB7 Wheel: ${Z.wheel==="zoom"?"zoom":"scroll"}`)}let G,ne,oe,ve="",ge,ye=()=>document,Ie=!1;async function Ue($,O){if(Ie)return;if(!$){je(o.unreadable);return}let K=JSON.stringify(O);if(K===ve&&ne){dt()||Tt(),D&&(D=!1,C());return}if(x==="2d"&&!z)try{await Q()}catch(te){x="3d",J(),n.note(`The 2D view couldn't load: ${te.message}`,"warn")}let W;try{W=s.draw($,O,n.theme)}catch(te){je(`The canvas couldn't draw this: ${te.message}`);return}if(W.diags.length){je(`The canvas couldn't draw this: ${W.diags[0]}`);return}if(ve=K,se=$,Me=O,dt()){Ce=!0;return}await Te(W),G.pinNotes.length&&n.note(`Pins: ${G.pinNotes.join("; ")}`,"warn")}let D=!1,se,Me,Ce=!1,he,ie;function Ke(){if(!ie)return;let $=ie;ie=void 0,$.m.finish(),$.from.remove(),$.to.style.visibility=""}function Oe($,O){let K=z?.morph?.(M,G.scene,$,O,{motion:s.flat?.motion,duration:s.flat?.duration});if(!K){$.svg.remove();return}$.svg.style.visibility="hidden",O.style.visibility="hidden";let W={m:K,from:$.svg,to:O};ie=W,M.classList.add("morphing"),K.done.then(()=>{ie===W&&Ke(),M.classList.remove("morphing")})}async function Te($){Ke();let O,K=$.scene.rendered.viewBox;try{if(x==="2d"&&z){N=z.draw($.scene,M,{styles:s.flat?.styles,title:s.flat?.title,options:s.flat?.options}),K=N.full,O=Ho(N.svg);for(let fe of O.querySelectorAll("[tabindex]"))fe.removeAttribute("tabindex"),fe.removeAttribute("role")}else N=void 0,O=Ho($.svg)}catch(fe){je(`The canvas couldn't draw this: ${fe.message}`);return}G=$,O.classList.add("scene"),O.removeAttribute("width"),O.removeAttribute("height"),O.setAttribute("preserveAspectRatio","xMidYMid meet"),O.setAttribute("aria-hidden","true"),oe=document.createElementNS(mn,"g"),oe.setAttribute("class","overlay"),oe.setAttribute("fill","none"),oe.setAttribute("stroke","currentColor"),oe.setAttribute("pointer-events","none"),O.append(oe,...F?.groups?.()??[]);let W=he;he=void 0,W&&ne===W.svg&&ne.parentNode===M?(W.svg.querySelector(".overlay")?.replaceChildren(),W.svg.style.position="absolute",W.svg.style.inset="0",M.append(O)):ne?.parentNode===M?ne.replaceWith(O):M.append(O),ne=O;let[te,le,ce,ue]=K;Pe.full={x:te,y:le,w:ce,h:ue},D?(D=!1,Pe.view={...Pe.full},C()):Pe.view?P(q):(Pe.view={...Pe.full},R()),X.hidden=!0,F?.drawn?.(),wi&&Rd(wi)&&(wi=void 0),J(),Tt(),W&&W.svg!==O&&(getComputedStyle(M).position==="static"&&(M.style.position="relative"),Oe(W,O))}function je($){he=void 0,X.textContent=$,X.hidden=!1}function lt($){Tt()}function We(){if(!G||!ne)return;let $=[...new Set([...G.pathOf.values()].filter(K=>{let W=v(K);return W&&W.path===K}))],O=F?.extent?.()??[];return He([...$.flatMap(K=>de(K)).filter(K=>K.getBBox().width||K.getBBox().height).map(De),...O])}function ft(){if(!G||!ne)return;let $=Object.keys(G.scene.rendered.paths).flatMap(O=>[...ne.querySelectorAll(`[data-id="${CSS.escape(O)}"], [data-hl="${CSS.escape(O)}"], [data-for="${CSS.escape(O)}"]`)]).filter(O=>!O.closest(".pre, .overlay, .g-marks, .g-badges, .g-anim"));return He($.filter(O=>O.getBBox().width||O.getBBox().height).map(De))}let ut=r.paletteLayout==="docked",it=ut?M:t,Pe=Ya(it,{svg:()=>ne,onApply:$=>{ne.classList.toggle("zoom-near",$>=1);let O=Math.round($*100);I.textContent=`${O}%`,n.onZoom(O)},onRezoom:()=>Tt(),itemsBox:()=>We(),alsoBox:()=>ft(),marksShowing:()=>!!F?.showing?.()}),{size:mt,scale:rt,quietly:P,applyView:q,toSvg:U,zoomAt:ae,fit:m,fitItems:C,autoFit:R,actual:H,settled:ee}=Pe;function $e(){let $=Ye(e.selection);$&&m({x:$.x-20,y:$.y-20,w:$.w+40,h:$.h+40})}j.addEventListener("click",()=>ae(1.25)),A.addEventListener("click",()=>ae(.8)),I.addEventListener("click",()=>C()),L.addEventListener("click",()=>C());let de=$=>!ne||!G?[]:[...G.pathOf.entries()].filter(([,K])=>K===$||$&&K.startsWith($+"/")&&!1).map(([K])=>K).flatMap(K=>[...ne.querySelectorAll(`[data-id="${CSS.escape(K)}"]`)]).filter(K=>!K.closest(".pre")&&!K.classList.contains("pre")),De=$=>{let O=$.getBBox(),K=$.getCTM(),W=ne.getCTM();if(!K||!W)return{x:O.x,y:O.y,w:O.width,h:O.height};let te=W.inverse().multiply(K),le=[[O.x,O.y],[O.x+O.width,O.y],[O.x,O.y+O.height],[O.x+O.width,O.y+O.height]].map(([fe,me])=>({x:te.a*fe+te.c*me+te.e,y:te.b*fe+te.d*me+te.f})),ce=le.map(fe=>fe.x),ue=le.map(fe=>fe.y);return{x:Math.min(...ce),y:Math.min(...ue),w:Math.max(...ce)-Math.min(...ce),h:Math.max(...ue)-Math.min(...ue)}},He=$=>{if(!$.length)return;let O=Math.min(...$.map(le=>le.x)),K=Math.min(...$.map(le=>le.y)),W=Math.max(...$.map(le=>le.x+le.w)),te=Math.max(...$.map(le=>le.y+le.h));return{x:O,y:K,w:W-O,h:te-K}},Ne=$=>{let O=Se($),K=de(O),W=v(O);return!K.length&&W&&W.path!==O&&(K=de(W.path)),K.length?He(K.filter(te=>te.getBBox().width||te.getBBox().height).map(De)):void 0},Ye=$=>He($.map(Ne).filter(O=>!!O)),ot=$=>{let O=$?.closest?.("[data-id]");if(!O||!G)return;let K=O;for(;K;){let W=K.getAttribute("data-id");if(W&&G.pathOf.has(W))return G.pathOf.get(W);K=K.parentElement?.closest("[data-id]")??null}},Mt=$=>!!G&&Object.hasOwn(G.scene.rendered.paths,$),$n=()=>G?sp(G.pathOf,Mt,s.objectOf):new Map,Ct=6,xt=($,O,K)=>{let W=ot($),te=qe=>{let Le=qe?.closest?.("[data-id]")?.getAttribute("data-id");if(!Le||!G||Mt(Le))return!1;if(N){let nt=U(O,K);return!N.panelsAt(nt.x,nt.y).includes(Le)&&G.scene.layout.byId.has(Le)}return G.scene.layout.byId.get(Le)?.type==="node"},le=$;if(!G||!ne||!le?.closest||le!==ne&&!ne.contains(le)&&le!==M||te(le))return W;let ce=$n();if(!ce.size||W!==void 0&&ce.has(W))return W;let ue=U(O,K),fe=rt(),me=it.getBoundingClientRect(),Ee;for(let qe of ce.keys())for(let Le of wt(qe)){if(Le.kind!=="route")continue;let nt=rp(Le.d,ue.x,ue.y);!nt||nt.dist*fe>Ct||Ee&&nt.dist>=Ee.dist||te(ye().elementFromPoint(me.left+(nt.x-Pe.view.x)*fe,me.top+(nt.y-Pe.view.y)*fe))||(Ee={ptr:qe,dist:nt.dist})}return Ee?Ee.ptr:W};function wt($){if(!G)return[];let O=[],K=new Set([...G.pathOf].filter(([,W])=>W===$).map(([W])=>W));if(N&&ne)return N.outlines(K,ne);for(let[W,te]of G.pathOf){if(te!==$)continue;let le=G.scene.layout.byId.get(W),ce=le?.parent;for(;ce&&!K.has(ce.id);)ce=ce.parent;if(!ce)if(le){if(ne?.querySelector(`[data-id="${CSS.escape(W)}"].pre`))continue;let ue=Dt(s.catalog,le.region?.kind)?.shape,fe=le.type==="node"||ue==="slab"||ue==="block";O.push({kind:"poly",id:W,points:fe?za(le.box):Ur(le.box)})}else G.scene.rendered.paths[W]&&!ne?.querySelector(`[data-id="${CSS.escape(W)}"].pre`)&&O.push({kind:"route",d:G.scene.rendered.paths[W]})}return O}function Tt(){if(Pe.painted(Pe.view?rt():0),!oe||!ne)return;let $=ye();oe.replaceChildren();let O=(ue,fe,me=4)=>{let Ee=$.createElementNS(mn,"rect");Ee.setAttribute("class",fe),Ee.setAttribute("x",String(ue.x-me)),Ee.setAttribute("y",String(ue.y-me)),Ee.setAttribute("width",String(ue.w+me*2)),Ee.setAttribute("height",String(ue.h+me*2)),Ee.setAttribute("rx","6"),oe.append(Ee)},K=(ue,fe)=>{let me=v(ue),Ee=wt(ue);if(!Ee.length&&me&&me.path!==ue&&(Ee=wt(me.path)),!Ee.length){let qe=Ne(et(ue));qe&&O(qe,fe,fe==="hover"?3:4);return}for(let qe of Ee)if(qe.kind==="route"){let Le=$.createElementNS(mn,"path");Le.setAttribute("class",fe==="ring"?"route-ring":"route-hover"),Le.setAttribute("d",qe.d),oe.append(Le)}else{let Le=$.createElementNS(mn,"polygon");Le.setAttribute("class",fe),Le.setAttribute("points",qe.points.map(([nt,Je])=>`${nt.toFixed(1)},${Je.toFixed(1)}`).join(" ")),Le.setAttribute("data-for",qe.id),oe.append(Le)}};ge!==void 0&&!e.selection.some(ue=>Se(ue)===ge)&&K(ge,"hover");for(let ue of e.selection)K(Se(ue),"ring");let W=Pr(),te=y?.from??W,le=te?Ne(et(te.path)):void 0;if(le&&s.connect){let ue=rt(),fe=le.x+le.w+10/ue,me=le.y+le.h/2;if(y&&y.x!==void 0&&y.y!==void 0){y.over&&K(y.over,"hover");let Ee=$.createElementNS(mn,"line");Ee.setAttribute("class",`connect-line${y.over?" ok":""}`),Ee.setAttribute("x1",String(fe)),Ee.setAttribute("y1",String(me)),Ee.setAttribute("x2",String(y.x)),Ee.setAttribute("y2",String(y.y)),oe.append(Ee)}if(!y){let Ee=$.createElementNS(mn,"circle");Ee.setAttribute("class","connect-handle"),Ee.setAttribute("cx",String(fe)),Ee.setAttribute("cy",String(me)),Ee.setAttribute("r",String(7/ue)),Ee.style.pointerEvents="all",Ee.style.cursor="crosshair";let qe=$.createElementNS(mn,"title");qe.textContent=`Drag to what ${te.name} connects to`,Ee.append(qe),oe.append(Ee)}}let ce=new Map;for(let ue of n.problems()){if(ue.file)continue;let fe=v(ue.path);if(!fe)continue;let me=ce.get(fe.path)??{e:0,w:0};ue.severity==="error"?me.e++:me.w++,ce.set(fe.path,me)}for(let[ue,fe]of ce){let me=de(ue).filter(ws=>G.scene.layout.byId.has(ws.getAttribute("data-id")??"")),Ee=He(me.map(De));if(!Ee)continue;let qe=$.createElementNS(mn,"g");qe.setAttribute("class",`badge${fe.e?"":" warn"}`);let Le=rt(),nt=Ee.x+Ee.w,Je=Ee.y,Bt=9/Le,Ve=$.createElementNS(mn,"circle");Ve.setAttribute("cx",String(nt)),Ve.setAttribute("cy",String(Je)),Ve.setAttribute("r",String(Bt));let Et=$.createElementNS(mn,"text");Et.setAttribute("x",String(nt)),Et.setAttribute("y",String(Je)),Et.style.fontSize=`${(11/Le).toFixed(2)}px`,Et.textContent=String(fe.e||fe.w),qe.append(Ve,Et),oe.append(qe)}F?.paint?.($)}let ze,Ft=!1,Wt=()=>{M.addEventListener("pointerdown",Ks),M.addEventListener("pointermove",Zt),M.addEventListener("pointerup",vt),M.addEventListener("pointercancel",vt),M.addEventListener("wheel",hn,{passive:!1}),M.addEventListener("contextmenu",Ar),M.addEventListener("dblclick",$=>{let O=xt($.target===M?ye().elementFromPoint($.clientX,$.clientY):$.target,$.clientX,$.clientY);O!==void 0&&(r.doubleClick==="rename"&&e.doc.ok&&v(O)?.path===O?xo(et(O)):n.showInText(et(O)))})},jt=$=>({x:$.clientX,y:$.clientY}),Ot=$=>{try{M.setPointerCapture($.pointerId)}catch{}};function Ks($){if(M.focus({preventScroll:!0}),F?.down?.($))return;let{x:O,y:K}=jt($);if($.button===0&&y?.pick){$.preventDefault(),_s(ot($.target));return}if($.button===0&&$.target?.closest?.(".connect-handle")){let qe=Pr();if(qe){Ot($),$.preventDefault();let Le=U(O,K);y={from:qe,x:Le.x,y:Le.y},Tt();return}}($.button===0||$.button===1)&&Ot($);let W=()=>{ze={kind:"pan",x0:O,y0:K,v0:{...Pe.view}},ne?.classList.add("panning"),$.preventDefault()};if($.button===1||Ft){W();return}if($.button!==0)return;let te=xt($.target,O,K);if(te===void 0){let qe=$.shiftKey||$.metaKey||$.ctrlKey;if(Z.drag==="pan"&&!qe){ze={kind:"pan",x0:O,y0:K,v0:{...Pe.view},emptyClick:!0},ne?.classList.add("panning");return}let Le=Z.drag==="select"&&qe;ze={kind:"marquee",x0:O,y0:K,sel0:Le?e.selection:[],add:Le,touch:$.altKey};return}let le=et(te),ce=e.selection.map(Se);if($.shiftKey||$.metaKey||$.ctrlKey){e.select(ce.includes(te)?e.selection.filter(qe=>Se(qe)!==te):[...e.selection,le],"canvas");return}ce.includes(te)||e.select([le],"canvas");let ue=ce.includes(te)&&ce.length>1?te:void 0;ze={kind:"click",x0:O,y0:K,ptr:ue};let fe=v(te),me=fe&&fe.path===te?fe.name:void 0,Ee=me&&x==="3d"?G?.pinId.get(me):void 0;if(Ee&&G){let qe=G.scene.layout.byId.get(Ee),Le=qr(G.scene,Ee);if(qe&&Le){let nt=qe.box,Je=qe.parent,Bt=(Je?Je.children:G.scene.layout.items.filter(Ve=>!Ve.parent)).filter(Ve=>Ve!==qe).map(Ve=>({x0:Ve.box.x0,y0:Ve.box.y0,x1:Ve.box.x1,y1:Ve.box.y1}));ze={kind:"pin",x0:O,y0:K,name:me,id:Ee,ptr:te,narrow:ue,start:Le,shown:Le,z0:nt.z0,size:[nt.x1-nt.x0,nt.y1-nt.y0],siblings:Bt,parent:Je?{w:Je.box.x1-Je.box.x0,d:Je.box.y1-Je.box.y0,pad:ei(s.catalog,Je.region),box:Je.box,label:Je.region?.label??Je.id}:void 0,origCd:G}}}}function Zt($){let{x:O,y:K}=jt($);if(y){let te=U(O,K),le=ot(document.elementFromPoint(O,K)),ce=le===void 0?void 0:v(le);y={...y,x:te.x,y:te.y,over:ce&&ce.path!==y.from.path?ce.path:void 0},Tt();return}if(!ze){let te=xt($.target,O,K);te!==ge&&(ge=te,Tt());return}let W=rt();if(ze.kind==="click"&&x==="2d"&&!ze.moved&&Math.hypot(O-ze.x0,K-ze.y0)>4){ze.moved=!0,n.onHint?.("Moving is in 3D: switch to 3D to drag it where it goes");return}if(ze.kind==="pan")Math.hypot(O-ze.x0,K-ze.y0)>3&&(ze.emptyClick=!1),Pe.view={...ze.v0,x:ze.v0.x-(O-ze.x0)/W,y:ze.v0.y-(K-ze.y0)/W},q();else if(ze.kind==="marquee"){if(Math.hypot(O-ze.x0,K-ze.y0)<3)return;ze.moved=!0;let te=U(ze.x0,ze.y0),le=U(O,K);if(N){ys(te,le);return}let[ce,ue]=Cs(te.x,te.y),[fe,me]=Cs(le.x,le.y),Ee={x0:Math.min(ce,fe),y0:Math.min(ue,me),x1:Math.max(ce,fe),y1:Math.max(ue,me)},qe=new Map;for(let[Je,Bt]of Ze()){let Ve=Bt,Et=Ve.x0>=Ee.x0&&Ve.y0>=Ee.y0&&Ve.x1<=Ee.x1&&Ve.y1<=Ee.y1,ws=Ve.x0<Ee.x1&&Ve.x1>Ee.x0&&Ve.y0<Ee.y1&&Ve.y1>Ee.y0;(ze.touch?ws:Et)&&qe.set(Je,et(Je))}let Le=new Map((ze.sel0??[]).map(Je=>[Se(Je),Je]));for(let[Je,Bt]of qe)Le.set(Je,Bt);e.select([...Le.values()],"canvas"),Tt();let nt=ye().createElementNS(mn,"polygon");nt.setAttribute("class","marquee"),nt.setAttribute("points",[[Ee.x0,Ee.y0],[Ee.x1,Ee.y0],[Ee.x1,Ee.y1],[Ee.x0,Ee.y1]].map(([Je,Bt])=>Xe(Je,Bt,0).map(Ve=>Ve.toFixed(1)).join(",")).join(" ")),oe.append(nt),En=Ee}else if(ze.kind==="pin"){if(!ze.moved&&Math.hypot(O-ze.x0,K-ze.y0)<4)return;if(ze.moved=!0,tt={x:O,y:K,alt:$.altKey},!Ln){Ln=!0;let te=()=>{Ln&&(Ln=!1,nn())};requestAnimationFrame(te),setTimeout(te,32)}}}function ys($,O){if(!ze||!N||!G)return;let K={l:Math.min($.x,O.x),t:Math.min($.y,O.y),r:Math.max($.x,O.x),b:Math.max($.y,O.y)},W=new Map;for(let ce of N.hits(K,!!ze.touch)){let ue=G.pathOf.get(ce);ue!==void 0&&v(ue)?.path===ue&&W.set(ue,et(ue))}let te=new Map((ze.sel0??[]).map(ce=>[Se(ce),ce]));for(let[ce,ue]of W)te.set(ce,ue);e.select([...te.values()],"canvas"),Tt();let le=ye().createElementNS(mn,"rect");le.setAttribute("class","marquee"),le.setAttribute("x",String(K.l)),le.setAttribute("y",String(K.t)),le.setAttribute("width",String(K.r-K.l)),le.setAttribute("height",String(K.b-K.t)),oe.append(le)}let Ln=!1,tt,on=0,dt=()=>ze?.kind==="pin"&&ze.moved?ze:void 0;function nn(){let $=dt();if(!$||!tt||!G)return;let O=rt(),K=tt.alt?.5:1;$.step=K;let W=ti($.start,Cs((tt.x-$.x0)/O,(tt.y-$.y0)/O),K,$.size,$.parent),te=$.parent?$.parent.box.x0:0,le=$.parent?$.parent.box.y0:0,ce={x0:te+W.at[0],y0:le+W.at[1],x1:te+W.at[0]+$.size[0],y1:le+W.at[1]+$.size[1]},ue=!$.move||$.move.at[0]!==W.at[0]||$.move.at[1]!==W.at[1];$.move=W,$.invalid=gr(ce,$.siblings),ne?.classList.add("dragging"),ne?.classList.toggle("drag-bad",$.invalid),pe($.id,[W.at[0]-$.shown[0],W.at[1]-$.shown[1]]),ke(ce);let fe=$.parent?`within ${$.parent.label}`:"on the canvas";n.onHint?.(`Moving ${$.name} ${fe} \xB7 ${K===1?"whole cells (\u2325: half cells)":"half cells"} \xB7 ${$.invalid?"overlaps: it won't drop here":"Esc cancels"}${o.pinHint}`),ue&&!$.invalid&&se&&(clearTimeout(on),on=window.setTimeout(async()=>{let me=dt();if(!me||me.invalid||!me.move)return;let Ee;try{({next:Ee,keep:me.keep}=Y(me))}catch{return}dt()===me&&(await Te(Ee),dt()===me&&(me.shown=me.move.at,pe(me.id,[0,0]),ke(me.parent?{x0:me.parent.box.x0+me.move.at[0],y0:me.parent.box.y0+me.move.at[1],x1:me.parent.box.x0+me.move.at[0]+me.size[0],y1:me.parent.box.y0+me.move.at[1]+me.size[1]}:ce)))},0))}function Y($){let O=JSON.parse(JSON.stringify(Me??{}));s.pins.legacyOnly(O)&&(O[k]=O[s.pins.legacyKey],delete O[s.pins.legacyKey]),O[k]??={},O[k].layout??={};let K=O[k].layout;K[$.name]={at:$.move.at};let W=s.draw(se,O,n.theme),te=$.origCd,le=new Map([...te.pinId].map(([me,Ee])=>[Ee,me])),ce=te.scene.layout.byId.get($.id),ue=ce.parent?ce.parent.children:te.scene.layout.items.filter(me=>!me.parent),fe=[];for(let me of ue){if(me===ce)continue;let Ee=le.get(me.id),qe=qr(te.scene,me.id),Le=W.scene.layout.byId.get(me.id)?.box;!Ee||!qe||!Le||Ee in K||(Math.abs(Le.x0-me.box.x0)>1e-6||Math.abs(Le.y0-me.box.y0)>1e-6)&&fe.push([Ee,qe])}if(fe.length){for(let[me,Ee]of fe)K[me]={at:Ee};W=s.draw(se,O,n.theme)}return{next:W,keep:fe}}function pe($,[O,K]){if(!ne||!G)return;let[W,te]=[(O-K)*Kt*yt,(O+K)*.5*yt],le=new Set([$]);for(let ce of G.scene.layout.items){let ue=ce.parent;for(;ue;){if(ue.id===$){le.add(ce.id);break}ue=ue.parent}}for(let ce of ne.querySelectorAll("[data-id]"))le.has(ce.getAttribute("data-id")??"")&&(ce.parentElement?.closest(`[data-id="${CSS.escape(ce.getAttribute("data-id"))}"]`)||ce.setAttribute("transform",O||K?`translate(${W.toFixed(1)} ${te.toFixed(1)})`:""))}function ke($){let O=dt();if(!O||!oe)return;Tt();let K=ye(),W=K.createElementNS(mn,"g");W.setAttribute("class",O.gridShown?"gridwrap":"gridwrap fresh"),O.gridShown=!0;let te=O.z0,le=(Le,nt)=>Xe(Le,nt,te).map(Je=>Je.toFixed(1)).join(","),ce=O.parent?O.parent.box:{x0:Math.floor($.x0)-8,y0:Math.floor($.y0)-8,x1:Math.ceil($.x1)+8,y1:Math.ceil($.y1)+8},ue=(Le,nt,Je,Bt,Ve)=>{let Et=K.createElementNS(mn,"polyline");Et.setAttribute("class",Ve),Et.setAttribute("points",`${le(Le,nt)} ${le(Je,Bt)}`),W.append(Et)},fe=O.parent?O.parent.box.x0:0,me=O.parent?O.parent.box.y0:0,Ee=O.step??1;for(let Le=Math.ceil((ce.x0-fe)/Ee)*Ee;fe+Le<=ce.x1+1e-9;Le+=Ee)ue(fe+Le,ce.y0,fe+Le,ce.y1,Number.isInteger(Le)?"dgrid":"dgrid sub");for(let Le=Math.ceil((ce.y0-me)/Ee)*Ee;me+Le<=ce.y1+1e-9;Le+=Ee)ue(ce.x0,me+Le,ce.x1,me+Le,Number.isInteger(Le)?"dgrid":"dgrid sub");oe.append(W);let qe=K.createElementNS(mn,"polygon");if(qe.setAttribute("class",`drop${O.invalid?" bad":""}`),qe.setAttribute("points",[[$.x0,$.y0],[$.x1,$.y0],[$.x1,$.y1],[$.x0,$.y1]].map(([Le,nt])=>le(Le,nt)).join(" ")),oe.append(qe),O.parent&&O.move){let Le=O.parent.box,nt=O.move.clamped,Je=O.parent.pad,Bt=(Ve,Et,ws,vs)=>{let wo=K.createElementNS(mn,"polyline");wo.setAttribute("class","edge"),wo.setAttribute("points",`${le(Ve,Et)} ${le(ws,vs)}`),oe.append(wo)};nt.left&&Bt(Le.x0+Je,Le.y0,Le.x0+Je,Le.y1),nt.right&&Bt(Le.x1-Je,Le.y0,Le.x1-Je,Le.y1),nt.top&&Bt(Le.x0,Le.y0+Je,Le.x1,Le.y0+Je),nt.bottom&&Bt(Le.x0,Le.y1-Je,Le.x1,Le.y1-Je)}}let Ae=0;async function Re($){if(dt()){Ae++;try{await at($)}finally{Ae--}}}async function at($){let O=dt();if(!O)return;ze=void 0,clearTimeout(on);let K=oe?[...oe.querySelectorAll(".gridwrap, .drop, .edge")]:[];if(K.length){for(let le of K)le.classList.add("out");matchMedia("(prefers-reduced-motion: reduce)").matches||await new Promise(le=>setTimeout(le,160))}ve="",ne?.classList.remove("dragging","drag-bad"),J();let W=O.move,te=W&&(W.at[0]!==O.start[0]||W.at[1]!==O.start[1]);if($&&W&&te&&!O.invalid){let le=`Pin ${p(et(O.ptr))} at [${W.at.join(", ")}]`,ce=O.keep??[];if(!O.shown||O.shown[0]!==W.at[0]||O.shown[1]!==W.at[1])try{ce=Y(O).keep}catch{}xn(e,ce.length?d([[O.name,W.at],...ce],`${le} (${ce.map(([ue])=>ue).join(", ")} kept in place)`):u(i([k,"layout",O.name],{at:W.at},le)),"canvas",n.note),Ce&&se&&(Ce=!1,ve="",Ue(se,Me));return}$&&O.invalid&&n.note(`${O.name} can't go there: it would overlap`,"warn"),await Te(O.origCd),Ce&&se&&(Ce=!1,ve="",Ue(se,Me))}function vt($){if(y&&!y.pick){let{x:le,y:ce}=jt($);_s(ot(document.elementFromPoint(le,ce)));return}let O=ze;if(ze=void 0,ne?.classList.remove("panning"),!O)return;let{x:K,y:W}=jt($);(O.kind==="marquee"&&!O.moved&&!O.add||O.kind==="pan"&&O.emptyClick)&&e.select([],"canvas");let te=O.kind==="click"?O.ptr:O.kind==="pin"&&!O.moved?O.narrow:void 0;if(te&&e.select([et(te)],"canvas"),O.kind==="pin"&&O.moved){ze=O,tt={x:K,y:W,alt:$.altKey},Ln=!1,nn(),Re(!0);return}Tt()}let En;function Ze(){let $=new Map;if(!G)return $;for(let[O,K]of G.pathOf){let W=v(K);if(!W||W.path!==K)continue;let te=G.scene.layout.byId.get(O);if(!te||ne?.querySelector(`[data-id="${CSS.escape(O)}"].pre`))continue;let le=te.box,ce=le.z0,ue={x0:le.x0-ce,y0:le.y0-ce,x1:le.x1-ce,y1:le.y1-ce},fe=$.get(K);$.set(K,fe?{x0:Math.min(fe.x0,ue.x0),y0:Math.min(fe.y0,ue.y0),x1:Math.max(fe.x1,ue.x1),y1:Math.max(fe.y1,ue.y1)}:ue)}return $}let Qe=$=>Math.round($*2)/2,Gt=([$,O])=>[Qe($),Qe(O)],sn=($,O)=>{let[K,W]=Cs(1,0),[te,le]=Cs(0,1),ce=K*le-W*te;return[($*le-O*te)/ce,(O*K-$*W)/ce]};function hn($){$.preventDefault();let{x:O,y:K}=jt($),W=rt();if($.ctrlKey||$.metaKey){ae(Math.exp(-$.deltaY*.01),O,K);return}if($.shiftKey){Pe.view={...Pe.view,x:Pe.view.x+($.deltaX||$.deltaY)/W},q();return}Z.wheel==="zoom"?ae(Math.exp(-$.deltaY*.0025),O,K):(Pe.view={...Pe.view,x:Pe.view.x+$.deltaX/W,y:Pe.view.y+$.deltaY/W},q())}function Ar($){$.preventDefault();let{x:O,y:K}=jt($);if(F?.context?.($,{x:O,y:K}))return;let W=xt($.target,O,K);W!==void 0&&!e.selection.some(te=>Se(te)===W)&&e.select([et(W)],"canvas"),bs(bi(W),{x:O,y:K},"Canvas")}function bi($){let O=e.selection,K=[],W=!e.doc.ok;if($===void 0||!O.length){for(let ue of r.newOrder)K.push({label:`New ${w(ue).singular}`,icon:"plus",disabled:W,onSelect:()=>Fe(ue)});n.clipItems&&K.push({sep:!0},...n.clipItems().filter(ue=>"label"in ue&&ue.label==="Paste")),K.push({sep:!0},{label:"Fit",keys:"0",onSelect:()=>C()},{label:"Fit the whole drawing",onSelect:()=>m()},{label:"Zoom 100%",keys:"1",onSelect:()=>H()});let ce=!!s.pins.of(e.goodDoc.data);return K.push({label:"Reset layout",icon:"rotate-ccw",desc:"Remove every pin (x-editor.layout)",disabled:W||!ce,why:"Nothing is pinned",onSelect:pp}),K}let te=O.length===1?O[0]:void 0,le=te&&v(Se(te))?.path===Se(te);if(te){K.push(...s.objectItems(e,te,"canvas",n.note)),K.length&&K.push({sep:!0}),K.push({label:"Rename\u2026",icon:"pencil",keys:"F2",disabled:W||!le,why:o.renameWhy,onSelect:()=>xo(te)}),K.push({label:"Duplicate",icon:"copy",keys:"\u2318D",disabled:W||!le,why:o.duplicateWhy,onSelect:()=>h(e,te,"canvas",n.note)});let ce=le?v(Se(te)).name:"";s.pins.of(e.goodDoc.data)?.[ce]&&K.push({label:"Unpin",icon:"rotate-ccw",desc:"Let the layout place it again",onSelect:()=>xn(e,u({...a([k,"layout",ce]),label:`Unpin ${p(te)}`}),"canvas",n.note)}),K.push({sep:!0}),K.push({label:"Show in text",icon:"code-xml",onSelect:()=>n.showInText(te)}),K.push({label:"Show in tree",icon:"list-tree",onSelect:()=>n.showInTree(te)})}return s.connect&&te&&le&&K.push({label:"Connect to\u2026",icon:"link",desc:"Then click what it connects to (Esc cancels)",disabled:W,onSelect:()=>ar()}),s.group&&K.push({label:O.length>1?`Group ${O.length} items`:"Group",icon:"box",keys:"\u2318G",desc:"Into a new container, as one step",disabled:W||!mo().length,why:"Only objects are grouped",onSelect:xe}),K.push({label:"Select parent",icon:"arrow-up-right",keys:"\u2318\u2191",onSelect:Od}),K.push({label:"Select connected",icon:"link",desc:"What refers to it, and what it refers to",onSelect:()=>e.select(b(e,O),"canvas")}),K.push({label:"Zoom to selection",keys:"\u21E72",onSelect:$e}),n.clipItems&&K.push({sep:!0},...n.clipItems()),K.push({sep:!0},{label:O.length>1?`Delete ${O.length} items`:"Delete",icon:"trash-2",keys:"\u232B",danger:!0,disabled:W,onSelect:()=>g(e,O,"canvas",n.note)}),K}function Pr(){if(!s.connect||!e.doc.ok||e.selection.length!==1)return;let $=Se(e.selection[0]),O=v($);return O&&O.path===$?O:void 0}function ar(){let $=Pr();$&&(y={from:$,pick:!0},n.note(`Click what ${$.name} connects to (Esc cancels)`),Tt())}function _s($){let O=y?.from;if(y=void 0,Tt(),!O||$===void 0)return;let K=v($);if(!K||K.path===O.path){n.note("Not connected: drop it on another object","warn");return}let W=e.goodDoc.data,te=s.connect?.(O,K,W);if(!te){n.note(`${O.name} and ${K.name} can't be connected`,"warn");return}let le=te.label??`Connect ${O.name} to ${K.name}`,ce,ue;if(te.name!==void 0){let fe=f(e.text,te.name);ce=l(te.at,fe,te.value,{label:le}),ue=[...te.at,fe]}else{let fe=te.at.reduce((me,Ee)=>me&&typeof me=="object"?me[Ee]:void 0,W);ue=[...te.at,Array.isArray(fe)?fe.length:0],ce=c(te.at,te.value,void 0,le)}xn(e,{...ce,select:[ue]},"canvas",n.note)&&e.select([ue],"canvas")}function mo(){let $=new Map;for(let O of e.selection){let K=v(Se(O));K&&$.set(K.path,K)}return[...$.values()]}function xe(){if(!s.group||!e.doc.ok)return;let $=mo();if(!$.length){n.note("Only objects are grouped","warn");return}let O=s.group($,e.goodDoc.data);if(!O){n.note($.length>1?`These ${$.length} can't be grouped`:`${$[0].name} can't be grouped`,"warn");return}let K=f(e.text,O.name),W=s.pins.of(e.goodDoc.data)??{},te=$.filter(fe=>W[fe.name]!==void 0).map(fe=>u(a([k,"layout",fe.name]))),le=O.label??`Group ${$.length>1?`${$.length} items`:$[0].name} into ${K}`,ce=[...O.at,K],ue=pi(le,[l(O.at,K,O.value,{label:le}),...O.members(K).map(fe=>i(fe.path,fe.value)),...te]);xn(e,{...ue,select:[ce]},"canvas",n.note)&&e.select([ce],"canvas")}function Fe($){let O=w($),K=f(e.text,O.singular),W=[...O.section,K];xn(e,l(W.slice(0,-1),K,O.template(),{label:`Add ${O.singular} ${K}`}),"canvas",n.note)&&(e.select([W],"canvas"),xo(W,{joins:e.undoId}))}function pt($,O,K){if(!G||!ne)return;let W=O.build(e.text).steps.reduce((vs,wo)=>yn(vs,wo),e.text),te;try{te=s.trial(W,n.theme)}catch{return}if(!te)return;let le=te.pinId.get($),ce=le?te.scene.layout.byId.get(le):void 0,ue=le?qr(te.scene,le):void 0;if(!ce||!ue)return;let fe=ce.box,me=ce.parent,Ee=(fe.x0+fe.x1)/2,qe=(fe.y0+fe.y1)/2,Le=[(Ee-qe)*Kt*yt,(Ee+qe)*.5*yt-fe.z0*yt],nt=U(K.x,K.y),Je=ti(ue,Cs(nt.x-Le[0],nt.y-Le[1]),1,[fe.x1-fe.x0,fe.y1-fe.y0],me?{w:me.box.x1-me.box.x0,d:me.box.y1-me.box.y0,pad:ei(s.catalog,me.region)}:void 0),Bt=Je.at[0]-ue[0],Ve=Je.at[1]-ue[1],Et={x0:fe.x0+Bt,y0:fe.y0+Ve,x1:fe.x1+Bt,y1:fe.y1+Ve},ws=(me?me.children:te.scene.layout.items.filter(vs=>!vs.parent)).filter(vs=>vs!==ce).map(vs=>vs.box);return gr(Et,ws)?void 0:Je.at}function St($,O){if(!G)return;let K=U(O.x,O.y);if(N){for(let te of N.panelsAt(K.x,K.y)){let le=[...G.pinId].find(([,ce])=>ce===te)?.[0];if(le&&v(G.pathOf.get(te)??"")?.kind===$)return le}return}let W=te=>{let le=!1;for(let ce=0,ue=te.length-1;ce<te.length;ue=ce++){let[fe,me]=te[ce],[Ee,qe]=te[ue];me>K.y!=qe>K.y&&K.x<(Ee-fe)*(K.y-me)/(qe-me)+fe&&(le=!le)}return le};for(let[te,le]of G.pinId){if(v(G.pathOf.get(le)??"")?.kind!==$)continue;let ce=G.scene.layout.byId.get(le);if(ce&&W(Ur(ce.box)))return te}}function ht($){if(!G)return[];let O=U($.x,$.y),K=ue=>{let fe=G.pathOf.get(ue),me=fe===void 0?void 0:v(fe);return me&&me.path===fe?me:void 0};if(N)return N.panelsAt(O.x,O.y).map(K).filter(ue=>!!ue);let W=ue=>{let fe=!1;for(let me=0,Ee=ue.length-1;me<ue.length;Ee=me++){let[qe,Le]=ue[me],[nt,Je]=ue[Ee];Le>O.y!=Je>O.y&&O.x<(nt-qe)*(O.y-Le)/(Je-Le)+qe&&(fe=!fe)}return fe},te=ue=>{let fe=0;for(let me=ue.parent;me;me=me.parent)fe++;return fe},le=new Map;for(let ue of ye().elementsFromPoint($.x,$.y))if(ne?.contains(ue))for(let fe=ue.closest("[data-id]");fe;fe=fe.parentElement?.closest("[data-id]")??null){let me=K(fe.getAttribute("data-id")??"");me&&!le.has(me.path)&&le.set(me.path,me)}let ce=[];for(let[,ue]of G.pinId){let fe=G.scene.layout.byId.get(ue),me=K(ue);fe&&me&&!le.has(me.path)&&W(Ur(fe.box))&&ce.push({r:me,d:te(fe),a:(fe.box.x1-fe.box.x0)*(fe.box.y1-fe.box.y0)})}return[...le.values(),...ce.sort((ue,fe)=>fe.d-ue.d||ue.a-fe.a).map(ue=>ue.r)]}function At($,O,K){if(!e.doc.ok){n.note("Fix the YAML first","warn");return}let W=w($),te=K?.value?.(),le=K&&te!==void 0?K.label.toLowerCase():W.singular,ce=f(e.text,K?.name??W.singular),ue=[...W.section,ce],fe=te??W.template(),me,Ee=O?s.dropInto?.($):void 0;if(O&&Ee){let Ve=St(Ee.container,O);Ve&&(me=Ve,fe={...Ee.value(Ve),...te??{}})}let qe=me?Ee.label(me):"";if(O&&!me&&s.dropOnto)for(let Ve of ht(O)){let Et=s.dropOnto(Ve,fe,$,e.goodDoc.data);if(Et){me=Ve.name,fe=Et.value,qe=Et.label?` ${Et.label}`:` in ${Ve.name}`;break}}let Le=`Add ${le} ${ce}${qe}`,nt=l(ue.slice(0,-1),ce,fe,{label:Le}),Je=O&&!me&&x==="3d"?pt(ce,nt,O):void 0,Bt=Je?pi(`${Le} at [${Je.join(", ")}]`,[nt,u(i([k,"layout",ce],{at:Je}))]):nt;if(xn(e,{...Bt,select:[ue]},"canvas",n.note))return O&&!me&&!Je&&n.note(x==="2d"?`${W.singular} ${ce} added; the layout placed it (in 3D a drop pins it where it lands)`:`${W.singular} ${ce} added; that spot is taken, so the layout placed it`),e.select([ue],"canvas"),xo(ue,{joins:e.undoId,at:O}),ue}let Pt=_("div",{class:"palette",role:"toolbar","aria-label":o.palette,"aria-orientation":"vertical"}),en=new Map,zn="canvas-palette",Qt;try{let $=JSON.parse(n.store?.get(zn)??"{}");typeof $.last=="string"&&(Qt=$.last)}catch{}let wn=[...new Set(r.palette.map($=>$.section).filter($=>$!==void 0))],$t=Qt!==void 0&&wn.includes(Qt)?Qt:wn[0],Ht=($,O)=>{let K=en.get($);K&&(K.head.setAttribute("aria-expanded",String(O)),K.body.hidden=!O)};function Jt($){let O=en.get($);if(O)return O.body;let K=`pal-sec-${en.size}-${Math.random().toString(36).slice(2,8)}`,W=_("button",{type:"button",class:"pal-head","aria-expanded":"false","aria-controls":K,"data-section-head":$},Ut("chevron-right","pal-chev"),_("span",{class:"pal-head-label"},$)),te=_("div",{class:"pal-body",id:K,role:"group","aria-label":$,"data-section-body":$});return W.addEventListener("click",()=>Ht($,W.getAttribute("aria-expanded")!=="true")),Pt.append(_("div",{class:"pal-section","data-pal-section":$},W,te)),en.set($,{head:W,body:te}),Ht($,$===$t),te}let yi="canvas-palette-dock",ns={};try{let $=JSON.parse(n.store?.get(yi)??"{}");typeof $.w=="number"&&Number.isFinite($.w)&&(ns.w=$.w),$.collapsed===!0&&(ns.collapsed=!0)}catch{}let ho=()=>{try{n.store?.set(yi,JSON.stringify(ns))}catch{}},go=160,bo=440,lr=ut?_("aside",{class:"pal-dock","aria-label":"Palette"}):Pt,Vn=_("div",{class:"pal-grip",role:"separator","aria-orientation":"vertical","aria-label":"Resize the palette",tabindex:"0"}),xs=_("input",{type:"search",class:"pal-search",placeholder:"Search","aria-label":"Search the palette",autocomplete:"off",spellcheck:"false"}),jl=_("p",{class:"pal-none",role:"status",hidden:""}),Cr=_("button",{type:"button",class:"btn sm quiet icon-only pal-collapse","aria-expanded":"true","aria-label":"Collapse the palette",title:"Collapse the palette"},Ut("chevron-left")),Ad=()=>[...Pt.querySelectorAll(".pal-item")].filter($=>!$.hidden&&!$.closest("[hidden]")),yo;function Pd(){let $=xs.value.toLowerCase().split(/\s+/).filter(Boolean);$.length&&!yo&&(yo=new Map([...en].map(([K,W])=>[K,W.head.getAttribute("aria-expanded")==="true"])));let O=0;for(let K of Pt.querySelectorAll(".pal-item")){let W=r.palette[Number(K.dataset.entry)],te=`${W.label} ${W.section??""}`.toLowerCase();K.hidden=!$.every(le=>te.includes(le)),K.hidden||O++}for(let[K,W]of en){let te=[...W.body.querySelectorAll(".pal-item")].some(le=>!le.hidden);W.head.parentElement.hidden=$.length>0&&!te,$.length&&Ht(K,te)}if(!$.length&&yo){for(let[K,W]of yo)Ht(K,W);yo=void 0}jl.hidden=O>0,jl.textContent=O?"":`Nothing matches "${xs.value.trim()}"`}let xi=($,O=!0)=>{let K=Math.round(Math.min(bo,Math.max(go,$)));t.style.setProperty("--pal-w",`${K}px`),Vn.setAttribute("aria-valuenow",String(K)),O&&(ns.w=K,ho())},Cd=($,O=!0)=>{t.classList.toggle("pal-collapsed",$),Cr.setAttribute("aria-expanded",String(!$));let K=$?"Show the palette":"Collapse the palette";Cr.setAttribute("aria-label",K),Cr.title=K,Cr.replaceChildren(Ut($?"chevron-right":"chevron-left")),O&&($?ns.collapsed=!0:delete ns.collapsed,ho())};ut&&(t.classList.add("pal-docked"),Pt.classList.add("pal-list"),lr.append(_("div",{class:"pal-dock-head"},Cr,_("label",{class:"pal-search-wrap"},Ut("search"),xs)),Pt,jl),Vn.setAttribute("aria-valuemin",String(go)),Vn.setAttribute("aria-valuemax",String(bo)),xi(ns.w??220,!1),Cd(!!ns.collapsed,!1),Cr.addEventListener("click",()=>{Cd(!t.classList.contains("pal-collapsed")),t.classList.contains("pal-collapsed")||xs.focus()}),xs.addEventListener("input",Pd),xs.addEventListener("keydown",$=>{if($.key==="Escape"&&xs.value)$.preventDefault(),$.stopPropagation(),xs.value="",Pd();else if($.key==="ArrowDown"){let O=Ad()[0];O&&($.preventDefault(),O.focus())}else if($.key==="Enter"){let O=Ad()[0];O&&($.preventDefault(),O.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0})))}}),Pt.addEventListener("keydown",$=>{if($.key!=="ArrowDown"&&$.key!=="ArrowUp")return;let O=[...Pt.querySelectorAll(".pal-head, .pal-item")].filter(W=>!W.hidden&&!W.parentElement?.closest("[hidden]")&&(W.classList.contains("pal-head")||!W.closest(".pal-body[hidden]"))),K=O.indexOf(document.activeElement);K<0||($.preventDefault(),$.key==="ArrowUp"&&K===0?xs.focus():O[Math.min(O.length-1,Math.max(0,K+($.key==="ArrowDown"?1:-1)))].focus())}),Vn.addEventListener("pointerdown",$=>{if($.button!==0)return;try{Vn.setPointerCapture($.pointerId)}catch{}let O=$.clientX,K=lr.getBoundingClientRect().width,W=le=>xi(K+le.clientX-O,!1),te=le=>{Vn.removeEventListener("pointermove",W),Vn.removeEventListener("pointerup",te),xi(K+le.clientX-O)};Vn.addEventListener("pointermove",W),Vn.addEventListener("pointerup",te)}),Vn.addEventListener("keydown",$=>{let O=$.key==="ArrowLeft"?-16:$.key==="ArrowRight"?16:0;O&&($.preventDefault(),xi(lr.getBoundingClientRect().width+O))}));let Bl=$=>{if(!($.section===void 0||$.section===Qt)){Qt=$.section;try{n.store?.set(zn,JSON.stringify({last:Qt}))}catch{}}};r.palette.forEach(($,O)=>{let{kind:K,icon:W,label:te}=$,le=_("button",{type:"button",class:"pal-item","data-section":K,"data-entry":String(O),title:`Add ${te.toLowerCase()} (click), or drag it where it goes`},Ut(W),_("span",{class:"pal-label"},te));le.addEventListener("pointerdown",ce=>{if(ce.button!==0)return;ce.preventDefault();try{le.setPointerCapture(ce.pointerId)}catch{}let ue=ce.clientX,fe=ce.clientY,me,Ee=Ve=>{let Et=M.getBoundingClientRect();return Ve.clientX>=Et.left&&Ve.clientX<=Et.right&&Ve.clientY>=Et.top&&Ve.clientY<=Et.bottom&&!lr.contains(document.elementFromPoint(Ve.clientX,Ve.clientY))},qe=Ve=>{if(!me&&Math.hypot(Ve.clientX-ue,Ve.clientY-fe)<4)return;me||(me=_("div",{class:"pal-ghost","aria-hidden":"true"},Ut(W),te),t.append(me));let Et=t.getBoundingClientRect();me.style.left=`${Ve.clientX-Et.left+8}px`,me.style.top=`${Ve.clientY-Et.top+8}px`,me.classList.toggle("bad",!Ee(Ve))},Le=(Ve,Et)=>{le.removeEventListener("pointermove",qe),le.removeEventListener("pointerup",nt),le.removeEventListener("pointercancel",Je),removeEventListener("keydown",Bt,!0);let ws=!!me;me?.remove(),Et&&(ws?Ee(Ve)&&(Bl($),At(K,{x:Ve.clientX,y:Ve.clientY},$)):(Bl($),At(K,void 0,$)))},nt=Ve=>Le(Ve,!0),Je=Ve=>Le(Ve,!1),Bt=Ve=>{Ve.key==="Escape"&&(Ve.stopPropagation(),Ve.preventDefault(),Le(ce,!1))};le.addEventListener("pointermove",qe),le.addEventListener("pointerup",nt),le.addEventListener("pointercancel",Je),addEventListener("keydown",Bt,!0)}),le.addEventListener("keydown",ce=>{(ce.key==="Enter"||ce.key===" ")&&(ce.preventDefault(),Bl($),At(K,void 0,$))}),($.section===void 0?Pt:Jt($.section)).append(le)}),ut?t.prepend(lr,Vn):t.append(Pt);function pp(){let $=s.pins.keyOf(e.goodDoc.data),O=e.goodDoc.data?.[$],K=O&&Object.keys(O).length===1;xn(e,{...a(K?[$]:[$,"layout"]),label:"Reset the layout"},"canvas",n.note)}function xo($,O={}){let K=$,W=e.on(te=>{K&&te.remap&&(K=te.remap(K))});s.actions.rename(e,$,"canvas",n.note,{...O,back:M,late:M,busy:()=>!!ze||Ae>0,bounds:()=>M.getBoundingClientRect(),place:()=>{let te=K&&Pe.view?Ne(K):void 0;if(!te)return;let le=it.getBoundingClientRect(),ce=rt();return{left:le.left+(te.x-Pe.view.x)*ce,top:le.top+(te.y-Pe.view.y)*ce,width:te.w*ce,height:te.h*ce}}}).finally(W)}function Od(){let $=new Map;for(let O of e.selection){let K=v(Se(O)),W=K&&K.path!==Se(O)?et(K.path):K?w(K.kind).section:[];$.set(Se(W),W)}e.select([...$.values()],"canvas")}function Kl($){if($.type==="keyup"&&$.key!==" ")return;if($.key===" "){Ft=$.type==="keydown",ne?.classList.toggle(r.panKeyClass,Ft),$.preventDefault();return}let O=F?.key?.($);if(O==="ignore")return;if(O==="handled"){$.preventDefault(),$.stopPropagation();return}let K=$.metaKey||$.ctrlKey,W=e.selection,te=[...new Set([...G?.pathOf.values()??[]].filter(ce=>v(ce)?.path===ce))],le=!e.doc.ok;switch($.key){case"+":case"=":ae(1.25);break;case"-":case"_":ae(.8);break;case"0":C();break;case"1":H();break;case"@":case"2":if($.shiftKey||$.key==="@")$e();else return;break;case"Escape":if(y){y=void 0,Tt(),n.note("Not connected");break}if(dt()){Re(!1);break}e.select([],"canvas");break;case"Delete":case"Backspace":W.length&&!le&&g(e,W,"canvas",n.note);break;case"F2":W.length===1&&!le&&xo(W[0]);break;case"ArrowUp":if(K){Od();break}return;case"Tab":case"ArrowRight":case"ArrowLeft":case"ArrowDown":{if(te.push(...$n().keys()),!te.length)return;let ce=W.length?te.indexOf(Se(W[0])):-1,ue=$.key==="ArrowLeft"||$.key==="Tab"&&$.shiftKey,fe=ce<0?0:(ce+(ue?-1:1)+te.length)%te.length;e.select([et(te[fe])],"canvas"),Nd(et(te[fe]));break}case"ContextMenu":case"F10":if($.key==="F10"&&!$.shiftKey)return;{let ce=Ye(W),ue=it.getBoundingClientRect(),fe=rt();bs(bi(W.length?Se(W[0]):void 0),ce?{x:ue.left+(ce.x+ce.w-Pe.view.x)*fe,y:ue.top+(ce.y-Pe.view.y)*fe}:{x:ue.left+40,y:ue.top+40},"Canvas")}break;default:if(K&&$.key.toLowerCase()==="d"&&W.length===1&&!le){h(e,W[0],"canvas",n.note);break}if(K&&$.key.toLowerCase()==="a"){e.select(te.map(et),"canvas");break}if(K&&$.key.toLowerCase()==="g"&&s.group&&W.length&&!le){xe();break}return}$.preventDefault(),$.stopPropagation()}M.addEventListener("keydown",Kl),M.addEventListener("keyup",Kl);let Ld=$=>t.classList.toggle("has-focus",$);M.addEventListener("focus",()=>Ld(!0)),M.addEventListener("blur",()=>Ld(!1)),J();function Nd($){let O=Ne($);!O||!Pe.view||(O.x<Pe.view.x||O.y<Pe.view.y||O.x+O.w>Pe.view.x+Pe.view.w||O.y+O.h>Pe.view.y+Pe.view.h)&&(Pe.view={...Pe.view,x:O.x+O.w/2-Pe.view.w/2,y:O.y+O.h/2-Pe.view.h/2},q())}function Rd($){if(!Pe.view||!$.length)return!0;let O=$.map(Ne);if(O.some(te=>!te))return!1;let K=He(O),W=24/rt();return K.x-W>=Pe.view.x&&K.y-W>=Pe.view.y&&K.x+K.w+W<=Pe.view.x+Pe.view.w&&K.y+K.h+W<=Pe.view.y+Pe.view.h?!0:K.w+2*W>Pe.view.w||K.h+2*W>Pe.view.h?(m({x:K.x-W,y:K.y-W,w:K.w+2*W,h:K.h+2*W}),!0):(Pe.view={...Pe.view,x:K.x+K.w/2-Pe.view.w/2,y:K.y+K.h/2-Pe.view.h/2},q(),!0)}let wi;Wt(),e.onSelect($=>{Tt(),!($.origin==="canvas"||!$.paths.length)&&(wi=Rd($.paths)?void 0:$.paths)});let Id={addFromPalette:At,palette:Pt,groupSelection:xe,startPick:ar,objectsUnder:ht,get linking(){return y},render:Ue,setTheme:lt,paintOverlay:Tt,fit:C,fitNext(){D=!0},fitAll:m,actual:H,zoomAt:ae,itemsBox:We,routesBox:ft,get moved(){return Pe.moved},settled:ee,get zoom(){return Pe.zoom},dispose(){Ke(),clearTimeout(on),Pe.dispose(),Ie=!0},focus:()=>M.focus(),get view(){return Pe.view},get doc(){return G},get mode(){return x},setMode:be,get flat(){return N?.layout},stage:M,key:Kl,scale:()=>rt(),nav:Z,paintNav:J,outlinesFor:wt,footprints:Ze,get drag(){return dt()},get lastMarquee(){return En},boxFor:Ne,pageXYOf:$=>{let O=Ne($),K=it.getBoundingClientRect(),W=rt();return O&&Pe.view?{x:K.left+(O.x+O.w/2-Pe.view.x)*W,y:K.top+(O.y+O.h/2-Pe.view.y)*W}:void 0}};return F&&Object.defineProperties(Id,Object.getOwnPropertyDescriptors(F.api)),Id}var op={draw(t,e,n){let s=to(e),r;try{r=Js(br(t),s,n.options)}finally{s.dispose()}let o=r.bounds,i=l=>r.cards.find(c=>c.id===l)?.rect??r.panels.find(c=>c.id===l)?.rect;return{svg:eo(r,{id:"canvas-2d",title:n.title,styles:n.styles}),full:[o.l,o.t,o.r-o.l,o.b-o.t],layout:r,outlines(l,c){let d=[];for(let u of l){let f=i(u);if(f){d.push({kind:"poly",id:u,points:[[f.l,f.t],[f.r,f.t],[f.r,f.b],[f.l,f.b]]});continue}let p=c.querySelector(`path.conn[data-id="${CSS.escape(u)}"]`)?.getAttribute("d");p&&d.push({kind:"route",d:p})}return d},hits(l,c){return[...r.cards,...r.panels].filter(d=>{let u=d.rect;return c?u.l<l.r&&u.r>l.l&&u.t<l.b&&u.b>l.t:u.l>=l.l&&u.t>=l.t&&u.r<=l.r&&u.b<=l.b}).map(d=>d.id)},panelsAt(l,c){return[...r.panels].sort((d,u)=>u.depth-d.depth).filter(d=>l>=d.rect.l&&l<=d.rect.r&&c>=d.rect.t&&c<=d.rect.b).map(d=>d.id)}}},morph(t,e,n,s,r){let o=n.mode==="3d"?n.svg:s;return no(o,e,br(e)),cl(t,n.svg,s,n.mode,r)}};var rh=t=>`
|
|
471
471
|
<header class="titlebar">
|
|
472
472
|
<button id="se-tree" class="btn sm quiet icon-only" type="button" aria-expanded="false" aria-controls="se-side" aria-label="Show the outline" title="The outline"><svg class="icon" aria-hidden="true"><use href="#se-i-list-tree"></use></svg></button>
|
|
473
473
|
<span class="brand" data-se="brand" hidden>${t.brand}</span>
|
|
@@ -541,10 +541,10 @@ ${t.slots} <div id="se-grip" role="separator" aria-orientation="horizontal" a
|
|
|
541
541
|
<span id="se-st-pos"></span>
|
|
542
542
|
<span id="se-st-kind"></span>
|
|
543
543
|
<span id="se-announce" class="sr-only" aria-live="polite"></span>
|
|
544
|
-
</footer>`;function Mf(t,e,n){let s=n.features,r=n.kit,o=n.words,i=n.load,a=!!e.watch,l=e.host??{},c={get:m=>{try{return e.storage?.get(m)??null}catch{return null}},set:(m,O)=>{try{e.storage?.set(m,O)}catch{}}},d=z("div",{class:o.rootClass,"data-view":"both"}),u=document.createElement("template");u.innerHTML=n.sprite??"";let f=document.createElement("template");f.innerHTML=wm(o),d.append(u.content,f.content),t.append(d),pr(d);let p=m=>d.querySelector(`#se-${m}`),g=[],h=(m,O,L,G)=>{m.addEventListener(O,L,G),g.push(()=>m.removeEventListener(O,L,G))};h(d,"focusin",()=>pr(d)),h(d,"pointerdown",()=>pr(d));let b={problems:[],lifetimes:new Map,read:void 0,plan:void 0,view:a?"canvas":c.get(Yo.view)??"both",theme:e.theme??(l.themeControls?c.get("theme")??"system":"system"),density:l.themeControls?c.get("density")??"comfortable":"comfortable",readOnly:!!e.readOnly||!s.edit,problemsOpen:!1,problemsSeen:0,checks:0};l.brand&&(d.querySelector('[data-se="brand"]').hidden=!1);for(let m of l.titleStart??[])d.querySelector('[data-se="title-start"]').append(m);p("save").hidden=!e.onSave,p("theme").hidden=p("density").hidden=!l.themeControls;let k=new Ur;for(let m of["apply","undo","redo"]){let O=k[m].bind(k);k[m]=(...L)=>b.readOnly?(fe("This file is read-only here","warn"),!1):O(...L)}let v=()=>s.text?s.text.textPane(p("code"),k,{onOpen:m=>l.onOpen?.(m),onSave:()=>{me()},onSaveAs:()=>l.onSaveAs?.()}):vm(),M=v(),x=m=>!!m?.closest?.(".monaco-editor, #se-code"),T=s.edit?s.edit.clipboard(k,(m,O)=>fe(m,O)):{items:()=>[],attach:()=>()=>{}},y=il(p("outline"),k,{kit:n.tree,clipItems:()=>T.items(),nav:()=>r.nav(k.text),problems:()=>b.problems,role:()=>r.role(k.text),lifetimes:()=>b.lifetimes,showInText:m=>C(m),note:(m,O)=>fe(m,O)}),A=s.edit?s.edit.propsPanel(p("sel-body"),k,{nav:()=>r.nav(k.text),problems:()=>b.problems,read:()=>b.read,note:(m,O)=>fe(m,O),showInText:m=>C(m),now:m=>Be?.now?.(m)}):{paint:()=>{},dispose:()=>{}},D=()=>{p("st-sel").textContent=k.selection.length>1?`${k.selection.length} selected`:"",A.paint()};k.onSelect(D);let K=s.canvas?s.canvas.canvasView(p("canvas"),k,{problems:()=>b.problems,note:(m,O)=>fe(m,O),showInText:m=>C(m),showInTree:m=>{p("tab-outline").click(),k.select([m],"menu"),y.focus()},onZoom:m=>{p("st-zoom").textContent=`${m}%`},onHint:m=>{p("st-hint").textContent=m},clipItems:()=>T.items(),store:c,...n.canvasOpts?.(()=>Be.api)}):km(n.noCanvas);g.push(T.attach(d,m=>!!m?.closest?.("#se-outline, .canvas, #se-sel-body")));function C(m){b.view==="canvas"&&$("both",!0),M.goTo(m)}let _=d.querySelector(".side-tabs");for(let m of l.sideTabs??[]){let O=z("button",{class:"seg",type:"button",role:"tab",id:`se-tab-${m.id}`,"aria-controls":m.panel.id,"aria-selected":"false"}),L=document.createElementNS("http://www.w3.org/2000/svg","svg");L.setAttribute("class","icon"),L.setAttribute("aria-hidden","true");let G=document.createElementNS("http://www.w3.org/2000/svg","use");G.setAttribute("href",`#se-i-${m.icon}`),L.append(G),O.append(L,m.label),_.append(O),m.panel.setAttribute("role","tabpanel"),m.panel.setAttribute("aria-labelledby",O.id),m.panel.hidden=!0,d.querySelector("nav.side").append(m.panel)}_.hidden=!(l.sideTabs??[]).length;for(let m of _.querySelectorAll('[role="tab"]'))h(m,"click",()=>{for(let O of _.querySelectorAll('[role="tab"]')){let L=O===m;O.setAttribute("aria-selected",String(L)),O.classList.toggle("active",L),d.querySelector(`#${O.getAttribute("aria-controls")}`).hidden=!L}c.set("tab",m.id)});c.get("tab")&&c.get("tab")!=="se-tab-outline"&&d.querySelector(`#${c.get("tab")}`)?d.querySelector(`#${c.get("tab")}`).click():p("tab-outline").classList.add("active");let S=b.view;function $(m,O=!1){O&&(S=m,a||c.set(Yo.view,m)),s.text?s.canvas||(m="text"):m="canvas",b.view=m,d.dataset.view=m;for(let L of d.querySelectorAll("#se-views .seg"))L.setAttribute("aria-pressed",String(L.dataset.v===m));M.editor.layout()}for(let m of d.querySelectorAll("#se-views .seg"))h(m,"click",()=>$(m.dataset.v,!0));let w=m=>{d.classList.toggle("side-open",m),p("tree").setAttribute("aria-expanded",String(m)),p("tree").setAttribute("aria-label",m?"Hide the outline":"Show the outline"),p("scrim").hidden=!m};h(p("tree"),"click",()=>w(!d.classList.contains("side-open"))),h(p("scrim"),"click",()=>w(!1)),h(d,"keydown",m=>{m.key==="Escape"&&d.classList.contains("side-open")&&!m.target.closest?.("dialog, .menu")&&(w(!1),p("tree").focus())});{let m=new ResizeObserver(()=>{d.classList.contains("side-open")&&d.clientWidth>760&&w(!1)});m.observe(d),g.push(()=>m.disconnect())}function N(m,O,L,G,Z){let Se=p(m),ue=c.get(O);ue&&d.style.setProperty(O,`${ue}px`);let Ke=()=>parseFloat(getComputedStyle(d).getPropertyValue(O))||(L==="left"?260:280),Ye=Ie=>{let De=Math.round(Math.min(Z,Math.max(G,Ie)));d.style.setProperty(O,`${De}px`),c.set(O,String(De))};h(Se,"pointerdown",Ie=>{Se.setPointerCapture(Ie.pointerId);let De=Ie.clientX,Ce=Ke(),vt=kt=>Ye(L==="left"?Ce+kt.clientX-De:Ce-(kt.clientX-De)),Mn=()=>{Se.removeEventListener("pointermove",vt),Se.removeEventListener("pointerup",Mn)};Se.addEventListener("pointermove",vt),Se.addEventListener("pointerup",Mn)}),h(Se,"keydown",Ie=>{let De=Ie.key==="ArrowLeft"?-16:Ie.key==="ArrowRight"?16:0;De&&(Ye(Ke()+(L==="left"?De:-De)),Ie.preventDefault())})}N("side-grip","--side-w","left",180,520),N("right-grip","--right-w","right",200,520),N("work-grip","--canvas-w","left",240,1600);let F=m=>{d.classList.toggle("no-right",!m),p("panel").setAttribute("aria-pressed",String(m)),c.set("panel",m?"1":"0")};F(c.get("panel")!=="0"),h(p("panel"),"click",()=>F(d.classList.contains("no-right")));let J=matchMedia("(prefers-color-scheme: dark)"),ae=()=>b.theme==="dark"||b.theme==="system"&&J.matches;function we(){d.style.colorScheme=b.theme==="system"?"light dark":b.theme,b.theme==="system"?delete d.dataset.theme:d.dataset.theme=b.theme,b.density==="compact"?d.dataset.density="compact":delete d.dataset.density,M.setTheme(ae()),K.setTheme(ae()?"dark":"light");for(let m of d.querySelectorAll("#se-theme .seg"))m.setAttribute("aria-pressed",String(m.dataset.v===b.theme));p("density").setAttribute("aria-pressed",String(b.density==="compact"))}h(J,"change",()=>{b.theme==="system"&&we()});let j=m=>{b.theme=m,l.themeControls&&c.set("theme",m),we()},U=m=>{b.density=m,c.set("density",m),we()};for(let m of d.querySelectorAll("#se-theme .seg"))h(m,"click",()=>j(m.dataset.v));h(p("density"),"click",()=>U(b.density==="compact"?"comfortable":"compact"));let ee=0;function fe(m,O="info"){let L=p("note");L.className=`callout compact ${O==="info"?"":O}`,L.querySelector(".c-body").textContent=m,L.hidden=!1,clearTimeout(ee),ee=window.setTimeout(()=>{L.hidden=!0},6e3)}function B(m,O){let L=p("filebar");L.querySelector(".c-body").replaceChildren(...m),L.querySelector(".c-acts").replaceChildren(...O.map(Z=>{let Se=z("button",{type:"button",class:`btn sm${Z.primary?" primary":""}`},Z.label);return Se.addEventListener("click",Z.run),Se})),L.hidden=!1}let X=()=>{p("filebar").hidden=!0},Q=()=>k.dirty,te=!1;function ne(){p("save").disabled=!Q()||b.readOnly,Q()!==te&&(te=Q(),e.onDirtyChange?.(te))}async function me(){if(!e.onSave||b.readOnly)return!1;if(!Q())return!0;let m=k.text;k.seal();let O;try{O=await e.onSave(m)}catch(L){return fe(`Not saved: ${L.message??L}`,"bad"),!1}return"conflict"in O?l.onConflict?(l.onConflict(),!1):(B([z("span",{class:"c-title"},"Changed elsewhere."),z("span",null," This file changed outside the editor since it was loaded, so it wasn't saved.")],[{label:"Dismiss",run:X}]),!1):(k.text===m&&k.markClean(),X(),ne(),!0)}h(p("save"),"click",()=>{me()});let ye=l.keymap?sl(r.keymap,l.keymap):r.keymap,xe=()=>rl(ye);h(p("keys"),"click",()=>xe()),h(d,"keydown",m=>{let O=m.target;if(m.key==="?"&&!m.metaKey&&!m.ctrlKey&&!m.altKey){if(O.closest?.("input, textarea, select, .monaco-editor, #se-code, [contenteditable], dialog"))return;m.preventDefault(),xe();return}if(l.keys?.(m)||!(m.metaKey||m.ctrlKey)||m.altKey||x(m.target))return;let L=m.key.toLowerCase();L==="s"&&!m.shiftKey?(m.preventDefault(),me()):L==="z"&&!m.shiftKey?(k.undo(),m.preventDefault()):(L==="z"&&m.shiftKey||L==="y")&&(k.redo(),m.preventDefault())});let Re=m=>r.objectPath(m,b.read),Ue=()=>s.plan?s.plan.planPanel(p("plan"),{has:m=>!!Re(m),select:m=>{let O=Re(m);return O?(k.select([nt(O)],"menu"),!0):!1}}):{paint:()=>{}},I=Ue(),re=c.get("bottom-tab")??"problems";function $e(m){re=m,c.set("bottom-tab",m);for(let O of d.querySelectorAll('.bottom-tabs [role="tab"]')){let L=O.id===`se-tab-${m}`;O.setAttribute("aria-selected",String(L)),O.classList.toggle("active",L)}p("problems-list").hidden=m!=="problems",p("plan").hidden=m!=="plan",p("problems-toggle").setAttribute("aria-controls",m==="plan"?"se-plan":"se-problems-list")}for(let m of d.querySelectorAll('.bottom-tabs [role="tab"]'))h(m,"click",()=>{$e(m.id==="se-tab-plan"?"plan":"problems"),Ee(!0,!1)});function Pe(){I.paint(b.plan,n.hasExtra);let m=r.extraLabel(b.plan);p("plan-label").textContent=m.text,p("plan-label").className=`plan-label ${m.cls}`}let be=0,ce=!1;async function ze(){clearTimeout(be);let m=k.text,O=k.version,L=await r.check(m,b.plan,fe);ce||k.version!==O||(b.plan=L.extra,b.problems=L.problems,b.read=L.read,b.lifetimes=L.tags,b.checks++,M.setProblems(b.problems.filter(G=>!G.file)),it(),Pe(),y.paint(),D(),K.render(L.model,L.data))}g.push(k.on(()=>{ne(),Oe(),clearTimeout(be),be=window.setTimeout(()=>{ze()},150)}));function Oe(){let m=p("undo"),O=p("redo");m.disabled=!k.canUndo||b.readOnly,O.disabled=!k.canRedo||b.readOnly,m.title=k.canUndo?`Undo ${k.undoLabel} (\u2318Z)`:"Nothing to undo",O.title=k.canRedo?`Redo ${k.redoLabel} (\u21E7\u2318Z)`:"Nothing to redo",m.setAttribute("aria-label",m.title),O.setAttribute("aria-label",O.title)}h(p("undo"),"click",()=>{k.undo(),M.focus()}),h(p("redo"),"click",()=>{k.redo(),M.focus()});function Ee(m,O){O&&!b.problems.length&&!Be?.attention?.()?.count&&re==="problems"&&(m=!1),b.problemsOpen=m,p("problems").classList.toggle("collapsed",!m),p("problems-toggle").setAttribute("aria-expanded",String(m)),M.editor.layout()}h(p("problems-toggle"),"click",()=>Ee(!b.problemsOpen,!0));let Be;function it(){let m=p("problems-list");m.replaceChildren();let O=b.problems.filter(ue=>ue.severity==="error").length,L=b.problems.length-O;p("problems-label").textContent=b.problems.length?`Problems \xB7 ${O} error${O===1?"":"s"}, ${L} warning${L===1?"":"s"}`:"No problems";let G=b.problemsSeen,Z=Be?.attention?.();b.problemsSeen=b.problems.length+(Z?.count??0);let Se=Z?.opens??0;Z?.still&&!b.problems.length?Ee(b.problemsOpen,!1):!b.problems.length&&!Se&&re==="problems"?Ee(!1,!1):(b.problems.length||Se)&&!G?Ee(!0,!1):Ee(b.problemsOpen,!1),p("st-problems").textContent=`${O} \u2715 ${L} \u26A0`,p("st-problems").className=O?"bad":L?"warn":"ok",Z?.rows.length&&(m.append(...Z.rows),b.problems.length&&m.append(z("div",{class:"prob-head"},"In the file"))),p("problems-label").textContent=(b.problems.length?p("problems-label").textContent:Z?.count?"":"No problems")+(Z?.count?`${b.problems.length?" \xB7 ":""}${Z.label}`:"");for(let ue of b.problems){let Ke=z("button",{type:"button",class:`prob ${ue.severity}${ue.file?" other-file":""}`},z("span",{class:"where"},ue.file?`${ue.file} \xB7 line ${ue.startLine}`:`${ue.startLine}:${ue.startCol}`),z("span",{class:"msg"},ue.message),ue.hint?z("span",{class:"hint"},ue.hint):null);ue.file?Ke.title=`In ${ue.file}, line ${ue.startLine}: not in this file`:Ke.addEventListener("click",()=>M.goToOffset(el(k.text,ue)[0])),m.append(Ke)}}let We=0,Ne=()=>{We||(We=requestAnimationFrame(()=>{We=0;let m=M.caret();p("st-pos").textContent=m?`Ln ${m.line}, Col ${m.col}`:""}))},gt=qs(()=>Ze());function Ze(){let m=M.pathAtCaret();p("st-path").textContent=m.length?m.join(" \u203A "):"",p("st-path").title=Me(m),p("st-kind").textContent=r.kindLabel(k.text)}let ft=()=>M.onCaret(()=>{Ne(),gt()});ft(),g.push(k.on(m=>{Ne(),Ys(m)?gt():gt.now()}));{let m=p("grip"),O=G=>{let Z=Math.min(Math.max(p("problems").getBoundingClientRect().height-G,48),innerHeight*.6);d.style.setProperty("--problems-h",`${Z}px`),c.set("problems-h",String(Math.round(Z)))},L=c.get("problems-h");L&&d.style.setProperty("--problems-h",`${L}px`),h(m,"pointerdown",G=>{m.setPointerCapture(G.pointerId);let Z=G.clientY,Se=Ke=>{O(Ke.clientY-Z),Z=Ke.clientY},ue=()=>{m.removeEventListener("pointermove",Se),m.removeEventListener("pointerup",ue)};m.addEventListener("pointermove",Se),m.addEventListener("pointerup",ue)}),h(m,"keydown",G=>{G.key==="ArrowUp"&&(O(-16),G.preventDefault()),G.key==="ArrowDown"&&(O(16),G.preventDefault())})}Be=n.part?.({root:d,byId:p,doc:k,store:c,note:fe,watch:a,on:(m,O,L)=>h(m,O,L),disposed:()=>ce,paintProblems:()=>it(),paintProps:()=>A.paint()},{canvas:()=>K,objectPath:Re});function ot(m){m=m||!s.edit,b.readOnly=m,d.classList.toggle("read-only",m),p("ro").hidden=!m,M.setReadOnly(m),ne(),Oe()}function at(){p("views").hidden=!(s.text&&s.canvas),p("right").hidden=p("right-grip").hidden=!s.edit,p("tab-plan").hidden=!s.plan,d.dataset.features=Object.keys(s).sort().join(" ")}!s.plan&&re==="plan"&&(re="problems"),$e(re),at(),$(b.view),we(),ot(b.readOnly),k.load(e.text??""),Be?.start?.(),ne(),Oe();let E=n.late,Y=Promise.resolve();async function q(m){let O=m.filter(G=>!n.names.includes(G));if(O.length)throw new Error(`unknown feature ${O.join(", ")}: the features are ${n.names.join(", ")}`);let L=Y.then(async()=>{if(ce)throw new Error("the editor was disposed");let G=[...new Set(m)].filter(Ke=>!s[Ke]);if(!G.length)return;let Z=G.filter(Ke=>!E.includes(Ke));if(Z.length)throw new Error(`${Z.join(", ")} can't be added to a mounted editor (only ${E.join(" and ")} can): mount with ${Z.length>1?"them":"it"}`);if(!i)throw new Error(`this build has no loader for ${G.join(", ")}: mount with ${G.length>1?"them":"it"}`);let Se=await i(G);if(ce)throw new Error("the editor was disposed");let ue=k.selection.slice();for(let Ke of Se)s[Ke.name]=Ke;G.includes("text")&&(M.dispose(),M=v(),ft(),M.setReadOnly(b.readOnly),M.setProblems(b.problems.filter(Ke=>!Ke.file)),we(),ue.length&&k.select(ue,"menu")),G.includes("plan")&&(I=Ue(),Pe()),at(),$(S),Ze()});return Y=L.catch(()=>{}),L}let de={root:d,doc:k,get pane(){return M},tree:y,canvas:K,props:A,clip:T,state:b,check:ze,save:me,note:fe,setView:$,showBanner:B,hideBanner:X,keySheet:xe,setTheme:j,setDensity:U,setBottomTab:$e,markers:()=>M.monaco.editor.getModelMarkers({resource:M.model.uri}).map(O=>({severity:O.severity,message:O.message,line:O.startLineNumber,col:O.startColumn,endCol:O.endColumn}))};return n.internal&&Object.defineProperties(de,Object.getOwnPropertyDescriptors(n.internal)),Be&&Object.defineProperties(de,Object.getOwnPropertyDescriptors(Be.api)),{internal:de,getText:()=>k.text,setText(m){X(),k.load(m),k.markClean(),ne(),Oe()},setReadOnly:ot,setTheme:j,addFeatures:q,fit(){ce||K.fit()},dispose(){if(!ce){ce=!0,clearTimeout(be),clearTimeout(ee),Be?.dispose?.(),cancelAnimationFrame(We),gt.cancel(),nl();for(let m of g.splice(0))m();y.dispose(),A.dispose(),K.dispose(),M.dispose(),d.remove(),pr(null)}}}}function vm(){let t=()=>{};return{setTheme:t,setReadOnly:t,setProblems:t,goTo:t,goToOffset:t,focus:t,dispose:t,onCaret:t,caret:()=>{},pathAtCaret:()=>[],editor:{layout:t,focus:t},model:void 0,monaco:void 0,resyncs:()=>0}}function km(t={}){let e={palette:void 0,doc:void 0,stage:void 0,...t};return new Proxy({},{get:(n,s)=>s in e?e[s]:()=>{}})}var $f=1;function Ef(t,e){return!!t&&typeof t=="object"&&t.v===1&&e.includes(t.type)}var Zr={"arrow-up-right":'<path d="M7 7h10v10" /> <path d="M7 17 17 7" />',box:'<path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z" /> <path d="m3.3 7 8.7 5 8.7-5" /> <path d="M12 22V12" />',"chevron-down":'<path d="m6 9 6 6 6-6" />',"chevron-right":'<path d="m9 18 6-6-6-6" />',"circle-dot":'<circle cx="12" cy="12" r="1" /> <circle cx="12" cy="12" r="10" />',"circle-x":'<circle cx="12" cy="12" r="10" /> <path d="m15 9-6 6" /> <path d="m9 9 6 6" />',clipboard:'<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /> <path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" />',"clipboard-paste":'<path d="M11 14h10" /> <path d="M16 4h2a2 2 0 0 1 2 2v1.344" /> <path d="m17 18 4-4-4-4" /> <path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /> <rect x="8" y="2" width="8" height="4" rx="1" />',"code-xml":'<path d="m18 16 4-4-4-4" /> <path d="m6 8-4 4 4 4" /> <path d="m14.5 4-5 16" />',copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /> <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /> <path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /> <path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',link:'<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /> <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />',list:'<path d="M3 5h.01" /> <path d="M3 12h.01" /> <path d="M3 19h.01" /> <path d="M8 5h13" /> <path d="M8 12h13" /> <path d="M8 19h13" />',"list-tree":'<path d="M8 5h13" /> <path d="M13 12h8" /> <path d="M13 19h8" /> <path d="M3 10a2 2 0 0 0 2 2h3" /> <path d="M3 5v12a2 2 0 0 0 2 2h3" />',"panel-right":'<rect width="18" height="18" x="3" y="3" rx="2" /> <path d="M15 3v18" />',pencil:'<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /> <path d="m15 5 4 4" />',plus:'<path d="M5 12h14" /> <path d="M12 5v14" />',"rotate-ccw":'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /> <path d="M3 3v5h5" />',"trash-2":'<path d="M10 11v6" /> <path d="M14 11v6" /> <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /> <path d="M3 6h18" /> <path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',"triangle-alert":'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" /> <path d="M12 9v4" /> <path d="M12 17h.01" />',x:'<path d="M18 6 6 18" /> <path d="m6 6 12 12" />'},Tf=Object.keys(Zr),Wo=t=>Object.entries(t).map(([e,n])=>`<symbol id="se-i-${e}" viewBox="0 0 24 24">${n}</symbol>`).join(""),Jo=t=>`<svg xmlns="http://www.w3.org/2000/svg" class="sprite" aria-hidden="true" focusable="false">${t}</svg>`,Af=Jo(Wo(Zr));var Sm=/^[a-z][a-z0-9-]*$/,Qc={rootClass:"iso-editor",brand:"iso <b>editor</b>",sideLabel:"The file",canvasLabel:"The file, drawn",problemsLabel:"Problems",bottomTabsLabel:"Problems",extraTab:"Check",slots:""},ul=[{where:"Anywhere in the editor",keys:[["\u2318S","Save"],["\u2318Z","Undo"],["\u21E7\u2318Z or \u2318Y","Redo"],["?","This sheet"],["Esc","Close a menu or dialog"]]},{where:"The tree and the canvas",keys:[["F2","Rename"],["\u232B","Delete"],["\u2318D","Duplicate"],["\u2318\u2191","Select the parent"]]},{where:"The canvas",keys:[["+ \u2212","Zoom"],["0","Fit"],["1","100%"],["\u21E72","Zoom to the selection"]]}];function Pf(t,e,n){let s=Xr(t),r=e.nameRule??Sm,o=e.nameHint??"a lower-case letter, then lower-case letters, digits and -",i=e.icon??(()=>"box"),a=al({commands:s,objectOf:t.objectOf,kinds:t.kinds,nameRule:r,nameHint:o}),l=Qa(t),c={docFor:Xa,completionAt:l.completionAt,hoverAt:l.hoverAt,definitionAt:l.definitionAt,rangeOfPath:Za},d=(x,T)=>T.reduce((y,A)=>y&&typeof y=="object"?y[A]:void 0,x),u=(x,T)=>d(x,[T,"layout"]),f={key:t.pins.key,legacyKey:t.pins.legacyKey,legacyOnly:t.pins.legacyOnly,of:x=>u(x,t.pins.key)??(t.pins.legacyKey?u(x,t.pins.legacyKey):void 0),keyOf:x=>t.pins.legacyOnly(x)&&t.pins.legacyKey?t.pins.legacyKey:t.pins.key},p=(x,T=e.fileName)=>t.read(x,{fileName:T,role:t.role(x)}),g={outline:(x,T,y)=>Wa(x,t,T,y),commands:s,slotAt:t.slotAt,kinds:t.kinds,entryGroups:t.entryGroups,nameRule:r,ui:{label:"The file, as a tree",rootIcon:"layers",kindIcon:i,keyIcon:()=>{},entryIcon:()=>"list-tree",newItems:x=>[{label:`New ${t.kinds.find(y=>y.kind===x).singular}`,icon:i(x)}],tagPill:x=>({title:x}),nameHint:o,text:{root:"File",rootAdd:"the file",renameWhy:"Groups and the file itself have fixed names",deleteWhy:"The file itself stays",duplicateNote:"Duplicate works on objects",duplicateWhy:"Only objects can be duplicated"}}},h={commands:s,actions:a,slotAt:t.slotAt,objectOf:t.objectOf,kinds:t.kinds,ui:{important:()=>[],isExternal:()=>!1,inheritedFrom:"the base file",extensionDoc:"An extension: ignored by the reader.",rootTitle:"The file",rootItem:"(the file)"}},b={rootClass:"iso-canvas",panKeyClass:"pan-key",newOrder:t.kinds.map(x=>x.kind),palette:e.palette?e.palette.map(x=>({kind:x.kind,label:x.label,icon:x.icon??i(x.kind),name:x.name,...x.value===void 0?{}:{value:()=>structuredClone(x.value)}})):t.kinds.map(x=>({kind:x.kind,icon:i(x.kind),label:x.singular[0].toUpperCase()+x.singular.slice(1)})),text:{stage:"The file, drawn: arrow keys and Tab move through what is drawn; + and \u2212 zoom, 0 fits",dragGroup:"A drag on nothing",dragSelectTip:"Drag draws a selection; hold the space key to pan",unreadable:"The canvas draws a file that reads cleanly; fix the problems listed to see it.",palette:"Add to the file: click, or drag onto the canvas",pinHint:"",renameWhy:"Only objects are renamed here",duplicateWhy:"Only objects are duplicated"}},k={draw:e.draw,catalog:e.catalog,objectOf:t.objectOf,kinds:t.kinds,commands:s,actions:a,objectItems:()=>[],pins:f,ui:b,flat:e.flat,...t.connect?{connect:(x,T,y)=>t.connect(x,T,y)}:{},...t.group?{group:(x,T)=>t.group(x,T)}:{},...t.dropInto?{dropOnto:(x,T,y,A)=>t.dropInto(x,T,y,A)}:{},trial:(x,T)=>{let y=p(x);return y.read===void 0||y.diags.some(A=>A.severity==="error")?void 0:e.draw(y.read,y.read.data,T)}},v={async check(x){let T=Ja(t,x,{fileName:e.fileName}),y=!T.problems.some(A=>A.severity==="error")&&T.read!==void 0;return{problems:T.problems,read:T.read,tags:T.tags,model:y?T.read:void 0,data:T.read?.data,extra:void 0}},role:x=>t.role(x),kindLabel:()=>t.id,nav:l.navFor,objectPath(x,T){let y=T?.data;for(let A of t.kinds)if(d(y,[...A.section,x])!==void 0)return Me([...A.section,x])},extraLabel:()=>({text:"",cls:""}),keymap:e.keymap??(t.group?ul.map(x=>x.where==="The tree and the canvas"?{...x,keys:[...x.keys,["\u2318G","Group the selection"]]}:x):ul)},M={canvas:{canvasView:(x,T,y)=>dl(x,T,{...y,theme:e.theme,kit:k,layer:e.layer})},edit:{propsPanel:(x,T,y)=>cl(x,T,{...y,kit:h}),clipboard:(x,T)=>ol(x,T,qa(t))},...n?{text:{textPane:(x,T,y)=>n(x,T,{...y,services:c})}}:{}};return{kit:v,tree:g,words:{...Qc,...e.words},features:M,names:["text","canvas","edit"],late:["text"],hasExtra:!1,part:e.part?x=>e.part(x):void 0,sprite:Jo(Wo({...Zr,...e.icons}))}}function Mm(t){let e=[],n=t.replace(/\/\*[\s\S]*?\*\//g,""),s=0;for(;s<n.length;){let r=n.indexOf("{",s),o=n.indexOf(";",s);if(r<0&&o<0)break;if(o>=0&&(r<0||o<r)){let l=n.slice(s,o).trim();l&&e.push([l,null]),s=o+1;continue}let i=1,a=r+1;for(;a<n.length&&i;)n[a]==="{"?i++:n[a]==="}"&&i--,a++;e.push([n.slice(s,r).trim(),n.slice(r+1,a-1)]),s=a}return e}function $m(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 Zc(t,e){let n=`.${e}`,s=/^(?:html|body|:root)((?:\[[^\]]*\]|\.[\w-]+|:not\([^)]*\))*)(.*)$/.exec(t);return s&&/^(html|body|:root)(?![\w-])/.test(t)?`${n}${s[1]}${s[2].trim()?" "+s[2].trim():""}`:t==="*"?`${n}, ${n} *`:`${n} ${t}`}function ed(t,e){let n="";for(let[s,r]of Mm(t)){if(r===null){(s.startsWith("@layer")||s.startsWith("@import"))&&(n+=`${s};
|
|
544
|
+
</footer>`;function ip(t,e,n){let s=n.features,r=n.kit,o=n.words,i=n.load,a=!!e.watch,l=e.host??{},c={get:m=>{try{return e.storage?.get(m)??null}catch{return null}},set:(m,C)=>{try{e.storage?.set(m,C)}catch{}}},d=_("div",{class:o.rootClass,"data-view":"both"}),u=document.createElement("template");u.innerHTML=n.sprite??"";let f=document.createElement("template");f.innerHTML=rh(o),d.append(u.content,f.content),t.append(d),$r(d);let p=m=>d.querySelector(`#se-${m}`),g=[],h=(m,C,R,H)=>{m.addEventListener(C,R,H),g.push(()=>m.removeEventListener(C,R,H))};h(d,"focusin",()=>$r(d)),h(d,"pointerdown",()=>$r(d));let b={problems:[],lifetimes:new Map,read:void 0,plan:void 0,view:a?"canvas":c.get(fi.view)??"both",theme:e.theme??(l.themeControls?c.get("theme")??"system":"system"),density:l.themeControls?c.get("density")??"comfortable":"comfortable",readOnly:!!e.readOnly||!s.edit,problemsOpen:!1,problemsSeen:0,checks:0};l.brand&&(d.querySelector('[data-se="brand"]').hidden=!1);for(let m of l.titleStart??[])d.querySelector('[data-se="title-start"]').append(m);p("save").hidden=!e.onSave,p("theme").hidden=p("density").hidden=!l.themeControls;let v=new ao;for(let m of["apply","undo","redo"]){let C=v[m].bind(v);v[m]=(...R)=>b.readOnly?(be("This file is read-only here","warn"),!1):C(...R)}let w=()=>s.text?s.text.textPane(p("code"),v,{onOpen:m=>l.onOpen?.(m),onSave:()=>{ve()},onSaveAs:()=>l.onSaveAs?.()}):oh(),k=w(),y=m=>!!m?.closest?.(".monaco-editor, #se-code"),M=s.edit?s.edit.clipboard(v,(m,C)=>be(m,C)):{items:()=>[],attach:()=>()=>{}},T=Ol(p("outline"),v,{kit:n.tree,clipItems:()=>M.items(),nav:()=>r.nav(v.text),problems:()=>b.problems,role:()=>r.role(v.text),lifetimes:()=>b.lifetimes,showInText:m=>L(m),note:(m,C)=>be(m,C)}),A=s.edit?s.edit.propsPanel(p("sel-body"),v,{nav:()=>r.nav(v.text),problems:()=>b.problems,read:()=>b.read,note:(m,C)=>be(m,C),showInText:m=>L(m),now:m=>je?.now?.(m)}):{paint:()=>{},dispose:()=>{}},I=()=>{p("st-sel").textContent=v.selection.length>1?`${v.selection.length} selected`:"",A.paint()};v.onSelect(I);let j=s.canvas?s.canvas.canvasView(p("canvas"),v,{problems:()=>b.problems,note:(m,C)=>be(m,C),showInText:m=>L(m),showInTree:m=>{p("tab-outline").click(),v.select([m],"menu"),T.focus()},onZoom:m=>{p("st-zoom").textContent=`${m}%`},onHint:m=>{p("st-hint").textContent=m},clipItems:()=>M.items(),store:c,...n.canvasOpts?.(()=>je.api)}):ih(n.noCanvas);g.push(M.attach(d,m=>!!m?.closest?.("#se-outline, .canvas, #se-sel-body")));function L(m){b.view==="canvas"&&E("both",!0),k.goTo(m)}let B=d.querySelector(".side-tabs");for(let m of l.sideTabs??[]){let C=_("button",{class:"seg",type:"button",role:"tab",id:`se-tab-${m.id}`,"aria-controls":m.panel.id,"aria-selected":"false"}),R=document.createElementNS("http://www.w3.org/2000/svg","svg");R.setAttribute("class","icon"),R.setAttribute("aria-hidden","true");let H=document.createElementNS("http://www.w3.org/2000/svg","use");H.setAttribute("href",`#se-i-${m.icon}`),R.append(H),C.append(R,m.label),B.append(C),m.panel.setAttribute("role","tabpanel"),m.panel.setAttribute("aria-labelledby",C.id),m.panel.hidden=!0,d.querySelector("nav.side").append(m.panel)}B.hidden=!(l.sideTabs??[]).length;for(let m of B.querySelectorAll('[role="tab"]'))h(m,"click",()=>{for(let C of B.querySelectorAll('[role="tab"]')){let R=C===m;C.setAttribute("aria-selected",String(R)),C.classList.toggle("active",R),d.querySelector(`#${C.getAttribute("aria-controls")}`).hidden=!R}c.set("tab",m.id)});c.get("tab")&&c.get("tab")!=="se-tab-outline"&&d.querySelector(`#${c.get("tab")}`)?d.querySelector(`#${c.get("tab")}`).click():p("tab-outline").classList.add("active");let S=b.view;function E(m,C=!1){C&&(S=m,a||c.set(fi.view,m)),s.text?s.canvas||(m="text"):m="canvas",b.view=m,d.dataset.view=m;for(let R of d.querySelectorAll("#se-views .seg"))R.setAttribute("aria-pressed",String(R.dataset.v===m));k.editor.layout()}for(let m of d.querySelectorAll("#se-views .seg"))h(m,"click",()=>E(m.dataset.v,!0));let x=m=>{d.classList.toggle("side-open",m),p("tree").setAttribute("aria-expanded",String(m)),p("tree").setAttribute("aria-label",m?"Hide the outline":"Show the outline"),p("scrim").hidden=!m};h(p("tree"),"click",()=>x(!d.classList.contains("side-open"))),h(p("scrim"),"click",()=>x(!1)),h(d,"keydown",m=>{m.key==="Escape"&&d.classList.contains("side-open")&&!m.target.closest?.("dialog, .menu")&&(x(!1),p("tree").focus())});{let m=new ResizeObserver(()=>{d.classList.contains("side-open")&&d.clientWidth>760&&x(!1)});m.observe(d),g.push(()=>m.disconnect())}function N(m,C,R,H,ee){let $e=p(m),de=c.get(C);de&&d.style.setProperty(C,`${de}px`);let De=()=>parseFloat(getComputedStyle(d).getPropertyValue(C))||(R==="left"?260:280),He=Ne=>{let Ye=Math.round(Math.min(ee,Math.max(H,Ne)));d.style.setProperty(C,`${Ye}px`),c.set(C,String(Ye))};h($e,"pointerdown",Ne=>{$e.setPointerCapture(Ne.pointerId);let Ye=Ne.clientX,ot=De(),Mt=Ct=>He(R==="left"?ot+Ct.clientX-Ye:ot-(Ct.clientX-Ye)),$n=()=>{$e.removeEventListener("pointermove",Mt),$e.removeEventListener("pointerup",$n)};$e.addEventListener("pointermove",Mt),$e.addEventListener("pointerup",$n)}),h($e,"keydown",Ne=>{let Ye=Ne.key==="ArrowLeft"?-16:Ne.key==="ArrowRight"?16:0;Ye&&(He(De()+(R==="left"?Ye:-Ye)),Ne.preventDefault())})}N("side-grip","--side-w","left",180,520),N("right-grip","--right-w","right",200,520),N("work-grip","--canvas-w","left",240,1600);let z=m=>{d.classList.toggle("no-right",!m),p("panel").setAttribute("aria-pressed",String(m)),c.set("panel",m?"1":"0")};z(c.get("panel")!=="0"),h(p("panel"),"click",()=>z(d.classList.contains("no-right")));let Q=matchMedia("(prefers-color-scheme: dark)"),re=()=>b.theme==="dark"||b.theme==="system"&&Q.matches;function we(){d.style.colorScheme=b.theme==="system"?"light dark":b.theme,b.theme==="system"?delete d.dataset.theme:d.dataset.theme=b.theme,b.density==="compact"?d.dataset.density="compact":delete d.dataset.density,k.setTheme(re()),j.setTheme(re()?"dark":"light");for(let m of d.querySelectorAll("#se-theme .seg"))m.setAttribute("aria-pressed",String(m.dataset.v===b.theme));p("density").setAttribute("aria-pressed",String(b.density==="compact"))}h(Q,"change",()=>{b.theme==="system"&&we()});let F=m=>{b.theme=m,l.themeControls&&c.set("theme",m),we()},X=m=>{b.density=m,c.set("density",m),we()};for(let m of d.querySelectorAll("#se-theme .seg"))h(m,"click",()=>F(m.dataset.v));h(p("density"),"click",()=>X(b.density==="compact"?"comfortable":"compact"));let Z=0;function be(m,C="info"){let R=p("note");R.className=`callout compact ${C==="info"?"":C}`,R.querySelector(".c-body").textContent=m,R.hidden=!1,clearTimeout(Z),Z=window.setTimeout(()=>{R.hidden=!0},6e3)}function V(m,C){let R=p("filebar");R.querySelector(".c-body").replaceChildren(...m),R.querySelector(".c-acts").replaceChildren(...C.map(ee=>{let $e=_("button",{type:"button",class:`btn sm${ee.primary?" primary":""}`},ee.label);return $e.addEventListener("click",ee.run),$e})),R.hidden=!1}let J=()=>{p("filebar").hidden=!0},G=()=>v.dirty,ne=!1;function oe(){p("save").disabled=!G()||b.readOnly,G()!==ne&&(ne=G(),e.onDirtyChange?.(ne))}async function ve(){if(!e.onSave||b.readOnly)return!1;if(!G())return!0;let m=v.text;v.seal();let C;try{C=await e.onSave(m)}catch(R){return be(`Not saved: ${R.message??R}`,"bad"),!1}return"conflict"in C?l.onConflict?(l.onConflict(),!1):(V([_("span",{class:"c-title"},"Changed elsewhere."),_("span",null," This file changed outside the editor since it was loaded, so it wasn't saved.")],[{label:"Dismiss",run:J}]),!1):(v.text===m&&v.markClean(),J(),oe(),!0)}h(p("save"),"click",()=>{ve()});let ge=l.keymap?Al(r.keymap,l.keymap):r.keymap,ye=()=>Pl(ge);h(p("keys"),"click",()=>ye()),h(d,"keydown",m=>{let C=m.target;if(m.key==="?"&&!m.metaKey&&!m.ctrlKey&&!m.altKey){if(C.closest?.("input, textarea, select, .monaco-editor, #se-code, [contenteditable], dialog"))return;m.preventDefault(),ye();return}if(l.keys?.(m)||!(m.metaKey||m.ctrlKey)||m.altKey||y(m.target))return;let R=m.key.toLowerCase();R==="s"&&!m.shiftKey?(m.preventDefault(),ve()):R==="z"&&!m.shiftKey?(v.undo(),m.preventDefault()):(R==="z"&&m.shiftKey||R==="y")&&(v.redo(),m.preventDefault())});let Ie=m=>r.objectPath(m,b.read),Ue=()=>s.plan?s.plan.planPanel(p("plan"),{has:m=>!!Ie(m),select:m=>{let C=Ie(m);return C?(v.select([et(C)],"menu"),!0):!1}}):{paint:()=>{}},D=Ue(),se=c.get("bottom-tab")??"problems";function Me(m){se=m,c.set("bottom-tab",m);for(let C of d.querySelectorAll('.bottom-tabs [role="tab"]')){let R=C.id===`se-tab-${m}`;C.setAttribute("aria-selected",String(R)),C.classList.toggle("active",R)}p("problems-list").hidden=m!=="problems",p("plan").hidden=m!=="plan",p("problems-toggle").setAttribute("aria-controls",m==="plan"?"se-plan":"se-problems-list")}for(let m of d.querySelectorAll('.bottom-tabs [role="tab"]'))h(m,"click",()=>{Me(m.id==="se-tab-plan"?"plan":"problems"),Te(!0,!1)});function Ce(){D.paint(b.plan,n.hasExtra);let m=r.extraLabel(b.plan);p("plan-label").textContent=m.text,p("plan-label").className=`plan-label ${m.cls}`}let he=0,ie=!1;async function Ke(){clearTimeout(he);let m=v.text,C=v.version,R=await r.check(m,b.plan,be);ie||v.version!==C||(b.plan=R.extra,b.problems=R.problems,b.read=R.read,b.lifetimes=R.tags,b.checks++,k.setProblems(b.problems.filter(H=>!H.file)),lt(),Ce(),T.paint(),I(),j.render(R.model,R.data))}g.push(v.on(()=>{oe(),Oe(),clearTimeout(he),he=window.setTimeout(()=>{Ke()},150)}));function Oe(){let m=p("undo"),C=p("redo");m.disabled=!v.canUndo||b.readOnly,C.disabled=!v.canRedo||b.readOnly,m.title=v.canUndo?`Undo ${v.undoLabel} (\u2318Z)`:"Nothing to undo",C.title=v.canRedo?`Redo ${v.redoLabel} (\u21E7\u2318Z)`:"Nothing to redo",m.setAttribute("aria-label",m.title),C.setAttribute("aria-label",C.title)}h(p("undo"),"click",()=>{v.undo(),k.focus()}),h(p("redo"),"click",()=>{v.redo(),k.focus()});function Te(m,C){C&&!b.problems.length&&!je?.attention?.()?.count&&se==="problems"&&(m=!1),b.problemsOpen=m,p("problems").classList.toggle("collapsed",!m),p("problems-toggle").setAttribute("aria-expanded",String(m)),k.editor.layout()}h(p("problems-toggle"),"click",()=>Te(!b.problemsOpen,!0));let je;function lt(){let m=p("problems-list");m.replaceChildren();let C=b.problems.filter(de=>de.severity==="error").length,R=b.problems.length-C;p("problems-label").textContent=b.problems.length?`Problems \xB7 ${C} error${C===1?"":"s"}, ${R} warning${R===1?"":"s"}`:"No problems";let H=b.problemsSeen,ee=je?.attention?.();b.problemsSeen=b.problems.length+(ee?.count??0);let $e=ee?.opens??0;ee?.still&&!b.problems.length?Te(b.problemsOpen,!1):!b.problems.length&&!$e&&se==="problems"?Te(!1,!1):(b.problems.length||$e)&&!H?Te(!0,!1):Te(b.problemsOpen,!1),p("st-problems").textContent=`${C} \u2715 ${R} \u26A0`,p("st-problems").className=C?"bad":R?"warn":"ok",ee?.rows.length&&(m.append(...ee.rows),b.problems.length&&m.append(_("div",{class:"prob-head"},"In the file"))),p("problems-label").textContent=(b.problems.length?p("problems-label").textContent:ee?.count?"":"No problems")+(ee?.count?`${b.problems.length?" \xB7 ":""}${ee.label}`:"");for(let de of b.problems){let De=_("button",{type:"button",class:`prob ${de.severity}${de.file?" other-file":""}`},_("span",{class:"where"},de.file?`${de.file} \xB7 line ${de.startLine}`:`${de.startLine}:${de.startCol}`),_("span",{class:"msg"},de.message),de.hint?_("span",{class:"hint"},de.hint):null);de.file?De.title=`In ${de.file}, line ${de.startLine}: not in this file`:De.addEventListener("click",()=>k.goToOffset($l(v.text,de)[0])),m.append(De)}}let We=0,ft=()=>{We||(We=requestAnimationFrame(()=>{We=0;let m=k.caret();p("st-pos").textContent=m?`Ln ${m.line}, Col ${m.col}`:""}))},ut=or(()=>it());function it(){let m=k.pathAtCaret();p("st-path").textContent=m.length?m.join(" \u203A "):"",p("st-path").title=Se(m),p("st-kind").textContent=r.kindLabel(v.text)}let Pe=()=>k.onCaret(()=>{ft(),ut()});Pe(),g.push(v.on(m=>{ft(),rr(m)?ut():ut.now()}));{let m=p("grip"),C=H=>{let ee=Math.min(Math.max(p("problems").getBoundingClientRect().height-H,48),innerHeight*.6);d.style.setProperty("--problems-h",`${ee}px`),c.set("problems-h",String(Math.round(ee)))},R=c.get("problems-h");R&&d.style.setProperty("--problems-h",`${R}px`),h(m,"pointerdown",H=>{m.setPointerCapture(H.pointerId);let ee=H.clientY,$e=De=>{C(De.clientY-ee),ee=De.clientY},de=()=>{m.removeEventListener("pointermove",$e),m.removeEventListener("pointerup",de)};m.addEventListener("pointermove",$e),m.addEventListener("pointerup",de)}),h(m,"keydown",H=>{H.key==="ArrowUp"&&(C(-16),H.preventDefault()),H.key==="ArrowDown"&&(C(16),H.preventDefault())})}je=n.part?.({root:d,byId:p,doc:v,store:c,note:be,watch:a,on:(m,C,R)=>h(m,C,R),disposed:()=>ie,paintProblems:()=>lt(),paintProps:()=>A.paint()},{canvas:()=>j,objectPath:Ie});function mt(m){m=m||!s.edit,b.readOnly=m,d.classList.toggle("read-only",m),p("ro").hidden=!m,k.setReadOnly(m),oe(),Oe()}function rt(){p("views").hidden=!(s.text&&s.canvas),p("right").hidden=p("right-grip").hidden=!s.edit,p("tab-plan").hidden=!s.plan,d.dataset.features=Object.keys(s).sort().join(" ")}!s.plan&&se==="plan"&&(se="problems"),Me(se),rt(),E(b.view),we(),mt(b.readOnly),v.load(e.text??""),je?.start?.(),oe(),Oe();let P=n.late,q=Promise.resolve();async function U(m){let C=m.filter(H=>!n.names.includes(H));if(C.length)throw new Error(`unknown feature ${C.join(", ")}: the features are ${n.names.join(", ")}`);let R=q.then(async()=>{if(ie)throw new Error("the editor was disposed");let H=[...new Set(m)].filter(De=>!s[De]);if(!H.length)return;let ee=H.filter(De=>!P.includes(De));if(ee.length)throw new Error(`${ee.join(", ")} can't be added to a mounted editor (only ${P.join(" and ")} can): mount with ${ee.length>1?"them":"it"}`);if(!i)throw new Error(`this build has no loader for ${H.join(", ")}: mount with ${H.length>1?"them":"it"}`);let $e=await i(H);if(ie)throw new Error("the editor was disposed");let de=v.selection.slice();for(let De of $e)s[De.name]=De;H.includes("text")&&(k.dispose(),k=w(),Pe(),k.setReadOnly(b.readOnly),k.setProblems(b.problems.filter(De=>!De.file)),we(),de.length&&v.select(de,"menu")),H.includes("plan")&&(D=Ue(),Ce()),rt(),E(S),it()});return q=R.catch(()=>{}),R}let ae={root:d,doc:v,get pane(){return k},tree:T,canvas:j,props:A,clip:M,state:b,check:Ke,save:ve,note:be,setView:E,showBanner:V,hideBanner:J,keySheet:ye,setTheme:F,setDensity:X,setBottomTab:Me,markers:()=>k.monaco.editor.getModelMarkers({resource:k.model.uri}).map(C=>({severity:C.severity,message:C.message,line:C.startLineNumber,col:C.startColumn,endCol:C.endColumn}))};return n.internal&&Object.defineProperties(ae,Object.getOwnPropertyDescriptors(n.internal)),je&&Object.defineProperties(ae,Object.getOwnPropertyDescriptors(je.api)),{internal:ae,getText:()=>v.text,setText(m,C={}){J(),C.fit&&!ie&&j.fitNext?.(),v.load(m),v.markClean(),oe(),Oe()},setReadOnly:mt,setTheme:F,addFeatures:U,fit(){ie||j.fit()},dispose(){if(!ie){ie=!0,clearTimeout(he),clearTimeout(Z),je?.dispose?.(),cancelAnimationFrame(We),ut.cancel(),Tl();for(let m of g.splice(0))m();T.dispose(),A.dispose(),j.dispose(),k.dispose(),d.remove(),$r(null)}}}}function oh(){let t=()=>{};return{setTheme:t,setReadOnly:t,setProblems:t,goTo:t,goToOffset:t,focus:t,dispose:t,onCaret:t,caret:()=>{},pathAtCaret:()=>[],editor:{layout:t,focus:t},model:void 0,monaco:void 0,resyncs:()=>0}}function ih(t={}){let e={palette:void 0,doc:void 0,stage:void 0,...t};return new Proxy({},{get:(n,s)=>s in e?e[s]:()=>{}})}var ap=1;function lp(t,e){return!!t&&typeof t=="object"&&t.v===1&&e.includes(t.type)}var po={"arrow-up-right":'<path d="M7 7h10v10" /> <path d="M7 17 17 7" />',box:'<path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z" /> <path d="m3.3 7 8.7 5 8.7-5" /> <path d="M12 22V12" />',"chevron-down":'<path d="m6 9 6 6 6-6" />',"chevron-left":'<path d="m15 18-6-6 6-6" />',"chevron-right":'<path d="m9 18 6-6-6-6" />',"circle-dot":'<circle cx="12" cy="12" r="1" /> <circle cx="12" cy="12" r="10" />',"circle-x":'<circle cx="12" cy="12" r="10" /> <path d="m15 9-6 6" /> <path d="m9 9 6 6" />',clipboard:'<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /> <path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" />',"clipboard-paste":'<path d="M11 14h10" /> <path d="M16 4h2a2 2 0 0 1 2 2v1.344" /> <path d="m17 18 4-4-4-4" /> <path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /> <rect x="8" y="2" width="8" height="4" rx="1" />',"code-xml":'<path d="m18 16 4-4-4-4" /> <path d="m6 8-4 4 4 4" /> <path d="m14.5 4-5 16" />',copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /> <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /> <path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /> <path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',link:'<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /> <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />',list:'<path d="M3 5h.01" /> <path d="M3 12h.01" /> <path d="M3 19h.01" /> <path d="M8 5h13" /> <path d="M8 12h13" /> <path d="M8 19h13" />',"list-tree":'<path d="M8 5h13" /> <path d="M13 12h8" /> <path d="M13 19h8" /> <path d="M3 10a2 2 0 0 0 2 2h3" /> <path d="M3 5v12a2 2 0 0 0 2 2h3" />',"panel-right":'<rect width="18" height="18" x="3" y="3" rx="2" /> <path d="M15 3v18" />',pencil:'<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /> <path d="m15 5 4 4" />',plus:'<path d="M5 12h14" /> <path d="M12 5v14" />',"rotate-ccw":'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /> <path d="M3 3v5h5" />',search:'<path d="m21 21-4.34-4.34" /> <circle cx="11" cy="11" r="8" />',"trash-2":'<path d="M10 11v6" /> <path d="M14 11v6" /> <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /> <path d="M3 6h18" /> <path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',"triangle-alert":'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" /> <path d="M12 9v4" /> <path d="M12 17h.01" />',x:'<path d="M18 6 6 18" /> <path d="m6 6 12 12" />'},cp=Object.keys(po),hi=t=>Object.entries(t).map(([e,n])=>`<symbol id="se-i-${e}" viewBox="0 0 24 24">${n}</symbol>`).join(""),gi=t=>`<svg xmlns="http://www.w3.org/2000/svg" class="sprite" aria-hidden="true" focusable="false">${t}</svg>`,dp=gi(hi(po));var ah=/^[a-z][a-z0-9-]*$/,$d={rootClass:"iso-editor",brand:"iso <b>editor</b>",sideLabel:"The file",canvasLabel:"The file, drawn",problemsLabel:"Problems",bottomTabsLabel:"Problems",extraTab:"Check",slots:""},Fl=[{where:"Anywhere in the editor",keys:[["\u2318S","Save"],["\u2318Z","Undo"],["\u21E7\u2318Z or \u2318Y","Redo"],["?","This sheet"],["Esc","Close a menu or dialog"]]},{where:"The tree and the canvas",keys:[["F2","Rename"],["\u232B","Delete"],["\u2318D","Duplicate"],["\u2318\u2191","Select the parent"]]},{where:"The canvas",keys:[["+ \u2212","Zoom"],["0","Fit"],["1","100%"],["\u21E72","Zoom to the selection"]]}];function up(t,e,n){let s=co(t),r=e.nameRule??ah,o=e.nameHint??"a lower-case letter, then lower-case letters, digits and -",i=e.icon??(()=>"box"),a=Nl({commands:s,objectOf:t.objectOf,kinds:t.kinds,nameRule:r,nameHint:o}),l=Sl(t),c={docFor:kl,completionAt:l.completionAt,hoverAt:l.hoverAt,definitionAt:l.definitionAt,rangeOfPath:Ml},d=(y,M)=>M.reduce((T,A)=>T&&typeof T=="object"?T[A]:void 0,y),u=(y,M)=>d(y,[M,"layout"]),f={key:t.pins.key,legacyKey:t.pins.legacyKey,legacyOnly:t.pins.legacyOnly,of:y=>u(y,t.pins.key)??(t.pins.legacyKey?u(y,t.pins.legacyKey):void 0),keyOf:y=>t.pins.legacyOnly(y)&&t.pins.legacyKey?t.pins.legacyKey:t.pins.key},p=(y,M=e.fileName)=>t.read(y,{fileName:M,role:t.role(y)}),g={outline:(y,M,T)=>wl(y,t,M,T),commands:s,slotAt:t.slotAt,kinds:t.kinds,entryGroups:t.entryGroups,nameRule:r,ui:{label:"The file, as a tree",rootIcon:"layers",kindIcon:i,keyIcon:()=>{},entryIcon:()=>"list-tree",newItems:y=>[{label:`New ${t.kinds.find(T=>T.kind===y).singular}`,icon:i(y)}],tagPill:y=>({title:y}),nameHint:o,text:{root:"File",rootAdd:"the file",renameWhy:"Groups and the file itself have fixed names",deleteWhy:"The file itself stays",duplicateNote:"Duplicate works on objects",duplicateWhy:"Only objects can be duplicated"}}},h={commands:s,actions:a,slotAt:t.slotAt,objectOf:t.objectOf,kinds:t.kinds,ui:{important:()=>[],isExternal:()=>!1,inheritedFrom:"the base file",extensionDoc:"An extension: ignored by the reader.",rootTitle:"The file",rootItem:"(the file)"}},b={rootClass:"iso-canvas",panKeyClass:"pan-key",newOrder:t.kinds.map(y=>y.kind),palette:e.palette?e.palette.map(y=>({kind:y.kind,label:y.label,icon:y.icon??i(y.kind),name:y.name,...y.section===void 0?{}:{section:y.section},...y.value===void 0?{}:{value:()=>structuredClone(y.value)}})):t.kinds.map(y=>({kind:y.kind,icon:i(y.kind),label:y.singular[0].toUpperCase()+y.singular.slice(1)})),...e.paletteLayout===void 0?{}:{paletteLayout:e.paletteLayout},...e.doubleClick===void 0?{}:{doubleClick:e.doubleClick},text:{stage:"The file, drawn: arrow keys and Tab move through what is drawn; + and \u2212 zoom, 0 fits",dragGroup:"A drag on nothing",dragSelectTip:"Drag draws a selection; hold the space key to pan",unreadable:"The canvas draws a file that reads cleanly; fix the problems listed to see it.",palette:"Add to the file: click, or drag onto the canvas",pinHint:"",renameWhy:"Only objects are renamed here",duplicateWhy:"Only objects are duplicated"}},v={draw:e.draw,catalog:e.catalog,objectOf:t.objectOf,kinds:t.kinds,commands:s,actions:a,objectItems:()=>[],pins:f,ui:b,flat:e.flat,...t.connect?{connect:(y,M,T)=>t.connect(y,M,T)}:{},...t.group?{group:(y,M)=>t.group(y,M)}:{},...t.dropInto?{dropOnto:(y,M,T,A)=>t.dropInto(y,M,T,A)}:{},trial:(y,M)=>{let T=p(y);return T.read===void 0||T.diags.some(A=>A.severity==="error")?void 0:e.draw(T.read,T.read.data,M)}},w={async check(y){let M=vl(t,y,{fileName:e.fileName}),T=!M.problems.some(A=>A.severity==="error")&&M.read!==void 0;return{problems:M.problems,read:M.read,tags:M.tags,model:T?M.read:void 0,data:M.read?.data,extra:void 0}},role:y=>t.role(y),kindLabel:()=>t.id,nav:l.navFor,objectPath(y,M){let T=M?.data;for(let A of t.kinds)if(d(T,[...A.section,y])!==void 0)return Se([...A.section,y])},extraLabel:()=>({text:"",cls:""}),keymap:e.keymap??(t.group?Fl.map(y=>y.where==="The tree and the canvas"?{...y,keys:[...y.keys,["\u2318G","Group the selection"]]}:y):Fl)},k={canvas:{canvasView:(y,M,T)=>Dl(y,M,{...T,theme:e.theme,kit:v,layer:e.layer})},edit:{propsPanel:(y,M,T)=>Il(y,M,{...T,kit:h}),clipboard:(y,M)=>Cl(y,M,yl(t))},...n?{text:{textPane:(y,M,T)=>n(y,M,{...T,services:c})}}:{}};return{kit:w,tree:g,words:{...$d,...e.words},features:k,names:["text","canvas","edit"],late:["text"],hasExtra:!1,part:e.part?y=>e.part(y):void 0,sprite:gi(hi({...po,...e.icons}))}}function lh(t){let e=[],n=t.replace(/\/\*[\s\S]*?\*\//g,""),s=0;for(;s<n.length;){let r=n.indexOf("{",s),o=n.indexOf(";",s);if(r<0&&o<0)break;if(o>=0&&(r<0||o<r)){let l=n.slice(s,o).trim();l&&e.push([l,null]),s=o+1;continue}let i=1,a=r+1;for(;a<n.length&&i;)n[a]==="{"?i++:n[a]==="}"&&i--,a++;e.push([n.slice(s,r).trim(),n.slice(r+1,a-1)]),s=a}return e}function ch(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 Ed(t,e){let n=`.${e}`,s=/^(?:html|body|:root)((?:\[[^\]]*\]|\.[\w-]+|:not\([^)]*\))*)(.*)$/.exec(t);return s&&/^(html|body|:root)(?![\w-])/.test(t)?`${n}${s[1]}${s[2].trim()?" "+s[2].trim():""}`:t==="*"?`${n}, ${n} *`:`${n} ${t}`}function Td(t,e){let n="";for(let[s,r]of lh(t)){if(r===null){(s.startsWith("@layer")||s.startsWith("@import"))&&(n+=`${s};
|
|
545
545
|
`);continue}if(s.startsWith("@keyframes")){n+=`@keyframes se-${s.slice(10).trim()}{${r}}
|
|
546
546
|
`;continue}if(/^@(layer|media|container|supports)\b/.test(s)){n+=`${s}{
|
|
547
|
-
${
|
|
547
|
+
${Td(r,e)}}
|
|
548
548
|
`;continue}if(s.startsWith("@font-face")){n+=`${s}{${r}}
|
|
549
|
-
`;continue}if(s.startsWith("@"))throw new Error(`the editor's CSS has an at-rule it can't scope: ${s}`);let o=[...new Set(
|
|
550
|
-
`}return n}export{
|
|
549
|
+
`;continue}if(s.startsWith("@"))throw new Error(`the editor's CSS has an at-rule it can't scope: ${s}`);let o=[...new Set(ch(s).flatMap(i=>Ed(i,e).split(", ")))].join(",");n+=`${o}{${r.replace(/\banimation(-name)?:\s*([a-z][\w-]*)/g,(i,a,l)=>l==="none"?i:`animation${a??""}:se-${l}`)}}
|
|
550
|
+
`}return n}export{Bu as core,fp as editor,of as objects,Gf as viewer};
|