Files

11 lines
22 KiB
JavaScript
Raw Permalink Normal View History

2025-11-23 14:59:17 -08:00
import{D as _t,M as vt,O as bt,P as St,Q as wt,R as Lt,S as At,T as Et,U as Tt,W as U,Y as Ct}from"./chunk-KXVH62NG.mjs";import{E as Nt,h as X,m as Mt}from"./chunk-63GW7ZVL.mjs";import{a as e}from"./chunk-GTKDMUJJ.mjs";var lt=(function(){var t=e(function(x,o,a,l){for(a=a||{},l=x.length;l--;a[x[l]]=o);return a},"o"),r=[1,9],i=[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(o,a,l,k,_,p,v){var C=p.length-1;switch(_){case 7:let E=k.findOrCreateNode(p[C-4].trim().replaceAll('""','"')),M=k.findOrCreateNode(p[C-2].trim().replaceAll('""','"')),D=parseFloat(p[C].trim());k.addLink(E,M,D);break;case 8:case 9:case 11:this.$=p[C];break;case 10:this.$=p[C-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:r,20:i},{1:[2,6],7:11,10:[1,12]},t(i,[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(i,[2,2]),{6:17,8:5,15:6,16:7,17:8,18:r,20:i},{15:18,16:7,17:8,18:r,20:i},{18:[1,19]},t(i,[2,3]),{12:[1,20]},t(u,[2,10]),{15:21,16:7,17:8,18:r,20:i},t([1,5,10],[2,7])],defaultActions:{11:[2,1],12:[2,5]},parseError:e(function(o,a){if(a.recoverable)this.trace(o);else{var l=new Error(o);throw l.hash=a,l}},"parseError"),parse:e(function(o){var a=this,l=[0],k=[],_=[null],p=[],v=this.table,C="",E=0,M=0,D=0,z=2,B=1,R=p.slice.call(arguments,1),w=Object.create(this.lexer),N={yy:{}};for(var P in this.yy)Object.prototype.hasOwnProperty.call(this.yy,P)&&(N.yy[P]=this.yy[P]);w.setInput(o,N.yy),N.yy.lexer=w,N.yy.parser=this,typeof w.yylloc>"u"&&(w.yylloc={});var O=w.yylloc;p.push(O);var y=w.options&&w.options.ranges;typeof N.yy.parseError=="function"?this.parseError=N.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function T(L){l.length=l.length-2*L,_.length=_.length-L,p.length=p.length-L}e(T,"popStack");function st(){var L;return L=k.pop()||w.lex()||B,typeof L!="number"&&(L instanceof Array&&(k=L,L=k.pop()),L=a.symbols_[L]||L),L}e(st,"lex");for(var A,Y,n,f,h,d,s={},g,b,$,I;;){if(n=l[l.length-1],this.defaultActions[n]?f=this.defaultActions[n]:((A===null||typeof A>"u")&&(A=st()),f=v[n]&&v[n][A]),typeof f>"u"||!f.length||!f[0]){var j="";I=[];for(g in v[n])this.terminals_[g]&&g>z&&I.push("'"+this.terminals_[g]+"'");w.showPosition?j="Parse error on line "+(E+1)+`:
`+w.showPosition()+`
Expecting `+I.join(", ")+", got '"+(this.terminals_[A]||A)+"'":j="Parse error on line "+(E+1)+": Unexpected "+(A==B?"end of input":"'"+(this.terminals_[A]||A)+"'"),this.parseError(j,{text:w.match,token:this.terminals_[A]||A,line:w.yylineno,loc:O,expected:I})}if(f[0]instanceof Array&&f.length>1)throw new Error("Parse Error: multiple actions possible at state: "+n+", token: "+A);switch(f[0]){case 1:l.push(A),_.push(w.yytext),p.push(w.yylloc),l.push(f[1]),A=null,Y?(A=Y,Y=null):(M=w.yyleng,C=w.yytext,E=w.yylineno,O=w.yylloc,D>0&&D--);break;case 2:if(b=this.productions_[f[1]][1],s.$=_[_.length-b],s._$={first_line:p[p.length-(b||1)].first_line,last_line:p[p.length-1].last_line,first_column:p[p.length-(b||1)].first_column,last_column:p[p.length-1].last_column},y&&(s._$.range=[p[p.length-(b||1)].range[0],p[p.length-1].range[1]]),d=this.performAction.apply(s,[C,M,E,N.yy,f[1],_,p].concat(R)),typeof d<"u")return d;b&&(l=l.slice(0,-1*b*2),_=_.slice(0,-1*b),p=p.slice(0,-1*b)),l.push(this.productions_[f[1]][0]),_.push(s.$),p.push(s._$),$=v[l[l.length-2]][l[l.length-1]],l.push($);break;case 3:return!0}}return!0},"parse")},S=(function(){var x={EOF:1,parseError:e(function(a,l){if(this.yy.parser)this.yy.parser.parseError(a,l);else throw new Error(a)},"parseError"),setInput:e(function(o,a){return this.yy=a||this.yy||{},this._input=o,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 o=this._input[0];this.yytext+=o,this.yyleng++,this.offset++,this.match+=o,this.matched+=o;var a=o.match(/(?:\r\n?|\n).*/g);return a?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),o},"input"),unput:e(function(o){var a=o.length,l=o.split(/(?:\r\n?|\n)/g);this._input=o+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-a),this.offset-=a;var k=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),l.length-1&&(this.yylineno-=l.length-1);var _=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:l?(l.length===k.length?this.yylloc.first_column:0)+k[k.length-l.length].length-l[0].length:this.yylloc.first_column-a},this.options.ranges&&(this.yylloc.range=[_[0],_[0]+this.yyleng-a]),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(o){this.unput(this.match.slice(o))},"less"),pastInput:e(function(){var o=this.matched.substr(0,this.matched.length-this.match.length);return(o.length>20?"...":"")+o.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:e(function(){var o=this.match;return o.length<20&&(o+=this._input.substr(0,20-o.length)),(o.substr(0,20)+(o.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:e(function(){var o=this.pastInput(),a=new Array(o.length+1).join("-");return o+this.upcomingInput()+`
`+a+"^"},"showPosition"),test_match:e(function(o,a){var l,k,_;if(this.options.backtrack_lexer&&(_={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&&(_.yylloc.range=this.yylloc.range.slice(0))),k=o[0].match(/(?:\r\n?|\n).*/g),k&&(this.yylineno+=k.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:k?k[k.length-1].length-k[k.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+o[0].length},this.yytext+=o[0],this.match+=o[0],this.matches=o,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(o[0].length),this.matched+=o[0],l=this.performAction.call(this,this.yy,this,a,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),l)return l;if(this._backtrack){for(var p in _)this[p]=_[p];return!1}return!1},"test_match"),next:e(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var o,a,l,k;this._more||(this.yytext="",this.match="");for(var _=this._currentRules(),p=0;p<_.length;p++)if(l=this._input.match(this.rules[_[p]]),l&&(!a||l[0].length>a[0].length)){if(a=l,k=p,this.options.backtrack_lexer){if(o=this.test_match(l,_[p]),o!==!1)return o;if(this._backtrack){a=!1;continue}else return!1}else if(!this.options.flex)break}return a?(o=this.test_match(a,_[k]),o!==!1?o:!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 a=this.next();return a||this.lex()},"lex"),begin:e(function(a){this.conditionStack.push(a)},"begin"),popState:e(function(){var a=this.conditionStack.length-1;return a>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(a){return a=this.conditionStack.length-1-Math.abs(a||0),a>=0?this.conditionStack[a]:"INITIAL"},"topState"),pushState:e(function(a){this.begin(a)},"pushState"),stateStackSize:e(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:e(function(a,l,k,_){var p=_;switch(k){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 x})();c.lexer=S;function m(){this.yy={}}return e(m,"Parser"),m.prototype=c,c.Parser=m,new m})();lt.parser=lt;var G=lt;var tt=[],et=[],Z=new Map,Ht=e(()=>{tt=[],et=[],Z=new Map,bt()},"clear"),ut=class{constructor(r,i,u=0){this.source=r;this.target=i;this.value=u}static{e(this,"SankeyLink")}},Yt=e((t,r,i)=>{tt.push(new ut(t,r,i))},"addLink"),ft=class{constructor(r){this.ID=r}static{e(this,"SankeyNode")}},qt=e(t=>{t=_t.sanitizeText(t,U());let r=Z.get(t);return r===void 0&&(r=new ft(t),Z.set(t,r),et.push(r)),r},"findOrCreateNode"),Ut=e(()=>et,"getNodes"),Xt=e(()=>tt,"getLinks"),Gt=e(()=>({nodes:et.map(t=>({id:t.ID})),links:tt.map(t=>({source:t.source.ID,target:t.target.ID,value:t.value}))}),"getGraph"),Ot={nodesMap:Z,getConfig:e(()=>U().sankey,"getConfig"),getNodes:Ut,getLinks:Xt,getGraph:Gt,addLink:Yt,findOrCreateNode:qt,getAccTitle:wt,setAccTitle:St,getAccDescription:At,setAccDescription:Lt,getDiagramTitle:Tt,setDiagramTitle:Et,clear:Ht};function J(t,r){let i;if(r===void 0)for(let u of t)u!=null&&(i<u||i===void 0&&u>=u)&&(i=u);else{let u=-1;for(let c of t)(c=r(c,++u,t))!=null&&(i<c||i===void 0&&c>=c)&&(i=c)}return i}e(J,"max");function F(t,r){let i;if(r===void 0)for(let u of t)u!=null&&(i>u||i===void 0&&u>=u)&&(i=u);else{let u=-1;for(let c of t)(c=r(c,++u,t))!=null&&(i>c||i===void 0&&c>=c)&&(i=c)}return i}e(F,"min");function W(t,r){let i=0;if(r===void 0)for(let u of t)(u=+u)&&(i+=u);else{let u=-1;for(let c of t)(c=+r(c,++u,t))&&(i+=c)}return i}e(W,"sum");function Jt(t){return t.target.depth}e(Jt,"targetDepth");function ct(t){return t.depth}e(ct,"left");function ht(t,r){return r-1-t.height}e(ht,"right");function Q(t,r){return t.sourceLinks.length?t.depth:r-1}e(Q,"justify");function dt(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?F(t.sourceLinks,Jt)-1:0}e(dt,"center");function H(t){return function(){return t}}e(H,"constant");function It(t,r){return nt(t.source,r.source)||t.index-r.index}e(It,"ascendingSourceBreadth");function Dt(t,r){return nt(t.target,r.target)||t.index-r.index}e(Dt,"ascendingTargetBreadth");function nt(t,r){return t.y0-r.y0}e(nt,"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 Pt(t,r){let i=t.get(r);if(!i)throw new Error("missing: "+r);return i}e(Pt,"find");function Rt({nodes:t}){for(let r of t){let
${v}${Math.round(T*100)/100}${C}`:y,"getText");a.append("g").attr("class","node-labels").attr("font-size",14).selectAll("text").data(M.nodes).join("text").attr("x",y=>y.x0<l/2?y.x1+6:y.x0-6).attr("y",y=>(y.y1+y.y0)/2).attr("dy",`${E?"0":"0.35"}em`).attr("text-anchor",y=>y.x0<l/2?"start":"end").text(w);let N=a.append("g").attr("class","links").attr("fill","none").attr("stroke-opacity",.5).selectAll(".link").data(M.links).join("g").attr("class","link").style("mix-blend-mode","multiply"),P=S?.linkColor??"gradient";if(P==="gradient"){let y=N.append("linearGradient").attr("id",T=>(T.uid=K.next("linearGradient-")).id).attr("gradientUnits","userSpaceOnUse").attr("x1",T=>T.source.x1).attr("x2",T=>T.target.x0);y.append("stop").attr("offset","0%").attr("stop-color",T=>R(T.source.id)),y.append("stop").attr("offset","100%").attr("stop-color",T=>R(T.target.id))}let O;switch(P){case"gradient":O=e(y=>y.uid,"coloring");break;case"source":O=e(y=>R(y.source.id),"coloring");break;case"target":O=e(y=>R(y.target.id),"coloring");break;default:O=P}N.append("path").attr("d",it()).attr("stroke",O).attr("stroke-width",y=>Math.max(1,y.width)),vt(void 0,a,0,_)},"draw"),Vt={draw:le};var Ft=e(t=>t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g,"").replaceAll(/([\n\r])+/g,`
`).trim(),"prepareTextForParsing");var ue=e(t=>`.label {
font-family: ${t.fontFamily};
}`,"getStyles"),Wt=ue;var fe=G.parse.bind(G);G.parse=t=>fe(Ft(t));var Cn={styles:Wt,parser:G,db:Ot,renderer:Vt};export{Cn as diagram};