import{$a as ut,B as K,Da as Q,E as rt,Fa as at,G as $t,Ka as ct,Ua as lt,Va as ot,Za as X,_a as ht,b as Et,bb as pt,c as wt,cb as yt,db as ft,eb as dt,fb as gt,gb as _t,hb as mt,jb as vt,l as nt}from"./chunk-PBNKOM7K.min.js";import{d as J}from"./chunk-P42HNYSU.min.js";var Yt=J(Et(),1),Zt=J(wt(),1),qt=J($t(),1);var tt=function(){var e=function(y,t,s,n){for(s=s||{},n=y.length;n--;s[y[n]]=t);return s},p=[1,4],x=[1,5],d=[1,6],w=[1,7],S=[1,9],_=[1,11,13,15,17,19,20,26,27,28,29],L=[2,5],$=[1,6,11,13,15,17,19,20,26,27,28,29],h=[26,27,28],D=[2,8],I=[1,18],z=[1,19],m=[1,20],C=[1,21],v=[1,22],o=[1,23],O=[1,28],V=[6,26,27,28,29],E={trace:function(){},yy:{},symbols_:{error:2,start:3,eol:4,directive:5,PIE:6,document:7,showData:8,line:9,statement: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,openDirective:21,typeDirective:22,closeDirective:23,":":24,argDirective:25,NEWLINE:26,";":27,EOF:28,open_directive:29,type_directive:30,arg_directive:31,close_directive:32,$accept:0,$end:1},terminals_:{2:"error",6:"PIE",8:"showData",11:"txt",12:"value",13:"title",14:"title_value",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",24:":",26:"NEWLINE",27:";",28:"EOF",29:"open_directive",30:"type_directive",31:"arg_directive",32:"close_directive"},productions_:[0,[3,2],[3,2],[3,2],[3,3],[7,0],[7,2],[9,2],[10,0],[10,2],[10,2],[10,2],[10,2],[10,1],[10,1],[10,1],[5,3],[5,5],[4,1],[4,1],[4,1],[21,1],[22,1],[25,1],[23,1]],performAction:function(t,s,n,r,a,i,g){var c=i.length-1;switch(a){case 4:r.setShowData(!0);break;case 7:this.$=i[c-1];break;case 9:r.addSection(i[c-1],r.cleanupValue(i[c]));break;case 10:this.$=i[c].trim(),r.setDiagramTitle(this.$);break;case 11:this.$=i[c].trim(),r.setAccTitle(this.$);break;case 12:case 13:this.$=i[c].trim(),r.setAccDescription(this.$);break;case 14:r.addSection(i[c].substr(8)),this.$=i[c].substr(8);break;case 21:r.parseDirective("%%{","open_directive");break;case 22:r.parseDirective(i[c],"type_directive");break;case 23:i[c]=i[c].trim().replace(/'/g,'"'),r.parseDirective(i[c],"arg_directive");break;case 24:r.parseDirective("}%%","close_directive","pie");break}},table:[{3:1,4:2,5:3,6:p,21:8,26:x,27:d,28:w,29:S},{1:[3]},{3:10,4:2,5:3,6:p,21:8,26:x,27:d,28:w,29:S},{3:11,4:2,5:3,6:p,21:8,26:x,27:d,28:w,29:S},e(_,L,{7:12,8:[1,13]}),e($,[2,18]),e($,[2,19]),e($,[2,20]),{22:14,30:[1,15]},{30:[2,21]},{1:[2,1]},{1:[2,2]},e(h,D,{21:8,9:16,10:17,5:24,1:[2,3],11:I,13:z,15:m,17:C,19:v,20:o,29:S}),e(_,L,{7:25}),{23:26,24:[1,27],32:O},e([24,32],[2,22]),e(_,[2,6]),{4:29,26:x,27:d,28:w},{12:[1,30]},{14:[1,31]},{16:[1,32]},{18:[1,33]},e(h,[2,13]),e(h,[2,14]),e(h,[2,15]),e(h,D,{21:8,9:16,10:17,5:24,1:[2,4],11:I,13:z,15:m,17:C,19:v,20:o,29:S}),e(V,[2,16]),{25:34,31:[1,35]},e(V,[2,24]),e(_,[2,7]),e(h,[2,9]),e(h,[2,10]),e(h,[2,11]),e(h,[2,12]),{23:36,32:O},{32:[2,23]},e(V,[2,17])],defaultActions:{9:[2,21],10:[2,1],11:[2,2],35:[2,23]},parseError:function(t,s){if(s.recoverable)this.trace(t);else{var n=new Error(t);throw n.hash=s,n}},parse:function(t){var s=this,n=[0],r=[],a=[null],i=[],g=this.table,c="",P=0,R=0,U=2,it=1,kt=i.slice.call(arguments,1),l=Object.create(this.lexer),A={yy:{}};for(var Y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,Y)&&(A.yy[Y]=this.yy[Y]);l.setInput(t,A.yy),A.yy.lexer=l,A.yy.parser=this,typeof l.yylloc>"u"&&(l.yylloc={});var Z=l.yylloc;i.push(Z);var xt=l.options&&l.options.ranges;typeof A.yy.parseError=="function"?this.parseError=A.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function St(){var k;return k=r.pop()||l.lex()||it,typeof k!="number"&&(k instanceof Array&&(r=k,k=r.pop()),k=s.symbols_[k]||k),k}for(var u,T,f,q,F={},j,b,st,W;;){if(T=n[n.length-1],this.defaultActions[T]?f=this.defaultActions[T]:((u===null||typeof u>"u")&&(u=St()),f=g[T]&&g[T][u]),typeof f>"u"||!f.length||!f[0]){var H="";W=[];for(j in g[T])this.terminals_[j]&&j>U&&W.push("'"+this.terminals_[j]+"'");l.showPosition?H="Parse error on line "+(P+1)+`:
`+l.showPosition()+`
Expecting `+W.join(", ")+", got '"+(this.terminals_[u]||u)+"'":H="Parse error on line "+(P+1)+": Unexpected "+(u==it?"end of input":"'"+(this.terminals_[u]||u)+"'"),this.parseError(H,{text:l.match,token:this.terminals_[u]||u,line:l.yylineno,loc:Z,expected:W})}if(f[0]instanceof Array&&f.length>1)throw new Error("Parse Error: multiple actions possible at state: "+T+", token: "+u);switch(f[0]){case 1:n.push(u),a.push(l.yytext),i.push(l.yylloc),n.push(f[1]),u=null,R=l.yyleng,c=l.yytext,P=l.yylineno,Z=l.yylloc;break;case 2:if(b=this.productions_[f[1]][1],F.$=a[a.length-b],F._$={first_line:i[i.length-(b||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(b||1)].first_column,last_column:i[i.length-1].last_column},xt&&(F._$.range=[i[i.length-(b||1)].range[0],i[i.length-1].range[1]]),q=this.performAction.apply(F,[c,R,P,A.yy,f[1],a,i].concat(kt)),typeof q<"u")return q;b&&(n=n.slice(0,-1*b*2),a=a.slice(0,-1*b),i=i.slice(0,-1*b)),n.push(this.productions_[f[1]][0]),a.push(F.$),i.push(F._$),st=g[n[n.length-2]][n[n.length-1]],n.push(st);break;case 3:return!0}}return!0}},B=function(){var y={EOF:1,parseError:function(s,n){if(this.yy.parser)this.yy.parser.parseError(s,n);else throw new Error(s)},setInput:function(t,s){return this.yy=s||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 s=t.match(/(?:\r\n?|\n).*/g);return s?(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 s=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var r=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),n.length-1&&(this.yylineno-=n.length-1);var a=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:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-s]),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(),s=new Array(t.length+1).join("-");return t+this.upcomingInput()+`
`+s+"^"},test_match:function(t,s){var n,r,a;if(this.options.backtrack_lexer&&(a={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&&(a.yylloc.range=this.yylloc.range.slice(0))),r=t[0].match(/(?:\r\n?|\n).*/g),r&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.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],n=this.performAction.call(this,this.yy,this,s,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var i in a)this[i]=a[i];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,s,n,r;this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),i=0;i<a.length;i++)if(n=this._input.match(this.rules[a[i]]),n&&(!s||n[0].length>s[0].length)){if(s=n,r=i,this.options.backtrack_lexer){if(t=this.test_match(n,a[i]),t!==!1)return t;if(this._backtrack){s=!1;continue}else return!1}else if(!this.options.flex)break}return s?(t=this.test_match(s,a[r]),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 s=this.next();return s||this.lex()},begin:function(s){this.conditionStack.push(s)},popState:function(){var s=this.conditionStack.length-1;return s>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(s){return s=this.conditionStack.length-1-Math.abs(s||0),s>=0?this.conditionStack[s]:"INITIAL"},pushState:function(s){this.begin(s)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(s,n,r,a){switch(r){case 0:return this.begin("open_directive"),29;case 1:return this.begin("type_directive"),30;case 2:return this.popState(),this.begin("arg_directive"),24;case 3:return this.popState(),this.popState(),32;case 4:return 31;case 5:break;case 6:break;case 7:return 26;case 8:break;case 9:break;case 10:return this.begin("title"),13;case 11:return this.popState(),"title_value";case 12:return this.begin("acc_title"),15;case 13:return this.popState(),"acc_title_value";case 14:return this.begin("acc_descr"),17;case 15:return this.popState(),"acc_descr_value";case 16:this.begin("acc_descr_multiline");break;case 17:this.popState();break;case 18:return"acc_descr_multiline_value";case 19:this.begin("string");break;case 20:this.popState();break;case 21:return"txt";case 22:return 6;case 23:return 8;case 24:return"value";case 25:return 28}},rules:[/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/i,/^(?:%%(?!\{)[^\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:[17,18],inclusive:!1},acc_descr:{rules:[15],inclusive:!1},acc_title:{rules:[13],inclusive:!1},close_directive:{rules:[],inclusive:!1},arg_directive:{rules:[3,4],inclusive:!1},type_directive:{rules:[2,3],inclusive:!1},open_directive:{rules:[1],inclusive:!1},title:{rules:[11],inclusive:!1},string:{rules:[20,21],inclusive:!1},INITIAL:{rules:[0,5,6,7,8,9,10,12,14,16,19,22,23,24,25],inclusive:!0}}};return y}();E.lexer=B;function N(){this.yy={}}return N.prototype=E,E.Parser=N,new N}();tt.parser=tt;var Dt=tt,bt=ct.pie,G={sections:{},showData:!1,config:bt},M=G.sections,et=G.showData,At=structuredClone(bt),Tt=()=>structuredClone(At),It=(e,p,x)=>{vt(void 0,e,p,x)},Ct=()=>{M=structuredClone(G.sections),et=G.showData,pt()},Ot=(e,p)=>{e=at(e,X()),M[e]===void 0&&(M[e]=p,Q.debug(`added new section: ${e}, with value: ${p}`))},Vt=()=>M,Pt=e=>(e.substring(0,1)===":"&&(e=e.substring(1).trim()),Number(e.trim())),Ft=e=>{et=e},Lt=()=>et,Nt={getConfig:Tt,parseDirective:It,clear:Ct,setDiagramTitle:_t,getDiagramTitle:mt,setAccTitle:yt,getAccTitle:ft,setAccDescription:dt,getAccDescription:gt,addSection:Ot,getSections:Vt,cleanupValue:Pt,setShowData:Ft,getShowData:Lt},zt=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};
  }
`,Rt=zt,jt=e=>{let p=Object.entries(e).map(d=>({label:d[0],value:d[1]}));return rt().value(d=>d.value)(p)},Wt=(e,p,x,d)=>{var w,S;Q.debug(`rendering pie chart
`+e);let _=d.db,L=X(),$=ot(_.getConfig(),L.pie),h=450,D=((S=(w=document.getElementById(p))==null?void 0:w.parentElement)==null?void 0:S.offsetWidth)??$.useWidth,I=ht(p);I.attr("viewBox",`0 0 ${D} ${h}`),ut(I,h,D,$.useMaxWidth);let z=40,m=18,C=4,v=I.append("g");v.attr("transform","translate("+D/2+","+h/2+")");let{themeVariables:o}=L,[O]=lt(o.pieOuterStrokeWidth);O??(O=2);let V=$.textPosition,E=Math.min(D,h)/2-z,B=K().innerRadius(0).outerRadius(E),N=K().innerRadius(E*V).outerRadius(E*V);v.append("circle").attr("cx",0).attr("cy",0).attr("r",E+O/2).attr("class","pieOuterCircle");let y=_.getSections(),t=jt(y),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],n=nt(s);v.selectAll("mySlices").data(t).enter().append("path").attr("d",B).attr("fill",i=>n(i.data.label)).attr("class","pieCircle");let r=0;Object.keys(y).forEach(i=>{r+=y[i]}),v.selectAll("mySlices").data(t).enter().append("text").text(i=>(i.data.value/r*100).toFixed(0)+"%").attr("transform",i=>"translate("+N.centroid(i)+")").style("text-anchor","middle").attr("class","slice"),v.append("text").text(_.getDiagramTitle()).attr("x",0).attr("y",-(h-50)/2).attr("class","pieTitleText");let a=v.selectAll(".legend").data(n.domain()).enter().append("g").attr("class","legend").attr("transform",(i,g)=>{let c=m+C,P=c*n.domain().length/2,R=12*m,U=g*c-P;return"translate("+R+","+U+")"});a.append("rect").attr("width",m).attr("height",m).style("fill",n).style("stroke",n),a.data(t).append("text").attr("x",m+C).attr("y",m-C).text(i=>{let{label:g,value:c}=i.data;return _.getShowData()?`${g} [${c}]`:g})},Gt={draw:Wt},Ht={parser:Dt,db:Nt,renderer:Gt,styles:Rt};export{Ht as diagram};
//# sourceMappingURL=pieDiagram-3fca7ce7-O7VT65XQ.min.js.map
