import{s as bt}from"./chunk-PUD22X6X.mjs";import{K as vt}from"./chunk-6WX52H5W.mjs";import{e as ht,f as ft,g as pt,h as yt,i as dt,j as mt,k as gt,l as _t}from"./chunk-GO66RM32.mjs";import"./chunk-UW4DGUNY.mjs";import{G as rt,J as ct,a,g as W,m as K,q as ot,ra as I,ua as ut}from"./chunk-3OFI44Y5.mjs";var nt=function(){var r=a(function(b,e,n,i){for(n=n||{},i=b.length;i--;n[b[i]]=e);return n},"o"),d=[1,4],D=[1,5],S=[1,6],V=[1,7],p=[1,9],w=[1,11,13,15,17,19,20,26,27,28,29],A=[2,5],_=[1,6,11,13,15,17,19,20,26,27,28,29],u=[26,27,28],F=[2,8],M=[1,18],E=[1,19],R=[1,20],Y=[1,21],O=[1,22],B=[1,23],U=[1,28],P=[6,26,27,28,29],v={trace:a(function(){},"trace"),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:a(function(e,n,i,s,l,t,m){var o=t.length-1;switch(l){case 4:s.setShowData(!0);break;case 7:this.$=t[o-1];break;case 9:s.addSection(t[o-1],s.cleanupValue(t[o]));break;case 10:this.$=t[o].trim(),s.setDiagramTitle(this.$);break;case 11:this.$=t[o].trim(),s.setAccTitle(this.$);break;case 12:case 13:this.$=t[o].trim(),s.setAccDescription(this.$);break;case 14:s.addSection(t[o].substr(8)),this.$=t[o].substr(8);break;case 21:s.parseDirective("%%{","open_directive");break;case 22:s.parseDirective(t[o],"type_directive");break;case 23:t[o]=t[o].trim().replace(/'/g,'"'),s.parseDirective(t[o],"arg_directive");break;case 24:s.parseDirective("}%%","close_directive","pie");break}},"anonymous"),table:[{3:1,4:2,5:3,6:d,21:8,26:D,27:S,28:V,29:p},{1:[3]},{3:10,4:2,5:3,6:d,21:8,26:D,27:S,28:V,29:p},{3:11,4:2,5:3,6:d,21:8,26:D,27:S,28:V,29:p},r(w,A,{7:12,8:[1,13]}),r(_,[2,18]),r(_,[2,19]),r(_,[2,20]),{22:14,30:[1,15]},{30:[2,21]},{1:[2,1]},{1:[2,2]},r(u,F,{21:8,9:16,10:17,5:24,1:[2,3],11:M,13:E,15:R,17:Y,19:O,20:B,29:p}),r(w,A,{7:25}),{23:26,24:[1,27],32:U},r([24,32],[2,22]),r(w,[2,6]),{4:29,26:D,27:S,28:V},{12:[1,30]},{14:[1,31]},{16:[1,32]},{18:[1,33]},r(u,[2,13]),r(u,[2,14]),r(u,[2,15]),r(u,F,{21:8,9:16,10:17,5:24,1:[2,4],11:M,13:E,15:R,17:Y,19:O,20:B,29:p}),r(P,[2,16]),{25:34,31:[1,35]},r(P,[2,24]),r(w,[2,7]),r(u,[2,9]),r(u,[2,10]),r(u,[2,11]),r(u,[2,12]),{23:36,32:U},{32:[2,23]},r(P,[2,17])],defaultActions:{9:[2,21],10:[2,1],11:[2,2],35:[2,23]},parseError:a(function(e,n){if(n.recoverable)this.trace(e);else{var i=new Error(e);throw i.hash=n,i}},"parseError"),parse:a(function(e){var n=this,i=[0],s=[],l=[null],t=[],m=this.table,o="",C=0,q=0,G=0,Et=2,at=1,Dt=t.slice.call(arguments,1),c=Object.create(this.lexer),T={yy:{}};for(var X in this.yy)Object.prototype.hasOwnProperty.call(this.yy,X)&&(T.yy[X]=this.yy[X]);c.setInput(e,T.yy),T.yy.lexer=c,T.yy.parser=this,typeof c.yylloc>"u"&&(c.yylloc={});var Z=c.yylloc;t.push(Z);var At=c.options&&c.options.ranges;typeof T.yy.parseError=="function"?this.parseError=T.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function zt(f){i.length=i.length-2*f,l.length=l.length-f,t.length=t.length-f}a(zt,"popStack");function Tt(){var f;return f=s.pop()||c.lex()||at,typeof f!="number"&&(f instanceof Array&&(s=f,f=s.pop()),f=n.symbols_[f]||f),f}a(Tt,"lex");for(var h,tt,$,y,jt,et,L={},H,k,lt,J;;){if($=i[i.length-1],this.defaultActions[$]?y=this.defaultActions[$]:((h===null||typeof h>"u")&&(h=Tt()),y=m[$]&&m[$][h]),typeof y>"u"||!y.length||!y[0]){var it="";J=[];for(H in m[$])this.terminals_[H]&&H>Et&&J.push("'"+this.terminals_[H]+"'");c.showPosition?it="Parse error on line "+(C+1)+`: `+c.showPosition()+` Expecting `+J.join(", ")+", got '"+(this.terminals_[h]||h)+"'":it="Parse error on line "+(C+1)+": Unexpected "+(h==at?"end of input":"'"+(this.terminals_[h]||h)+"'"),this.parseError(it,{text:c.match,token:this.terminals_[h]||h,line:c.yylineno,loc:Z,expected:J})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+$+", token: "+h);switch(y[0]){case 1:i.push(h),l.push(c.yytext),t.push(c.yylloc),i.push(y[1]),h=null,tt?(h=tt,tt=null):(q=c.yyleng,o=c.yytext,C=c.yylineno,Z=c.yylloc,G>0&&G--);break;case 2:if(k=this.productions_[y[1]][1],L.$=l[l.length-k],L._$={first_line:t[t.length-(k||1)].first_line,last_line:t[t.length-1].last_line,first_column:t[t.length-(k||1)].first_column,last_column:t[t.length-1].last_column},At&&(L._$.range=[t[t.length-(k||1)].range[0],t[t.length-1].range[1]]),et=this.performAction.apply(L,[o,q,C,T.yy,y[1],l,t].concat(Dt)),typeof et<"u")return et;k&&(i=i.slice(0,-1*k*2),l=l.slice(0,-1*k),t=t.slice(0,-1*k)),i.push(this.productions_[y[1]][0]),l.push(L.$),t.push(L._$),lt=m[i[i.length-2]][i[i.length-1]],i.push(lt);break;case 3:return!0}}return!0},"parse")},N=function(){var b={EOF:1,parseError:a(function(n,i){if(this.yy.parser)this.yy.parser.parseError(n,i);else throw new Error(n)},"parseError"),setInput:function(e,n){return this.yy=n||this.yy||{},this._input=e,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 e=this._input[0];this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e;var n=e.match(/(?:\r\n?|\n).*/g);return n?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var n=e.length,i=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-n),this.offset-=n;var s=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),i.length-1&&(this.yylineno-=i.length-1);var l=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:i?(i.length===s.length?this.yylloc.first_column:0)+s[s.length-i.length].length-i[0].length:this.yylloc.first_column-n},this.options.ranges&&(this.yylloc.range=[l[0],l[0]+this.yyleng-n]),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(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),n=new Array(e.length+1).join("-");return e+this.upcomingInput()+` `+n+"^"},test_match:function(e,n){var i,s,l;if(this.options.backtrack_lexer&&(l={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&&(l.yylloc.range=this.yylloc.range.slice(0))),s=e[0].match(/(?:\r\n?|\n).*/g),s&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,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(e[0].length),this.matched+=e[0],i=this.performAction.call(this,this.yy,this,n,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var t in l)this[t]=l[t];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var e,n,i,s;this._more||(this.yytext="",this.match="");for(var l=this._currentRules(),t=0;tn[0].length)){if(n=i,s=t,this.options.backtrack_lexer){if(e=this.test_match(i,l[t]),e!==!1)return e;if(this._backtrack){n=!1;continue}else return!1}else if(!this.options.flex)break}return n?(e=this.test_match(n,l[s]),e!==!1?e:!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:a(function(){var n=this.next();return n||this.lex()},"lex"),begin:a(function(n){this.conditionStack.push(n)},"begin"),popState:a(function(){var n=this.conditionStack.length-1;return n>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:a(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:a(function(n){return n=this.conditionStack.length-1-Math.abs(n||0),n>=0?this.conditionStack[n]:"INITIAL"},"topState"),pushState:a(function(n){this.begin(n)},"pushState"),stateStackSize:a(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:a(function(n,i,s,l){var t=l;switch(s){case 0:return this.begin("open_directive"),29;break;case 1:return this.begin("type_directive"),30;break;case 2:return this.popState(),this.begin("arg_directive"),24;break;case 3:return this.popState(),this.popState(),32;break;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;break;case 11:return this.popState(),"title_value";break;case 12:return this.begin("acc_title"),15;break;case 13:return this.popState(),"acc_title_value";break;case 14:return this.begin("acc_descr"),17;break;case 15:return this.popState(),"acc_descr_value";break;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}},"anonymous"),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 b}();v.lexer=N;function z(){this.yy={}}return a(z,"Parser"),z.prototype=v,v.Parser=z,new z}();nt.parser=nt;var kt=nt;var Q={},st=!1,It=a(function(r,d,D){bt.parseDirective(this,r,d,D)},"parseDirective"),Vt=a(function(r,d){r=ht.sanitizeText(r,I()),Q[r]===void 0&&(Q[r]=d,W.debug("Added new section :",r))},"addSection"),Ot=a(()=>Q,"getSections"),Pt=a(function(r){st=r},"setShowData"),Ct=a(function(){return st},"getShowData"),Lt=a(function(r){return r.substring(0,1)===":"&&(r=r.substring(1).trim()),Number(r.trim())},"cleanupValue"),Wt=a(function(){Q={},st=!1,ft()},"clear"),xt={parseDirective:It,getConfig:()=>I().pie,addSection:Vt,getSections:Ot,cleanupValue:Lt,clear:Wt,setAccTitle:pt,getAccTitle:yt,setDiagramTitle:gt,getDiagramTitle:_t,setShowData:Pt,getShowData:Ct,getAccDescription:mt,setAccDescription:dt};var Ft=a(r=>` .pieCircle{ stroke: ${r.pieStrokeColor}; stroke-width : ${r.pieStrokeWidth}; opacity : ${r.pieOpacity}; } .pieOuterCircle{ stroke: ${r.pieOuterStrokeColor}; stroke-width: ${r.pieOuterStrokeWidth}; fill: none; } .pieTitleText { text-anchor: middle; font-size: ${r.pieTitleTextSize}; fill: ${r.pieTitleTextColor}; font-family: ${r.fontFamily}; } .slice { font-family: ${r.fontFamily}; fill: ${r.pieSectionTextColor}; font-size:${r.pieSectionTextSize}; // fill: white; } .legend text { fill: ${r.pieLegendTextColor}; font-family: ${r.fontFamily}; font-size: ${r.pieLegendTextSize}; } `,"getStyles"),St=Ft;var g=I(),x,j=450,Nt=a((r,d,D,S)=>{try{g=I(),W.debug(`Rendering info diagram `+r);let v=I().securityLevel,N;v==="sandbox"&&(N=K("#i"+d));let z=v==="sandbox"?K(N.nodes()[0].contentDocument.body):K("body"),e=(v==="sandbox"?N.nodes()[0].contentDocument:document).getElementById(d);x=e.parentElement.offsetWidth,x===void 0&&(x=1200),g.useWidth!==void 0&&(x=g.useWidth),g.pie.useWidth!==void 0&&(x=g.pie.useWidth);let n=z.select("#"+d);ut(n,j,x,g.pie.useMaxWidth),e.setAttribute("viewBox","0 0 "+x+" "+j);var V=40,p=18,w=4,A=Math.min(x,j)/2-V,_=n.append("g").attr("transform","translate("+x/2+","+j/2+")"),u=S.db.getSections(),F=0;Object.keys(u).forEach(function(t){F+=u[t]});let i=g.themeVariables;var M=[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 s=g.pie?.textPosition??.75,[l]=vt(i.pieOuterStrokeWidth);l??=2;var E=ot().range(M),R=Object.entries(u).map(function(t,m){return{order:m,name:t[0],value:t[1]}}),Y=ct().value(function(t){return t.value}).sort(function(t,m){return t.order-m.order}),O=Y(R),B=rt().innerRadius(0).outerRadius(A),U=rt().innerRadius(A*s).outerRadius(A*s);_.append("circle").attr("cx",0).attr("cy",0).attr("r",A+l/2).attr("class","pieOuterCircle"),_.selectAll("mySlices").data(O).enter().append("path").attr("d",B).attr("fill",function(t){return E(t.data.name)}).attr("class","pieCircle"),_.selectAll("mySlices").data(O).enter().append("text").text(function(t){return(t.data.value/F*100).toFixed(0)+"%"}).attr("transform",function(t){return"translate("+U.centroid(t)+")"}).style("text-anchor","middle").attr("class","slice"),_.append("text").text(S.db.getDiagramTitle()).attr("x",0).attr("y",-(j-50)/2).attr("class","pieTitleText");var P=_.selectAll(".legend").data(E.domain()).enter().append("g").attr("class","legend").attr("transform",function(t,m){let o=p+w,C=o*E.domain().length/2,q=12*p,G=m*o-C;return"translate("+q+","+G+")"});P.append("rect").attr("width",p).attr("height",p).style("fill",E).style("stroke",E),P.data(O).append("text").attr("x",p+w).attr("y",p-w).text(function(t){return S.db.getShowData()||g.showData||g.pie.showData?t.data.name+" ["+t.data.value+"]":t.data.name})}catch(v){W.error("Error while rendering info diagram"),W.error(v)}},"draw"),wt={draw:Nt};var le={parser:kt,db:xt,renderer:wt,styles:St};export{le as diagram};