HomeDashboard/.venv/lib/python3.12/site-packages/nicegui/elements/mermaid/dist/sankeyDiagram-XSL23WO4-CiWF1Wt0.js
2026-01-03 14:54:18 +01:00

3 lines
22 KiB
JavaScript

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