2026-06-16 05:58:18 +00:00
import { _ as y , q as xt , t as _t , s as vt , g as bt , b as St , a as wt , c as lt , B as Lt , d as H , af as Et , A as At , k as Tt } from "./mermaid.core.BrszyIat.js" ; import { o as Mt } from "./ordinal.BYWQX77i.js" ; import "./framework.C2AwuPrQ.js" ; import "./init.Gi6I4Gst.js" ; function Nt ( t ) { for ( var n = t . length / 6 | 0 , s = new Array ( n ) , a = 0 ; a < n ; ) s [ a ] = "#" + t . slice ( a * 6 , ++ a * 6 ) ; return s } const Ct = Nt ( "4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab" ) ; function ct ( t , n ) { let s ; if ( n === void 0 ) for ( const a of t ) a != null && ( s < a || s === void 0 && a >= a ) && ( s = a ) ; else { let a = - 1 ; for ( let u of t ) ( u = n ( u , ++ a , t ) ) != null && ( s < u || s === void 0 && u >= u ) && ( s = u ) } return s } function pt ( t , n ) { let s ; if ( n === void 0 ) for ( const a of t ) a != null && ( s > a || s === void 0 && a >= a ) && ( s = a ) ; else { let a = - 1 ; for ( let u of t ) ( u = n ( u , ++ a , t ) ) != null && ( s > u || s === void 0 && u >= u ) && ( s = u ) } return s } function nt ( t , n ) { let s = 0 ; if ( n === void 0 ) for ( let a of t ) ( a = + a ) && ( s += a ) ; else { let a = - 1 ; for ( let u of t ) ( u = + n ( u , ++ a , t ) ) && ( s += u ) } return s } function Pt ( t ) { return t . target . depth } function It ( t ) { return t . depth } function Ot ( t , n ) { return n - 1 - t . height } function kt ( t , n ) { return t . sourceLinks . length ? t . depth : n - 1 } function $t ( t ) { return t . targetLinks . length ? t . depth : t . sourceLinks . length ? pt ( t . sourceLinks , Pt ) - 1 : 0 } function X ( t ) { return function ( ) { return t } } function ut ( t , n ) { return Q ( t . source , n . source ) || t . index - n . index } function ht ( t , n ) { return Q ( t . target , n . target ) || t . index - n . index } function Q ( t , n ) { return t . y0 - n . y0 } function it ( t ) { return t . value } function Dt ( t ) { return t . index } function jt ( t ) { return t . nodes } function zt ( t ) { return t . links } function ft ( t , n ) { const s = t . get ( n ) ; if ( ! s ) throw new Error ( "missing: " + n ) ; return s } function yt ( { nodes : t } ) { for ( const n of t ) { let s = n . y0 , a = s ; for ( const u of n . sourceLinks ) u . y0 = s + u . width / 2 , s += u . width ; for ( const u of n . targetLinks ) u . y1 = a + u . width / 2 , a += u . width } } function Bt ( ) { let t = 0 , n = 0 , s = 1 , a = 1 , u = 24 , x = 8 , g , k = Dt , o = kt , l , h , m = jt , _ = zt , d = 6 ; function v ( ) { const i = { nodes : m . apply ( null , arguments ) , links : _ . apply ( null , arguments ) } ; return T ( i ) , A ( i ) , M ( i ) , I ( i ) , S ( i ) , yt ( i ) , i } v . update = function ( i ) { return yt ( i ) , i } , v . nodeId = function ( i ) { return arguments . length ? ( k = typeof i == "function" ? i : X ( i ) , v ) : k } , v . nodeAlign = function ( i ) { return arguments . length ? ( o = typeof i == "function" ? i : X ( i ) , v ) : o } , v . nodeSort = function ( i ) { return arguments . length ? ( l = i , v ) : l } , v . nodeWidth = function ( i ) { return arguments . length ? ( u = + i , v ) : u } , v . nodePadding = function ( i ) { return arguments . length ? ( x = g = + i , v ) : x } , v . nodes = function ( i ) { return arguments . length ? ( m = typeof i == "function" ? i : X ( i ) , v ) : m } , v . links = function ( i ) { return arguments . length ? ( _ = typeof i == "function" ? i : X ( i ) , v ) : _ } , v . linkSort = function ( i ) { return arguments . length ? ( h = i , v ) : h } , v . size = function ( i ) { return arguments . length ? ( t = n = 0 , s = + i [ 0 ] , a = + i [ 1 ] , v ) : [ s - t , a - n ] } , v . extent = function ( i ) { return arguments . length ? ( t = + i [ 0 ] [ 0 ] , s = + i [ 1 ] [ 0 ] , n = + i [ 0 ] [ 1 ] , a = + i [ 1 ] [ 1 ] , v ) : [ [ t , n ] , [ s , a ] ] } , v . iterations = function ( i ) { return arguments . length ? ( d = + i , v ) : d } ; function T ( { nodes : i , links : f } ) { for ( const [ e , r ] of i . entries ( ) ) r . index = e , r . sourceLinks = [ ] , r . targetLinks = [ ] ; const c = new Map ( i . map ( ( e , r ) => [ k ( e , r , i ) , e ] ) ) ; for ( const [ e , r ] of f . entries ( ) ) { r . index = e ; let { source : p , target : b } = r ; typeof p != "object" && ( p = r . source = ft ( c , p ) ) , typeof b != "object" && ( b = r . target = ft ( c , b ) ) , p . sourceLinks . push ( r ) , b . targetLinks . push ( r ) } if ( h != null ) for ( const { sourceLinks : e , targetLinks : r } of i ) e . sort ( h ) , r . sort ( h ) } function A ( { nodes : i } ) { for ( const f of i ) f . value = f . fixedValue === void 0 ? Math . max ( nt ( f . sourceLinks , it ) , nt ( f . targetLinks , it ) ) : f . fixedValue } function M ( { nodes : i } ) { const f = i . length ; let c = new Set ( i ) , e = new Set , r = 0 ; for ( ; c . size ; ) { for ( const p of c ) { p . depth = r ; for ( const { target : b } of p . sourceLinks ) e . add ( b ) } if ( ++ r > f ) throw new Error ( "circular link" ) ; c = e , e = new Set } } function I ( { nodes : i } ) { const f = i . length ; let c = new Set ( i ) , e = new Set , r = 0 ; for ( ; c . size ; ) { for ( const p of c ) { p . height = r ; for ( const { source : b } of p . targetLinks ) e . add ( b ) } if ( ++ r > f ) throw new Error ( "circular link" ) ; c = e , e = new Set } } function N ( { nodes : i } ) { const f = ct ( i , r => r . depth ) + 1 , c = ( s - t - u ) / ( f - 1 ) , e = new Array ( f ) ; for ( const r of i ) { const p = Math . max ( 0 , Math . min ( f - 1 , Math . floor ( o . call ( null , r , f ) ) ) ) ; r . layer = p , r . x0 = t + p * c , r . x1 = r . x0 + u , e [ p ] ? e [ p ] . push ( r ) : e [ p ] = [ r ] } if ( l ) for ( const r of e ) r . sort ( l ) ; return e } function D ( i ) { const f = pt ( i , c => ( a - n - ( c . length - 1 ) * g ) / nt ( c , it
2026-05-21 07:27:56 +00:00
` +S.showPosition()+ `
Expecting ` +p.join(", ")+", got '"+(this.terminals_[w]||w)+"'":b="Parse error on line "+(A+1)+": Unexpected "+(w==N?"end of input":"'"+(this.terminals_[w]||w)+"'"),this.parseError(b,{text:S.match,token:this.terminals_[w]||w,line:S.yylineno,loc:j,expected:p})}if(E[0]instanceof Array&&E.length>1)throw new Error("Parse Error: multiple actions possible at state: "+P+", token: "+w);switch(E[0]){case 1:h.push(w),_.push(S.yytext),d.push(S.yylloc),h.push(E[1]),w=null,M=S.yyleng,T=S.yytext,A=S.yylineno,j=S.yylloc;break;case 2:if(e=this.productions_[E[1]][1],f. $ =_[_.length-e],f._ $ ={first_line:d[d.length-(e||1)].first_line,last_line:d[d.length-1].last_line,first_column:d[d.length-(e||1)].first_column,last_column:d[d.length-1].last_column},V&&(f._ $ .range=[d[d.length-(e||1)].range[0],d[d.length-1].range[1]]),i=this.performAction.apply(f,[T,M,A,C.yy,E[1],_,d].concat(D)),typeof i<"u")return i;e&&(h=h.slice(0,-1*e*2),_=_.slice(0,-1*e),d=d.slice(0,-1*e)),h.push(this.productions_[E[1]][0]),_.push(f. $ ),d.push(f._ $ ),r=v[h[h.length-2]][h[h.length-1]],h.push(r);break;case 3:return!0}}return!0},"parse")},x=(function(){var k={EOF:1,parseError:y(function(l,h){if(this.yy.parser)this.yy.parser.parseError(l,h);else throw new Error(l)},"parseError"),setInput:y(function(o,l){return this.yy=l||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:y(function(){var o=this._input[0];this.yytext+=o,this.yyleng++,this.offset++,this.match+=o,this.matched+=o;var l=o.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),o},"input"),unput:y(function(o){var l=o.length,h=o.split(/(?: \r \n ?| \n )/g);this._input=o+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-l),this.offset-=l;var m=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 _=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===m.length?this.yylloc.first_column:0)+m[m.length-h.length].length-h[0].length:this.yylloc.first_column-l},this.options.ranges&&(this.yylloc.range=[_[0],_[0]+this.yyleng-l]),this.yyleng=this.yytext.length,this},"unput"),more:y(function(){return this._more=!0,this},"more"),reject:y(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:y(function(o){this.unput(this.match.slice(o))},"less"),pastInput:y(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:y(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:y(function(){var o=this.pastInput(),l=new Array(o.length+1).join("-");return o+this.upcomingInput()+ `
` +l+"^"},"showPosition"),test_match:y(function(o,l){var h,m,_;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))),m=o[0].match(/(?: \r \n ?| \n ).*/g),m&&(this.yylineno+=m.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:m?m[m.length-1].length-m[m.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],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 d in _)this[d]=_[d];return!1}return!1},"test_match"),next:y(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var o,l,h,m;this._more||(this.yytext="",this.match="");for(var _=this._currentRules(),d=0;d<_.length;d++)if(h=this._input.match(this.rules[_[d]]),h&&(!l||h[0].length>l[0].length)){if(l=h,m=d,this.options.backtrack_lexer){if(o=this.test_match(h,_[d]),o!==!1)return o;if(this._backtrack){l=!1;continue}else return!1}else if(!this.options.flex)break}return l?(o=this.test_match(l,_[m]),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:y(function(){var l=this.next();return l||this.lex()},"lex"),begin:y(function(l){this.conditionStack.push(l)},"begin"),popState:y(function(){var l=this.conditionStack.length-1;return l>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:y(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:y(function(l){return l=this.conditionStack.length-1-Math.abs(l||0),l>=0?this.conditionStack[l]:"INITIAL"},"topState"),pushState:y(function(l){this.begin(l)},"pushState"),stateStackSize:y(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:y(function(l,h,m,_){switch(m){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,/^(?:(( \u 000D \u 000A)|( \u 000A)))/i,/^(?:( \u 002C))/i,/^(?:( \u 0022))/i,/^(?:([ \u 0020- \u 0021 \u 0023- \u 002B \u 002D- \u 007E])*)/i,/^(?:( \u 0022)(?!( \u 0022)))/i,/^(?:(([ \u 0020- \u 0021 \u 0023- \u 002B \u 002D- \u 007E])|( \u 002C)|( \u 000D)|( \u 000A)|( \u 0022)( \u 0022))*)/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})();u.lexer=x;function g(){this.yy={}}return y(g,"Parser"),g.prototype=u,u.Parser=g,new g})();at.parser=at;var K=at,J=[],tt=[],Z=new Map,Zt=y(()=>{J=[],tt=[],Z=new Map,At()},"clear"),W,Jt=(W=class{constructor(n,s,a=0){this.source=n,this.target=s,this.value=a}},y(W,"SankeyLink"),W),te=y((t,n,s)=>{J.push(new Jt(t,n,s))},"addLink"),G,ee=(G=class{constructor(n){this.ID=n}},y(G,"SankeyNode"),G),ne=y(t=>{t=Tt.sanitizeText(t,lt());let n=Z.get(t);return n===void 0&&(n=new ee(t),Z.set(t,n),tt.push(n)),n},"findOrCreateNode"),ie=y(()=>tt,"getNodes"),re=y(()=>J,"getLinks"),se=y(()=>({nodes:tt.map(t=>({id:t.ID})),links:J.map(t=>({source:t.source.ID,target:t.target.ID,value:t.value}))}),"getGraph"),oe={nodesMap:Z,getConfig:y(()=>lt().sankey,"getConfig"),getNodes:ie,getLinks:re,getGraph:se,addLink:te,findOrCreateNode:ne,getAccTitle:wt,setAccTitle:St,getAccDescription:bt,setAccDescription:vt,getDiagramTitle:_t,setDiagramTitle:xt,clear:Zt}, $ ,gt=( $ =class{static next(n){return new $ (n+ ++ $ .count)}constructor(n){this.id=n,this.href= ` # $ { n } ` }toString(){return"url("+this.href+")"}},y( $ ,"Uid"), $ .count=0, $ ),ae={left:It,right:Ot,center: $ t,justify:kt},le=y(t=>{let n=0,s=0;for(const a of t){const u=a.value??0;u>n&&(n=u,s=a.layer??0)}return s},"findCentralNodeLayer"),ce=y(function(t,n,s,a){const{securityLevel:u,sankey:x}=lt(),g=Lt.sankey;let k;u==="sandbox"&&(k=H("#i"+n));const o=u==="sandbox"?H(k.nodes()[0].contentDocument.body):H("body"),l=u==="sandbox"?o.select( ` [ id = "${n}" ] ` ):H( ` [ id = "${n}" ] ` ),h=x?.width??g.width,m=x?.height??g.width,_=x?.useMaxWidth??g.useMaxWidth,d=x?.nodeAlignment??g.nodeAlignment,v=x?.prefix??g.prefix,T=x?.suffix??g.suffix,A=x?.showValues??g.showValues,M=x?.nodeWidth??g.nodeWidth??10,I=x?.nodePadding??g.nodePadding??12,N=x?.labelStyle??g.labelStyle??"legacy",D=x?.nodeColors??{},S=a.db.getGraph(),C=ae[d];Bt().nodeId(e=>e.id).nodeWidth(M).nodePadding(I+(A?15:0)).nodeAlign(C).extent([[0,0],[h,m]])(S);const j=le(S.nodes),V=Mt(Ct),O=y(e=>D[e]??V(e),"getNodeColor");l.append("g").attr("class","nodes").selectAll(".node").data(S.nodes).join("g").attr("class","node").attr("id",e=>(e.uid=gt.next("node-")).id).attr("transform",function(e){return"translate("+e.x0+","+e.y0+")"}).attr("x",e=>e.x0).attr("y",e=>e.y0).append("rect").attr("height",e=>e.y1-e.y0).attr("width",e=>e.x1-e.x0).attr("fill",e=>O(e.id));const z=y(({id:e,value:r})=>A? ` $ { e }
$ { v } $ { Math . round ( r * 100 ) / 100 } $ { T } ` :e,"getText"),w=y(e=>N==="outlined"?(e.layer??0)<j?{x:e.x0-6,anchor:"end"}:{x:e.x1+6,anchor:"start"}:e.x0<h/2?{x:e.x1+6,anchor:"start"}:{x:e.x0-6,anchor:"end"},"getLabelPosition"),P=l.append("g").attr("class","node-labels").attr("font-size",14),E=y(e=>P.selectAll(e? ` . $ { e } ` :"text").data(S.nodes).join("text").attr("class",e??null).attr("x",r=>w(r).x).attr("y",r=>(r.y1+r.y0)/2).attr("dy", ` $ { A ? "0" : "0.35" } em ` ).attr("text-anchor",r=>w(r).anchor).text(z),"appendLabel");N==="outlined"?(E("sankey-label-bg"),E("sankey-label-fg")):E();const i=l.append("g").attr("class","links").attr("fill","none").attr("stroke-opacity",.5).selectAll(".link").data(S.links).join("g").attr("class","link").style("mix-blend-mode","multiply"),f=x?.linkColor??"gradient";if(f==="gradient"){const e=i.append("linearGradient").attr("id",r=>(r.uid=gt.next("linearGradient-")).id).attr("gradientUnits","userSpaceOnUse").attr("x1",r=>r.source.x1).attr("x2",r=>r.target.x0);e.append("stop").attr("offset","0%").attr("stop-color",r=>O(r.source.id)),e.append("stop").attr("offset","100%").attr("stop-color",r=>O(r.target.id))}let c;switch(f){case"gradient":c=y(e=>e.uid,"coloring");break;case"source":c=y(e=>O(e.source.id),"coloring");break;case"target":c=y(e=>O(e.target.id),"coloring");break;default:c=f}i.append("path").attr("d",Kt()).attr("stroke",c).attr("stroke-width",e=>Math.max(1,e.width)),Et(void 0,l,0,_)},"draw"),ue={draw:ce},he=y(t=>t.replaceAll(/^[^ \S \n \r ]+|[^ \S \n \r ]+ $ /g,"").replaceAll(/([ \n \r ])+/g, `
` ).trim(),"prepareTextForParsing"),fe=y(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 : 4 px ;
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"),ye=fe,de=K.parse.bind(K);K.parse=t=>de(he(t));var xe={styles:ye,parser:K,db:oe,renderer:ue};export{xe as diagram};