41 lines
24 KiB
JavaScript
41 lines
24 KiB
JavaScript
|
|
import{G as _t,P as bt,S as vt,T as St,U as Lt,V as wt,W as Et,X as At,Y as Tt,_ as X,aa as Ct}from"./chunk-67TQ5CYL.mjs";import{E as Mt,h as G,m as Nt}from"./chunk-7W6UQGC5.mjs";import{a as e}from"./chunk-AQ6EADP3.mjs";var lt=(function(){var t=e(function(g,a,l,h){for(l=l||{},h=g.length;h--;l[g[h]]=a);return l},"o"),o=[1,9],s=[1,10],u=[1,5,10,12],c={trace:e(function(){},"trace"),yy:{},symbols_:{error:2,start:3,SANKEY:4,NEWLINE:5,csv:6,opt_eof:7,record:8,csv_tail:9,EOF:10,"field[source]":11,COMMA:12,"field[target]":13,"field[value]":14,field:15,escaped:16,non_escaped:17,DQUOTE:18,ESCAPED_TEXT:19,NON_ESCAPED_TEXT:20,$accept:0,$end:1},terminals_:{2:"error",4:"SANKEY",5:"NEWLINE",10:"EOF",11:"field[source]",12:"COMMA",13:"field[target]",14:"field[value]",18:"DQUOTE",19:"ESCAPED_TEXT",20:"NON_ESCAPED_TEXT"},productions_:[0,[3,4],[6,2],[9,2],[9,0],[7,1],[7,0],[8,5],[15,1],[15,1],[16,3],[17,1]],performAction:e(function(a,l,h,x,k,p,b){var A=p.length-1;switch(k){case 7:let E=x.findOrCreateNode(p[A-4].trim().replaceAll('""','"')),C=x.findOrCreateNode(p[A-2].trim().replaceAll('""','"')),N=parseFloat(p[A].trim());x.addLink(E,C,N);break;case 8:case 9:case 11:this.$=p[A];break;case 10:this.$=p[A-1];break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},{5:[1,3]},{6:4,8:5,15:6,16:7,17:8,18:o,20:s},{1:[2,6],7:11,10:[1,12]},t(s,[2,4],{9:13,5:[1,14]}),{12:[1,15]},t(u,[2,8]),t(u,[2,9]),{19:[1,16]},t(u,[2,11]),{1:[2,1]},{1:[2,5]},t(s,[2,2]),{6:17,8:5,15:6,16:7,17:8,18:o,20:s},{15:18,16:7,17:8,18:o,20:s},{18:[1,19]},t(s,[2,3]),{12:[1,20]},t(u,[2,10]),{15:21,16:7,17:8,18:o,20:s},t([1,5,10],[2,7])],defaultActions:{11:[2,1],12:[2,5]},parseError:e(function(a,l){if(l.recoverable)this.trace(a);else{var h=new Error(a);throw h.hash=l,h}},"parseError"),parse:e(function(a){var l=this,h=[0],x=[],k=[null],p=[],b=this.table,A="",E=0,C=0,N=0,M=2,P=1,D=p.slice.call(arguments,1),S=Object.create(this.lexer),O={yy:{}};for(var z in this.yy)Object.prototype.hasOwnProperty.call(this.yy,z)&&(O.yy[z]=this.yy[z]);S.setInput(a,O.yy),O.yy.lexer=S,O.yy.parser=this,typeof S.yylloc>"u"&&(S.yylloc={});var $=S.yylloc;p.push($);var I=S.options&&S.options.ranges;typeof O.yy.parseError=="function"?this.parseError=O.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function q(w){h.length=h.length-2*w,k.length=k.length-w,p.length=p.length-w}e(q,"popStack");function W(){var w;return w=x.pop()||S.lex()||P,typeof w!="number"&&(w instanceof Array&&(x=w,w=x.pop()),w=l.symbols_[w]||w),w}e(W,"lex");for(var L,R,n,f,d,r,i={},m,v,B,T;;){if(n=h[h.length-1],this.defaultActions[n]?f=this.defaultActions[n]:((L===null||typeof L>"u")&&(L=W()),f=b[n]&&b[n][L]),typeof f>"u"||!f.length||!f[0]){var j="";T=[];for(m in b[n])this.terminals_[m]&&m>M&&T.push("'"+this.terminals_[m]+"'");S.showPosition?j="Parse error on line "+(E+1)+`:
|
||
|
|
`+S.showPosition()+`
|
||
|
|
Expecting `+T.join(", ")+", got '"+(this.terminals_[L]||L)+"'":j="Parse error on line "+(E+1)+": Unexpected "+(L==P?"end of input":"'"+(this.terminals_[L]||L)+"'"),this.parseError(j,{text:S.match,token:this.terminals_[L]||L,line:S.yylineno,loc:$,expected:T})}if(f[0]instanceof Array&&f.length>1)throw new Error("Parse Error: multiple actions possible at state: "+n+", token: "+L);switch(f[0]){case 1:h.push(L),k.push(S.yytext),p.push(S.yylloc),h.push(f[1]),L=null,R?(L=R,R=null):(C=S.yyleng,A=S.yytext,E=S.yylineno,$=S.yylloc,N>0&&N--);break;case 2:if(v=this.productions_[f[1]][1],i.$=k[k.length-v],i._$={first_line:p[p.length-(v||1)].first_line,last_line:p[p.length-1].last_line,first_column:p[p.length-(v||1)].first_column,last_column:p[p.length-1].last_column},I&&(i._$.range=[p[p.length-(v||1)].range[0],p[p.length-1].range[1]]),r=this.performAction.apply(i,[A,C,E,O.yy,f[1],k,p].concat(D)),typeof r<"u")return r;v&&(h=h.slice(0,-1*v*2),k=k.slice(0,-1*v),p=p.slice(0,-1*v)),h.push(this.productions_[f[1]][0]),k.push(i.$),p.push(i._$),B=b[h[h.length-2]][h[h.length-1]],h.push(B);break;case 3:return!0}}return!0},"parse")},_=(function(){var g={EOF:1,parseError:e(function(l,h){if(this.yy.parser)this.yy.parser.parseError(l,h);else throw new Error(l)},"parseError"),setInput:e(function(a,l){return this.yy=l||this.yy||{},this._input=a,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},"setInput"),input:e(function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var l=a.match(/(?:\r\n?|\n).*/g);return l?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},"input"),unput:e(function(a){var l=a.length,h=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-l),this.offset-=l;var x=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),h.length-1&&(this.yylineno-=h.length-1);var k=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:h?(h.length===x.length?this.yylloc.first_column:0)+x[x.length-h.length].length-h[0].length:this.yylloc.first_column-l},this.options.ranges&&(this.yylloc.range=[k[0],k[0]+this.yyleng-l]),this.yyleng=this.yytext.length,this},"unput"),more:e(function(){return this._more=!0,this},"more"),reject:e(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},"reject"),less:e(function(a){this.unput(this.match.slice(a))},"less"),pastInput:e(function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:e(function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:e(function(){var a=this.pastInput(),l=new Array(a.length+1).join("-");return a+this.upcomingInput()+`
|
||
|
|
`+l+"^"},"showPosition"),test_match:e(function(a,l){var h,x,k;if(this.options.backtrack_lexer&&(k={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&&(k.yylloc.range=this.yylloc.range.slice(0))),x=a[0].match(/(?:\r\n?|\n).*/g),x&&(this.yylineno+=x.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:x?x[x.length-1].length-x[x.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,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(a[0].length),this.matched+=a[0],h=this.performAction.call(this,this.yy,this,l,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),h)return h;if(this._backtrack){for(var p in k)this[p]=k[p];return!1}return!1},"test_match"),next:e(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,l,h,x;this._more||(this.yytext="",this.match="");for(var k=this._currentRules(),p=0;p<k.length;p++)if(h=this._input.match(this.rules[k[p]]),h&&(!l||h[0].length>l[0].length)){if(l=h,x=p,this.options.backtrack_lexer){if(a=this.test_match(h,k[p]),a!==!1)return a;if(this._backtrack){l=!1;continue}else return!1}else if(!this.options.flex)break}return l?(a=this.test_match(l,k[x]),a!==!1?a:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
||
|
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:e(function(){var l=this.next();return l||this.lex()},"lex"),begin:e(function(l){this.conditionStack.push(l)},"begin"),popState:e(function(){var l=this.conditionStack.length-1;return l>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:e(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:e(function(l){return l=this.conditionStack.length-1-Math.abs(l||0),l>=0?this.conditionStack[l]:"INITIAL"},"topState"),pushState:e(function(l){this.begin(l)},"pushState"),stateStackSize:e(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:e(function(l,h,x,k){var p=k;switch(x){case 0:return this.pushState("csv"),4;break;case 1:return this.pushState("csv"),4;break;case 2:return 10;case 3:return 5;case 4:return 12;case 5:return this.pushState("escaped_text"),18;break;case 6:return 20;case 7:return this.popState("escaped_text"),18;break;case 8:return 19}},"anonymous"),rules:[/^(?:sankey-beta\b)/i,/^(?:sankey\b)/i,/^(?:$)/i,/^(?:((\u000D\u000A)|(\u000A)))/i,/^(?:(\u002C))/i,/^(?:(\u0022))/i,/^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i,/^(?:(\u0022)(?!(\u0022)))/i,/^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],conditions:{csv:{rules:[2,3,4,5,6,7,8],inclusive:!1},escaped_text:{rules:[7,8],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8],inclusive:!0}}};return g})();c.lexer=_;function y(){this.yy={}}return e(y,"Parser"),y.prototype=c,c.Parser=y,new y})();lt.parser=lt;var J=lt;var et=[],nt=[],tt=new Map,Ht=e(()=>{et=[],nt=[],tt=new Map,vt()},"clear"),ut=class{constructor(o,s,u=0){this.source=o;this.target=s;this.value=u}static{e(this,"SankeyLink")}},Yt=e((t,o,s)=>{et.push(new ut(t,o,s))},"addLink"),ft=class{constructor(o){this.ID=o}static{e(this,"SankeyNode")}},qt=e(t=>{t=_t.sanitizeText(t,X());let o=tt.get(t);return o===void 0&&(o=new ft(t),tt.set(t,o),nt.push(o)),o},"findOrCreateNode"),Ut=e(()=>nt,"getNodes"),Xt=e(()=>et,"getLinks"),Gt=e(()=>({nodes:nt.map(t=>({id:t.ID})),links:et.map(t=>({source:t.source.ID,target:t.target.ID,value:t.value}))}),"getGraph"),Ot={nodesMap:tt,getConfig:e(()=>X().sankey,"getConfig"),getNodes:Ut,getLinks:Xt,getGraph:Gt,addLink:Yt,findOrCreateNode:qt,getAccTitle:Lt,setAccTitle:St,getAccDescription:Et,setAccDescription:wt,getDiagramTitle:Tt,setDiagramTitle:At,clear:Ht};function Q(t,o){let s;if(o===void 0)for(let u of t)u!=null&&(s<u||s===void 0&&u>=u)&&(s=u);else{let u=-1;for(let c of t)(c=o(c,++u,t))!=null&&(s<c||s===void 0&&c>=c)&&(s=c)}return s}e(Q,"max");function F(t,o){let s;if(o===void 0)for(let u of t)u!=null&&(s>u||s===void 0&&u>=u)&&(s=u);else{let u=-1;for(let c of t)(c=o(c,++u,t))!=null&&(s>c||s===void 0&&c>=c)&&(s=c)}return s}e(F,"min");function H(t,o){let s=0;if(o===void 0)for(let u of t)(u=+u)&&(s+=u);else{let u=-1;for(let c of t)(c=+o(c,++u,t))&&(s+=c)}return s}e(H,"sum");function Jt(t){return t.target.depth}e(Jt,"targetDepth");function ct(t){return t.depth}e(ct,"left");function ht(t,o){return o-1-t.height}e(ht,"right");function K(t,o){return t.sourceLinks.length?t.depth:o-1}e(K,"justify");function dt(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?F(t.sourceLinks,Jt)-1:0}e(dt,"center");function Y(t){return function(){return t}}e(Y,"constant");function It(t,o){return rt(t.source,o.source)||t.index-o.index}e(It,"ascendingSourceBreadth");function Pt(t,o){return rt(t.target,o.target)||t.index-o.index}e(Pt,"ascendingTargetBreadth");function rt(t,o){return t.y0-o.y0}e(rt,"ascendingBreadth");function pt(t){return t.value}e(pt,"value");function Qt(t){return t.index}e(Qt,"defaultId");function Kt(t){return t.nodes}e(Kt,"defaultNodes");function Zt(t){return t.links}e(Zt,"defaultLinks");function Dt(t,o){let s=t.get(o);if(!s)throw new Error("missing: "+o);return s}e(Dt,"find");function Rt({nodes:t}){for(let o of t)
|
||
|
|
${b}${Math.round(i*100)/100}${A}`:r,"getText"),W=e(r=>M==="outlined"?(r.layer??0)<z?{x:r.x0-6,anchor:"end"}:{x:r.x1+6,anchor:"start"}:r.x0<h/2?{x:r.x1+6,anchor:"start"}:{x:r.x0-6,anchor:"end"},"getLabelPosition"),L=l.append("g").attr("class","node-labels").attr("font-size",14),R=e(r=>L.selectAll(r?`.${r}`:"text").data(D.nodes).join("text").attr("class",r??null).attr("x",i=>W(i).x).attr("y",i=>(i.y1+i.y0)/2).attr("dy",`${E?"0":"0.35"}em`).attr("text-anchor",i=>W(i).anchor).text(q),"appendLabel");M==="outlined"?(R("sankey-label-bg"),R("sankey-label-fg")):R();let n=l.append("g").attr("class","links").attr("fill","none").attr("stroke-opacity",.5).selectAll(".link").data(D.links).join("g").attr("class","link").style("mix-blend-mode","multiply"),f=_?.linkColor??"gradient";if(f==="gradient"){let r=n.append("linearGradient").attr("id",i=>(i.uid=Z.next("linearGradient-")).id).attr("gradientUnits","userSpaceOnUse").attr("x1",i=>i.source.x1).attr("x2",i=>i.target.x0);r.append("stop").attr("offset","0%").attr("stop-color",i=>I(i.source.id)),r.append("stop").attr("offset","100%").attr("stop-color",i=>I(i.target.id))}let d;switch(f){case"gradient":d=e(r=>r.uid,"coloring");break;case"source":d=e(r=>I(r.source.id),"coloring");break;case"target":d=e(r=>I(r.target.id),"coloring");break;default:d=f}n.append("path").attr("d",st()).attr("stroke",d).attr("stroke-width",r=>Math.max(1,r.width)),bt(void 0,l,0,k)},"draw"),Vt={draw:ue};var Wt=e(t=>t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g,"").replaceAll(/([\n\r])+/g,`
|
||
|
|
`).trim(),"prepareTextForParsing");var fe=e(t=>`.label {
|
||
|
|
font-family: ${t.fontFamily};
|
||
|
|
}
|
||
|
|
|
||
|
|
.node-labels {
|
||
|
|
font-family: ${t.fontFamily};
|
||
|
|
}
|
||
|
|
|
||
|
|
/* Outlined label style - background stroke for better readability */
|
||
|
|
.sankey-label-bg {
|
||
|
|
stroke: ${t.mainBkg||t.background||"#fff"};
|
||
|
|
stroke-width: 4px;
|
||
|
|
stroke-linejoin: round;
|
||
|
|
paint-order: stroke;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* Foreground label text */
|
||
|
|
.sankey-label-fg {
|
||
|
|
fill: ${t.textColor};
|
||
|
|
}
|
||
|
|
|
||
|
|
/* Node styling */
|
||
|
|
.node rect {
|
||
|
|
shape-rendering: crispEdges;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* Link styling */
|
||
|
|
.link {
|
||
|
|
fill: none;
|
||
|
|
stroke-opacity: 0.5;
|
||
|
|
mix-blend-mode: multiply;
|
||
|
|
}
|
||
|
|
`,"getStyles"),Ft=fe;var ce=J.parse.bind(J);J.parse=t=>ce(Wt(t));var Nn={styles:Ft,parser:J,db:Ot,renderer:Vt};export{Nn as diagram};
|