import{aI as Z,aJ as rt,x as at,y as lt,s as ot,g as ct,b as ht,a as ut,A as yt,d as pt,c as tt,l as et,aK as gt,aH as ft,aL as mt,i as dt}from"./mermaid.core-HDjDB8ON.chunk.mjs";import{a as Y}from"./arc-B3IkmSQ3.chunk.mjs";import{o as _t}from"./ordinal-D6YK7yj2.chunk.mjs";import{a as bt}from"./array-COaDM5L-.chunk.mjs";import{c as R}from"./path-CUa11n33.chunk.mjs";import"./modulepreload-polyfill-DE-oIJqv.chunk.mjs";import"./emoji-picker-KVqjnXYv.chunk.mjs";import"./vue.runtime.esm-DO2cz8pp.chunk.mjs";import"./init-CLzSasj9.chunk.mjs";function xt(e,h){return h<e?-1:h>e?1:h>=e?0:NaN}function vt(e){return e}function kt(){var e=vt,h=xt,p=null,$=R(0),k=R(Z),S=R(0);function u(r){var l,m=(r=bt(r)).length,d,I,T=0,_=new Array(m),x=new Array(m),o=+$.apply(this,arguments),A=Math.min(Z,Math.max(-Z,k.apply(this,arguments)-o)),N,E=Math.min(Math.abs(A)/m,S.apply(this,arguments)),g=E*(A<0?-1:1),t;for(l=0;l<m;++l)(t=x[_[l]=l]=+e(r[l],l,r))>0&&(T+=t);for(h!=null?_.sort(function(i,s){return h(x[i],x[s])}):p!=null&&_.sort(function(i,s){return p(r[i],r[s])}),l=0,I=T?(A-m*g)/T:0;l<m;++l,o=N)d=_[l],t=x[d],N=o+(t>0?t*I:0)+g,x[d]={data:r[d],index:l,value:t,startAngle:o,endAngle:N,padAngle:E};return x}return u.value=function(r){return arguments.length?(e=typeof r=="function"?r:R(+r),u):e},u.sortValues=function(r){return arguments.length?(h=r,p=null,u):h},u.sort=function(r){return arguments.length?(p=r,h=null,u):p},u.startAngle=function(r){return arguments.length?($=typeof r=="function"?r:R(+r),u):$},u.endAngle=function(r){return arguments.length?(k=typeof r=="function"?r:R(+r),u):k},u.padAngle=function(r){return arguments.length?(S=typeof r=="function"?r:R(+r),u):S},u}var J=function(){var e=function(g,t,i,s){for(i=i||{},s=g.length;s--;i[g[s]]=t);return i},h=[1,3],p=[1,4],$=[1,5],k=[1,6],S=[1,10,12,14,16,18,19,20,21,22],u=[2,4],r=[1,5,10,12,14,16,18,19,20,21,22],l=[20,21,22],m=[2,7],d=[1,12],I=[1,13],T=[1,14],_=[1,15],x=[1,16],o=[1,17],A={trace:function(){},yy:{},symbols_:{error:2,start:3,eol:4,PIE:5,document:6,showData:7,line:8,statement:9,txt:10,value:11,title:12,title_value:13,acc_title:14,acc_title_value:15,acc_descr:16,acc_descr_value:17,acc_descr_multiline_value:18,section:19,NEWLINE:20,";":21,EOF:22,$accept:0,$end:1},terminals_:{2:"error",5:"PIE",7:"showData",10:"txt",11:"value",12:"title",13:"title_value",14:"acc_title",15:"acc_title_value",16:"acc_descr",17:"acc_descr_value",18:"acc_descr_multiline_value",19:"section",20:"NEWLINE",21:";",22:"EOF"},productions_:[0,[3,2],[3,2],[3,3],[6,0],[6,2],[8,2],[9,0],[9,2],[9,2],[9,2],[9,2],[9,1],[9,1],[4,1],[4,1],[4,1]],performAction:function(g,t,i,s,a,n,y){var v=n.length-1;switch(a){case 3:s.setShowData(!0);break;case 6:this.$=n[v-1];break;case 8:s.addSection(n[v-1],s.cleanupValue(n[v]));break;case 9:this.$=n[v].trim(),s.setDiagramTitle(this.$);break;case 10:this.$=n[v].trim(),s.setAccTitle(this.$);break;case 11:case 12:this.$=n[v].trim(),s.setAccDescription(this.$);break;case 13:s.addSection(n[v].substr(8)),this.$=n[v].substr(8);break}},table:[{3:1,4:2,5:h,20:p,21:$,22:k},{1:[3]},{3:7,4:2,5:h,20:p,21:$,22:k},e(S,u,{6:8,7:[1,9]}),e(r,[2,14]),e(r,[2,15]),e(r,[2,16]),{1:[2,1]},e(l,m,{8:10,9:11,1:[2,2],10:d,12:I,14:T,16:_,18:x,19:o}),e(S,u,{6:18}),e(S,[2,5]),{4:19,20:p,21:$,22:k},{11:[1,20]},{13:[1,21]},{15:[1,22]},{17:[1,23]},e(l,[2,12]),e(l,[2,13]),e(l,m,{8:10,9:11,1:[2,3],10:d,12:I,14:T,16:_,18:x,19:o}),e(S,[2,6]),e(l,[2,8]),e(l,[2,9]),e(l,[2,10]),e(l,[2,11])],defaultActions:{7:[2,1]},parseError:function(g,t){if(t.recoverable)this.trace(g);else{var i=new Error(g);throw i.hash=t,i}},parse:function(g){var t=this,i=[0],s=[],a=[null],n=[],y=this.table,v="",D=0,f=0,V=2,F=1,W=n.slice.call(arguments,1),c=Object.create(this.lexer),O={yy:{}};for(var H in this.yy)Object.prototype.hasOwnProperty.call(this.yy,H)&&(O.yy[H]=this.yy[H]);c.setInput(g,O.yy),O.yy.lexer=c,O.yy.parser=this,typeof c.yylloc>"u"&&(c.yylloc={});var q=c.yylloc;n.push(q);var nt=c.options&&c.options.ranges;typeof O.yy.parseError=="function"?this.parseError=O.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function st(){var P;return P=s.pop()||c.lex()||F,typeof P!="number"&&(P instanceof Array&&(s=P,P=s.pop()),P=t.symbols_[P]||P),P}for(var b,M,w,G,j={},L,C,X,z;;){if(M=i[i.length-1],this.defaultActions[M]?w=this.defaultActions[M]:((b===null||typeof b>"u")&&(b=st()),w=y[M]&&y[M][b]),typeof w>"u"||!w.length||!w[0]){var Q="";z=[];for(L in y[M])this.terminals_[L]&&L>V&&z.push("'"+this.terminals_[L]+"'");c.showPosition?Q="Parse error on line "+(D+1)+`:
`+c.showPosition()+`
Expecting `+z.join(", ")+", got '"+(this.terminals_[b]||b)+"'":Q="Parse error on line "+(D+1)+": Unexpected "+(b==F?"end of input":"'"+(this.terminals_[b]||b)+"'"),this.parseError(Q,{text:c.match,token:this.terminals_[b]||b,line:c.yylineno,loc:q,expected:z})}if(w[0]instanceof Array&&w.length>1)throw new Error("Parse Error: multiple actions possible at state: "+M+", token: "+b);switch(w[0]){case 1:i.push(b),a.push(c.yytext),n.push(c.yylloc),i.push(w[1]),b=null,f=c.yyleng,v=c.yytext,D=c.yylineno,q=c.yylloc;break;case 2:if(C=this.productions_[w[1]][1],j.$=a[a.length-C],j._$={first_line:n[n.length-(C||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(C||1)].first_column,last_column:n[n.length-1].last_column},nt&&(j._$.range=[n[n.length-(C||1)].range[0],n[n.length-1].range[1]]),G=this.performAction.apply(j,[v,f,D,O.yy,w[1],a,n].concat(W)),typeof G<"u")return G;C&&(i=i.slice(0,-1*C*2),a=a.slice(0,-1*C),n=n.slice(0,-1*C)),i.push(this.productions_[w[1]][0]),a.push(j.$),n.push(j._$),X=y[i[i.length-2]][i[i.length-1]],i.push(X);break;case 3:return!0}}return!0}},N=function(){var g={EOF:1,parseError:function(t,i){if(this.yy.parser)this.yy.parser.parseError(t,i);else throw new Error(t)},setInput:function(t,i){return this.yy=i||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var i=t.match(/(?:\r\n?|\n).*/g);return i?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var i=t.length,s=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-i),this.offset-=i;var a=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),s.length-1&&(this.yylineno-=s.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:s?(s.length===a.length?this.yylloc.first_column:0)+a[a.length-s.length].length-s[0].length:this.yylloc.first_column-i},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-i]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),i=new Array(t.length+1).join("-");return t+this.upcomingInput()+`
`+i+"^"},test_match:function(t,i){var s,a,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),a=t[0].match(/(?:\r\n?|\n).*/g),a&&(this.yylineno+=a.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:a?a[a.length-1].length-a[a.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],s=this.performAction.call(this,this.yy,this,i,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),s)return s;if(this._backtrack){for(var y in n)this[y]=n[y];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,i,s,a;this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),y=0;y<n.length;y++)if(s=this._input.match(this.rules[n[y]]),s&&(!i||s[0].length>i[0].length)){if(i=s,a=y,this.options.backtrack_lexer){if(t=this.test_match(s,n[y]),t!==!1)return t;if(this._backtrack){i=!1;continue}else return!1}else if(!this.options.flex)break}return i?(t=this.test_match(i,n[a]),t!==!1?t:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){var t=this.conditionStack.length-1;return t>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return t=this.conditionStack.length-1-Math.abs(t||0),t>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,i,s,a){switch(s){case 0:break;case 1:break;case 2:return 20;case 3:break;case 4:break;case 5:return this.begin("title"),12;case 6:return this.popState(),"title_value";case 7:return this.begin("acc_title"),14;case 8:return this.popState(),"acc_title_value";case 9:return this.begin("acc_descr"),16;case 10:return this.popState(),"acc_descr_value";case 11:this.begin("acc_descr_multiline");break;case 12:this.popState();break;case 13:return"acc_descr_multiline_value";case 14:this.begin("string");break;case 15:this.popState();break;case 16:return"txt";case 17:return 5;case 18:return 7;case 19:return"value";case 20:return 22}},rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[\s]+)/i,/^(?:title\b)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:pie\b)/i,/^(?:showData\b)/i,/^(?::[\s]*[\d]+(?:\.[\d]+)?)/i,/^(?:$)/i],conditions:{acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},title:{rules:[6],inclusive:!1},string:{rules:[15,16],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,7,9,11,14,17,18,19,20],inclusive:!0}}};return g}();A.lexer=N;function E(){this.yy={}}return E.prototype=A,A.Parser=E,new E}();J.parser=J;const wt=J,it=rt.pie,B={sections:{},showData:!1,config:it};let U=B.sections,K=B.showData;const $t=structuredClone(it),St=()=>structuredClone($t),At=()=>{U=structuredClone(B.sections),K=B.showData,yt()},Et=(e,h)=>{e=pt(e,tt()),U[e]===void 0&&(U[e]=h,et.debug(`added new section: ${e}, with value: ${h}`))},Tt=()=>U,It=e=>(e.substring(0,1)===":"&&(e=e.substring(1).trim()),Number(e.trim())),Ot=e=>{K=e},Ct=()=>K,Pt={getConfig:St,clear:At,setDiagramTitle:at,getDiagramTitle:lt,setAccTitle:ot,getAccTitle:ct,setAccDescription:ht,getAccDescription:ut,addSection:Et,getSections:Tt,cleanupValue:It,setShowData:Ot,getShowData:Ct},Nt=e=>`
  .pieCircle{
    stroke: ${e.pieStrokeColor};
    stroke-width : ${e.pieStrokeWidth};
    opacity : ${e.pieOpacity};
  }
  .pieOuterCircle{
    stroke: ${e.pieOuterStrokeColor};
    stroke-width: ${e.pieOuterStrokeWidth};
    fill: none;
  }
  .pieTitleText {
    text-anchor: middle;
    font-size: ${e.pieTitleTextSize};
    fill: ${e.pieTitleTextColor};
    font-family: ${e.fontFamily};
  }
  .slice {
    font-family: ${e.fontFamily};
    fill: ${e.pieSectionTextColor};
    font-size:${e.pieSectionTextSize};
    // fill: white;
  }
  .legend text {
    fill: ${e.pieLegendTextColor};
    font-family: ${e.fontFamily};
    font-size: ${e.pieLegendTextSize};
  }
`,Dt=Nt,Ft=e=>{const h=Object.entries(e).map(p=>({label:p[0],value:p[1]})).sort((p,$)=>$.value-p.value);return kt().value(p=>p.value)(h)},Mt=(e,h,p,$)=>{et.debug(`rendering pie chart
`+e);const k=$.db,S=tt(),u=gt(k.getConfig(),S.pie),r=40,l=18,m=4,d=450,I=d,T=ft(h),_=T.append("g"),x=k.getSections();_.attr("transform","translate("+I/2+","+d/2+")");const{themeVariables:o}=S;let[A]=mt(o.pieOuterStrokeWidth);A??(A=2);const N=u.textPosition,E=Math.min(I,d)/2-r,g=Y().innerRadius(0).outerRadius(E),t=Y().innerRadius(E*N).outerRadius(E*N);_.append("circle").attr("cx",0).attr("cy",0).attr("r",E+A/2).attr("class","pieOuterCircle");const i=Ft(x),s=[o.pie1,o.pie2,o.pie3,o.pie4,o.pie5,o.pie6,o.pie7,o.pie8,o.pie9,o.pie10,o.pie11,o.pie12],a=_t(s);_.selectAll("mySlices").data(i).enter().append("path").attr("d",g).attr("fill",f=>a(f.data.label)).attr("class","pieCircle");let n=0;Object.keys(x).forEach(f=>{n+=x[f]}),_.selectAll("mySlices").data(i).enter().append("text").text(f=>(f.data.value/n*100).toFixed(0)+"%").attr("transform",f=>"translate("+t.centroid(f)+")").style("text-anchor","middle").attr("class","slice"),_.append("text").text(k.getDiagramTitle()).attr("x",0).attr("y",-(d-50)/2).attr("class","pieTitleText");const y=_.selectAll(".legend").data(a.domain()).enter().append("g").attr("class","legend").attr("transform",(f,V)=>{const F=l+m,W=F*a.domain().length/2,c=12*l,O=V*F-W;return"translate("+c+","+O+")"});y.append("rect").attr("width",l).attr("height",l).style("fill",a).style("stroke",a),y.data(i).append("text").attr("x",l+m).attr("y",l-m).text(f=>{const{label:V,value:F}=f.data;return k.getShowData()?`${V} [${F}]`:V});const v=Math.max(...y.selectAll("text").nodes().map(f=>f?.getBoundingClientRect().width??0)),D=I+r+l+m+v;T.attr("viewBox",`0 0 ${D} ${d}`),dt(T,d,D,u.useMaxWidth)},Rt={draw:Mt},Gt={parser:wt,db:Pt,renderer:Rt,styles:Dt};export{Gt as diagram};
//# sourceMappingURL=pieDiagram-8a3498a8-LT3eu-iN.chunk.mjs.map
