const e=require("./custom-Bl_fVJZ0.cjs"),t=require("./src-BMjps4Ui.cjs"),n=require("./chunk-ABZYJK2D-CbIYYZa_.cjs"),r=require("./chunk-S3R3BYOJ-B2ozcJNg.cjs"),i=require("./mermaid-parser.core-C9EbhVVg.cjs"),a=require("./chunk-4BX2VUAB-HXFjpyQg.cjs");var o={showLegend:!0,ticks:5,max:null,min:0,graticule:`circle`},s={axes:[],curves:[],options:o},c=structuredClone(s),l=n.d.radar,u=t.h(()=>r.r({...l,...n.y().radar}),`getConfig`),d=t.h(()=>c.axes,`getAxes`),f=t.h(()=>c.curves,`getCurves`),p=t.h(()=>c.options,`getOptions`),m=t.h(e=>{c.axes=e.map(e=>({name:e.name,label:e.label??e.name}))},`setAxes`),h=t.h(e=>{c.curves=e.map(e=>({name:e.name,label:e.label??e.name,entries:g(e.entries)}))},`setCurves`),g=t.h(e=>{if(e[0].axis==null)return e.map(e=>e.value);let t=d();if(t.length===0)throw Error(`Axes must be populated before curves for reference entries`);return t.map(t=>{let n=e.find(e=>e.axis?.$refText===t.name);if(n===void 0)throw Error(`Missing entry for axis `+t.label);return n.value})},`computeCurveEntries`),_={getAxes:d,getCurves:f,getOptions:p,setAxes:m,setCurves:h,setOptions:t.h(e=>{let t=e.reduce((e,t)=>(e[t.name]=t,e),{});c.options={showLegend:t.showLegend?.value??o.showLegend,ticks:t.ticks?.value??o.ticks,max:t.max?.value??o.max,min:t.min?.value??o.min,graticule:t.graticule?.value??o.graticule}},`setOptions`),getConfig:u,clear:t.h(()=>{n.a(),c=structuredClone(s)},`clear`),setAccTitle:n.B,getAccTitle:n.v,setDiagramTitle:n.U,getDiagramTitle:n.C,getAccDescription:n._,setAccDescription:n.z},v=t.h(e=>{a.t(e,_);let{axes:t,curves:n,options:r}=e;_.setAxes(t),_.setCurves(n),_.setOptions(r)},`populate`),y={parse:t.h(async e=>{let n=await i.t(`radar`,e);t.g.debug(n),v(n)},`parse`)},b=t.h((t,n,r,i)=>{let a=i.db,o=a.getAxes(),s=a.getCurves(),c=a.getOptions(),l=a.getConfig(),u=a.getDiagramTitle(),d=x(e.f(n),l),f=c.max??Math.max(...s.map(e=>Math.max(...e.entries))),p=c.min,m=Math.min(l.width,l.height)/2;S(d,o,m,c.ticks,c.graticule),C(d,o,m,l),w(d,o,s,p,f,c.graticule,l),D(d,s,c.showLegend,l),d.append(`text`).attr(`class`,`radarTitle`).text(u).attr(`x`,0).attr(`y`,-l.height/2-l.marginTop)},`draw`),x=t.h((e,t)=>{let n=t.width+t.marginLeft+t.marginRight,r=t.height+t.marginTop+t.marginBottom,i={x:t.marginLeft+t.width/2,y:t.marginTop+t.height/2};return e.attr(`viewbox`,`0 0 ${n} ${r}`).attr(`width`,n).attr(`height`,r),e.append(`g`).attr(`transform`,`translate(${i.x}, ${i.y})`)},`drawFrame`),S=t.h((e,t,n,r,i)=>{if(i===`circle`)for(let t=0;t<r;t++){let i=n*(t+1)/r;e.append(`circle`).attr(`r`,i).attr(`class`,`radarGraticule`)}else if(i===`polygon`){let i=t.length;for(let a=0;a<r;a++){let o=n*(a+1)/r,s=t.map((e,t)=>{let n=2*t*Math.PI/i-Math.PI/2;return`${o*Math.cos(n)},${o*Math.sin(n)}`}).join(` `);e.append(`polygon`).attr(`points`,s).attr(`class`,`radarGraticule`)}}},`drawGraticule`),C=t.h((e,t,n,r)=>{let i=t.length;for(let a=0;a<i;a++){let o=t[a].label,s=2*a*Math.PI/i-Math.PI/2;e.append(`line`).attr(`x1`,0).attr(`y1`,0).attr(`x2`,n*r.axisScaleFactor*Math.cos(s)).attr(`y2`,n*r.axisScaleFactor*Math.sin(s)).attr(`class`,`radarAxisLine`),e.append(`text`).text(o).attr(`x`,n*r.axisLabelFactor*Math.cos(s)).attr(`y`,n*r.axisLabelFactor*Math.sin(s)).attr(`class`,`radarAxisLabel`)}},`drawAxes`);function w(e,t,n,r,i,a,o){let s=t.length,c=Math.min(o.width,o.height)/2;n.forEach((t,n)=>{if(t.entries.length!==s)return;let l=t.entries.map((e,t)=>{let n=2*Math.PI*t/s-Math.PI/2,a=T(e,r,i,c);return{x:a*Math.cos(n),y:a*Math.sin(n)}});a===`circle`?e.append(`path`).attr(`d`,E(l,o.curveTension)).attr(`class`,`radarCurve-${n}`):a===`polygon`&&e.append(`polygon`).attr(`points`,l.map(e=>`${e.x},${e.y}`).join(` `)).attr(`class`,`radarCurve-${n}`)})}t.h(w,`drawCurves`);function T(e,t,n,r){return r*(Math.min(Math.max(e,t),n)-t)/(n-t)}t.h(T,`relativeRadius`);function E(e,t){let n=e.length,r=`M${e[0].x},${e[0].y}`;for(let i=0;i<n;i++){let a=e[(i-1+n)%n],o=e[i],s=e[(i+1)%n],c=e[(i+2)%n],l={x:o.x+(s.x-a.x)*t,y:o.y+(s.y-a.y)*t},u={x:s.x-(c.x-o.x)*t,y:s.y-(c.y-o.y)*t};r+=` C${l.x},${l.y} ${u.x},${u.y} ${s.x},${s.y}`}return`${r} Z`}t.h(E,`closedRoundCurve`);function D(e,t,n,r){if(!n)return;let i=(r.width/2+r.marginRight)*3/4,a=-(r.height/2+r.marginTop)*3/4;t.forEach((t,n)=>{let r=e.append(`g`).attr(`transform`,`translate(${i}, ${a+n*20})`);r.append(`rect`).attr(`width`,12).attr(`height`,12).attr(`class`,`radarLegendBox-${n}`),r.append(`text`).attr(`x`,16).attr(`y`,0).attr(`class`,`radarLegendText`).text(t.label)})}t.h(D,`drawLegend`);var O={draw:b},k=t.h((e,t)=>{let n=``;for(let r=0;r<e.THEME_COLOR_LIMIT;r++){let i=e[`cScale${r}`];n+=`
		.radarCurve-${r} {
			color: ${i};
			fill: ${i};
			fill-opacity: ${t.curveOpacity};
			stroke: ${i};
			stroke-width: ${t.curveStrokeWidth};
		}
		.radarLegendBox-${r} {
			fill: ${i};
			fill-opacity: ${t.curveOpacity};
			stroke: ${i};
		}
		`}return n},`genIndexStyles`),A=t.h(e=>{let t=r.r(n.T(),n.y().themeVariables);return{themeVariables:t,radarOptions:r.r(t.radar,e)}},`buildRadarStyleOptions`),j={parser:y,db:_,renderer:O,styles:t.h(({radar:e}={})=>{let{themeVariables:t,radarOptions:n}=A(e);return`
	.radarTitle {
		font-size: ${t.fontSize};
		color: ${t.titleColor};
		dominant-baseline: hanging;
		text-anchor: middle;
	}
	.radarAxisLine {
		stroke: ${n.axisColor};
		stroke-width: ${n.axisStrokeWidth};
	}
	.radarAxisLabel {
		dominant-baseline: middle;
		text-anchor: middle;
		font-size: ${n.axisLabelFontSize}px;
		color: ${n.axisColor};
	}
	.radarGraticule {
		fill: ${n.graticuleColor};
		fill-opacity: ${n.graticuleOpacity};
		stroke: ${n.graticuleColor};
		stroke-width: ${n.graticuleStrokeWidth};
	}
	.radarLegendText {
		text-anchor: start;
		font-size: ${n.legendFontSize}px;
		dominant-baseline: hanging;
	}
	${k(t,n)}
	`},`styles`)};exports.diagram=j;