import{_ as u,g as j,s as q,a as H,b as Z,q as J,p as K,l as z,c as Q,D as X,H as Y,N as tt,e as et,y as rt,F as at,a4 as S,aG as it,a7 as F}from"./mermaid.core-BN1TdaiK-CkX93Jpj.js";import{p as nt}from"./chunk-4BX2VUAB-CxusDcOF-BgF98TWZ.js";import{p as ot}from"./treemap-KMMF4GRG-CvaGS1yA-NJdGYCDs.js";import{d as I}from"./arc-DGycnZ_r-CJZQCo8W.js";import{o as st}from"./ordinal-DSZU4PqD-DOFoVEQk.js";import"./index-Ds2meNS5.js";import"./svelte/svelte_svelte.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_client.js";import"./svelte/svelte_internal_flags_async.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_store.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";import"./Index-BpHS9YhG.js";import"./i18n-BldJSFLV.js";import"./utils.svelte-Ceck75cM.js";import"./index-tFQomdd2.js";import"./dsv-DB8NKgIY.js";import"./index-CnqicUFC.js";import"./ModifyUpload-BzsLgPw2.js";import"./IconButtonWrapper-Cljb5D-5.js";import"./MarkdownCode-C2b9iIxl.js";import"./prism-python-CpYAgONt.js";import"./Index-aAgh1OXe.js";import"./StreamingBar-b2qVLPYU.js";import"./FullscreenButton-Cqzqqtq6.js";import"./Example-BRN12iqL.js";import"./_baseUniq-BCzTs16Z-BRql6QeN.js";import"./_basePickBy-BSV_1zpR-D13SnWW2.js";import"./clone-04FuOcyX-A55wydoQ.js";import"./init-ZxktEp_H-Gi6I4Gst.js";function lt(t,r){return r<t?-1:r>t?1:r>=t?0:NaN}function ct(t){return t}function pt(){var t=ct,r=lt,g=null,y=S(0),o=S(F),l=S(0);function s(e){var i,c=(e=it(e)).length,m,x,v=0,p=new Array(c),n=new Array(c),f=+y.apply(this,arguments),w=Math.min(F,Math.max(-F,o.apply(this,arguments)-f)),h,C=Math.min(Math.abs(w)/c,l.apply(this,arguments)),$=C*(w<0?-1:1),d;for(i=0;i<c;++i)(d=n[p[i]=i]=+t(e[i],i,e))>0&&(v+=d);for(r!=null?p.sort(function(A,D){return r(n[A],n[D])}):g!=null&&p.sort(function(A,D){return g(e[A],e[D])}),i=0,x=v?(w-c*$)/v:0;i<c;++i,f=h)m=p[i],d=n[m],h=f+(d>0?d*x:0)+$,n[m]={data:e[m],index:i,value:d,startAngle:f,endAngle:h,padAngle:C};return n}return s.value=function(e){return arguments.length?(t=typeof e=="function"?e:S(+e),s):t},s.sortValues=function(e){return arguments.length?(r=e,g=null,s):r},s.sort=function(e){return arguments.length?(g=e,r=null,s):g},s.startAngle=function(e){return arguments.length?(y=typeof e=="function"?e:S(+e),s):y},s.endAngle=function(e){return arguments.length?(o=typeof e=="function"?e:S(+e),s):o},s.padAngle=function(e){return arguments.length?(l=typeof e=="function"?e:S(+e),s):l},s}var ut=at.pie,G={sections:new Map,showData:!1},T=G.sections,N=G.showData,mt=structuredClone(ut),dt=u(()=>structuredClone(mt),"getConfig"),gt=u(()=>{T=new Map,N=G.showData,rt()},"clear"),ft=u(({label:t,value:r})=>{if(r<0)throw new Error(`"${t}" has invalid value: ${r}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);T.has(t)||(T.set(t,r),z.debug(`added new section: ${t}, with value: ${r}`))},"addSection"),ht=u(()=>T,"getSections"),vt=u(t=>{N=t},"setShowData"),St=u(()=>N,"getShowData"),L={getConfig:dt,clear:gt,setDiagramTitle:K,getDiagramTitle:J,setAccTitle:Z,getAccTitle:H,setAccDescription:q,getAccDescription:j,addSection:ft,getSections:ht,setShowData:vt,getShowData:St},yt=u((t,r)=>{nt(t,r),r.setShowData(t.showData),t.sections.map(r.addSection)},"populateDb"),xt={parse:u(async t=>{const r=await ot("pie",t);z.debug(r),yt(r,L)},"parse")},wt=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"),At=wt,Dt=u(t=>{const r=[...t.values()].reduce((o,l)=>o+l,0),g=[...t.entries()].map(([o,l])=>({label:o,value:l})).filter(o=>o.value/r*100>=1).sort((o,l)=>l.value-o.value);return pt().value(o=>o.value)(g)},"createPieArcs"),Ct=u((t,r,g,y)=>{z.debug(`rendering pie chart
`+t);const o=y.db,l=Q(),s=X(o.getConfig(),l.pie),e=40,i=18,c=4,m=450,x=m,v=Y(r),p=v.append("g");p.attr("transform","translate("+x/2+","+m/2+")");const{themeVariables:n}=l;let[f]=tt(n.pieOuterStrokeWidth);f??(f=2);const w=s.textPosition,h=Math.min(x,m)/2-e,C=I().innerRadius(0).outerRadius(h),$=I().innerRadius(h*w).outerRadius(h*w);p.append("circle").attr("cx",0).attr("cy",0).attr("r",h+f/2).attr("class","pieOuterCircle");const d=o.getSections(),A=Dt(d),D=[n.pie1,n.pie2,n.pie3,n.pie4,n.pie5,n.pie6,n.pie7,n.pie8,n.pie9,n.pie10,n.pie11,n.pie12];let b=0;d.forEach(a=>{b+=a});const W=A.filter(a=>(a.data.value/b*100).toFixed(0)!=="0"),E=st(D);p.selectAll("mySlices").data(W).enter().append("path").attr("d",C).attr("fill",a=>E(a.data.label)).attr("class","pieCircle"),p.selectAll("mySlices").data(W).enter().append("text").text(a=>(a.data.value/b*100).toFixed(0)+"%").attr("transform",a=>"translate("+$.centroid(a)+")").style("text-anchor","middle").attr("class","slice"),p.append("text").text(o.getDiagramTitle()).attr("x",0).attr("y",-400/2).attr("class","pieTitleText");const O=[...d.entries()].map(([a,M])=>({label:a,value:M})),k=p.selectAll(".legend").data(O).enter().append("g").attr("class","legend").attr("transform",(a,M)=>{const R=i+c,B=R*O.length/2,V=12*i,U=M*R-B;return"translate("+V+","+U+")"});k.append("rect").attr("width",i).attr("height",i).style("fill",a=>E(a.label)).style("stroke",a=>E(a.label)),k.append("text").attr("x",i+c).attr("y",i-c).text(a=>o.getShowData()?`${a.label} [${a.value}]`:a.label);const _=Math.max(...k.selectAll("text").nodes().map(a=>a?.getBoundingClientRect().width??0)),P=x+e+i+c+_;v.attr("viewBox",`0 0 ${P} ${m}`),et(v,m,P,s.useMaxWidth)},"draw"),$t={draw:Ct},de={parser:xt,db:L,renderer:$t,styles:At};export{de as diagram};
