import{Q as w,T as R,aE as Z,_ as u,g as J,s as K,a as tt,b as et,t as at,q as rt,l as I,c as nt,H as it,L as st,a4 as ot,e as lt,A as ct,I as dt}from"./mermaid.core-BMua9uWp.js";import{p as ut}from"./chunk-4BX2VUAB-D2OCPNfC.js";import{p as pt}from"./wardley-RL74JXVD-B19Iaomu.js";import{d as O}from"./arc-DGPiDAPj.js";import{o as gt}from"./ordinal-syO2Mdip.js";import"./preload-helper-DLdknYSj.js";import"./misc-BNcbB3dR.js";import"./jsx-runtime-hUI6LOBV.js";import"./index-CFdT0RIo.js";import"./chunk-EVOBXE3Y-Bmgys8-c.js";import"./min-BtgwXF5n.js";import"./_baseUniq-C0JF2TKV.js";import"./init-DB8TqInT.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"66e9b849450b819e11683314a547a341cb57f7d0"};var a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="12a07421-6a48-420c-8318-59051389bcab",t._sentryDebugIdIdentifier="sentry-dbid-12a07421-6a48-420c-8318-59051389bcab")}catch{}})();function ft(t,a){return a<t?-1:a>t?1:a>=t?0:NaN}function ht(t){return t}function mt(){var t=ht,a=ft,f=null,x=w(0),s=w(R),p=w(0);function o(e){var n,l=(e=Z(e)).length,g,h,v=0,c=new Array(l),i=new Array(l),y=+x.apply(this,arguments),S=Math.min(R,Math.max(-R,s.apply(this,arguments)-y)),m,b=Math.min(Math.abs(S)/l,p.apply(this,arguments)),C=b*(S<0?-1:1),d;for(n=0;n<l;++n)(d=i[c[n]=n]=+t(e[n],n,e))>0&&(v+=d);for(a!=null?c.sort(function(A,D){return a(i[A],i[D])}):f!=null&&c.sort(function(A,D){return f(e[A],e[D])}),n=0,h=v?(S-l*C)/v:0;n<l;++n,y=m)g=c[n],d=i[g],m=y+(d>0?d*h:0)+C,i[g]={data:e[g],index:n,value:d,startAngle:y,endAngle:m,padAngle:b};return i}return o.value=function(e){return arguments.length?(t=typeof e=="function"?e:w(+e),o):t},o.sortValues=function(e){return arguments.length?(a=e,f=null,o):a},o.sort=function(e){return arguments.length?(f=e,a=null,o):f},o.startAngle=function(e){return arguments.length?(x=typeof e=="function"?e:w(+e),o):x},o.endAngle=function(e){return arguments.length?(s=typeof e=="function"?e:w(+e),o):s},o.padAngle=function(e){return arguments.length?(p=typeof e=="function"?e:w(+e),o):p},o}var vt=dt.pie,_={sections:new Map,showData:!1},T=_.sections,L=_.showData,yt=structuredClone(vt),wt=u(()=>structuredClone(yt),"getConfig"),xt=u(()=>{T=new Map,L=_.showData,ct()},"clear"),St=u(({label:t,value:a})=>{if(a<0)throw new Error(`"${t}" has invalid value: ${a}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);T.has(t)||(T.set(t,a),I.debug(`added new section: ${t}, with value: ${a}`))},"addSection"),At=u(()=>T,"getSections"),Dt=u(t=>{L=t},"setShowData"),bt=u(()=>L,"getShowData"),P={getConfig:wt,clear:xt,setDiagramTitle:rt,getDiagramTitle:at,setAccTitle:et,getAccTitle:tt,setAccDescription:K,getAccDescription:J,addSection:St,getSections:At,setShowData:Dt,getShowData:bt},Ct=u((t,a)=>{ut(t,a),a.setShowData(t.showData),t.sections.map(a.addSection)},"populateDb"),Tt={parse:u(async t=>{const a=await pt("pie",t);I.debug(a),Ct(a,P)},"parse")},$t=u(t=>`
  .pieCircle{
    stroke: ${t.pieStrokeColor};
    stroke-width : ${t.pieStrokeWidth};
    opacity : ${t.pieOpacity};
  }
  .pieOuterCircle{
    stroke: ${t.pieOuterStrokeColor};
    stroke-width: ${t.pieOuterStrokeWidth};
    fill: none;
  }
  .pieTitleText {
    text-anchor: middle;
    font-size: ${t.pieTitleTextSize};
    fill: ${t.pieTitleTextColor};
    font-family: ${t.fontFamily};
  }
  .slice {
    font-family: ${t.fontFamily};
    fill: ${t.pieSectionTextColor};
    font-size:${t.pieSectionTextSize};
    // fill: white;
  }
  .legend text {
    fill: ${t.pieLegendTextColor};
    font-family: ${t.fontFamily};
    font-size: ${t.pieLegendTextSize};
  }
`,"getStyles"),Et=$t,kt=u(t=>{const a=[...t.values()].reduce((s,p)=>s+p,0),f=[...t.entries()].map(([s,p])=>({label:s,value:p})).filter(s=>s.value/a*100>=1);return mt().value(s=>s.value).sort(null)(f)},"createPieArcs"),Mt=u((t,a,f,x)=>{I.debug(`rendering pie chart
`+t);const s=x.db,p=nt(),o=it(s.getConfig(),p.pie),e=40,n=18,l=4,g=450,h=g,v=st(a),c=v.append("g");c.attr("transform","translate("+h/2+","+g/2+")");const{themeVariables:i}=p;let[y]=ot(i.pieOuterStrokeWidth);y??=2;const S=o.textPosition,m=Math.min(h,g)/2-e,b=O().innerRadius(0).outerRadius(m),C=O().innerRadius(m*S).outerRadius(m*S);c.append("circle").attr("cx",0).attr("cy",0).attr("r",m+y/2).attr("class","pieOuterCircle");const d=s.getSections(),A=kt(d),D=[i.pie1,i.pie2,i.pie3,i.pie4,i.pie5,i.pie6,i.pie7,i.pie8,i.pie9,i.pie10,i.pie11,i.pie12];let $=0;d.forEach(r=>{$+=r});const W=A.filter(r=>(r.data.value/$*100).toFixed(0)!=="0"),E=gt(D).domain([...d.keys()]);c.selectAll("mySlices").data(W).enter().append("path").attr("d",b).attr("fill",r=>E(r.data.label)).attr("class","pieCircle"),c.selectAll("mySlices").data(W).enter().append("text").text(r=>(r.data.value/$*100).toFixed(0)+"%").attr("transform",r=>"translate("+C.centroid(r)+")").style("text-anchor","middle").attr("class","slice");const V=c.append("text").text(s.getDiagramTitle()).attr("x",0).attr("y",-400/2).attr("class","pieTitleText"),z=[...d.entries()].map(([r,M])=>({label:r,value:M})),k=c.selectAll(".legend").data(z).enter().append("g").attr("class","legend").attr("transform",(r,M)=>{const B=n+l,Q=B*z.length/2,X=12*n,Y=M*B-Q;return"translate("+X+","+Y+")"});k.append("rect").attr("width",n).attr("height",n).style("fill",r=>E(r.label)).style("stroke",r=>E(r.label)),k.append("text").attr("x",n+l).attr("y",n-l).text(r=>s.getShowData()?`${r.label} [${r.value}]`:r.label);const U=Math.max(...k.selectAll("text").nodes().map(r=>r?.getBoundingClientRect().width??0)),j=h+e+n+l+U,F=V.node()?.getBoundingClientRect().width??0,q=h/2-F/2,H=h/2+F/2,N=Math.min(0,q),G=Math.max(j,H)-N;v.attr("viewBox",`${N} 0 ${G} ${g}`),lt(v,g,G,o.useMaxWidth)},"draw"),Rt={draw:Mt},qt={parser:Tt,db:P,renderer:Rt,styles:Et};export{qt as diagram};
//# sourceMappingURL=pieDiagram-DEJITSTG-CrlFJnNo.js.map
