import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as t}from"./src-BY_WSiz7.js";import{D as n,H as r,K as i,U as a,a as o,b as s,c,f as l,v as u,w as d,y as f}from"./chunk-I66GZJ75-DyIufBk3.js";import{i as p}from"./chunk-NSK5VX7P-C5rgTOqf.js";import{t as m}from"./chunk-3NCLNEKW-CxJ1byyi.js";import{t as h}from"./chunk-JWPE2WC7-DVXcaiue.js";import{n as g}from"./mermaid-parser.core-3r-A_QO0.js";var _={showLegend:!0,ticks:5,max:null,min:0,graticule:`circle`},v=32,y={axes:[],curves:[],options:_},b=structuredClone(y),x=l.radar,S=e(()=>p({...x,...s().radar}),`getConfig`),C=e(()=>b.axes,`getAxes`),w=e(()=>b.curves,`getCurves`),T=e(()=>b.options,`getOptions`),E=e(e=>{b.axes=e.map(e=>({name:e.name,label:e.label??e.name}))},`setAxes`),D=e(e=>{b.curves=e.map(e=>({name:e.name,label:e.label??e.name,entries:O(e.entries)}))},`setCurves`),O=e(e=>{if(e[0].axis==null)return e.map(e=>e.value);let t=C();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`),k={getAxes:C,getCurves:w,getOptions:T,setAxes:E,setCurves:D,setOptions:e(e=>{let n=e.reduce((e,t)=>(e[t.name]=t,e),{});b.options={showLegend:n.showLegend?.value??_.showLegend,ticks:n.ticks?.value??_.ticks,max:n.max?.value??_.max,min:n.min?.value??_.min,graticule:n.graticule?.value??_.graticule},b.options.ticks>v&&(t.warn(`Radar diagram ticks (${b.options.ticks}) exceeds maximum allowed (${v}). Using ${v} instead.`),b.options.ticks=v)},`setOptions`),getConfig:S,clear:e(()=>{o(),b=structuredClone(y)},`clear`),setAccTitle:a,getAccTitle:f,setDiagramTitle:i,getDiagramTitle:d,getAccDescription:u,setAccDescription:r},A=e(e=>{h(e,k);let{axes:t,curves:n,options:r}=e;k.setAxes(t),k.setCurves(n),k.setOptions(r)},`populate`),j={parse:e(async e=>{let n=await g(`radar`,e);t.debug(n),A(n)},`parse`)},M=e((e,t,n,r)=>{let i=r.db,a=i.getAxes(),o=i.getCurves(),s=i.getOptions(),c=i.getConfig(),l=i.getDiagramTitle(),u=N(m(t),c),d=s.max??Math.max(...o.map(e=>Math.max(...e.entries))),f=s.min,p=Math.min(c.width,c.height)/2;P(u,a,p,s.ticks,s.graticule),F(u,a,p,c),I(u,a,o,f,d,s.graticule,c),z(u,o,s.showLegend,c),u.append(`text`).attr(`class`,`radarTitle`).text(l).attr(`x`,0).attr(`y`,-c.height/2-c.marginTop)},`draw`),N=e((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 c(e,r,n,t.useMaxWidth??!0),e.attr(`viewBox`,`0 0 ${n} ${r}`).attr(`overflow`,`visible`),e.append(`g`).attr(`transform`,`translate(${i.x}, ${i.y})`)},`drawFrame`),P=e((e,t,n,r,i)=>{if(i===`circle`)for(let t=0;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`),F=e((e,t,n,r)=>{let i=t.length;for(let a=0;a.01?`start`:c<-.01?`end`:`middle`,d=l>.01?`hanging`:l<-.01?`auto`:`central`;e.append(`text`).text(o).attr(`x`,n*r.axisLabelFactor*c+4*c).attr(`y`,n*r.axisLabelFactor*l+4*l).attr(`text-anchor`,u).attr(`dominant-baseline`,d).attr(`class`,`radarAxisLabel`)}},`drawAxes`);function I(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=L(e,r,i,c);return{x:a*Math.cos(n),y:a*Math.sin(n)}});a===`circle`?e.append(`path`).attr(`d`,R(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}`)})}e(I,`drawCurves`);function L(e,t,n,r){return r*(Math.min(Math.max(e,t),n)-t)/(n-t)}e(L,`relativeRadius`);function R(e,t){let n=e.length,r=`M${e[0].x},${e[0].y}`;for(let i=0;i{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)})}e(z,`drawLegend`);var B={draw:M},V=e((e,t)=>{let n=``;for(let r=0;r{let t=n(),r=s(),i=p(t,r.themeVariables);return{themeVariables:i,radarOptions:p(i.radar,e)}},`buildRadarStyleOptions`),U={parser:j,db:k,renderer:B,styles:e(({radar:e}={})=>{let{themeVariables:t,radarOptions:n}=H(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 { 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; } ${V(t,n)} `},`styles`)};export{U as diagram};