// d3-sankey@0.12.3 downloaded from https://ga.jspm.io/npm:d3-sankey@0.12.3/dist/d3-sankey.js import e from"d3-array";import t from"d3-shape";var n={};(function(o,r){r(n,e,t)})(n,(function(e,t,n){function targetDepth(e){return e.target.depth}function left(e){return e.depth}function right(e,t){return t-1-e.height}function justify(e,t){return e.sourceLinks.length?e.depth:t-1}function center(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?t.min(e.sourceLinks,targetDepth)-1:0}function constant(e){return function(){return e}}function ascendingSourceBreadth(e,t){return ascendingBreadth(e.source,t.source)||e.index-t.index}function ascendingTargetBreadth(e,t){return ascendingBreadth(e.target,t.target)||e.index-t.index}function ascendingBreadth(e,t){return e.y0-t.y0}function value(e){return e.value}function defaultId(e){return e.index}function defaultNodes(e){return e.nodes}function defaultLinks(e){return e.links}function find(e,t){const n=e.get(t);if(!n)throw new Error("missing: "+t);return n}function computeLinkBreadths({nodes:e}){for(const t of e){let e=t.y0;let n=e;for(const n of t.sourceLinks){n.y0=e+n.width/2;e+=n.width}for(const e of t.targetLinks){e.y1=n+e.width/2;n+=e.width}}}function Sankey(){let e=0,n=0,o=1,r=1;let s=24;let i=8,a;let u=defaultId;let c=justify;let f;let l;let d=defaultNodes;let k=defaultLinks;let h=6;function sankey(){const e={nodes:d.apply(null,arguments),links:k.apply(null,arguments)};computeNodeLinks(e);computeNodeValues(e);computeNodeDepths(e);computeNodeHeights(e);computeNodeBreadths(e);computeLinkBreadths(e);return e}sankey.update=function(e){computeLinkBreadths(e);return e};sankey.nodeId=function(e){return arguments.length?(u="function"===typeof e?e:constant(e),sankey):u};sankey.nodeAlign=function(e){return arguments.length?(c="function"===typeof e?e:constant(e),sankey):c};sankey.nodeSort=function(e){return arguments.length?(f=e,sankey):f};sankey.nodeWidth=function(e){return arguments.length?(s=+e,sankey):s};sankey.nodePadding=function(e){return arguments.length?(i=a=+e,sankey):i};sankey.nodes=function(e){return arguments.length?(d="function"===typeof e?e:constant(e),sankey):d};sankey.links=function(e){return arguments.length?(k="function"===typeof e?e:constant(e),sankey):k};sankey.linkSort=function(e){return arguments.length?(l=e,sankey):l};sankey.size=function(t){return arguments.length?(e=n=0,o=+t[0],r=+t[1],sankey):[o-e,r-n]};sankey.extent=function(t){return arguments.length?(e=+t[0][0],o=+t[1][0],n=+t[0][1],r=+t[1][1],sankey):[[e,n],[o,r]]};sankey.iterations=function(e){return arguments.length?(h=+e,sankey):h};function computeNodeLinks({nodes:e,links:t}){for(const[t,n]of e.entries()){n.index=t;n.sourceLinks=[];n.targetLinks=[]}const n=new Map(e.map((t,n)=>[u(t,n,e),t]));for(const[e,o]of t.entries()){o.index=e;let{source:t,target:r}=o;"object"!==typeof t&&(t=o.source=find(n,t));"object"!==typeof r&&(r=o.target=find(n,r));t.sourceLinks.push(o);r.targetLinks.push(o)}if(null!=l)for(const{sourceLinks:t,targetLinks:n}of e){t.sort(l);n.sort(l)}}function computeNodeValues({nodes:e}){for(const n of e)n.value=void 0===n.fixedValue?Math.max(t.sum(n.sourceLinks,value),t.sum(n.targetLinks,value)):n.fixedValue}function computeNodeDepths({nodes:e}){const t=e.length;let n=new Set(e);let o=new Set;let r=0;while(n.size){for(const e of n){e.depth=r;for(const{target:t}of e.sourceLinks)o.add(t)}if(++r>t)throw new Error("circular link");n=o;o=new Set}}function computeNodeHeights({nodes:e}){const t=e.length;let n=new Set(e);let o=new Set;let r=0;while(n.size){for(const e of n){e.height=r;for(const{source:t}of e.targetLinks)o.add(t)}if(++r>t)throw new Error("circular link");n=o;o=new Set}}function computeNodeLayers({nodes:n}){const r=t.max(n,e=>e.depth)+1;const i=(o-e-s)/(r-1);const a=new Array(r);for(const t of n){const n=Math.max(0,Math.min(r-1,Math.floor(c.call(null,t,r))));t.layer=n;t.x0=e+n*i;t.x1=t.x0+s;a[n]?a[n].push(t):a[n]=[t]}if(f)for(const e of a)e.sort(f);return a}function initializeNodeBreadths(e){const o=t.min(e,e=>(r-n-(e.length-1)*a)/t.sum(e,value));for(const t of e){let e=n;for(const n of t){n.y0=e;n.y1=e+n.value*o;e=n.y1+a;for(const e of n.sourceLinks)e.width=e.value*o}e=(r-e+a)/(t.length+1);for(let n=0;ne.length)-1));initializeNodeBreadths(o);for(let e=0;e0))continue;let r=(n/o-e.y0)*t;e.y0+=r;e.y1+=r;reorderNodeLinks(e)}void 0===f&&r.sort(ascendingBreadth);resolveCollisions(r,n)}}function relaxRightToLeft(e,t,n){for(let o=e.length,r=o-2;r>=0;--r){const o=e[r];for(const e of o){let n=0;let o=0;for(const{target:t,value:r}of e.sourceLinks){let s=r*(t.layer-e.layer);n+=sourceTop(e,t)*s;o+=s}if(!(o>0))continue;let r=(n/o-e.y0)*t;e.y0+=r;e.y1+=r;reorderNodeLinks(e)}void 0===f&&o.sort(ascendingBreadth);resolveCollisions(o,n)}}function resolveCollisions(e,t){const o=e.length>>1;const s=e[o];resolveCollisionsBottomToTop(e,s.y0-a,o-1,t);resolveCollisionsTopToBottom(e,s.y1+a,o+1,t);resolveCollisionsBottomToTop(e,r,e.length-1,t);resolveCollisionsTopToBottom(e,n,0,t)}function resolveCollisionsTopToBottom(e,t,n,o){for(;n1e-6&&(r.y0+=s,r.y1+=s);t=r.y1+a}}function resolveCollisionsBottomToTop(e,t,n,o){for(;n>=0;--n){const r=e[n];const s=(r.y1-t)*o;s>1e-6&&(r.y0-=s,r.y1-=s);t=r.y0-a}}function reorderNodeLinks({sourceLinks:e,targetLinks:t}){if(void 0===l){for(const{source:{sourceLinks:e}}of t)e.sort(ascendingTargetBreadth);for(const{target:{targetLinks:t}}of e)t.sort(ascendingSourceBreadth)}}function reorderLinks(e){if(void 0===l)for(const{sourceLinks:t,targetLinks:n}of e){t.sort(ascendingTargetBreadth);n.sort(ascendingSourceBreadth)}}function targetTop(e,t){let n=e.y0-(e.sourceLinks.length-1)*a/2;for(const{target:o,width:r}of e.sourceLinks){if(o===t)break;n+=r+a}for(const{source:o,width:r}of t.targetLinks){if(o===e)break;n-=r}return n}function sourceTop(e,t){let n=t.y0-(t.targetLinks.length-1)*a/2;for(const{source:o,width:r}of t.targetLinks){if(o===e)break;n+=r+a}for(const{target:o,width:r}of e.sourceLinks){if(o===t)break;n-=r}return n}return sankey}function horizontalSource(e){return[e.source.x1,e.y0]}function horizontalTarget(e){return[e.target.x0,e.y1]}function sankeyLinkHorizontal(){return n.linkHorizontal().source(horizontalSource).target(horizontalTarget)}e.sankey=Sankey;e.sankeyCenter=center;e.sankeyJustify=justify;e.sankeyLeft=left;e.sankeyLinkHorizontal=sankeyLinkHorizontal;e.sankeyRight=right;Object.defineProperty(e,"__esModule",{value:true})}));const o=n.sankey,r=n.sankeyCenter,s=n.sankeyJustify,i=n.sankeyLeft,a=n.sankeyLinkHorizontal,u=n.sankeyRight,c=n.__esModule;export default n;export{c as __esModule,o as sankey,r as sankeyCenter,s as sankeyJustify,i as sankeyLeft,a as sankeyLinkHorizontal,u as sankeyRight};