11 lines
22 KiB
JavaScript
11 lines
22 KiB
JavaScript
import{m as n,j as jt,e as zt,G as Bt,$ as Ft,H as Rt,U as Ut,a as dt,A as Gt,i as K,aR as Ht,b7 as Vt,N as Wt,h as qt,bg as Qt}from"./mermaid.esm.min-C3PPQ_C2.js";import"./app-COnnofor.js";var st=(function(){var t=n(function(k,r,a,f){for(a=a||{},f=k.length;f--;a[k[f]]=r);return a},"o"),i=[1,9],s=[1,10],l=[1,5,10,12],h={trace:n(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:n(function(k,r,a,f,_,d,b){var x=d.length-1;switch(_){case 7:let C=f.findOrCreateNode(d[x-4].trim().replaceAll('""','"')),A=f.findOrCreateNode(d[x-2].trim().replaceAll('""','"')),N=parseFloat(d[x].trim());f.addLink(C,A,N);break;case 8:case 9:case 11:this.$=d[x];break;case 10:this.$=d[x-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:i,20:s},{1:[2,6],7:11,10:[1,12]},t(s,[2,4],{9:13,5:[1,14]}),{12:[1,15]},t(l,[2,8]),t(l,[2,9]),{19:[1,16]},t(l,[2,11]),{1:[2,1]},{1:[2,5]},t(s,[2,2]),{6:17,8:5,15:6,16:7,17:8,18:i,20:s},{15:18,16:7,17:8,18:i,20:s},{18:[1,19]},t(s,[2,3]),{12:[1,20]},t(l,[2,10]),{15:21,16:7,17:8,18:i,20:s},t([1,5,10],[2,7])],defaultActions:{11:[2,1],12:[2,5]},parseError:n(function(k,r){if(r.recoverable)this.trace(k);else{var a=new Error(k);throw a.hash=r,a}},"parseError"),parse:n(function(k){var r=this,a=[0],f=[],_=[null],d=[],b=this.table,x="",C=0,A=0,N=0,j=2,M=1,z=d.slice.call(arguments,1),S=Object.create(this.lexer),I={yy:{}};for(var $ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,$)&&(I.yy[$]=this.yy[$]);S.setInput(k,I.yy),I.yy.lexer=S,I.yy.parser=this,typeof S.yylloc>"u"&&(S.yylloc={});var g=S.yylloc;d.push(g);var T=S.options&&S.options.ranges;typeof I.yy.parseError=="function"?this.parseError=I.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function V(L){a.length=a.length-2*L,_.length=_.length-L,d.length=d.length-L}n(V,"popStack");function R(){var L;return L=f.pop()||S.lex()||M,typeof L!="number"&&(L instanceof Array&&(f=L,L=f.pop()),L=r.symbols_[L]||L),L}n(R,"lex");for(var E,U,O,e,y,u,c={},o,p,w,P;;){if(O=a[a.length-1],this.defaultActions[O]?e=this.defaultActions[O]:((E===null||typeof E>"u")&&(E=R()),e=b[O]&&b[O][E]),typeof e>"u"||!e.length||!e[0]){var D="";P=[];for(o in b[O])this.terminals_[o]&&o>j&&P.push("'"+this.terminals_[o]+"'");S.showPosition?D="Parse error on line "+(C+1)+`:
|
|
`+S.showPosition()+`
|
|
Expecting `+P.join(", ")+", got '"+(this.terminals_[E]||E)+"'":D="Parse error on line "+(C+1)+": Unexpected "+(E==M?"end of input":"'"+(this.terminals_[E]||E)+"'"),this.parseError(D,{text:S.match,token:this.terminals_[E]||E,line:S.yylineno,loc:g,expected:P})}if(e[0]instanceof Array&&e.length>1)throw new Error("Parse Error: multiple actions possible at state: "+O+", token: "+E);switch(e[0]){case 1:a.push(E),_.push(S.yytext),d.push(S.yylloc),a.push(e[1]),E=null,U?(E=U,U=null):(A=S.yyleng,x=S.yytext,C=S.yylineno,g=S.yylloc,N>0);break;case 2:if(p=this.productions_[e[1]][1],c.$=_[_.length-p],c._$={first_line:d[d.length-(p||1)].first_line,last_line:d[d.length-1].last_line,first_column:d[d.length-(p||1)].first_column,last_column:d[d.length-1].last_column},T&&(c._$.range=[d[d.length-(p||1)].range[0],d[d.length-1].range[1]]),u=this.performAction.apply(c,[x,A,C,I.yy,e[1],_,d].concat(z)),typeof u<"u")return u;p&&(a=a.slice(0,-1*p*2),_=_.slice(0,-1*p),d=d.slice(0,-1*p)),a.push(this.productions_[e[1]][0]),_.push(c.$),d.push(c._$),w=b[a[a.length-2]][a[a.length-1]],a.push(w);break;case 3:return!0}}return!0},"parse")},v=(function(){var k={EOF:1,parseError:n(function(r,a){if(this.yy.parser)this.yy.parser.parseError(r,a);else throw new Error(r)},"parseError"),setInput:n(function(r,a){return this.yy=a||this.yy||{},this._input=r,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:n(function(){var r=this._input[0];this.yytext+=r,this.yyleng++,this.offset++,this.match+=r,this.matched+=r;var a=r.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),r},"input"),unput:n(function(r){var a=r.length,f=r.split(/(?:\r\n?|\n)/g);this._input=r+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-a),this.offset-=a;var _=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),f.length-1&&(this.yylineno-=f.length-1);var d=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:f?(f.length===_.length?this.yylloc.first_column:0)+_[_.length-f.length].length-f[0].length:this.yylloc.first_column-a},this.options.ranges&&(this.yylloc.range=[d[0],d[0]+this.yyleng-a]),this.yyleng=this.yytext.length,this},"unput"),more:n(function(){return this._more=!0,this},"more"),reject:n(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:n(function(r){this.unput(this.match.slice(r))},"less"),pastInput:n(function(){var r=this.matched.substr(0,this.matched.length-this.match.length);return(r.length>20?"...":"")+r.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:n(function(){var r=this.match;return r.length<20&&(r+=this._input.substr(0,20-r.length)),(r.substr(0,20)+(r.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:n(function(){var r=this.pastInput(),a=new Array(r.length+1).join("-");return r+this.upcomingInput()+`
|
|
`+a+"^"},"showPosition"),test_match:n(function(r,a){var f,_,d;if(this.options.backtrack_lexer&&(d={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&&(d.yylloc.range=this.yylloc.range.slice(0))),_=r[0].match(/(?:\r\n?|\n).*/g),_&&(this.yylineno+=_.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:_?_[_.length-1].length-_[_.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+r[0].length},this.yytext+=r[0],this.match+=r[0],this.matches=r,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(r[0].length),this.matched+=r[0],f=this.performAction.call(this,this.yy,this,a,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),f)return f;if(this._backtrack){for(var b in d)this[b]=d[b];return!1}return!1},"test_match"),next:n(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var r,a,f,_;this._more||(this.yytext="",this.match="");for(var d=this._currentRules(),b=0;b<d.length;b++)if(f=this._input.match(this.rules[d[b]]),f&&(!a||f[0].length>a[0].length)){if(a=f,_=b,this.options.backtrack_lexer){if(r=this.test_match(f,d[b]),r!==!1)return r;if(this._backtrack){a=!1;continue}else return!1}else if(!this.options.flex)break}return a?(r=this.test_match(a,d[_]),r!==!1?r:!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:n(function(){var r=this.next();return r||this.lex()},"lex"),begin:n(function(r){this.conditionStack.push(r)},"begin"),popState:n(function(){var r=this.conditionStack.length-1;return r>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:n(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:n(function(r){return r=this.conditionStack.length-1-Math.abs(r||0),r>=0?this.conditionStack[r]:"INITIAL"},"topState"),pushState:n(function(r){this.begin(r)},"pushState"),stateStackSize:n(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:n(function(r,a,f,_){switch(f){case 0:return this.pushState("csv"),4;case 1:return this.pushState("csv"),4;case 2:return 10;case 3:return 5;case 4:return 12;case 5:return this.pushState("escaped_text"),18;case 6:return 20;case 7:return this.popState("escaped_text"),18;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 k})();h.lexer=v;function m(){this.yy={}}return n(m,"Parser"),m.prototype=h,h.Parser=m,new m})();st.parser=st;var J=st,nt=[],it=[],tt=new Map,Xt=n(()=>{nt=[],it=[],tt=new Map,Wt()},"clear"),G,Kt=(G=class{constructor(i,s,l=0){this.source=i,this.target=s,this.value=l}},n(G,"SankeyLink"),G),Zt=n((t,i,s)=>{nt.push(new Kt(t,i,s))},"addLink"),H,Yt=(H=class{constructor(i){this.ID=i}},n(H,"SankeyNode"),H),Jt=n(t=>{t=qt.sanitizeText(t,dt());let i=tt.get(t);return i===void 0&&(i=new Yt(t),tt.set(t,i),it.push(i)),i},"findOrCreateNode"),te=n(()=>it,"getNodes"),ee=n(()=>nt,"getLinks"),ne=n(()=>({nodes:it.map(t=>({id:t.ID})),links:nt.map(t=>({source:t.source.ID,target:t.target.ID,value:t.value}))}),"getGraph"),ie={nodesMap:tt,getConfig:n(()=>dt().sankey,"getConfig"),getNodes:te,getLinks:ee,getGraph:ne,addLink:Zt,findOrCreateNode:Jt,getAccTitle:Ut,setAccTitle:Rt,getAccDescription:Ft,setAccDescription:Bt,getDiagramTitle:zt,setDiagramTitle:jt,clear:Xt};function ot(t,i){let s;if(i===void 0)for(let l of t)l!=null&&(s<l||s===void 0&&l>=l)&&(s=l);else{let l=-1;for(let h of t)(h=i(h,++l,t))!=null&&(s<h||s===void 0&&h>=h)&&(s=h)}return s}n(ot,"max");function gt(t,i){let s;if(i===void 0)for(let l of t)l!=null&&(s>l||s===void 0&&l>=l)&&(s=l);else{let l=-1;for(let h of t)(h=i(h,++l,t))!=null&&(s>h||s===void 0&&h>=h)&&(s=h)}return s}n(gt,"min");function Z(t,i){let s=0;if(i===void 0)for(let l of t)(l=+l)&&(s+=l);else{let l=-1;for(let h of t)(h=+i(h,++l,t))&&(s+=h)}return s}n(Z,"sum");function kt(t){return t.target.depth}n(kt,"targetDepth");function xt(t){return t.depth}n(xt,"left");function vt(t,i){return i-1-t.height}n(vt,"right");function pt(t,i){return t.sourceLinks.length?t.depth:i-1}n(pt,"justify");function wt(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?gt(t.sourceLinks,kt)-1:0}n(wt,"center");function Q(t){return function(){return t}}n(Q,"constant");function at(t,i){return X(t.source,i.source)||t.index-i.index}n(at,"ascendingSourceBreadth");function lt(t,i){return X(t.target,i.target)||t.index-i.index}n(lt,"ascendingTargetBreadth");function X(t,i){return t.y0-i.y0}n(X,"ascendingBreadth");function Y(t){return t.value}n(Y,"value");function bt(t){return t.index}n(bt,"defaultId");function St(t){return t.nodes}n(St,"defaultNodes");function Lt(t){return t.links}n(Lt,"defaultLinks");function ht(t,i){let s=t.get(i);if(!s)throw new Error("missing: "+i);return s}n(ht,"find");function ut({nodes:t}){for(let i of t){let s=i.y0,l=s;for(let h of i.sourceLinks)h.y0=s+h.width/2,s+=h.width;for(let h of i.targetLinks)h.y1=l+h.width/2,l+=h.width}}n(ut,"computeLinkBreadths");function Et(){let t=0,i=0,s=1,l=1,h=24,v=8,m,k=bt,r=pt,a,f,_=St,d=Lt,b=6;function x(){let e={nodes:_.apply(null,arguments),links:d.apply(null,arguments)};return C(e),A(e),N(e),j(e),S(e),ut(e),e}n(x,"sankey"),x.update=function(e){return ut(e),e},x.nodeId=function(e){return arguments.length?(k=typeof e=="function"?e:Q(e),x):k},x.nodeAlign=function(e){return arguments.length?(r=typeof e=="function"?e:Q(e),x):r},x.nodeSort=function(e){return arguments.length?(a=e,x):a},x.nodeWidth=function(e){return arguments.length?(h=+e,x):h},x.nodePadding=function(e){return arguments.length?(v=m=+e,x):v},x.nodes=function(e){return arguments.length?(_=typeof e=="function"?e:Q(e),x):_},x.links=function(e){return arguments.length?(d=typeof e=="function"?e:Q(e),x):d},x.linkSort=function(e){return arguments.length?(f=e,x):f},x.size=function(e){return arguments.length?(t=i=0,s=+e[0],l=+e[1],x):[s-t,l-i]},x.extent=function(e){return arguments.length?(t=+e[0][0],s=+e[1][0],i=+e[0][1],l=+e[1][1],x):[[t,i],[s,l]]},x.iterations=function(e){return arguments.length?(b=+e,x):b};function C({nodes:e,links:y}){for(let[c,o]of e.entries())o.index=c,o.sourceLinks=[],o.targetLinks=[];let u=new Map(e.map((c,o)=>[k(c,o,e),c]));for(let[c,o]of y.entries()){o.index=c;let{source:p,target:w}=o;typeof p!="object"&&(p=o.source=ht(u,p)),typeof w!="object"&&(w=o.target=ht(u,w)),p.sourceLinks.push(o),w.targetLinks.push(o)}if(f!=null)for(let{sourceLinks:c,targetLinks:o}of e)c.sort(f),o.sort(f)}n(C,"computeNodeLinks");function A({nodes:e}){for(let y of e)y.value=y.fixedValue===void 0?Math.max(Z(y.sourceLinks,Y),Z(y.targetLinks,Y)):y.fixedValue}n(A,"computeNodeValues");function N({nodes:e}){let y=e.length,u=new Set(e),c=new Set,o=0;for(;u.size;){for(let p of u){p.depth=o;for(let{target:w}of p.sourceLinks)c.add(w)}if(++o>y)throw new Error("circular link");u=c,c=new Set}}n(N,"computeNodeDepths");function j({nodes:e}){let y=e.length,u=new Set(e),c=new Set,o=0;for(;u.size;){for(let p of u){p.height=o;for(let{source:w}of p.targetLinks)c.add(w)}if(++o>y)throw new Error("circular link");u=c,c=new Set}}n(j,"computeNodeHeights");function M({nodes:e}){let y=ot(e,o=>o.depth)+1,u=(s-t-h)/(y-1),c=new Array(y);for(let o of e){let p=Math.max(0,Math.min(y-1,Math.floor(r.call(null,o,y))));o.layer=p,o.x0=t+p*u,o.x1=o.x0+h,c[p]?c[p].push(o):c[p]=[o]}if(a)for(let o of c)o.sort(a);return c}n(M,"computeNodeLayers");function z(e){let y=gt(e,u=>(l-i-(u.length-1)*m)/Z(u,Y));for(let u of e){let c=i;for(let o of u){o.y0=c,o.y1=c+o.value*y,c=o.y1+m;for(let p of o.sourceLinks)p.width=p.value*y}c=(l-c+m)/(u.length+1);for(let o=0;o<u.length;++o){let p=u[o];p.y0+=c*(o+1),p.y1+=c*(o+1)}E(u)}}n(z,"initializeNodeBreadths");function S(e){let y=M(e);m=Math.min(v,(l-i)/(ot(y,u=>u.length)-1)),z(y);for(let u=0;u<b;++u){let c=Math.pow(.99,u),o=Math.max(1-c,(u+1)/b);$(y,c,o),I(y,c,o)}}n(S,"computeNodeBreadths");function I(e,y,u){for(let c=1,o=e.length;c<o;++c){let p=e[c];for(let w of p){let P=0,D=0;for(let{source:W,value:rt}of w.targetLinks){let q=rt*(w.layer-W.layer);P+=U(W,w)*q,D+=q}if(!(D>0))continue;let L=(P/D-w.y0)*y;w.y0+=L,w.y1+=L,R(w)}a===void 0&&p.sort(X),g(p,u)}}n(I,"relaxLeftToRight");function $(e,y,u){for(let c=e.length,o=c-2;o>=0;--o){let p=e[o];for(let w of p){let P=0,D=0;for(let{target:W,value:rt}of w.sourceLinks){let q=rt*(W.layer-w.layer);P+=O(w,W)*q,D+=q}if(!(D>0))continue;let L=(P/D-w.y0)*y;w.y0+=L,w.y1+=L,R(w)}a===void 0&&p.sort(X),g(p,u)}}n($,"relaxRightToLeft");function g(e,y){let u=e.length>>1,c=e[u];V(e,c.y0-m,u-1,y),T(e,c.y1+m,u+1,y),V(e,l,e.length-1,y),T(e,i,0,y)}n(g,"resolveCollisions");function T(e,y,u,c){for(;u<e.length;++u){let o=e[u],p=(y-o.y0)*c;p>1e-6&&(o.y0+=p,o.y1+=p),y=o.y1+m}}n(T,"resolveCollisionsTopToBottom");function V(e,y,u,c){for(;u>=0;--u){let o=e[u],p=(o.y1-y)*c;p>1e-6&&(o.y0-=p,o.y1-=p),y=o.y0-m}}n(V,"resolveCollisionsBottomToTop");function R({sourceLinks:e,targetLinks:y}){if(f===void 0){for(let{source:{sourceLinks:u}}of y)u.sort(lt);for(let{target:{targetLinks:u}}of e)u.sort(at)}}n(R,"reorderNodeLinks");function E(e){if(f===void 0)for(let{sourceLinks:y,targetLinks:u}of e)y.sort(lt),u.sort(at)}n(E,"reorderLinks");function U(e,y){let u=e.y0-(e.sourceLinks.length-1)*m/2;for(let{target:c,width:o}of e.sourceLinks){if(c===y)break;u+=o+m}for(let{source:c,width:o}of y.targetLinks){if(c===e)break;u-=o}return u}n(U,"targetTop");function O(e,y){let u=y.y0-(y.targetLinks.length-1)*m/2;for(let{source:c,width:o}of y.targetLinks){if(c===e)break;u+=o+m}for(let{target:c,width:o}of e.sourceLinks){if(c===y)break;u-=o}return u}return n(O,"sourceTop"),x}n(Et,"Sankey");var ct=Math.PI,ft=2*ct,F=1e-6,re=ft-F;function et(){this._x0=this._y0=this._x1=this._y1=null,this._=""}n(et,"Path");function mt(){return new et}n(mt,"path");et.prototype=mt.prototype={constructor:et,moveTo:n(function(t,i){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+i)},"moveTo"),closePath:n(function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},"closePath"),lineTo:n(function(t,i){this._+="L"+(this._x1=+t)+","+(this._y1=+i)},"lineTo"),quadraticCurveTo:n(function(t,i,s,l){this._+="Q"+ +t+","+ +i+","+(this._x1=+s)+","+(this._y1=+l)},"quadraticCurveTo"),bezierCurveTo:n(function(t,i,s,l,h,v){this._+="C"+ +t+","+ +i+","+ +s+","+ +l+","+(this._x1=+h)+","+(this._y1=+v)},"bezierCurveTo"),arcTo:n(function(t,i,s,l,h){t=+t,i=+i,s=+s,l=+l,h=+h;var v=this._x1,m=this._y1,k=s-t,r=l-i,a=v-t,f=m-i,_=a*a+f*f;if(h<0)throw new Error("negative radius: "+h);if(this._x1===null)this._+="M"+(this._x1=t)+","+(this._y1=i);else if(_>F)if(!(Math.abs(f*k-r*a)>F)||!h)this._+="L"+(this._x1=t)+","+(this._y1=i);else{var d=s-v,b=l-m,x=k*k+r*r,C=d*d+b*b,A=Math.sqrt(x),N=Math.sqrt(_),j=h*Math.tan((ct-Math.acos((x+_-C)/(2*A*N)))/2),M=j/N,z=j/A;Math.abs(M-1)>F&&(this._+="L"+(t+M*a)+","+(i+M*f)),this._+="A"+h+","+h+",0,0,"+ +(f*d>a*b)+","+(this._x1=t+z*k)+","+(this._y1=i+z*r)}},"arcTo"),arc:n(function(t,i,s,l,h,v){t=+t,i=+i,s=+s,v=!!v;var m=s*Math.cos(l),k=s*Math.sin(l),r=t+m,a=i+k,f=1^v,_=v?l-h:h-l;if(s<0)throw new Error("negative radius: "+s);this._x1===null?this._+="M"+r+","+a:(Math.abs(this._x1-r)>F||Math.abs(this._y1-a)>F)&&(this._+="L"+r+","+a),s&&(_<0&&(_=_%ft+ft),_>re?this._+="A"+s+","+s+",0,1,"+f+","+(t-m)+","+(i-k)+"A"+s+","+s+",0,1,"+f+","+(this._x1=r)+","+(this._y1=a):_>F&&(this._+="A"+s+","+s+",0,"+ +(_>=ct)+","+f+","+(this._x1=t+s*Math.cos(h))+","+(this._y1=i+s*Math.sin(h))))},"arc"),rect:n(function(t,i,s,l){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+i)+"h"+ +s+"v"+ +l+"h"+-s+"Z"},"rect"),toString:n(function(){return this._},"toString")};var se=mt;function yt(t){return n(function(){return t},"constant")}n(yt,"default");function Tt(t){return t[0]}n(Tt,"x");function Mt(t){return t[1]}n(Mt,"y");var oe=Array.prototype.slice;function At(t){return t.source}n(At,"linkSource");function Nt(t){return t.target}n(Nt,"linkTarget");function It(t){var i=At,s=Nt,l=Tt,h=Mt,v=null;function m(){var k,r=oe.call(arguments),a=i.apply(this,r),f=s.apply(this,r);if(v||(v=k=se()),t(v,+l.apply(this,(r[0]=a,r)),+h.apply(this,r),+l.apply(this,(r[0]=f,r)),+h.apply(this,r)),k)return v=null,k+""||null}return n(m,"link"),m.source=function(k){return arguments.length?(i=k,m):i},m.target=function(k){return arguments.length?(s=k,m):s},m.x=function(k){return arguments.length?(l=typeof k=="function"?k:yt(+k),m):l},m.y=function(k){return arguments.length?(h=typeof k=="function"?k:yt(+k),m):h},m.context=function(k){return arguments.length?(v=k??null,m):v},m}n(It,"link");function Ct(t,i,s,l,h){t.moveTo(i,s),t.bezierCurveTo(i=(i+l)/2,s,i,h,l,h)}n(Ct,"curveHorizontal");function $t(){return It(Ct)}n($t,"linkHorizontal");function Dt(t){return[t.source.x1,t.y0]}n(Dt,"horizontalSource");function Ot(t){return[t.target.x0,t.y1]}n(Ot,"horizontalTarget");function Pt(){return $t().source(Dt).target(Ot)}n(Pt,"default");var B,_t=(B=class{static next(i){return new B(i+ ++B.count)}constructor(i){this.id=i,this.href=`#${i}`}toString(){return"url("+this.href+")"}},n(B,"Uid"),B.count=0,B),ae={left:xt,right:vt,center:wt,justify:pt},le=n(function(t,i,s,l){let{securityLevel:h,sankey:v}=dt(),m=Gt.sankey,k;h==="sandbox"&&(k=K("#i"+i));let r=h==="sandbox"?K(k.nodes()[0].contentDocument.body):K("body"),a=h==="sandbox"?r.select(`[id="${i}"]`):K(`[id="${i}"]`),f=v?.width??m.width,_=v?.height??m.width,d=v?.useMaxWidth??m.useMaxWidth,b=v?.nodeAlignment??m.nodeAlignment,x=v?.prefix??m.prefix,C=v?.suffix??m.suffix,A=v?.showValues??m.showValues,N=l.db.getGraph(),j=ae[b];Et().nodeId(g=>g.id).nodeWidth(10).nodePadding(10+(A?15:0)).nodeAlign(j).extent([[0,0],[f,_]])(N);let M=Ht(Qt);a.append("g").attr("class","nodes").selectAll(".node").data(N.nodes).join("g").attr("class","node").attr("id",g=>(g.uid=_t.next("node-")).id).attr("transform",function(g){return"translate("+g.x0+","+g.y0+")"}).attr("x",g=>g.x0).attr("y",g=>g.y0).append("rect").attr("height",g=>g.y1-g.y0).attr("width",g=>g.x1-g.x0).attr("fill",g=>M(g.id));let z=n(({id:g,value:T})=>A?`${g}
|
|
${x}${Math.round(T*100)/100}${C}`:g,"getText");a.append("g").attr("class","node-labels").attr("font-size",14).selectAll("text").data(N.nodes).join("text").attr("x",g=>g.x0<f/2?g.x1+6:g.x0-6).attr("y",g=>(g.y1+g.y0)/2).attr("dy",`${A?"0":"0.35"}em`).attr("text-anchor",g=>g.x0<f/2?"start":"end").text(z);let S=a.append("g").attr("class","links").attr("fill","none").attr("stroke-opacity",.5).selectAll(".link").data(N.links).join("g").attr("class","link").style("mix-blend-mode","multiply"),I=v?.linkColor??"gradient";if(I==="gradient"){let g=S.append("linearGradient").attr("id",T=>(T.uid=_t.next("linearGradient-")).id).attr("gradientUnits","userSpaceOnUse").attr("x1",T=>T.source.x1).attr("x2",T=>T.target.x0);g.append("stop").attr("offset","0%").attr("stop-color",T=>M(T.source.id)),g.append("stop").attr("offset","100%").attr("stop-color",T=>M(T.target.id))}let $;switch(I){case"gradient":$=n(g=>g.uid,"coloring");break;case"source":$=n(g=>M(g.source.id),"coloring");break;case"target":$=n(g=>M(g.target.id),"coloring");break;default:$=I}S.append("path").attr("d",Pt()).attr("stroke",$).attr("stroke-width",g=>Math.max(1,g.width)),Vt(void 0,a,0,d)},"draw"),he={draw:le},ue=n(t=>t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g,"").replaceAll(/([\n\r])+/g,`
|
|
`).trim(),"prepareTextForParsing"),ce=n(t=>`.label {
|
|
font-family: ${t.fontFamily};
|
|
}`,"getStyles"),fe=ce,ye=J.parse.bind(J);J.parse=t=>ye(ue(t));var pe={styles:fe,parser:J,db:ie,renderer:he};export{pe as diagram};
|