energy-visualization-sankey 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +497 -0
- package/babel.config.cjs +28 -0
- package/coverage/clover.xml +6 -0
- package/coverage/coverage-final.json +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +101 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +0 -0
- package/demo-caching.js +68 -0
- package/dist/core/Sankey.d.ts +294 -0
- package/dist/core/Sankey.d.ts.map +1 -0
- package/dist/core/events/EventBus.d.ts +195 -0
- package/dist/core/events/EventBus.d.ts.map +1 -0
- package/dist/core/types/events.d.ts +42 -0
- package/dist/core/types/events.d.ts.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/sankey.esm.js +5212 -0
- package/dist/sankey.esm.js.map +1 -0
- package/dist/sankey.standalone.esm.js +9111 -0
- package/dist/sankey.standalone.esm.js.map +1 -0
- package/dist/sankey.standalone.min.js +2 -0
- package/dist/sankey.standalone.min.js.map +1 -0
- package/dist/sankey.standalone.umd.js +9119 -0
- package/dist/sankey.standalone.umd.js.map +1 -0
- package/dist/sankey.umd.js +5237 -0
- package/dist/sankey.umd.js.map +1 -0
- package/dist/sankey.umd.min.js +2 -0
- package/dist/sankey.umd.min.js.map +1 -0
- package/dist/services/AnimationService.d.ts +229 -0
- package/dist/services/AnimationService.d.ts.map +1 -0
- package/dist/services/ConfigurationService.d.ts +173 -0
- package/dist/services/ConfigurationService.d.ts.map +1 -0
- package/dist/services/InteractionService.d.ts +377 -0
- package/dist/services/InteractionService.d.ts.map +1 -0
- package/dist/services/RenderingService.d.ts +152 -0
- package/dist/services/RenderingService.d.ts.map +1 -0
- package/dist/services/calculation/GraphService.d.ts +111 -0
- package/dist/services/calculation/GraphService.d.ts.map +1 -0
- package/dist/services/calculation/SummaryService.d.ts +149 -0
- package/dist/services/calculation/SummaryService.d.ts.map +1 -0
- package/dist/services/data/DataService.d.ts +167 -0
- package/dist/services/data/DataService.d.ts.map +1 -0
- package/dist/services/data/DataValidationService.d.ts +48 -0
- package/dist/services/data/DataValidationService.d.ts.map +1 -0
- package/dist/types/index.d.ts +189 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/Logger.d.ts +88 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/jest.config.cjs +20 -0
- package/package.json +68 -0
- package/rollup.config.js +131 -0
- package/scripts/performance-validation-real.js +411 -0
- package/scripts/validate-optimization.sh +147 -0
- package/scripts/visual-validation-real-data.js +374 -0
- package/src/core/Sankey.ts +1039 -0
- package/src/core/events/EventBus.ts +488 -0
- package/src/core/types/events.ts +80 -0
- package/src/index.ts +35 -0
- package/src/services/AnimationService.ts +983 -0
- package/src/services/ConfigurationService.ts +497 -0
- package/src/services/InteractionService.ts +920 -0
- package/src/services/RenderingService.ts +484 -0
- package/src/services/calculation/GraphService.ts +616 -0
- package/src/services/calculation/SummaryService.ts +394 -0
- package/src/services/data/DataService.ts +380 -0
- package/src/services/data/DataValidationService.ts +155 -0
- package/src/styles/controls.css +184 -0
- package/src/styles/sankey.css +211 -0
- package/src/types/index.ts +220 -0
- package/src/utils/Logger.ts +105 -0
- package/tests/numerical-validation.test.js +575 -0
- package/tests/setup.js +53 -0
- package/tsconfig.json +54 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self)["energy-visualization-sankey"]=e()}(this,function(){"use strict";function t(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function e(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function i(i){let r,s,a;function o(t,e,i=0,n=t.length){if(i<n){if(0!==r(e,e))return n;do{const r=i+n>>>1;s(t[r],e)<0?i=r+1:n=r}while(i<n)}return i}return 2!==i.length?(r=t,s=(e,n)=>t(i(e),n),a=(t,e)=>i(t)-e):(r=i===t||i===e?i:n,s=i,a=i),{left:o,center:function(t,e,i=0,n=t.length){const r=o(t,e,i,n-1);return r>i&&a(t[r-1],e)>-a(t[r],e)?r-1:r},right:function(t,e,i=0,n=t.length){if(i<n){if(0!==r(e,e))return n;do{const r=i+n>>>1;s(t[r],e)<=0?i=r+1:n=r}while(i<n)}return i}}}function n(){return 0}const r=i(t).right;i(function(t){return null===t?NaN:+t}).center;const s=Math.sqrt(50),a=Math.sqrt(10),o=Math.sqrt(2);function l(t,e,i){const n=(e-t)/Math.max(0,i),r=Math.floor(Math.log10(n)),c=n/Math.pow(10,r),h=c>=s?10:c>=a?5:c>=o?2:1;let u,d,f;return r<0?(f=Math.pow(10,-r)/h,u=Math.round(t*f),d=Math.round(e*f),u/f<t&&++u,d/f>e&&--d,f=-f):(f=Math.pow(10,r)*h,u=Math.round(t/f),d=Math.round(e/f),u*f<t&&++u,d*f>e&&--d),d<u&&.5<=i&&i<2?l(t,e,2*i):[u,d,f]}function c(t,e,i){return l(t=+t,e=+e,i=+i)[2]}function h(t){return t}var u=1e-6;function d(t){return"translate("+t+",0)"}function f(t){return"translate(0,"+t+")"}function g(t){return e=>+t(e)}function p(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),i=>+t(i)+e}function v(){return!this.__axis}function y(t,e){var i=[],n=null,r=null,s=6,a=6,o=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,c=1===t||4===t?-1:1,y=4===t||2===t?"x":"y",m=1===t||3===t?d:f;function w(d){var f=null==n?e.ticks?e.ticks.apply(e,i):e.domain():n,w=null==r?e.tickFormat?e.tickFormat.apply(e,i):h:r,S=Math.max(s,0)+o,_=e.range(),b=+_[0]+l,x=+_[_.length-1]+l,E=(e.bandwidth?p:g)(e.copy(),l),A=d.selection?d.selection():d,T=A.selectAll(".domain").data([null]),M=A.selectAll(".tick").data(f,e).order(),C=M.exit(),k=M.enter().append("g").attr("class","tick"),D=M.select("line"),B=M.select("text");T=T.merge(T.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),M=M.merge(k),D=D.merge(k.append("line").attr("stroke","currentColor").attr(y+"2",c*s)),B=B.merge(k.append("text").attr("fill","currentColor").attr(y,c*S).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),d!==A&&(T=T.transition(d),M=M.transition(d),D=D.transition(d),B=B.transition(d),C=C.transition(d).attr("opacity",u).attr("transform",function(t){return isFinite(t=E(t))?m(t+l):this.getAttribute("transform")}),k.attr("opacity",u).attr("transform",function(t){var e=this.parentNode.__axis;return m((e&&isFinite(e=e(t))?e:E(t))+l)})),C.remove(),T.attr("d",4===t||2===t?a?"M"+c*a+","+b+"H"+l+"V"+x+"H"+c*a:"M"+l+","+b+"V"+x:a?"M"+b+","+c*a+"V"+l+"H"+x+"V"+c*a:"M"+b+","+l+"H"+x),M.attr("opacity",1).attr("transform",function(t){return m(E(t)+l)}),D.attr(y+"2",c*s),B.attr(y,c*S).text(w),A.filter(v).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),A.each(function(){this.__axis=E})}return w.scale=function(t){return arguments.length?(e=t,w):e},w.ticks=function(){return i=Array.from(arguments),w},w.tickArguments=function(t){return arguments.length?(i=null==t?[]:Array.from(t),w):i.slice()},w.tickValues=function(t){return arguments.length?(n=null==t?null:Array.from(t),w):n&&n.slice()},w.tickFormat=function(t){return arguments.length?(r=t,w):r},w.tickSize=function(t){return arguments.length?(s=a=+t,w):s},w.tickSizeInner=function(t){return arguments.length?(s=+t,w):s},w.tickSizeOuter=function(t){return arguments.length?(a=+t,w):a},w.tickPadding=function(t){return arguments.length?(o=+t,w):o},w.offset=function(t){return arguments.length?(l=+t,w):l},w}var m={value:()=>{}};function w(){for(var t,e=0,i=arguments.length,n={};e<i;++e){if(!(t=arguments[e]+"")||t in n||/[\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new S(n)}function S(t){this._=t}function _(t,e){for(var i,n=0,r=t.length;n<r;++n)if((i=t[n]).name===e)return i.value}function b(t,e,i){for(var n=0,r=t.length;n<r;++n)if(t[n].name===e){t[n]=m,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=i&&t.push({name:e,value:i}),t}S.prototype=w.prototype={constructor:S,on:function(t,e){var i,n,r=this._,s=(n=r,(t+"").trim().split(/^|\s+/).map(function(t){var e="",i=t.indexOf(".");if(i>=0&&(e=t.slice(i+1),t=t.slice(0,i)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),a=-1,o=s.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<o;)if(i=(t=s[a]).type)r[i]=b(r[i],t.name,e);else if(null==e)for(i in r)r[i]=b(r[i],t.name,null);return this}for(;++a<o;)if((i=(t=s[a]).type)&&(i=_(r[i],t.name)))return i},copy:function(){var t={},e=this._;for(var i in e)t[i]=e[i].slice();return new S(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var i,n,r=new Array(i),s=0;s<i;++s)r[s]=arguments[s+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=0,i=(n=this._[t]).length;s<i;++s)n[s].value.apply(e,r)},apply:function(t,e,i){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],r=0,s=n.length;r<s;++r)n[r].value.apply(e,i)}};var x="http://www.w3.org/1999/xhtml",E={svg:"http://www.w3.org/2000/svg",xhtml:x,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function A(t){var e=t+="",i=e.indexOf(":");return i>=0&&"xmlns"!==(e=t.slice(0,i))&&(t=t.slice(i+1)),E.hasOwnProperty(e)?{space:E[e],local:t}:t}function T(t){return function(){var e=this.ownerDocument,i=this.namespaceURI;return i===x&&e.documentElement.namespaceURI===x?e.createElement(t):e.createElementNS(i,t)}}function M(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function C(t){var e=A(t);return(e.local?M:T)(e)}function k(){}function D(t){return null==t?k:function(){return this.querySelector(t)}}function B(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function I(){return[]}function L(t){return null==t?I:function(){return this.querySelectorAll(t)}}function $(t){return function(){return this.matches(t)}}function H(t){return function(e){return e.matches(t)}}var O=Array.prototype.find;function Y(){return this.firstElementChild}var N=Array.prototype.filter;function X(){return Array.from(this.children)}function P(t){return new Array(t.length)}function F(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function R(t,e,i,n,r,s){for(var a,o=0,l=e.length,c=s.length;o<c;++o)(a=e[o])?(a.__data__=s[o],n[o]=a):i[o]=new F(t,s[o]);for(;o<l;++o)(a=e[o])&&(r[o]=a)}function z(t,e,i,n,r,s,a){var o,l,c,h=new Map,u=e.length,d=s.length,f=new Array(u);for(o=0;o<u;++o)(l=e[o])&&(f[o]=c=a.call(l,l.__data__,o,e)+"",h.has(c)?r[o]=l:h.set(c,l));for(o=0;o<d;++o)c=a.call(t,s[o],o,s)+"",(l=h.get(c))?(n[o]=l,l.__data__=s[o],h.delete(c)):i[o]=new F(t,s[o]);for(o=0;o<u;++o)(l=e[o])&&h.get(f[o])===l&&(r[o]=l)}function W(t){return t.__data__}function G(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function V(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function q(t){return function(){this.removeAttribute(t)}}function U(t){return function(){this.removeAttributeNS(t.space,t.local)}}function j(t,e){return function(){this.setAttribute(t,e)}}function K(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function J(t,e){return function(){var i=e.apply(this,arguments);null==i?this.removeAttribute(t):this.setAttribute(t,i)}}function Z(t,e){return function(){var i=e.apply(this,arguments);null==i?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,i)}}function Q(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function tt(t){return function(){this.style.removeProperty(t)}}function et(t,e,i){return function(){this.style.setProperty(t,e,i)}}function it(t,e,i){return function(){var n=e.apply(this,arguments);null==n?this.style.removeProperty(t):this.style.setProperty(t,n,i)}}function nt(t,e){return t.style.getPropertyValue(e)||Q(t).getComputedStyle(t,null).getPropertyValue(e)}function rt(t){return function(){delete this[t]}}function st(t,e){return function(){this[t]=e}}function at(t,e){return function(){var i=e.apply(this,arguments);null==i?delete this[t]:this[t]=i}}function ot(t){return t.trim().split(/^|\s+/)}function lt(t){return t.classList||new ct(t)}function ct(t){this._node=t,this._names=ot(t.getAttribute("class")||"")}function ht(t,e){for(var i=lt(t),n=-1,r=e.length;++n<r;)i.add(e[n])}function ut(t,e){for(var i=lt(t),n=-1,r=e.length;++n<r;)i.remove(e[n])}function dt(t){return function(){ht(this,t)}}function ft(t){return function(){ut(this,t)}}function gt(t,e){return function(){(e.apply(this,arguments)?ht:ut)(this,t)}}function pt(){this.textContent=""}function vt(t){return function(){this.textContent=t}}function yt(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function mt(){this.innerHTML=""}function wt(t){return function(){this.innerHTML=t}}function St(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function _t(){this.nextSibling&&this.parentNode.appendChild(this)}function bt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function xt(){return null}function Et(){var t=this.parentNode;t&&t.removeChild(this)}function At(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Tt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Mt(t){return function(){var e=this.__on;if(e){for(var i,n=0,r=-1,s=e.length;n<s;++n)i=e[n],t.type&&i.type!==t.type||i.name!==t.name?e[++r]=i:this.removeEventListener(i.type,i.listener,i.options);++r?e.length=r:delete this.__on}}}function Ct(t,e,i){return function(){var n,r=this.__on,s=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(r)for(var a=0,o=r.length;a<o;++a)if((n=r[a]).type===t.type&&n.name===t.name)return this.removeEventListener(n.type,n.listener,n.options),this.addEventListener(n.type,n.listener=s,n.options=i),void(n.value=e);this.addEventListener(t.type,s,i),n={type:t.type,name:t.name,value:e,listener:s,options:i},r?r.push(n):this.__on=[n]}}function kt(t,e,i){var n=Q(t),r=n.CustomEvent;"function"==typeof r?r=new r(e,i):(r=n.document.createEvent("Event"),i?(r.initEvent(e,i.bubbles,i.cancelable),r.detail=i.detail):r.initEvent(e,!1,!1)),t.dispatchEvent(r)}function Dt(t,e){return function(){return kt(this,t,e)}}function Bt(t,e){return function(){return kt(this,t,e.apply(this,arguments))}}F.prototype={constructor:F,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},ct.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var It=[null];function Lt(t,e){this._groups=t,this._parents=e}function $t(){return new Lt([[document.documentElement]],It)}function Ht(t){return"string"==typeof t?new Lt([[document.querySelector(t)]],[document.documentElement]):new Lt([[t]],It)}function Ot(t,e,i){t.prototype=e.prototype=i,i.constructor=t}function Yt(t,e){var i=Object.create(t.prototype);for(var n in e)i[n]=e[n];return i}function Nt(){}Lt.prototype=$t.prototype={constructor:Lt,select:function(t){"function"!=typeof t&&(t=D(t));for(var e=this._groups,i=e.length,n=new Array(i),r=0;r<i;++r)for(var s,a,o=e[r],l=o.length,c=n[r]=new Array(l),h=0;h<l;++h)(s=o[h])&&(a=t.call(s,s.__data__,h,o))&&("__data__"in s&&(a.__data__=s.__data__),c[h]=a);return new Lt(n,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){return B(t.apply(this,arguments))}}(t):L(t);for(var e=this._groups,i=e.length,n=[],r=[],s=0;s<i;++s)for(var a,o=e[s],l=o.length,c=0;c<l;++c)(a=o[c])&&(n.push(t.call(a,a.__data__,c,o)),r.push(a));return new Lt(n,r)},selectChild:function(t){return this.select(null==t?Y:function(t){return function(){return O.call(this.children,t)}}("function"==typeof t?t:H(t)))},selectChildren:function(t){return this.selectAll(null==t?X:function(t){return function(){return N.call(this.children,t)}}("function"==typeof t?t:H(t)))},filter:function(t){"function"!=typeof t&&(t=$(t));for(var e=this._groups,i=e.length,n=new Array(i),r=0;r<i;++r)for(var s,a=e[r],o=a.length,l=n[r]=[],c=0;c<o;++c)(s=a[c])&&t.call(s,s.__data__,c,a)&&l.push(s);return new Lt(n,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,W);var i=e?z:R,n=this._parents,r=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var s=r.length,a=new Array(s),o=new Array(s),l=new Array(s),c=0;c<s;++c){var h=n[c],u=r[c],d=u.length,f=G(t.call(h,h&&h.__data__,c,n)),g=f.length,p=o[c]=new Array(g),v=a[c]=new Array(g);i(h,u,p,v,l[c]=new Array(d),f,e);for(var y,m,w=0,S=0;w<g;++w)if(y=p[w]){for(w>=S&&(S=w+1);!(m=v[S])&&++S<g;);y._next=m||null}}return(a=new Lt(a,n))._enter=o,a._exit=l,a},enter:function(){return new Lt(this._enter||this._groups.map(P),this._parents)},exit:function(){return new Lt(this._exit||this._groups.map(P),this._parents)},join:function(t,e,i){var n=this.enter(),r=this,s=this.exit();return"function"==typeof t?(n=t(n))&&(n=n.selection()):n=n.append(t+""),null!=e&&(r=e(r))&&(r=r.selection()),null==i?s.remove():i(s),n&&r?n.merge(r).order():r},merge:function(t){for(var e=t.selection?t.selection():t,i=this._groups,n=e._groups,r=i.length,s=n.length,a=Math.min(r,s),o=new Array(r),l=0;l<a;++l)for(var c,h=i[l],u=n[l],d=h.length,f=o[l]=new Array(d),g=0;g<d;++g)(c=h[g]||u[g])&&(f[g]=c);for(;l<r;++l)o[l]=i[l];return new Lt(o,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,i=t.length;++e<i;)for(var n,r=t[e],s=r.length-1,a=r[s];--s>=0;)(n=r[s])&&(a&&4^n.compareDocumentPosition(a)&&a.parentNode.insertBefore(n,a),a=n);return this},sort:function(t){function e(e,i){return e&&i?t(e.__data__,i.__data__):!e-!i}t||(t=V);for(var i=this._groups,n=i.length,r=new Array(n),s=0;s<n;++s){for(var a,o=i[s],l=o.length,c=r[s]=new Array(l),h=0;h<l;++h)(a=o[h])&&(c[h]=a);c.sort(e)}return new Lt(r,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,i=t.length;e<i;++e)for(var n=t[e],r=0,s=n.length;r<s;++r){var a=n[r];if(a)return a}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,i=0,n=e.length;i<n;++i)for(var r,s=e[i],a=0,o=s.length;a<o;++a)(r=s[a])&&t.call(r,r.__data__,a,s);return this},attr:function(t,e){var i=A(t);if(arguments.length<2){var n=this.node();return i.local?n.getAttributeNS(i.space,i.local):n.getAttribute(i)}return this.each((null==e?i.local?U:q:"function"==typeof e?i.local?Z:J:i.local?K:j)(i,e))},style:function(t,e,i){return arguments.length>1?this.each((null==e?tt:"function"==typeof e?it:et)(t,e,null==i?"":i)):nt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?rt:"function"==typeof e?at:st)(t,e)):this.node()[t]},classed:function(t,e){var i=ot(t+"");if(arguments.length<2){for(var n=lt(this.node()),r=-1,s=i.length;++r<s;)if(!n.contains(i[r]))return!1;return!0}return this.each(("function"==typeof e?gt:e?dt:ft)(i,e))},text:function(t){return arguments.length?this.each(null==t?pt:("function"==typeof t?yt:vt)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?mt:("function"==typeof t?St:wt)(t)):this.node().innerHTML},raise:function(){return this.each(_t)},lower:function(){return this.each(bt)},append:function(t){var e="function"==typeof t?t:C(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var i="function"==typeof t?t:C(t),n=null==e?xt:"function"==typeof e?e:D(e);return this.select(function(){return this.insertBefore(i.apply(this,arguments),n.apply(this,arguments)||null)})},remove:function(){return this.each(Et)},clone:function(t){return this.select(t?Tt:At)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,i){var n,r,s=function(t){return t.trim().split(/^|\s+/).map(function(t){var e="",i=t.indexOf(".");return i>=0&&(e=t.slice(i+1),t=t.slice(0,i)),{type:t,name:e}})}(t+""),a=s.length;if(!(arguments.length<2)){for(o=e?Ct:Mt,n=0;n<a;++n)this.each(o(s[n],e,i));return this}var o=this.node().__on;if(o)for(var l,c=0,h=o.length;c<h;++c)for(n=0,l=o[c];n<a;++n)if((r=s[n]).type===l.type&&r.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?Bt:Dt)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,i=t.length;e<i;++e)for(var n,r=t[e],s=0,a=r.length;s<a;++s)(n=r[s])&&(yield n)}};var Xt=.7,Pt=1/Xt,Ft="\\s*([+-]?\\d+)\\s*",Rt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",zt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Wt=/^#([0-9a-f]{3,8})$/,Gt=new RegExp(`^rgb\\(${Ft},${Ft},${Ft}\\)$`),Vt=new RegExp(`^rgb\\(${zt},${zt},${zt}\\)$`),qt=new RegExp(`^rgba\\(${Ft},${Ft},${Ft},${Rt}\\)$`),Ut=new RegExp(`^rgba\\(${zt},${zt},${zt},${Rt}\\)$`),jt=new RegExp(`^hsl\\(${Rt},${zt},${zt}\\)$`),Kt=new RegExp(`^hsla\\(${Rt},${zt},${zt},${Rt}\\)$`),Jt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Zt(){return this.rgb().formatHex()}function Qt(){return this.rgb().formatRgb()}function te(t){var e,i;return t=(t+"").trim().toLowerCase(),(e=Wt.exec(t))?(i=e[1].length,e=parseInt(e[1],16),6===i?ee(e):3===i?new re(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===i?ie(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===i?ie(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=Gt.exec(t))?new re(e[1],e[2],e[3],1):(e=Vt.exec(t))?new re(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=qt.exec(t))?ie(e[1],e[2],e[3],e[4]):(e=Ut.exec(t))?ie(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=jt.exec(t))?he(e[1],e[2]/100,e[3]/100,1):(e=Kt.exec(t))?he(e[1],e[2]/100,e[3]/100,e[4]):Jt.hasOwnProperty(t)?ee(Jt[t]):"transparent"===t?new re(NaN,NaN,NaN,0):null}function ee(t){return new re(t>>16&255,t>>8&255,255&t,1)}function ie(t,e,i,n){return n<=0&&(t=e=i=NaN),new re(t,e,i,n)}function ne(t,e,i,n){return 1===arguments.length?((r=t)instanceof Nt||(r=te(r)),r?new re((r=r.rgb()).r,r.g,r.b,r.opacity):new re):new re(t,e,i,null==n?1:n);var r}function re(t,e,i,n){this.r=+t,this.g=+e,this.b=+i,this.opacity=+n}function se(){return`#${ce(this.r)}${ce(this.g)}${ce(this.b)}`}function ae(){const t=oe(this.opacity);return`${1===t?"rgb(":"rgba("}${le(this.r)}, ${le(this.g)}, ${le(this.b)}${1===t?")":`, ${t})`}`}function oe(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function le(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ce(t){return((t=le(t))<16?"0":"")+t.toString(16)}function he(t,e,i,n){return n<=0?t=e=i=NaN:i<=0||i>=1?t=e=NaN:e<=0&&(t=NaN),new de(t,e,i,n)}function ue(t){if(t instanceof de)return new de(t.h,t.s,t.l,t.opacity);if(t instanceof Nt||(t=te(t)),!t)return new de;if(t instanceof de)return t;var e=(t=t.rgb()).r/255,i=t.g/255,n=t.b/255,r=Math.min(e,i,n),s=Math.max(e,i,n),a=NaN,o=s-r,l=(s+r)/2;return o?(a=e===s?(i-n)/o+6*(i<n):i===s?(n-e)/o+2:(e-i)/o+4,o/=l<.5?s+r:2-s-r,a*=60):o=l>0&&l<1?0:a,new de(a,o,l,t.opacity)}function de(t,e,i,n){this.h=+t,this.s=+e,this.l=+i,this.opacity=+n}function fe(t){return(t=(t||0)%360)<0?t+360:t}function ge(t){return Math.max(0,Math.min(1,t||0))}function pe(t,e,i){return 255*(t<60?e+(i-e)*t/60:t<180?i:t<240?e+(i-e)*(240-t)/60:e)}Ot(Nt,te,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Zt,formatHex:Zt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return ue(this).formatHsl()},formatRgb:Qt,toString:Qt}),Ot(re,ne,Yt(Nt,{brighter(t){return t=null==t?Pt:Math.pow(Pt,t),new re(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Xt:Math.pow(Xt,t),new re(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new re(le(this.r),le(this.g),le(this.b),oe(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:se,formatHex:se,formatHex8:function(){return`#${ce(this.r)}${ce(this.g)}${ce(this.b)}${ce(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:ae,toString:ae})),Ot(de,function(t,e,i,n){return 1===arguments.length?ue(t):new de(t,e,i,null==n?1:n)},Yt(Nt,{brighter(t){return t=null==t?Pt:Math.pow(Pt,t),new de(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Xt:Math.pow(Xt,t),new de(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,i=this.l,n=i+(i<.5?i:1-i)*e,r=2*i-n;return new re(pe(t>=240?t-240:t+120,r,n),pe(t,r,n),pe(t<120?t+240:t-120,r,n),this.opacity)},clamp(){return new de(fe(this.h),ge(this.s),ge(this.l),oe(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=oe(this.opacity);return`${1===t?"hsl(":"hsla("}${fe(this.h)}, ${100*ge(this.s)}%, ${100*ge(this.l)}%${1===t?")":`, ${t})`}`}}));var ve=t=>()=>t;function ye(t){return 1===(t=+t)?me:function(e,i){return i-e?function(t,e,i){return t=Math.pow(t,i),e=Math.pow(e,i)-t,i=1/i,function(n){return Math.pow(t+n*e,i)}}(e,i,t):ve(isNaN(e)?i:e)}}function me(t,e){var i=e-t;return i?function(t,e){return function(i){return t+i*e}}(t,i):ve(isNaN(t)?e:t)}var we=function t(e){var i=ye(e);function n(t,e){var n=i((t=ne(t)).r,(e=ne(e)).r),r=i(t.g,e.g),s=i(t.b,e.b),a=me(t.opacity,e.opacity);return function(e){return t.r=n(e),t.g=r(e),t.b=s(e),t.opacity=a(e),t+""}}return n.gamma=t,n}(1);function Se(t,e){e||(e=[]);var i,n=t?Math.min(e.length,t.length):0,r=e.slice();return function(s){for(i=0;i<n;++i)r[i]=t[i]*(1-s)+e[i]*s;return r}}function _e(t,e){var i,n=e?e.length:0,r=t?Math.min(n,t.length):0,s=new Array(r),a=new Array(n);for(i=0;i<r;++i)s[i]=Ce(t[i],e[i]);for(;i<n;++i)a[i]=e[i];return function(t){for(i=0;i<r;++i)a[i]=s[i](t);return a}}function be(t,e){var i=new Date;return t=+t,e=+e,function(n){return i.setTime(t*(1-n)+e*n),i}}function xe(t,e){return t=+t,e=+e,function(i){return t*(1-i)+e*i}}function Ee(t,e){var i,n={},r={};for(i in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)i in t?n[i]=Ce(t[i],e[i]):r[i]=e[i];return function(t){for(i in n)r[i]=n[i](t);return r}}var Ae=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Te=new RegExp(Ae.source,"g");function Me(t,e){var i,n,r,s=Ae.lastIndex=Te.lastIndex=0,a=-1,o=[],l=[];for(t+="",e+="";(i=Ae.exec(t))&&(n=Te.exec(e));)(r=n.index)>s&&(r=e.slice(s,r),o[a]?o[a]+=r:o[++a]=r),(i=i[0])===(n=n[0])?o[a]?o[a]+=n:o[++a]=n:(o[++a]=null,l.push({i:a,x:xe(i,n)})),s=Te.lastIndex;return s<e.length&&(r=e.slice(s),o[a]?o[a]+=r:o[++a]=r),o.length<2?l[0]?function(t){return function(e){return t(e)+""}}(l[0].x):function(t){return function(){return t}}(e):(e=l.length,function(t){for(var i,n=0;n<e;++n)o[(i=l[n]).i]=i.x(t);return o.join("")})}function Ce(t,e){var i,n=typeof e;return null==e||"boolean"===n?ve(e):("number"===n?xe:"string"===n?(i=te(e))?(e=i,we):Me:e instanceof te?we:e instanceof Date?be:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?Se:Array.isArray(e)?_e:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?Ee:xe)(t,e)}function ke(t,e){return t=+t,e=+e,function(i){return Math.round(t*(1-i)+e*i)}}var De,Be=180/Math.PI,Ie={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Le(t,e,i,n,r,s){var a,o,l;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(l=t*i+e*n)&&(i-=t*l,n-=e*l),(o=Math.sqrt(i*i+n*n))&&(i/=o,n/=o,l/=o),t*n<e*i&&(t=-t,e=-e,l=-l,a=-a),{translateX:r,translateY:s,rotate:Math.atan2(e,t)*Be,skewX:Math.atan(l)*Be,scaleX:a,scaleY:o}}function $e(t,e,i,n){function r(t){return t.length?t.pop()+" ":""}return function(s,a){var o=[],l=[];return s=t(s),a=t(a),function(t,n,r,s,a,o){if(t!==r||n!==s){var l=a.push("translate(",null,e,null,i);o.push({i:l-4,x:xe(t,r)},{i:l-2,x:xe(n,s)})}else(r||s)&&a.push("translate("+r+e+s+i)}(s.translateX,s.translateY,a.translateX,a.translateY,o,l),function(t,e,i,s){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),s.push({i:i.push(r(i)+"rotate(",null,n)-2,x:xe(t,e)})):e&&i.push(r(i)+"rotate("+e+n)}(s.rotate,a.rotate,o,l),function(t,e,i,s){t!==e?s.push({i:i.push(r(i)+"skewX(",null,n)-2,x:xe(t,e)}):e&&i.push(r(i)+"skewX("+e+n)}(s.skewX,a.skewX,o,l),function(t,e,i,n,s,a){if(t!==i||e!==n){var o=s.push(r(s)+"scale(",null,",",null,")");a.push({i:o-4,x:xe(t,i)},{i:o-2,x:xe(e,n)})}else 1===i&&1===n||s.push(r(s)+"scale("+i+","+n+")")}(s.scaleX,s.scaleY,a.scaleX,a.scaleY,o,l),s=a=null,function(t){for(var e,i=-1,n=l.length;++i<n;)o[(e=l[i]).i]=e.x(t);return o.join("")}}}var He,Oe,Ye=$e(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Ie:Le(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),Ne=$e(function(t){return null==t?Ie:(De||(De=document.createElementNS("http://www.w3.org/2000/svg","g")),De.setAttribute("transform",t),(t=De.transform.baseVal.consolidate())?Le((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Ie)},", ",")",")"),Xe=0,Pe=0,Fe=0,Re=0,ze=0,We=0,Ge="object"==typeof performance&&performance.now?performance:Date,Ve="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function qe(){return ze||(Ve(Ue),ze=Ge.now()+We)}function Ue(){ze=0}function je(){this._call=this._time=this._next=null}function Ke(t,e,i){var n=new je;return n.restart(t,e,i),n}function Je(){ze=(Re=Ge.now())+We,Xe=Pe=0;try{!function(){qe(),++Xe;for(var t,e=He;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Xe}()}finally{Xe=0,function(){var t,e,i=He,n=1/0;for(;i;)i._call?(n>i._time&&(n=i._time),t=i,i=i._next):(e=i._next,i._next=null,i=t?t._next=e:He=e);Oe=t,Qe(n)}(),ze=0}}function Ze(){var t=Ge.now(),e=t-Re;e>1e3&&(We-=e,Re=t)}function Qe(t){Xe||(Pe&&(Pe=clearTimeout(Pe)),t-ze>24?(t<1/0&&(Pe=setTimeout(Je,t-Ge.now()-We)),Fe&&(Fe=clearInterval(Fe))):(Fe||(Re=Ge.now(),Fe=setInterval(Ze,1e3)),Xe=1,Ve(Je)))}function ti(t,e,i){var n=new je;return e=null==e?0:+e,n.restart(i=>{n.stop(),t(i+e)},e,i),n}je.prototype=Ke.prototype={constructor:je,restart:function(t,e,i){if("function"!=typeof t)throw new TypeError("callback is not a function");i=(null==i?qe():+i)+(null==e?0:+e),this._next||Oe===this||(Oe?Oe._next=this:He=this,Oe=this),this._call=t,this._time=i,Qe()},stop:function(){this._call&&(this._call=null,this._time=1/0,Qe())}};var ei=w("start","end","cancel","interrupt"),ii=[];function ni(t,e,i,n,r,s){var a=t.__transition;if(a){if(i in a)return}else t.__transition={};!function(t,e,i){var n,r=t.__transition;function s(t){i.state=1,i.timer.restart(a,i.delay,i.time),i.delay<=t&&a(t-i.delay)}function a(s){var c,h,u,d;if(1!==i.state)return l();for(c in r)if((d=r[c]).name===i.name){if(3===d.state)return ti(a);4===d.state?(d.state=6,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete r[c]):+c<e&&(d.state=6,d.timer.stop(),d.on.call("cancel",t,t.__data__,d.index,d.group),delete r[c])}if(ti(function(){3===i.state&&(i.state=4,i.timer.restart(o,i.delay,i.time),o(s))}),i.state=2,i.on.call("start",t,t.__data__,i.index,i.group),2===i.state){for(i.state=3,n=new Array(u=i.tween.length),c=0,h=-1;c<u;++c)(d=i.tween[c].value.call(t,t.__data__,i.index,i.group))&&(n[++h]=d);n.length=h+1}}function o(e){for(var r=e<i.duration?i.ease.call(null,e/i.duration):(i.timer.restart(l),i.state=5,1),s=-1,a=n.length;++s<a;)n[s].call(t,r);5===i.state&&(i.on.call("end",t,t.__data__,i.index,i.group),l())}function l(){for(var n in i.state=6,i.timer.stop(),delete r[e],r)return;delete t.__transition}r[e]=i,i.timer=Ke(s,0,i.time)}(t,i,{name:e,index:n,group:r,on:ei,tween:ii,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:0})}function ri(t,e){var i=ai(t,e);if(i.state>0)throw new Error("too late; already scheduled");return i}function si(t,e){var i=ai(t,e);if(i.state>3)throw new Error("too late; already running");return i}function ai(t,e){var i=t.__transition;if(!i||!(i=i[e]))throw new Error("transition not found");return i}function oi(t,e){var i,n;return function(){var r=si(this,t),s=r.tween;if(s!==i)for(var a=0,o=(n=i=s).length;a<o;++a)if(n[a].name===e){(n=n.slice()).splice(a,1);break}r.tween=n}}function li(t,e,i){var n,r;if("function"!=typeof i)throw new Error;return function(){var s=si(this,t),a=s.tween;if(a!==n){r=(n=a).slice();for(var o={name:e,value:i},l=0,c=r.length;l<c;++l)if(r[l].name===e){r[l]=o;break}l===c&&r.push(o)}s.tween=r}}function ci(t,e,i){var n=t._id;return t.each(function(){var t=si(this,n);(t.value||(t.value={}))[e]=i.apply(this,arguments)}),function(t){return ai(t,n).value[e]}}function hi(t,e){var i;return("number"==typeof e?xe:e instanceof te?we:(i=te(e))?(e=i,we):Me)(t,e)}function ui(t){return function(){this.removeAttribute(t)}}function di(t){return function(){this.removeAttributeNS(t.space,t.local)}}function fi(t,e,i){var n,r,s=i+"";return function(){var a=this.getAttribute(t);return a===s?null:a===n?r:r=e(n=a,i)}}function gi(t,e,i){var n,r,s=i+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===s?null:a===n?r:r=e(n=a,i)}}function pi(t,e,i){var n,r,s;return function(){var a,o,l=i(this);if(null!=l)return(a=this.getAttribute(t))===(o=l+"")?null:a===n&&o===r?s:(r=o,s=e(n=a,l));this.removeAttribute(t)}}function vi(t,e,i){var n,r,s;return function(){var a,o,l=i(this);if(null!=l)return(a=this.getAttributeNS(t.space,t.local))===(o=l+"")?null:a===n&&o===r?s:(r=o,s=e(n=a,l));this.removeAttributeNS(t.space,t.local)}}function yi(t,e){var i,n;function r(){var r=e.apply(this,arguments);return r!==n&&(i=(n=r)&&function(t,e){return function(i){this.setAttributeNS(t.space,t.local,e.call(this,i))}}(t,r)),i}return r._value=e,r}function mi(t,e){var i,n;function r(){var r=e.apply(this,arguments);return r!==n&&(i=(n=r)&&function(t,e){return function(i){this.setAttribute(t,e.call(this,i))}}(t,r)),i}return r._value=e,r}function wi(t,e){return function(){ri(this,t).delay=+e.apply(this,arguments)}}function Si(t,e){return e=+e,function(){ri(this,t).delay=e}}function _i(t,e){return function(){si(this,t).duration=+e.apply(this,arguments)}}function bi(t,e){return e=+e,function(){si(this,t).duration=e}}var xi=$t.prototype.constructor;function Ei(t){return function(){this.style.removeProperty(t)}}var Ai=0;function Ti(t,e,i,n){this._groups=t,this._parents=e,this._name=i,this._id=n}function Mi(){return++Ai}var Ci=$t.prototype;Ti.prototype={constructor:Ti,select:function(t){var e=this._name,i=this._id;"function"!=typeof t&&(t=D(t));for(var n=this._groups,r=n.length,s=new Array(r),a=0;a<r;++a)for(var o,l,c=n[a],h=c.length,u=s[a]=new Array(h),d=0;d<h;++d)(o=c[d])&&(l=t.call(o,o.__data__,d,c))&&("__data__"in o&&(l.__data__=o.__data__),u[d]=l,ni(u[d],e,i,d,u,ai(o,i)));return new Ti(s,this._parents,e,i)},selectAll:function(t){var e=this._name,i=this._id;"function"!=typeof t&&(t=L(t));for(var n=this._groups,r=n.length,s=[],a=[],o=0;o<r;++o)for(var l,c=n[o],h=c.length,u=0;u<h;++u)if(l=c[u]){for(var d,f=t.call(l,l.__data__,u,c),g=ai(l,i),p=0,v=f.length;p<v;++p)(d=f[p])&&ni(d,e,i,p,f,g);s.push(f),a.push(l)}return new Ti(s,a,e,i)},selectChild:Ci.selectChild,selectChildren:Ci.selectChildren,filter:function(t){"function"!=typeof t&&(t=$(t));for(var e=this._groups,i=e.length,n=new Array(i),r=0;r<i;++r)for(var s,a=e[r],o=a.length,l=n[r]=[],c=0;c<o;++c)(s=a[c])&&t.call(s,s.__data__,c,a)&&l.push(s);return new Ti(n,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,i=t._groups,n=e.length,r=i.length,s=Math.min(n,r),a=new Array(n),o=0;o<s;++o)for(var l,c=e[o],h=i[o],u=c.length,d=a[o]=new Array(u),f=0;f<u;++f)(l=c[f]||h[f])&&(d[f]=l);for(;o<n;++o)a[o]=e[o];return new Ti(a,this._parents,this._name,this._id)},selection:function(){return new xi(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,i=Mi(),n=this._groups,r=n.length,s=0;s<r;++s)for(var a,o=n[s],l=o.length,c=0;c<l;++c)if(a=o[c]){var h=ai(a,e);ni(a,t,i,c,o,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new Ti(n,this._parents,t,i)},call:Ci.call,nodes:Ci.nodes,node:Ci.node,size:Ci.size,empty:Ci.empty,each:Ci.each,on:function(t,e){var i=this._id;return arguments.length<2?ai(this.node(),i).on.on(t):this.each(function(t,e,i){var n,r,s=function(t){return(t+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?ri:si;return function(){var a=s(this,t),o=a.on;o!==n&&(r=(n=o).copy()).on(e,i),a.on=r}}(i,t,e))},attr:function(t,e){var i=A(t),n="transform"===i?Ne:hi;return this.attrTween(t,"function"==typeof e?(i.local?vi:pi)(i,n,ci(this,"attr."+t,e)):null==e?(i.local?di:ui)(i):(i.local?gi:fi)(i,n,e))},attrTween:function(t,e){var i="attr."+t;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(null==e)return this.tween(i,null);if("function"!=typeof e)throw new Error;var n=A(t);return this.tween(i,(n.local?yi:mi)(n,e))},style:function(t,e,i){var n="transform"==(t+="")?Ye:hi;return null==e?this.styleTween(t,function(t,e){var i,n,r;return function(){var s=nt(this,t),a=(this.style.removeProperty(t),nt(this,t));return s===a?null:s===i&&a===n?r:r=e(i=s,n=a)}}(t,n)).on("end.style."+t,Ei(t)):"function"==typeof e?this.styleTween(t,function(t,e,i){var n,r,s;return function(){var a=nt(this,t),o=i(this),l=o+"";return null==o&&(this.style.removeProperty(t),l=o=nt(this,t)),a===l?null:a===n&&l===r?s:(r=l,s=e(n=a,o))}}(t,n,ci(this,"style."+t,e))).each(function(t,e){var i,n,r,s,a="style."+e,o="end."+a;return function(){var l=si(this,t),c=l.on,h=null==l.value[a]?s||(s=Ei(e)):void 0;c===i&&r===h||(n=(i=c).copy()).on(o,r=h),l.on=n}}(this._id,t)):this.styleTween(t,function(t,e,i){var n,r,s=i+"";return function(){var a=nt(this,t);return a===s?null:a===n?r:r=e(n=a,i)}}(t,n,e),i).on("end.style."+t,null)},styleTween:function(t,e,i){var n="style."+(t+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;return this.tween(n,function(t,e,i){var n,r;function s(){var s=e.apply(this,arguments);return s!==r&&(n=(r=s)&&function(t,e,i){return function(n){this.style.setProperty(t,e.call(this,n),i)}}(t,s,i)),n}return s._value=e,s}(t,e,null==i?"":i))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(ci(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,i;function n(){var n=t.apply(this,arguments);return n!==i&&(e=(i=n)&&function(t){return function(e){this.textContent=t.call(this,e)}}(n)),e}return n._value=t,n}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var i in this.__transition)if(+i!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var i=this._id;if(t+="",arguments.length<2){for(var n,r=ai(this.node(),i).tween,s=0,a=r.length;s<a;++s)if((n=r[s]).name===t)return n.value;return null}return this.each((null==e?oi:li)(i,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?wi:Si)(e,t)):ai(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?_i:bi)(e,t)):ai(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw new Error;return function(){si(this,t).ease=e}}(e,t)):ai(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var i=e.apply(this,arguments);if("function"!=typeof i)throw new Error;si(this,t).ease=i}}(this._id,t))},end:function(){var t,e,i=this,n=i._id,r=i.size();return new Promise(function(s,a){var o={value:a},l={value:function(){0===--r&&s()}};i.each(function(){var i=si(this,n),r=i.on;r!==t&&((e=(t=r).copy())._.cancel.push(o),e._.interrupt.push(o),e._.end.push(l)),i.on=e}),0===r&&s()})},[Symbol.iterator]:Ci[Symbol.iterator]};const ki=t=>+t;var Di={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Bi(t,e){for(var i;!(i=t.__transition)||!(i=i[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return i}$t.prototype.interrupt=function(t){return this.each(function(){!function(t,e){var i,n,r,s=t.__transition,a=!0;if(s){for(r in e=null==e?null:e+"",s)(i=s[r]).name===e?(n=i.state>2&&i.state<5,i.state=6,i.timer.stop(),i.on.call(n?"interrupt":"cancel",t,t.__data__,i.index,i.group),delete s[r]):a=!1;a&&delete t.__transition}}(this,t)})},$t.prototype.transition=function(t){var e,i;t instanceof Ti?(e=t._id,t=t._name):(e=Mi(),(i=Di).time=qe(),t=null==t?null:t+"");for(var n=this._groups,r=n.length,s=0;s<r;++s)for(var a,o=n[s],l=o.length,c=0;c<l;++c)(a=o[c])&&ni(a,t,e,c,o,i||Bi(a,e));return new Ti(n,this._parents,t,e)};var Ii=[null];const Li=Math.PI,$i=2*Li,Hi=1e-6,Oi=$i-Hi;function Yi(t){this._+=t[0];for(let e=1,i=t.length;e<i;++e)this._+=arguments[e]+t[e]}class Ni{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?Yi:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Yi;const i=10**e;return function(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=Math.round(arguments[e]*i)/i+t[e]}}(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,i,n){this._append`Q${+t},${+e},${this._x1=+i},${this._y1=+n}`}bezierCurveTo(t,e,i,n,r,s){this._append`C${+t},${+e},${+i},${+n},${this._x1=+r},${this._y1=+s}`}arcTo(t,e,i,n,r){if(t=+t,e=+e,i=+i,n=+n,(r=+r)<0)throw new Error(`negative radius: ${r}`);let s=this._x1,a=this._y1,o=i-t,l=n-e,c=s-t,h=a-e,u=c*c+h*h;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(u>Hi)if(Math.abs(h*o-l*c)>Hi&&r){let d=i-s,f=n-a,g=o*o+l*l,p=d*d+f*f,v=Math.sqrt(g),y=Math.sqrt(u),m=r*Math.tan((Li-Math.acos((g+u-p)/(2*v*y)))/2),w=m/y,S=m/v;Math.abs(w-1)>Hi&&this._append`L${t+w*c},${e+w*h}`,this._append`A${r},${r},0,0,${+(h*d>c*f)},${this._x1=t+S*o},${this._y1=e+S*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,i,n,r,s){if(t=+t,e=+e,s=!!s,(i=+i)<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(n),o=i*Math.sin(n),l=t+a,c=e+o,h=1^s,u=s?n-r:r-n;null===this._x1?this._append`M${l},${c}`:(Math.abs(this._x1-l)>Hi||Math.abs(this._y1-c)>Hi)&&this._append`L${l},${c}`,i&&(u<0&&(u=u%$i+$i),u>Oi?this._append`A${i},${i},0,1,${h},${t-a},${e-o}A${i},${i},0,1,${h},${this._x1=l},${this._y1=c}`:u>Hi&&this._append`A${i},${i},0,${+(u>=Li)},${h},${this._x1=t+i*Math.cos(r)},${this._y1=e+i*Math.sin(r)}`)}rect(t,e,i,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${i=+i}v${+n}h${-i}Z`}toString(){return this._}}function Xi(t,e){if((i=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var i,n=t.slice(0,i);return[n.length>1?n[0]+n.slice(2):n,+t.slice(i+1)]}function Pi(t){return(t=Xi(Math.abs(t)))?t[1]:NaN}var Fi,Ri=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function zi(t){if(!(e=Ri.exec(t)))throw new Error("invalid format: "+t);var e;return new Wi({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function Wi(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Gi(t,e){var i=Xi(t,e);if(!i)return t+"";var n=i[0],r=i[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}zi.prototype=Wi.prototype,Wi.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Vi={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Gi(100*t,e),r:Gi,s:function(t,e){var i=Xi(t,e);if(!i)return t+"";var n=i[0],r=i[1],s=r-(Fi=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,a=n.length;return s===a?n:s>a?n+new Array(s-a+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+Xi(t,Math.max(0,e+s-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function qi(t){return t}var Ui,ji,Ki,Ji=Array.prototype.map,Zi=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Qi(t){var e,i,n=void 0===t.grouping||void 0===t.thousands?qi:(e=Ji.call(t.grouping,Number),i=t.thousands+"",function(t,n){for(var r=t.length,s=[],a=0,o=e[0],l=0;r>0&&o>0&&(l+o+1>n&&(o=Math.max(1,n-l)),s.push(t.substring(r-=o,r+o)),!((l+=o+1)>n));)o=e[a=(a+1)%e.length];return s.reverse().join(i)}),r=void 0===t.currency?"":t.currency[0]+"",s=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",o=void 0===t.numerals?qi:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(Ji.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",c=void 0===t.minus?"−":t.minus+"",h=void 0===t.nan?"NaN":t.nan+"";function u(t){var e=(t=zi(t)).fill,i=t.align,u=t.sign,d=t.symbol,f=t.zero,g=t.width,p=t.comma,v=t.precision,y=t.trim,m=t.type;"n"===m?(p=!0,m="g"):Vi[m]||(void 0===v&&(v=12),y=!0,m="g"),(f||"0"===e&&"="===i)&&(f=!0,e="0",i="=");var w="$"===d?r:"#"===d&&/[boxX]/.test(m)?"0"+m.toLowerCase():"",S="$"===d?s:/[%p]/.test(m)?l:"",_=Vi[m],b=/[defgprs%]/.test(m);function x(t){var r,s,l,d=w,x=S;if("c"===m)x=_(t)+x,t="";else{var E=(t=+t)<0||1/t<0;if(t=isNaN(t)?h:_(Math.abs(t),v),y&&(t=function(t){t:for(var e,i=t.length,n=1,r=-1;n<i;++n)switch(t[n]){case".":r=e=n;break;case"0":0===r&&(r=n),e=n;break;default:if(!+t[n])break t;r>0&&(r=0)}return r>0?t.slice(0,r)+t.slice(e+1):t}(t)),E&&0===+t&&"+"!==u&&(E=!1),d=(E?"("===u?u:c:"-"===u||"("===u?"":u)+d,x=("s"===m?Zi[8+Fi/3]:"")+x+(E&&"("===u?")":""),b)for(r=-1,s=t.length;++r<s;)if(48>(l=t.charCodeAt(r))||l>57){x=(46===l?a+t.slice(r+1):t.slice(r))+x,t=t.slice(0,r);break}}p&&!f&&(t=n(t,1/0));var A=d.length+t.length+x.length,T=A<g?new Array(g-A+1).join(e):"";switch(p&&f&&(t=n(T+t,T.length?g-x.length:1/0),T=""),i){case"<":t=d+t+x+T;break;case"=":t=d+T+t+x;break;case"^":t=T.slice(0,A=T.length>>1)+d+t+x+T.slice(A);break;default:t=T+d+t+x}return o(t)}return v=void 0===v?6:/[gprs]/.test(m)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v)),x.toString=function(){return t+""},x}return{format:u,formatPrefix:function(t,e){var i=u(((t=zi(t)).type="f",t)),n=3*Math.max(-8,Math.min(8,Math.floor(Pi(e)/3))),r=Math.pow(10,-n),s=Zi[8+n/3];return function(t){return i(r*t)+s}}}}function tn(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function en(t){return+t}Ui=Qi({thousands:",",grouping:[3],currency:["$",""]}),ji=Ui.format,Ki=Ui.formatPrefix;var nn=[0,1];function rn(t){return t}function sn(t,e){return(e-=t=+t)?function(i){return(i-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function an(t,e,i){var n=t[0],r=t[1],s=e[0],a=e[1];return r<n?(n=sn(r,n),s=i(a,s)):(n=sn(n,r),s=i(s,a)),function(t){return s(n(t))}}function on(t,e,i){var n=Math.min(t.length,e.length)-1,s=new Array(n),a=new Array(n),o=-1;for(t[n]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<n;)s[o]=sn(t[o],t[o+1]),a[o]=i(e[o],e[o+1]);return function(e){var i=r(t,e,1,n)-1;return a[i](s[i](e))}}function ln(){var t,e,i,n,r,s,a=nn,o=nn,l=Ce,c=rn;function h(){var t,e,i,l=Math.min(a.length,o.length);return c!==rn&&(t=a[0],e=a[l-1],t>e&&(i=t,t=e,e=i),c=function(i){return Math.max(t,Math.min(e,i))}),n=l>2?on:an,r=s=null,u}function u(e){return null==e||isNaN(e=+e)?i:(r||(r=n(a.map(t),o,l)))(t(c(e)))}return u.invert=function(i){return c(e((s||(s=n(o,a.map(t),xe)))(i)))},u.domain=function(t){return arguments.length?(a=Array.from(t,en),h()):a.slice()},u.range=function(t){return arguments.length?(o=Array.from(t),h()):o.slice()},u.rangeRound=function(t){return o=Array.from(t),l=ke,h()},u.clamp=function(t){return arguments.length?(c=!!t||rn,h()):c!==rn},u.interpolate=function(t){return arguments.length?(l=t,h()):l},u.unknown=function(t){return arguments.length?(i=t,u):i},function(i,n){return t=i,e=n,h()}}function cn(t,e,i,n){var r,s=function(t,e,i){i=+i;const n=(e=+e)<(t=+t),r=n?c(e,t,i):c(t,e,i);return(n?-1:1)*(r<0?1/-r:r)}(t,e,i);switch((n=zi(null==n?",f":n)).type){case"s":var a=Math.max(Math.abs(t),Math.abs(e));return null!=n.precision||isNaN(r=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Pi(e)/3)))-Pi(Math.abs(t)))}(s,a))||(n.precision=r),Ki(n,a);case"":case"e":case"g":case"p":case"r":null!=n.precision||isNaN(r=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Pi(e)-Pi(t))+1}(s,Math.max(Math.abs(t),Math.abs(e))))||(n.precision=r-("e"===n.type));break;case"f":case"%":null!=n.precision||isNaN(r=function(t){return Math.max(0,-Pi(Math.abs(t)))}(s))||(n.precision=r-2*("%"===n.type))}return ji(n)}function hn(t){var e=t.domain;return t.ticks=function(t){var i=e();return function(t,e,i){if(!((i=+i)>0))return[];if((t=+t)===(e=+e))return[t];const n=e<t,[r,s,a]=n?l(e,t,i):l(t,e,i);if(!(s>=r))return[];const o=s-r+1,c=new Array(o);if(n)if(a<0)for(let t=0;t<o;++t)c[t]=(s-t)/-a;else for(let t=0;t<o;++t)c[t]=(s-t)*a;else if(a<0)for(let t=0;t<o;++t)c[t]=(r+t)/-a;else for(let t=0;t<o;++t)c[t]=(r+t)*a;return c}(i[0],i[i.length-1],null==t?10:t)},t.tickFormat=function(t,i){var n=e();return cn(n[0],n[n.length-1],null==t?10:t,i)},t.nice=function(i){null==i&&(i=10);var n,r,s=e(),a=0,o=s.length-1,l=s[a],h=s[o],u=10;for(h<l&&(r=l,l=h,h=r,r=a,a=o,o=r);u-- >0;){if((r=c(l,h,i))===n)return s[a]=l,s[o]=h,e(s);if(r>0)l=Math.floor(l/r)*r,h=Math.ceil(h/r)*r;else{if(!(r<0))break;l=Math.ceil(l*r)/r,h=Math.floor(h*r)/r}n=r}return t},t}function un(){var t=ln()(rn,rn);return t.copy=function(){return e=t,un().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},tn.apply(t,arguments),hn(t)}function dn(t){return function(){return t}}function fn(t){this._context=t}function gn(t){return new fn(t)}function pn(t){return t[0]}function vn(t){return t[1]}function yn(t,e){var i=dn(!0),n=null,r=gn,s=null,a=function(t){let e=3;return t.digits=function(i){if(!arguments.length)return e;if(null==i)e=null;else{const t=Math.floor(i);if(!(t>=0))throw new RangeError(`invalid digits: ${i}`);e=t}return t},()=>new Ni(e)}(o);function o(o){var l,c,h,u=(o=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(o)).length,d=!1;for(null==n&&(s=r(h=a())),l=0;l<=u;++l)!(l<u&&i(c=o[l],l,o))===d&&((d=!d)?s.lineStart():s.lineEnd()),d&&s.point(+t(c,l,o),+e(c,l,o));if(h)return s=null,h+""||null}return t="function"==typeof t?t:void 0===t?pn:dn(t),e="function"==typeof e?e:void 0===e?vn:dn(e),o.x=function(e){return arguments.length?(t="function"==typeof e?e:dn(+e),o):t},o.y=function(t){return arguments.length?(e="function"==typeof t?t:dn(+t),o):e},o.defined=function(t){return arguments.length?(i="function"==typeof t?t:dn(!!t),o):i},o.curve=function(t){return arguments.length?(r=t,null!=n&&(s=r(n)),o):r},o.context=function(t){return arguments.length?(null==t?n=s=null:s=r(n=t),o):n},o}function mn(t,e,i){this.k=t,this.x=e,this.y=i}fn.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}},mn.prototype={constructor:mn,scale:function(t){return 1===t?this:new mn(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new mn(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}},mn.prototype;class wn{constructor(t){this.logger=t,this.handlers=new Map,this.subscriptions=new Map,this.stats={totalSubscriptions:0,subscriptionsByType:{},totalEventsEmitted:0,eventsByType:{},averageHandlerTime:0,errorCount:0},this.handlerTimes=[],this.MAX_HANDLER_TIMES=100}emit(t){const e=this.handlers.get(t.type);e&&0!==e.size&&(this.stats.totalEventsEmitted++,this.stats.eventsByType[t.type]=(this.stats.eventsByType[t.type]||0)+1,Promise.resolve().then(()=>{const i=performance.now();let n=0,r=0;e.forEach(e=>{try{const i=performance.now(),r=e(t);r&&"function"==typeof r.catch&&r.catch(i=>{this.handleError(i,t,e)});const s=performance.now()-i;this.recordHandlerTime(s),n++}catch(i){this.handleError(i,t,e),r++}});const s=performance.now()-i;this.logger.log(`EventBus: ${t.type} → ${n} handlers (${r} errors) in ${s.toFixed(2)}ms`)}))}subscribe(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e);const i={id:this.generateSubscriptionId(),eventType:t,handler:e,createdAt:Date.now()};return this.subscriptions.set(i.id,i),this.stats.totalSubscriptions++,this.stats.subscriptionsByType[t]=(this.stats.subscriptionsByType[t]||0)+1,this.logger.debug(`EventBus: Subscribed to ${t} (${i.id}) - ${this.handlers.get(t).size} total handlers`),i}unsubscribe(t){var e;const i=this.handlers.get(t.eventType);i&&(i.delete(t.handler),0===i.size&&(this.handlers.delete(t.eventType),this.logger.debug(`EventBus: Removed empty handler set for ${t.eventType}`)));if(this.subscriptions.delete(t.id)){this.stats.totalSubscriptions=Math.max(0,this.stats.totalSubscriptions-1);const i=this.stats.subscriptionsByType[t.eventType]||0;this.stats.subscriptionsByType[t.eventType]=Math.max(0,i-1);const n=(null===(e=this.handlers.get(t.eventType))||void 0===e?void 0:e.size)||0;this.logger.debug(`EventBus: Unsubscribed from ${t.eventType} (${t.id}) - ${n} handlers remain`)}else this.logger.warn(`EventBus: Attempted to unsubscribe non-existent subscription ${t.id}`)}getStats(){return{...this.stats,averageHandlerTime:this.calculateAverageHandlerTime(),subscriptionsByType:{...this.stats.subscriptionsByType},eventsByType:{...this.stats.eventsByType}}}clear(){const t=this.subscriptions.size,e=this.handlers.size;this.handlers.clear(),this.subscriptions.clear(),this.stats={totalSubscriptions:0,subscriptionsByType:{},totalEventsEmitted:0,eventsByType:{},averageHandlerTime:0,errorCount:0},this.handlerTimes=[],this.logger.debug(`EventBus: Cleared ${t} subscriptions across ${e} event types`)}generateSubscriptionId(){return`sub_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}handleError(t,e,i){this.stats.errorCount++;const n={error:t instanceof Error?t.message:String(t),errorType:t instanceof Error?t.constructor.name:typeof t,stack:t instanceof Error?t.stack:void 0,eventType:e.type,eventSource:e.source,eventTimestamp:e.timestamp,handlerPreview:i.toString().substring(0,100)+"...",handlerLength:i.toString().length,totalErrors:this.stats.errorCount,totalEvents:this.stats.totalEventsEmitted,errorRate:this.stats.totalEventsEmitted>0?(this.stats.errorCount/this.stats.totalEventsEmitted*100).toFixed(2)+"%":"0%"};console.error(`EventBus: Handler error in ${e.type} (error #${this.stats.errorCount}):`,n),this.logger.warn("EventBus: Failing handler source preview:",n.handlerPreview),this.stats.errorCount>0&&this.stats.errorCount%10==0&&this.logger.warn(`EventBus: Error count reached ${this.stats.errorCount} - consider investigating handler stability`)}recordHandlerTime(t){this.handlerTimes.push(t),this.handlerTimes.length>this.MAX_HANDLER_TIMES&&this.handlerTimes.shift(),t>10&&this.logger.warn(`EventBus: Slow handler detected: ${t.toFixed(2)}ms execution time`)}calculateAverageHandlerTime(){if(0===this.handlerTimes.length)return 0;const t=this.handlerTimes.reduce((t,e)=>t+e,0)/this.handlerTimes.length;return Math.round(1e3*t)/1e3}getDebugInfo(){const t=Date.now(),e=Array.from(this.subscriptions.values()).map(e=>({id:e.id,eventType:e.eventType,createdAt:e.createdAt,age:t-e.createdAt})),i={};return this.handlers.forEach((t,e)=>{i[e]=t.size}),{activeSubscriptions:e,handlerCounts:i,recentPerformance:{averageHandlerTime:this.calculateAverageHandlerTime(),recentHandlerTimes:[...this.handlerTimes],totalEvents:this.stats.totalEventsEmitted,errorRate:this.stats.totalEventsEmitted>0?this.stats.errorCount/this.stats.totalEventsEmitted:0}}}}class Sn extends Error{constructor(t,e){super(t),this.code=e,this.name="SankeyError"}}class _n extends Sn{constructor(t,e){super(t,"DATA_VALIDATION"),this.field=e,this.name="DataValidationError"}}class bn{constructor(t){this.options=t}log(t,...e){this.options.debugLogging&&console.log(t,...e)}debug(t,...e){this.options.debugLogging&&console.debug(t,...e)}warn(t,...e){this.options.debugLogging&&console.warn(t,...e)}}class xn{constructor(t,e,i,n){this.container=t,this.options=e,this.eventBus=i,this.logger=n,this.hasHeatData=!1,this.HEIGHT=620,this.BOX_WIDTH=120,this.BOX_HEIGHT=30,this.LEFT_X=10,this.TOP_Y=100,this.SCALE=.02,this.ELEC_BOX_X=300,this.ELEC_BOX_Y=120,this.HEAT_BOX_X=750,this.HEAT_BOX_Y=200,this.LEFT_GAP=30,this.BLEED=.5,this.SR3=Math.sqrt(3),this.HSR3=Math.sqrt(3)/2,this.PATH_GAP=20,this.ELEC_GAP=19,this.FUELS=[{fuel:"elec",name:"Electricity",color:"#e49942"},{fuel:"heat",name:"Heat",color:"#98002e"},{fuel:"solar",name:"Solar",color:"#fed530"},{fuel:"nuclear",name:"Nuclear",color:"#ca0813"},{fuel:"hydro",name:"Hydro",color:"#0b24fb"},{fuel:"wind",name:"Wind",color:"#901d8f"},{fuel:"geo",name:"Geothermal",color:"#905a1c"},{fuel:"gas",name:"Natural Gas",color:"#4cabf2"},{fuel:"coal",name:"Coal",color:"#000000"},{fuel:"bio",name:"Biomass",color:"#46be48"},{fuel:"petro",name:"Petroleum",color:"#095f0b"}],this.BOXES=[{box:"elec",name:"Electricity",color:"#cccccc"},{box:"res",name:"Residential/Commercial",color:"#cccccc"},{box:"ag",name:"Agricultural",color:"#cccccc"},{box:"indus",name:"Industrial",color:"#cccccc"},{box:"trans",name:"Transportation",color:"#cccccc"},{box:"heat",name:"Heat",color:"#cccccc"}],this.BOXES_DEFAULT_FLOW_PATHS_ORDER={elec:1,res:2,ag:3,indus:4,trans:5,heat:6},this.HEAT_BOX_FIRST_FLOW_PATHS_ORDER={elec:1,heat:2,res:3,ag:4,indus:5,trans:6},this.FLOW_PATHS_ORDER={},this.BOX_NAMES=this.BOXES.map(t=>t.box),this.FUEL_NAMES=this.FUELS.map(t=>t.fuel),this.RIGHT_GAP=2.1*this.LEFT_GAP,this.SPEED=e.animationSpeed||200,this.FLOW_PATHS_ORDER={elec:this.BOXES_DEFAULT_FLOW_PATHS_ORDER,heat:this.BOXES_DEFAULT_FLOW_PATHS_ORDER,solar:this.BOXES_DEFAULT_FLOW_PATHS_ORDER,nuclear:this.BOXES_DEFAULT_FLOW_PATHS_ORDER,hydro:this.BOXES_DEFAULT_FLOW_PATHS_ORDER,wind:this.BOXES_DEFAULT_FLOW_PATHS_ORDER,geo:this.BOXES_DEFAULT_FLOW_PATHS_ORDER,gas:this.HEAT_BOX_FIRST_FLOW_PATHS_ORDER,coal:this.HEAT_BOX_FIRST_FLOW_PATHS_ORDER,bio:this.BOXES_DEFAULT_FLOW_PATHS_ORDER,petro:this.HEAT_BOX_FIRST_FLOW_PATHS_ORDER},this.validateConfiguration(),this.eventBus.emit({type:"system.initialized",timestamp:Date.now(),source:"ConfigurationService",data:{fuelsCount:this.FUELS.length,sectorsCount:this.BOXES.length,dimensions:{width:this.WIDTH,height:this.HEIGHT}}})}getFuelDisplayName(t){const e=this.FUELS.find(e=>e.fuel===t);if(e)return e.name;return{elec:"Electricity",waste:"Waste Heat"}[t]||t.charAt(0).toUpperCase()+t.slice(1)}getBoxDisplayName(t){const e=this.BOXES.find(e=>e.box===t);if(e)return e.name;return{res:"Residential",ag:"Agriculture",indus:"Industrial",trans:"Transportation",elec:"Electricity"}[t]||t.charAt(0).toUpperCase()+t.slice(1)}getFuelColor(t){const e=this.FUELS.find(e=>e.fuel===t);return(null==e?void 0:e.color)||"#CCCCCC"}getSectorColor(t){const e=this.BOXES.find(e=>e.box===t);return(null==e?void 0:e.color)||"#CCCCCC"}get WIDTH(){if(this.options.width)return this.options.width;{let t=this.container.getBoundingClientRect().width||this.getDefaultWidth();return t=Math.max(t,400),this.applyResponsiveAdjustments(t)}}getDefaultWidth(){return"undefined"!=typeof window&&window.innerWidth?Math.min(.9*window.innerWidth,1200):1e3}applyResponsiveAdjustments(t){if("undefined"!=typeof window){const e=window.innerWidth;e<768?t=Math.min(t,e-40):e<1024&&(t=Math.min(t,e-80))}return t}calculateRightBoxX(){return this.WIDTH-this.BOX_WIDTH}validateConfiguration(){if(this.WIDTH<=0||this.HEIGHT<=0)throw new Error("ConfigurationService: Invalid dimensions");if(this.BOX_WIDTH<=0||this.BOX_HEIGHT<=0)throw new Error("ConfigurationService: Invalid box dimensions");if(this.SCALE<=0)throw new Error("ConfigurationService: Invalid scale factor");if(this.ELEC_BOX_X<=0||this.ELEC_BOX_X<=0)throw new Error("ConfigurationService: Invalid electricity box position");if(0===this.FUELS.length)throw new Error("ConfigurationService: No fuels defined");if(0===this.BOXES.length)throw new Error("ConfigurationService: No sectors defined");const t=["elec","solar","nuclear","hydro","wind","geo","gas","coal","bio","petro"];for(const e of t)this.FUEL_NAMES.includes(e)||console.warn(`ConfigurationService: Missing required fuel: ${e}`);const e=["elec","res","ag","indus","trans"];for(const t of e)this.BOX_NAMES.includes(t)||console.warn(`ConfigurationService: Missing required sector: ${t}`);this.logger.log("ConfigurationService: All configuration validated successfully")}isValidFuel(t){return this.FUEL_NAMES.includes(t)}isValidSector(t){return this.BOX_NAMES.includes(t)}getAllFuels(){return this.FUELS}getAllSectors(){return this.BOXES}getFuelConfig(t){return this.FUELS.find(e=>e.fuel===t)}getSectorConfig(t){return this.BOXES.find(e=>e.box===t)}calculateResponsiveScale(t,e){this.WIDTH,this.HEIGHT;const i=t/this.WIDTH,n=e/this.HEIGHT,r=Math.min(i,n),s=this.WIDTH*r,a=this.HEIGHT*r;return{scale:r,width:s,height:a,offsetX:(t-s)/2,offsetY:(e-a)/2}}getMobileConfiguration(){return{BOX_WIDTH:Math.max(40,.8*this.BOX_WIDTH),LEFT_GAP:Math.max(5,.7*this.LEFT_GAP),RIGHT_GAP:Math.max(10,.7*this.RIGHT_GAP),PATH_GAP:Math.max(4,.7*this.PATH_GAP),SPEED:1.2*this.SPEED}}isMobileViewport(){return"undefined"!=typeof window&&(window.innerWidth<=768||window.innerHeight<=600)}}class En{constructor(t,e,i){this.configurationService=t,this.eventBus=e,this.logger=i}validateData(t){const e=performance.now();try{if(!Array.isArray(t))throw new _n("Data must be an array","data");if(0===t.length)throw new _n("Data array cannot be empty","data");const i=["elec","waste","solar","nuclear","hydro","wind","geo","gas","coal","bio","petro"],n=["elec","res","ag","indus","trans"];let r=!1;for(let e=0;e<t.length;e++){const s=t[e];if(!s.year)throw new _n(`Invalid year at index ${e}`,"year");for(const t of i){if(!(t in s))throw new _n(`Missing sector '${t}' in data point for year ${s.year}`,t);const e=s[t];if(!e||"object"!=typeof e)throw new _n(`Invalid sector data for '${t}' in year ${s.year}`,t);let i=[...n];"heat"in s&&(r=!0,i.push("heat"));for(const n of i)if(!(n in e)||"number"!=typeof e[n])throw new _n(`Invalid breakdown '${n}' for sector '${t}' in year ${s.year}`,`${t}.${n}`)}}r&&(this.configurationService.hasHeatData=r);const s=performance.now();this.eventBus.emit({type:"data.validated",timestamp:Date.now(),source:"DataValidationService",data:{dataPointCount:t.length,yearRange:t.length>0?[t[0].year,t[t.length-1].year]:[0,0],validationTime:s-e}}),this.logger.log(`DataValidationService: ${t.length} data points validated in ${(s-e).toFixed(2)}ms`)}catch(t){throw this.eventBus.emit({type:"system.error",timestamp:Date.now(),source:"DataValidationService",data:{error:t instanceof Error?t:new Error(String(t)),context:"data_validation",recoverable:!1}}),t}}}class An{constructor(t,e,i,n){this.validationService=e,this.eventBus=i,this.logger=n;const r=performance.now();this.validationService.validateData(t);const s=[...t].sort((t,e)=>t.year-e.year);this.data=Object.freeze(s),this.years=Object.freeze(this.data.map(t=>t.year)),this.yearsLength=this.years.length,this.firstYear=this.years[0],this.lastYear=this.years[this.yearsLength-1];const a=performance.now();this.eventBus.emit({type:"data.loaded",timestamp:Date.now(),source:"DataService",data:{dataPoints:[...this.data],yearCount:this.yearsLength,yearRange:[this.firstYear,this.lastYear]}}),this.logger.log(`DataService: ${this.data.length} data points loaded and sorted in ${(a-r).toFixed(2)}ms`),this.logger.log(`DataService: Year range ${this.firstYear}-${this.lastYear}`)}getYearData(t){return this.data.find(e=>e.year===t)}getYearIndex(t){return this.years.indexOf(t)}hasYear(t){return this.years.includes(t)}getYearDataByIndex(t){if(!(t<0||t>=this.data.length))return this.data[t]}isValidYear(t){return t>=this.firstYear&&t<=this.lastYear&&this.hasYear(t)}getYearRange(){return[this.firstYear,this.lastYear]}getDataCount(){return this.data.length}getNextYear(t){const e=this.getYearIndex(t);return-1===e||e===this.yearsLength-1?null:this.years[e+1]}getPreviousYear(t){const e=this.getYearIndex(t);return e<=0?null:this.years[e-1]}getTotalForYear(t,e,i){const n=this.getYearData(t);if(!n)return 0;const r=n[e];return r&&r[i]||0}getYearTotalForFuel(t,e){const i=this.getYearData(t);if(!i)return 0;const n=i[e];return n?(n.elec||0)+(n.res||0)+(n.ag||0)+(n.indus||0)+(n.trans||0):0}getYearTotalForSector(t,e){const i=this.getYearData(t);if(!i)return 0;let n=0;const r=["solar","nuclear","hydro","wind","geo","gas","coal","bio","petro"];for(const t of r){const r=i[t];r&&r[e]&&(n+=r[e])}return"elec"!==e&&i.elec[e]&&(n+=i.elec[e]),n}getMilestoneForYear(t){const e=this.getYearData(t);return null==e?void 0:e.milestone}getYearsWithMilestones(){return this.data.filter(t=>t.milestone).map(t=>t.year)}getAvailableFuels(){if(0===this.data.length)return[];const t=this.data[0];return Object.keys(t).filter(e=>"year"!==e&&"milestone"!==e&&"object"==typeof t[e])}getAvailableSectors(){if(0===this.data.length)return[];const t=this.data[0].elec;return t?Object.keys(t):[]}getDataStatistics(){const t=this.getYearsWithMilestones().length,e=this.getAvailableFuels().length,i=this.getAvailableSectors().length;let n=0;for(let t=1;t<this.yearsLength;t++)n+=this.years[t]-this.years[t-1];const r=this.yearsLength>1?n/(this.yearsLength-1):0;return{totalDataPoints:this.data.length,yearRange:[this.firstYear,this.lastYear],averageYearGap:r,milestonesCount:t,fuelsCount:e,sectorsCount:i}}}class Tn{constructor(t,e){this.dataService=t,this.configService=e,this.summary=null,this.totals=[],this.flows=[],this.labels=[],this.yearSums={},this.maxes={},this.boxTops=null,this.buildSummary()}buildSummary(){this.buildTotals(),this.buildMaxes(),this.buildBoxTops(),this.summary={totals:this.totals,flows:this.flows,labels:this.labels,maxes:this.maxes,boxTops:this.boxTops,yearSums:this.yearSums}}buildTotals(){const t=this.configService.FUELS,e=this.configService.BOX_NAMES,i=this.configService.ELEC_BOX_Y,n=this.configService.HEAT_BOX_Y,r=this.configService.TOP_Y,s=this.configService.SCALE,a=this.configService.LEFT_GAP;for(let o=0;o<this.dataService.data.length;++o){const l=this.dataService.data[o],c={year:l.year,elec:0,res:0,ag:0,indus:0,trans:0,solar:0,nuclear:0,hydro:0,wind:0,geo:0,gas:0,coal:0,bio:0,petro:0,fuel_height:0,waste:0};this.configService.hasHeatData&&(c.heat=0);const h={year:l.year,elec:i,res:0,ag:0,indus:0,trans:0,solar:0,nuclear:0,hydro:0,wind:0,geo:0,gas:0,coal:0,bio:0,petro:0};this.configService.hasHeatData&&(h.heat=n);const u={year:l.year,elec:0,res:0,ag:0,indus:0,trans:0};this.configService.hasHeatData&&(u.heat=0);for(let o=2;o<t.length;++o){const d=t[o].fuel,f=l[d];if(this.configService.hasHeatData||"heat"!=d){for(let t=0;t<e.length;++t){const i=e[t];(this.configService.hasHeatData||"heat"!=i)&&(f[i]>0&&u[i]++,c[i]+=f[i],c[d]+=f[i],2===o&&"elec"!==i&&(c[i]+=l.elec[i],c[i]+=l.waste[i]),2===o&&"heat"!==i&&this.configService.hasHeatData&&(c[i]+=l.heat[i]))}h[d]=r+c.fuel_height-5,h.elec=i-c.elec*s,this.configService.hasHeatData&&(h.heat=n-c.heat*s),c.fuel_height+=c[d]*s+a}}c.waste=l.waste.res+l.waste.ag+l.waste.indus+l.waste.trans,this.configService.hasHeatData&&(c.waste+=l.waste.heat),"milestone"in l&&(c.milestone=l.milestone),this.yearSums[l.year]=c.bio+c.coal+c.gas+c.geo+c.hydro+c.nuclear+c.petro+c.solar+c.wind,this.totals.push(c),this.flows.push(u),this.labels.push(h)}}buildMaxes(){for(let t=0;t<this.configService.BOXES.length;++t){const e=this.configService.BOXES[t].box;this.maxes[e]=Math.max(...this.totals.map(t=>t[e]))}}buildBoxTops(){this.boxTops={res:this.configService.ELEC_BOX_Y+50,heat:this.configService.HEAT_BOX_Y+50,ag:0,indus:0,trans:0},this.boxTops.ag=this.boxTops.res+this.maxes.res*this.configService.SCALE+this.configService.RIGHT_GAP,this.boxTops.indus=this.boxTops.ag+this.maxes.ag*this.configService.SCALE+this.configService.RIGHT_GAP,this.boxTops.trans=this.boxTops.indus+this.maxes.indus*this.configService.SCALE+this.configService.RIGHT_GAP}}class Mn{constructor(t,e,i){this.configService=t,this.dataService=e,this.summaryCalculationService=i,this.graphs=[],this.buildGraphs()}buildGraphs(){this.calculateGraphY(),console.log("calculateGraphY",JSON.stringify(this.graphs)),this.calculateGraphX(),console.log("calculateGraphX",JSON.stringify(this.graphs)),this.spaceUpsAndDowns(),console.log("spaceUpsAndDowns",JSON.stringify(this.graphs)),this.processWasteHeatFlows(),console.log("processWasteHeatFlows",JSON.stringify(this.graphs))}calculateGraphY(){const t=this.configService.SCALE,e=this.configService.ELEC_BOX_X,i=this.configService.ELEC_BOX_Y,n=this.configService.HEAT_BOX_X,r=this.configService.HEAT_BOX_Y,s=this.configService.BOX_WIDTH,a=this.configService.LEFT_X,o=this.configService.TOP_Y,l=this.configService.SR3,c=this.configService.PATH_GAP,h=this.configService.LEFT_GAP,u=this.configService.FUELS,d=this.configService.BOX_NAMES,f=this.configService.WIDTH,g=this.configService.FLOW_PATHS_ORDER,p=this.summaryCalculationService.summary;for(let v=0;v<this.dataService.data.length;++v){let y,m=[],w=o,S=i-p.totals[v].elec*t;this.configService.hasHeatData&&(y=r-p.totals[v].heat*t);let _={x:{solar:0,nuclear:0,hydro:0,wind:0,geo:0,gas:0,coal:0,bio:0,petro:0},y:{elec:0,res:0,ag:0,indus:0,trans:0}};this.configService.hasHeatData&&(_.y.heat=0);const b=this.dataService.data[v].year;let x=p.totals.filter(t=>t.year===b)[0],E=p.flows.filter(t=>t.year===b)[0],A=null,T=null,M=this.dataService.data[v].waste;for(let o=0;o<u.length;++o){let b=u[o].fuel;if(!this.configService.hasHeatData&&"heat"==b)continue;let E=this.dataService.data[v][b];E.total=0;const C=[...d].sort((t,e)=>g[b][t]-g[b][e]);for(let h=0;h<C.length;++h){const d=C[h];if(b===d)continue;if(!this.configService.hasHeatData&&"heat"==d)continue;let g={fuel:b,box:d,stroke:0,value:0,a:{x:0,y:0},b:{x:0,y:0},c:{x:0,y:0},cc:{x:0,y:0},d:{x:0,y:0}};if(A=E[C[h]]*t/2,g.value=E[C[h]],0===o?(S+=A,g.a.y=S,g.a.x=e+s,S+=A):1===o?(y+=A,g.a.y=y,g.a.x=n+s,y+=A):(w+=A,g.a.y=w,g.a.x=a),_.y[d]+=A,g.stroke=2*A,g.b.y=g.a.y,"elec"===d?(g.d.x=e,g.d.y=i-x.elec*t+_.y.elec,g.c.x=e-20-(x.elec*t-_.y.elec)/l-(u.length-o)*c,g.b.x=g.c.x-Math.abs(g.a.y-g.d.y)/l):"heat"===d?(g.d.x=n,g.d.y=r-x.heat*t+_.y.heat,g.c.x=n-20-(x.heat*t-_.y.heat)/l-(u.length-o)*c,g.b.x=g.c.x-Math.abs(g.a.y-g.d.y)/l):(g.d.x=f-s,g.d.y=p.boxTops[C[h]]+_.y[d]),g.c.y=g.d.y,_.y[d]+=A,o>1&&(w+=A),T=d,m.push(g),0===o){let e=JSON.parse(JSON.stringify(g));("elec"===b&&"res"===T||"elec"===b&&"ag"===T||"elec"===b&&"indus"===T||"elec"===b&&"trans"===T||"elec"===b&&"heat"===T&&this.configService.hasHeatData)&&(A=M[T]*t/2,S+=2*A,e.stroke=2*A,_.y[T]+=2*A,e.value=M[T]),m.push(e)}}o>1&&(w+=h)}this.graphs.push({graph:m,offsets:_,year:this.dataService.data[v].year,totals:x,flows:E})}}calculateGraphX(){this.calculateGraphXUps(),this.calculateGraphXDowns()}calculateGraphXUps(){const t=this.configService.WIDTH,e=this.configService.BOX_WIDTH,i=this.configService.SCALE,n=this.configService.SR3,r=this.configService.ELEC_GAP,s=this.configService.HSR3;for(let a=0;a<this.graphs.length;++a){let o=null;this.graphs[a].graph.filter(function(t){return t.a.y>t.d.y&&!["elec","heat"].includes(t.box)}).sort(this.sortGraphUp.bind(this)).forEach((l,c)=>{l.box!==o?(this.graphs[a].offsets.y[l.box]=l.stroke/2,l.c.x=t-e-20-l.stroke/2):l.c.x=t-e-20-(this.graphs[a].totals[l.box]*i-this.graphs[a].offsets.y[l.box])/n-c*r*s,l.b.x=l.c.x-Math.abs(l.a.y-l.c.y)/n,l.cc.x=l.c.x-Math.abs(this.graphs[a].totals.fuel_height-l.c.y)/n,o=l.box})}}calculateGraphXDowns(){const t=this.configService.WIDTH,e=this.configService.BOX_WIDTH,i=this.configService.SR3,n=this.configService.HSR3,r=this.configService.ELEC_GAP,s=this.configService.ELEC_BOX_Y;for(let a=0;a<this.graphs.length;++a){let o=null;this.graphs[a].graph.filter(function(t){return t.a.y<t.d.y&&!["elec","heat"].includes(t.box)}).sort(this.sortGraphDown.bind(this)).forEach((l,c)=>{l.box!==o?(this.graphs[a].offsets.y[l.box]=l.stroke/2,l.c.x=t-e-20-l.stroke/2):l.c.x=t-e-20-this.graphs[a].offsets.y[l.box]/i-c*r*n,l.b.x=l.c.x-Math.abs(l.a.y-l.c.y)/i,l.cc.x=l.c.x-Math.abs(s-l.c.y)/i,o=l.box})}}spaceUpsAndDowns(){const t=this.configService.PATH_GAP,e=this.configService.HSR3,i=this.configService.WIDTH,n=this.configService.BOX_WIDTH;let r=null,s=null;for(let a=0;a<this.graphs.length;++a){this.graphs[a].graph.sort(function(t,e){return e.cc.x-t.cc.x}),this.graphs[a].graph.filter(function(t){return!["elec","heat"].includes(t.box)}).forEach((i,n)=>{if(0===n)return void(r=i);let a=t*e;0===i.stroke&&(a=0),s=a-(r.cc.x-r.stroke/2-(i.cc.x+i.stroke/2)),i.cc.x-=s,i.c.x-=s,i.b.x-=s,r=i});let o=Math.max.apply(Math,this.graphs[a].graph.map(function(t){return t.cc.x}));this.graphs[a].graph.filter(function(t){return!["elec","heat"].includes(t.box)}).forEach(t=>{let e=o-(i-n-50);t.c.x-=e,t.b.x-=e})}}processWasteHeatFlows(){for(let t=0;t<this.graphs.length;++t){let e=null;this.graphs[t].graph.filter(t=>"elec"===t.fuel).sort(this.sortGraphDown.bind(this)).forEach((t,i)=>{if(i%2!=0){if(t.fuel="waste",e){const i=Math.abs(e.stroke+t.stroke);t.a.y=e.a.y+i/2,t.b.y=t.a.y,t.b.x=e.b.x-i/3.5,t.c.x=e.c.x-i/3.5,t.c.y=e.c.y+i/2,t.d.y=t.c.y}}else e=t})}}sortGraphUp(t,e){const i=this.configService.BOX_NAMES,n=this.configService.FUEL_NAMES;return i.indexOf(t.box)<i.indexOf(e.box)?1:i.indexOf(t.box)>i.indexOf(e.box)?-1:n.indexOf(t.fuel)<n.indexOf(e.fuel)?1:n.indexOf(t.fuel)>n.indexOf(e.fuel)?-1:0}sortGraphDown(t,e){const i=this.configService.BOX_NAMES,n=this.configService.FUEL_NAMES;return i.indexOf(t.box)<i.indexOf(e.box)?-1:i.indexOf(t.box)>i.indexOf(e.box)?1:n.indexOf(t.fuel)<n.indexOf(e.fuel)?-1:n.indexOf(t.fuel)>n.indexOf(e.fuel)?1:0}sigfig2(t){if(null==t||"string"==typeof t&&""===t.trim())return console.warn("sigfig2 received invalid input:",t),0;let e;if("string"==typeof t){if(e=parseFloat(t),isNaN(e))return console.warn("sigfig2 could not parse string to number:",t),0}else e=t;return isNaN(e)?(console.warn("sigfig2 received NaN:",t),0):e>1&&e<10?Number.parseFloat(e.toPrecision(1)):Number.parseFloat(e.toPrecision(2))}createLine(){return yn().x(function(t){return t.x}).y(function(t){return t.y})}}class Cn{constructor(t,e,i,n,r){this.configService=t,this.summaryCalculationService=e,this.graphCalculationService=i,this.dataService=n,this.eventBus=r,this.lineGenerator=yn().x(t=>t.x).y(t=>t.y)}drawHeader(){const t=Ht(".title_container").style("height","58px").append("svg").attr("id","title").attr("width",this.configService.WIDTH).attr("height",58),e=this.configService.options.country,i=t.append("text").text(`${e} energy usage`).attr("text-anchor","end").attr("x",this.configService.ELEC_BOX_X-10).attr("y","1.5em").attr("class","title");i.append("tspan").text("0 W/capita").attr("text-anchor","end").attr("x",this.configService.ELEC_BOX_X-13).attr("dy","1.4em").attr("class","unit year-total animate title-bottom").attr("data-incr","0").attr("data-value","0");const n=this.dataService.firstYear,r=this.dataService.lastYear;i.append("tspan").text(n.toString()).attr("text-anchor","start").attr("x",this.configService.ELEC_BOX_X).attr("dy","0em").attr("class","year animate").attr("data-incr","0").attr("data-value",n),t.append("text").text(`Energy Transitions in ${e} History, ${n}-${r}`).attr("x",this.configService.ELEC_BOX_X+this.configService.BOX_WIDTH+25).attr("y","1.5em").attr("class","affiliation").append("tspan").text("Suits, Matteson, and Moyer (2020)").attr("class","affiliation-bottom").attr("x",this.configService.ELEC_BOX_X+this.configService.BOX_WIDTH+25).attr("dy","1.4em");const s=this.configService.ELEC_BOX_X+this.configService.BOX_WIDTH+(this.configService.WIDTH-(this.configService.ELEC_BOX_X+this.configService.BOX_WIDTH))/2+50;t.append("text").text("Center for Robust Decision-making on").attr("x",s).attr("y","1.5em").attr("class","affiliation").append("tspan").text("Climate and Energy Policy, UChicago").attr("class","affiliation-bottom").attr("x",s).attr("dy","1.4em")}drawLeftLabels(t,e){const i=this.configService.FUELS.slice(2);t.selectAll(".fuel-label-left").data(i).join("text").attr("class",t=>`label animate fuel ${t.fuel} fuel-label-left`).text(t=>t.name).attr("x",this.configService.LEFT_X).attr("y",(t,n)=>{let r=this.configService.TOP_Y;for(let t=0;t<n;t++){const n=i[t];r+=(e[n.fuel]||0)*this.configService.SCALE+this.configService.LEFT_GAP}return r-5}).attr("data-incr","0").attr("data-fuel",t=>t.fuel).attr("data-value",t=>{const i=e[t.fuel]||0;return this.graphCalculationService.sigfig2(i)}).classed("hidden",t=>0===(e[t.fuel]||0))}drawBoxes(t,e){const i=this.summaryCalculationService.summary.boxTops;for(let n=0;n<this.configService.BOXES.length;n++){const r=this.configService.BOXES[n];let s,a;if(!this.configService.hasHeatData&&"heat"==r.box)continue;"elec"===r.box?(s=this.configService.ELEC_BOX_X,a=this.configService.ELEC_BOX_Y-e.elec*this.configService.SCALE):"heat"===r.box?(s=this.configService.HEAT_BOX_X,a=this.configService.HEAT_BOX_Y-e.heat*this.configService.SCALE):(s=this.configService.WIDTH-this.configService.BOX_WIDTH,a=i[r.box]||0);const o=e[r.box]||0;t.append("rect").attr("x",s).attr("y",a).attr("width",this.configService.BOX_WIDTH).attr("height",o>0?o*this.configService.SCALE+this.configService.BLEED:0).attr("class",`box sector animate ${r.box}`).classed("fuel",["elec","heat"].includes(r.box)).attr("data-sector",r.box).attr("data-fuel",["elec","heat"].includes(r.box)?r.box:"").attr("data-incr","0");const l=t.append("text").text("res"===r.box?"Residential":r.name).attr("x",s).attr("y",a-5).attr("dy","res"===r.box?"-1.8em":"-0.8em").attr("data-sector",r.box).attr("data-fuel",["elec","heat"].includes(r.box)?r.box:"").attr("class",`label sector animate ${r.box}`).classed("hidden",0===o).classed("fuel",["elec","heat"].includes(r.box));"res"===r.box&&l.append("tspan").text("/Commercial").attr("x",s).attr("dy","1em").attr("data-incr","0"),l.append("tspan").attr("class",`total sector animate ${r.box}`).attr("data-sector",r.box).attr("data-value",o).text(this.graphCalculationService.sigfig2(o)).attr("x",s).attr("dy","1.2em").attr("data-incr","0"),l.append("tspan").attr("class",`total waste-level sector animate ${r.box}`).attr("data-sector",r.box).attr("data-value","0").text(this.graphCalculationService.sigfig2(0)).attr("x",s+this.configService.BOX_WIDTH).attr("dy","0").attr("text-anchor","end").attr("data-incr","0")}}drawFlows(t,e,i){const n=this.graphCalculationService.graphs[e];console.log("graphData.graph",n.graph);const r=n.graph.filter(t=>null!==t.b.x&&void 0!==t.b.x).reduce((t,e)=>(t[e.fuel]||(t[e.fuel]=[]),t[e.fuel].push(e),t),{});console.log("strokesByFuel",r),Object.entries(r).forEach(([e,n])=>{t.select(`.fuel.${e}`).selectAll(".flow-path").data(n).join("path").attr("class",t=>`flow animate ${t.fuel} ${t.box} flow-path`).attr("d",t=>this.parseLineData(t)).attr("stroke-width",t=>t.stroke>0?t.stroke+this.configService.BLEED:0).attr("data-fuel",t=>t.fuel).attr("data-sector",t=>t.box).attr("data-incr","0").attr("stroke-linejoin",t=>"waste"!==t.fuel?"round":"").on("mouseover",(e,n)=>{i.attr("style",""),i.transition().duration(200).style("opacity",.9);const r=this.configService.getFuelDisplayName(n.fuel),s=this.configService.getBoxDisplayName(n.box),a=this.graphCalculationService.sigfig2(n.value),o=(null==e?void 0:e.pageX)||0,l=(null==e?void 0:e.pageY)||0;i.html(`${r} → ${s}<div class='fuel_value'>${a}</div>`).style("left",`${o}px`).style("top",l-28+"px"),this.highlightFuel(t,r)}).on("mouseout",()=>{i.transition().duration(500).style("opacity",0),this.resetHighlight(t)})}),this.eventBus.emit({type:"rendering.completed",timestamp:Date.now(),source:"ChartRenderingService",data:{type:"flows",year:n.year,flowCount:n.graph.length}})}clearChart(t){t.selectAll("*").remove()}drawInitialChart(t,e){const i=this.graphCalculationService.graphs;for(const e of this.configService.FUELS)t.append("g").attr("class",`fuel ${e.fuel}`);return t.append("g").attr("class","fuel waste"),this.drawHeader(),this.drawFlows(t,0,e),this.drawLeftLabels(t,i[0].totals),this.drawBoxes(t,i[0].totals),!0}highlightFuel(t,e){t.selectAll(".flow").style("opacity",function(){return Ht(this).attr("data-fuel")===e?1:.3})}resetHighlight(t){t.selectAll(".flow").style("opacity",function(){return"waste"===Ht(this).attr("data-fuel")?.6:.8})}parseLineData(t){const e=[t.a,t.b,t.c,t.d];return this.lineGenerator(e)||""}}var kn=Object.freeze({__proto__:null,AnimationService:class{constructor(t,e,i,n,r,s,a){this.configService=t,this.summaryCalculationService=e,this.graphCalculationService=i,this.dataService=n,this.options=r,this.eventBus=s,this.logger=a,this.state={currentYearIndex:0,isAnimating:!1,animationTimer:null,speed:200},this.svg=null,this.tooltip=null,this.graphs=[],this.graphNest=null,this.sliderWidth=null,this.state.speed=this.configService.SPEED}setupAnimation(t,e,i,n){this.logger.log("AnimationService: Setting up animation controls..."),this.state.currentYearIndex=0,this.svg=i,this.tooltip=n,this.graphs=t,this.graphNest=e,this.setupTimelineControls(),this.setYear(this.dataService.firstYear),this.logger.log(`AnimationControlService: Animation setup complete for ${this.dataService.yearsLength} years`)}setupTimelineControls(){const t=this;Ht("#rangeSlider").on("input",function(){const e=parseFloat(this.value);t.setYear(e),t.updateSliderIndicator()});const e=document.getElementById("rangeSlider");this.sliderWidth=e?e.getBoundingClientRect().width:1200;const i=Ht("#axisTop").style("margin","-5px").style("margin-left","5px").append("svg").attr("id","sliderYear").attr("width",this.sliderWidth).attr("height",40).attr("preserveAspectRatio","xMinYMin meet").attr("viewBox",`0 0 ${this.sliderWidth} 40`),n=Ht("#testTick").style("height","15px").style("margin","-5px").style("margin-top","-7px").style("margin-left","5px").append("svg").attr("id","slider").attr("width",this.sliderWidth).attr("height",50).attr("preserveAspectRatio","xMinYMin meet").attr("viewBox",`0 0 ${this.sliderWidth} 50`);this.setupMilestones(i,n);const r=document.getElementById("rangeSlider");r&&(r.min=this.dataService.firstYear.toString(),r.max=this.dataService.lastYear.toString(),r.value=this.dataService.firstYear.toString(),this.updateSliderIndicator())}setupMilestones(t,e){const i=un().range([0,this.sliderWidth-this.configService.LEFT_X]).domain([this.dataService.firstYear,this.dataService.lastYear]);let n=15;this.dataService.yearsLength<50&&(n=5);const r=[];for(let t=5;t<this.dataService.yearsLength;t+=n)r.push(this.dataService.years[t]);const s=function(t){return y(1,t)}(i).tickValues(r).tickFormat(t=>Math.floor(t).toString());t.append("g").attr("transform","translate(0, 53)").call(s).call(t=>t.select(".domain").remove()).call(t=>t.selectAll("line").remove()).selectAll(".tick text").attr("y",-25);const a=this.dataService.getYearsWithMilestones(),o=function(t){return y(3,t)}(i).tickValues(a).tickFormat(()=>"●"),l=e.append("g").attr("transform","translate(4, 0)").call(o).call(t=>t.select(".domain").remove());l.selectAll(".tick text").attr("data-toggle","dialog").style("font-size","20px").attr("y",3),this.setupMilestoneDialogs(l)}setupMilestoneDialogs(t){const e=this.createMilestoneDialog();setTimeout(()=>{document.addEventListener("click",t=>{const i=document.getElementById("dialog");if(!i||!e.isOpen)return;const n=i.contains(t.target),r=t.target.closest(".tick");n||null!==r||e.close()},!0)},100);const i=this;t.selectAll(".tick").select("text").on("click",function(t,n){const r=n;t&&t.stopPropagation(),i.setYear(r);const s=Ht("#rangeSlider").node();s&&(s.focus(),s.value=r.toString()),i.updateSliderIndicator(),i.state.animationTimer&&i.pause(),Ht("#play-button").classed("playbutton",!0);const a=i.dataService.getYearData(r);if(!(null==a?void 0:a.milestone))return;const o=a.year>=1800&&a.year<=1862,l=(a.year>=1877&&a.year,a.year>=1947&&a.year<=2019),c=`<b>${a.year}: </b>${a.milestone}`,h=Math.ceil(i.sliderWidth/2),u=this.getBoundingClientRect(),d=window.pageYOffset||document.documentElement.scrollTop,f=window.pageXOffset||document.documentElement.scrollLeft;let g;g=o?u.left+f:l?u.right+f-h:u.left+f+u.width/2-h/2,g=Math.max(10,Math.min(g,window.innerWidth-h-10)),e.isOpen&&e.close(),setTimeout(()=>{e.html(c);const t=u.bottom+d+5;e.dialog&&(e.dialog.style.width=`${h}px`,e.dialog.style.left=`${g}px`,e.dialog.style.top=`${t}px`),e.open(),window.innerWidth<768&&(e.dialog.style.width=window.innerWidth-20+"px")},20)}).style("cursor","pointer").attr("title",function(t){const e=t,n=i.dataService.getYearData(e);return(null==n?void 0:n.milestone)?`Click to see ${e} milestone`:""})}createMilestoneDialog(){let t=document.getElementById("dialog");return t||(t=document.createElement("div"),t.id="dialog",t.style.opacity="0",document.body.appendChild(t)),{isOpen:!1,dialog:t,open(){this.dialog.style.display="block",this.dialog.style.visibility="visible",this.dialog.style.position="absolute",this.dialog.style.background="#fff",this.dialog.style.border="1px solid #ddd",this.dialog.style.borderRadius="4px",this.dialog.style.boxShadow="0 4px 12px rgba(0,0,0,0.15)",this.dialog.style.padding="15px",this.dialog.style.zIndex="1000",this.dialog.style.fontSize="14px",this.dialog.style.lineHeight="1.4",this.dialog.style.color="#333",this.dialog.style.maxWidth="90vw",this.dialog.style.opacity="1",this.isOpen=!0},close(){this.dialog.style.opacity="0",this.dialog.style.display="none",this.isOpen=!1},html(t){this.dialog.innerHTML=t},option(t){t.width&&(this.dialog.style.width="number"==typeof t.width?`${t.width}px`:t.width)}}}setupPlayControls(){const t=document.getElementById("play-button");t&&(t.addEventListener("click",()=>{this.state.isAnimating?this.pause():this.play()}),t.className="playbutton",this.state.isAnimating=!1)}setupYearDisplay(){const t=document.getElementById("dynamicYear");t&&(t.textContent=this.dataService.years[0].toString())}setYear(t){const e=this.dataService.getYearIndex(t);if(-1===e)return void console.warn(`AnimationControlService: Year ${t} not found in available years`);const i=this.getCurrentYear();this.state.currentYearIndex=e;const n=document.getElementById("rangeSlider");n&&(n.value=t.toString()),this.animatePeriod(e),this.updateYearDisplay(t),this.eventBus.emit({type:"year.changed",timestamp:Date.now(),source:"AnimationControlService",data:{year:t,previousYear:i,yearIndex:e,isAnimating:this.state.isAnimating}})}animatePeriod(t){if(!this.svg||!this.graphs||!this.graphNest)return;const e=this.svg,i=this.tooltip,n=this.graphs,r=this.graphNest;e.selectAll(".label").classed("hidden",function(){var e,i;const r=Ht(this);if(r.classed("sector")){const i=r.attr("data-sector");return(null===(e=n[t])||void 0===e?void 0:e.totals[i])<=0}if(r.classed("fuel")){const e=r.attr("data-fuel");return(null===(i=n[t])||void 0===i?void 0:i.totals[e])<=0}return!1});const s=this.configService,a=this.graphCalculationService,o=this.summaryCalculationService,l=this.dataService.years;(function(t){return"string"==typeof t?new Lt([document.querySelectorAll(t)],[document.documentElement]):new Lt([B(t)],It)})(".animate").on("mouseover",function(e){var r;if(!i)return;const o=Ht(this);if(o.classed("flow")){const l=o.attr("data-fuel"),c=o.attr("data-sector"),h=null===(r=n[t])||void 0===r?void 0:r.graph.find(t=>t.fuel===l&&t.box===c);if(h){i.attr("style",""),i.transition().duration(200).style("opacity",1);const t=s.getFuelDisplayName(h.fuel),n=s.getBoxDisplayName(h.box),r=a.sigfig2(h.value),o=(null==e?void 0:e.pageX)||0,l=(null==e?void 0:e.pageY)||0;i.html(`${t} → ${n}<div class='fuel_value'>${r}</div>`).style("left",`${o}px`).style("top",l-35+"px")}}else if(o.classed("fuel")&&!o.classed("elec")&&!o.classed("heat")){if(!i)return;i.attr("style",""),i.transition().duration(200).style("opacity",1);const t=o.attr("data-fuel"),n=parseFloat(o.attr("data-value")||"0"),r=s.getFuelDisplayName(t),l=(null==e?void 0:e.pageX)||0,c=(null==e?void 0:e.pageY)||0;i.html(`${r} → ${a.sigfig2(n)}`).style("left",`${l}px`).style("top",c-35+"px")}}).on("mouseout",()=>{i&&i.transition().duration(500).style("opacity",0)}).transition().duration(5*this.configService.SPEED).ease(ki).on("start",function(){const e=Ht(this),i=function(t,e){var i,n,r=t.__transition;if(r)for(n in e=null==e?null:e+"",r)if((i=r[n]).state>1&&i.name===e)return new Ti([[t]],Ii,e,+n);return null}(this);i&&i.attr("d",function(){var i;if(e.classed("flow")){const r=e.attr("data-fuel"),s=e.attr("data-sector"),o=null===(i=n[t])||void 0===i?void 0:i.graph.find(t=>t.fuel===r&&t.box===s);if(o){return a.createLine()([o.a,o.b,o.c,o.d])}}return e.attr("d")}).attr("stroke-width",function(){if(e.classed("flow")){let i=r.strokes[l[t]][e.attr("data-fuel")][e.attr("data-sector")];return i>0?i+s.BLEED:0}return e.attr("stroke-width")}).attr("y",function(){return e.classed("box")&&e.classed("fuel")?r.tops[l[t]][e.attr("data-fuel")]:e.classed("label")&&e.classed("fuel")?r.tops[l[t]][e.attr("data-fuel")]-5:e.attr("y")}).attr("height",function(){return e.classed("box")&&e.classed("sector")?r.heights[l[t]][e.attr("data-sector")]:e.attr("height")}).attr("data-value",function(){return e.classed("label")&&e.classed("fuel")&&!e.classed("elec")&&!e.classed("heat")?n[t].totals[e.attr("data-fuel")]:e.attr("data-value")}).tween("text",function(){var i;const s=this;if(e.classed("year")){const e=parseInt(s.textContent||"0"),i=l[t];return function(t){const n=e+(i-e)*t;s.setAttribute("data-value",n.toString()),s.textContent=Math.round(n).toString()}}if(e.classed("year-total"))return function(e){const i=o.yearSums,n=Math.floor(i[l[t]]||0);s.setAttribute("data-value",n.toString()),s.textContent=`${Math.round(n)} W/capita`};if(e.classed("waste-level")){const e=parseFloat(s.getAttribute("data-value")||"0"),n=(null===(i=r.waste[l[t]])||void 0===i?void 0:i[s.getAttribute("data-sector")||""])||0;return function(t){const i=e+(n-e)*t;s.setAttribute("data-value",i.toString()),s.textContent=(a.sigfig2(i)||0).toString()}}if(e.classed("total")){const e=parseFloat(s.getAttribute("data-value")||"0"),i=n[t].totals[s.getAttribute("data-sector")||""]||0;return function(t){const n=e+(i-e)*t;s.setAttribute("data-value",n.toString()),s.textContent=a.sigfig2(n).toString()}}return null})}),this.updateSliderIndicator()}updateSliderIndicator(){const t=document.getElementById("rangeSlider"),e=document.getElementById("dynamicYear");if(!t||!e)return;const i=this.getCurrentYear(),n=this.dataService.firstYear,r=this.dataService.lastYear,s=this.calculateIndicatorPosition(t,i,n,r);this.applyIndicatorPosition(e,s,i)}calculateIndicatorPosition(t,e,i,n){return 5.5+(e-i)/(n-i)*(t.getBoundingClientRect().width-11)-26}applyIndicatorPosition(t,e,i){t.style.left=`${e}px`,t.textContent=i.toString(),this.logger.log(`AnimationControlService: Indicator positioned: ${e.toFixed(1)}px for year ${i}`)}updateYearDisplay(t){const e=document.getElementById("dynamicYear");e&&(e.textContent=t.toString())}play(){if(this.state.isAnimating)return;this.state.isAnimating=!0;const t=document.getElementById("play-button");t&&(t.className="playpaused"),this.state.animationTimer=window.setInterval(()=>{this.nextFrame()},this.state.speed),this.eventBus.emit({type:"animation.started",timestamp:Date.now(),source:"AnimationControlService",data:{isPlaying:!0,currentYear:this.getCurrentYear(),speed:this.state.speed}})}pause(){if(!this.state.isAnimating)return;this.state.isAnimating=!1;const t=document.getElementById("play-button");t&&(t.className="playbutton"),this.state.animationTimer&&(clearInterval(this.state.animationTimer),this.state.animationTimer=null),this.eventBus.emit({type:"animation.stopped",timestamp:Date.now(),source:"AnimationControlService",data:{isPlaying:!1,currentYear:this.getCurrentYear(),speed:this.state.speed}})}nextFrame(){this.state.currentYearIndex+1>=this.dataService.yearsLength&&(this.state.currentYearIndex=0,!this.options.loopAnimation)?this.pause():this.nextYear()}setSpeed(t){if(t<=0)throw new Error("Animation speed must be positive");this.state.speed=t,this.state.isAnimating&&(this.pause(),setTimeout(()=>{this.play()},100)),this.eventBus.emit({type:"speed.changed",timestamp:Date.now(),source:"AnimationControlService",data:{speed:t}})}isPlaying(){return this.state.isAnimating}getCurrentYear(){return this.dataService.years[this.state.currentYearIndex]||this.dataService.firstYear}nextYear(){this.state.currentYearIndex<this.dataService.yearsLength-1&&(this.state.currentYearIndex++,this.setYear(this.dataService.years[this.state.currentYearIndex]))}previousYear(){this.state.currentYearIndex>0&&(this.state.currentYearIndex--,this.setYear(this.dataService.years[this.state.currentYearIndex]))}cleanup(){this.pause(),this.state.currentYearIndex=0,this.state.isAnimating=!1,this.svg=null,this.tooltip=null,this.graphs=[],this.graphNest=null}}});var Dn=Object.freeze({__proto__:null,InteractionService:class{constructor(t,e,i,n){this.animationControlService=t,this.dataService=e,this.eventBus=i,this.logger=n,this.state={isMouseDown:!1,lastMousePosition:{x:0,y:0},selectedElement:null,isDragging:!1,touchStartTime:0,keyboardShortcutsEnabled:!0},this.handlers={},this.eventListeners=[]}initializeInteractions(t,e){this.logger.log("InteractionService: Initializing comprehensive multi-platform interactions..."),this.setupMouseInteractions(t,e),this.setupTouchInteractions(t,e),this.enableKeyboardNavigation(),this.setupSliderInteractions(),this.setupButtonInteractions(),this.eventBus.emit({type:"system.initialized",timestamp:Date.now(),source:"InteractionService",data:{mouseEnabled:!0,touchEnabled:"ontouchstart"in window,keyboardEnabled:this.state.keyboardShortcutsEnabled}}),this.logger.log("InteractionService: All interaction modalities initialized successfully")}setupMouseInteractions(t,e){const i=t.node();if(!i)return;this.addEventListener(i,"mousemove",t=>{this.state.lastMousePosition={x:t.clientX,y:t.clientY};const e=t.target;e&&(e.classList.contains("flow")||e.classList.contains("box"))&&this.handleElementHover(e,t)}),this.addEventListener(i,"click",t=>{const e=t.target;e&&this.handleElementClick(e,t)}),this.addEventListener(i,"mousedown",t=>{this.state.isMouseDown=!0,this.state.selectedElement=t.target}),this.addEventListener(document,"mouseup",()=>{this.state.isMouseDown=!1,this.state.selectedElement=null,this.state.isDragging=!1}),this.logger.log("InteractionService: Mouse interactions enabled")}setupTouchInteractions(t,e){const i=t.node();if(!i||!("ontouchstart"in window))return;this.addEventListener(i,"touchstart",t=>{this.state.touchStartTime=Date.now();const e=t.touches[0];e&&(this.state.lastMousePosition={x:e.clientX,y:e.clientY})}),this.addEventListener(i,"touchend",t=>{if(Date.now()-this.state.touchStartTime<300){const e=t.changedTouches[0];if(e){const t=document.elementFromPoint(e.clientX,e.clientY);if(t){const i=new MouseEvent("click",{clientX:e.clientX,clientY:e.clientY,bubbles:!0});this.handleElementClick(t,i)}}}}),this.addEventListener(i,"touchmove",t=>{t.preventDefault();const e=t.touches[0];e&&(this.state.lastMousePosition={x:e.clientX,y:e.clientY})}),this.logger.log("InteractionService: Touch interactions enabled")}enableKeyboardNavigation(){if(this.state.keyboardShortcutsEnabled)return;this.addEventListener(document,"keydown",t=>{t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLSelectElement||this.handleKeyboardNavigation(t)}),this.state.keyboardShortcutsEnabled=!0,this.logger.log("InteractionService: Keyboard navigation enabled")}disableKeyboardNavigation(){this.state.keyboardShortcutsEnabled=!1,this.logger.log("InteractionService: Keyboard navigation disabled")}handleKeyboardNavigation(t){const e=t.key.toLowerCase();switch(e){case" ":case"enter":t.preventDefault(),this.animationControlService.isPlaying()?this.animationControlService.pause():this.animationControlService.play();break;case"arrowleft":t.preventDefault(),this.animationControlService.previousYear();break;case"arrowright":t.preventDefault(),this.animationControlService.nextYear();break;case"home":t.preventDefault(),this.animationControlService.setYear(this.dataService.firstYear);break;case"end":t.preventDefault(),this.animationControlService.setYear(this.dataService.lastYear);break;case"escape":t.preventDefault(),this.animationControlService.pause()}this.eventBus.emit({type:"interaction.keypress",timestamp:Date.now(),source:"InteractionService",data:{key:e,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey}}),this.handlers.onKeyboardNavigation&&this.handlers.onKeyboardNavigation(e,t)}setupSliderInteractions(){const t=document.getElementById("rangeSlider");if(!t)return;this.addEventListener(t,"input",t=>{const e=t.target,i=parseFloat(e.value);this.animationControlService.setYear(i),this.eventBus.emit({type:"interaction.slider",timestamp:Date.now(),source:"InteractionService",data:{year:i,value:i}}),this.handlers.onSliderInteraction&&this.handlers.onSliderInteraction(i,t)}),this.logger.log("InteractionService: Slider interactions enabled")}setupButtonInteractions(){const t=document.getElementById("play-button");if(t){const e=t=>{t.preventDefault(),this.animationControlService.isPlaying()?this.animationControlService.pause():this.animationControlService.play(),this.eventBus.emit({type:"interaction.button",timestamp:Date.now(),source:"InteractionService",data:{buttonId:"play-button",action:this.animationControlService.isPlaying()?"play":"pause"}})};this.addEventListener(t,"click",e)}document.querySelectorAll("[data-speed]").forEach(t=>{this.addEventListener(t,"click",t=>{const e=t.target,i=parseInt(e.dataset.speed||"200");this.animationControlService.setSpeed(i),this.eventBus.emit({type:"interaction.button",timestamp:Date.now(),source:"InteractionService",data:{buttonId:e.id,action:"speed-change",speed:i}})})}),this.logger.log("InteractionService: Button interactions enabled")}setupAccessibilityFeatures(t){const e=t.node();if(!e)return;e.setAttribute("role","img"),e.setAttribute("aria-label","Interactive U.S. Energy Usage Sankey Diagram"),e.setAttribute("tabindex","0");this.addEventListener(e,"focus",()=>{e.style.outline="2px solid #007cba"}),this.addEventListener(e,"blur",()=>{e.style.outline="none"});const i=document.getElementById("rangeSlider");i&&(i.setAttribute("aria-label","Select year for energy data visualization"),i.setAttribute("role","slider"));const n=document.getElementById("play-button");n&&(n.setAttribute("aria-label","Play or pause animation"),n.setAttribute("role","button")),this.logger.log("InteractionService: Accessibility features enabled")}handleElementHover(t,e){t.classList.add("hovered"),document.querySelectorAll(".hovered").forEach(e=>{e!==t&&e.classList.remove("hovered")}),this.eventBus.emit({type:"interaction.hover",timestamp:Date.now(),source:"InteractionService",data:{elementType:t.classList.contains("flow")?"flow":"box",fuel:t.getAttribute("data-fuel"),sector:t.getAttribute("data-sector"),mousePosition:{x:e.clientX,y:e.clientY}}}),this.handlers.onElementHover&&this.handlers.onElementHover(t,e)}handleElementClick(t,e){this.eventBus.emit({type:"interaction.click",timestamp:Date.now(),source:"InteractionService",data:{elementType:t.classList.contains("flow")?"flow":"box",fuel:t.getAttribute("data-fuel"),sector:t.getAttribute("data-sector"),mousePosition:{x:e.clientX,y:e.clientY}}}),this.handlers.onElementClick&&this.handlers.onElementClick(t,e)}setInteractionHandlers(t){this.handlers={...this.handlers,...t},this.logger.log("InteractionService: Custom handlers updated")}addEventListener(t,e,i){t.addEventListener(e,i),this.eventListeners.push({element:t,event:e,handler:i})}cleanup(){this.eventListeners.forEach(({element:t,event:e,handler:i})=>{t.removeEventListener(e,i)}),this.eventListeners=[],this.state={isMouseDown:!1,lastMousePosition:{x:0,y:0},selectedElement:null,isDragging:!1,touchStartTime:0,keyboardShortcutsEnabled:!1},this.handlers={},document.querySelectorAll(".hovered, .selected").forEach(t=>{t.classList.remove("hovered","selected")}),this.logger.log("InteractionService: Cleanup completed")}getInteractionState(){return{...this.state}}isInteractionEnabled(){return this.eventListeners.length>0}getInteractionStats(){return{eventListeners:this.eventListeners.length,keyboardEnabled:this.state.keyboardShortcutsEnabled,touchSupported:"ontouchstart"in window,lastInteraction:this.state.lastMousePosition}}triggerElementHover(t){if(t){const e=new MouseEvent("mouseover",{bubbles:!0,clientX:this.state.lastMousePosition.x,clientY:this.state.lastMousePosition.y});this.handleElementHover(t,e)}}triggerElementClick(t){if(t){const e=new MouseEvent("click",{bubbles:!0,clientX:this.state.lastMousePosition.x,clientY:this.state.lastMousePosition.y});this.handleElementClick(t,e)}}}});return class{constructor(t,e){this.services={},this.svg=null,this.tooltip=null,this.initialized=!1,this.destroyed=!1,this.subscriptions=[],this.logger=new bn(e),this.validateInputs(t,e),this.container=this.resolveContainer(t),this.options=this.mergeOptionsWithDefaults(e),this.wasteHeatVisible=!1!==this.options.showWasteHeat,this.eventBus=new wn(this.logger),this.setupSystemEventListeners(),this.initialize()}async initialize(){const t=performance.now();try{this.eventBus.emit({type:"system.initialized",timestamp:Date.now(),source:"SankeyVisualization",data:{version:"7.0.0",services:[],initTime:0}}),this.logger.log("SankeyVisualization: Creating infrastructure services..."),await this.createConfigurationService(),this.logger.log("SankeyVisualization: Creating data processing services..."),await this.createDataServices(),this.logger.log("SankeyVisualization: Creating calculation services..."),await this.createCalculationServices(),this.logger.log("SankeyVisualization: Creating rendering services..."),await this.createRenderingServices(),this.logger.log("SankeyVisualization: Creating animation services..."),await this.createAnimationService(),this.logger.log("SankeyVisualization: Creating interaction services..."),await this.createInteractionServices(),this.logger.log("SankeyVisualization: Initializing DOM structure..."),this.initializeDOMElements(),this.logger.log("SankeyVisualization: Performing initial render..."),await this.performInitialRender();const e=performance.now()-t;this.eventBus.emit({type:"system.ready",timestamp:Date.now(),source:"SankeyVisualization",data:{version:"7.0.0",totalInitTime:e,dataPointCount:this.options.data.length,yearRange:[Math.min(...this.options.data.map(t=>t.year)),Math.max(...this.options.data.map(t=>t.year))]}}),this.initialized=!0,this.logger.log(`SankeyVisualization: Complete initialization in ${e.toFixed(2)}ms`),e>500&&(this.logger.warn(`SankeyVisualization: Slow initialization detected (${e.toFixed(2)}ms) - consider data size optimization`),this.logger.warn("Performance optimization suggestions:"),this.logger.warn(" - Check dataset size: Large datasets (>100 years) may require progressive loading"),this.logger.warn(" - Verify system resources: Low memory or CPU can impact initialization"),this.logger.warn(" - Monitor network performance: Slow dynamic imports affect service loading"),this.logger.warn(" - Consider cache prewarming: Precompute frequently accessed calculations"))}catch(t){this.handleInitializationError(t)}}async createConfigurationService(){this.services.configurationService=new xn(this.container,this.options,this.eventBus,this.logger),this.logger.debug("SankeyVisualization: ConfigurationService created")}async createDataServices(){this.services.dataValidationService=new En(this.services.configurationService,this.eventBus,this.logger),this.services.dataService=new An(this.options.data,this.services.dataValidationService,this.eventBus,this.logger),this.logger.debug("SankeyVisualization: Data services created ( services)")}async createCalculationServices(){this.services.summaryService=new Tn(this.services.dataService,this.services.configurationService),this.services.graphService=new Mn(this.services.configurationService,this.services.dataService,this.services.summaryService),this.logger.debug("SankeyVisualization: Calculation services created and wired (3 services)")}async createRenderingServices(){this.services.renderingService=new Cn(this.services.configurationService,this.services.summaryService,this.services.graphService,this.services.dataService,this.eventBus)}async createAnimationService(){const{AnimationService:t}=await Promise.resolve().then(function(){return kn});this.services.animationService=new t(this.services.configurationService,this.services.summaryService,this.services.graphService,this.services.dataService,this.options,this.eventBus,this.logger)}async createInteractionServices(){const{InteractionService:t}=await Promise.resolve().then(function(){return Dn});this.services.interactionService=new t(this.services.animationService,this.services.dataService,this.eventBus,this.logger)}initializeDOMElements(){const t=this.services.configurationService;this.injectHTML(),this.tooltip=Ht("body").append("div").attr("class","tooltip").style("opacity",0),this.svg=Ht(".sankey").append("svg").attr("id","chart").attr("width",this.options.width||t.WIDTH).attr("height",this.options.height||t.HEIGHT)}injectHTML(){let t='\n <div class="us-energy-sankey-wrapper">\n <div class="sankey" style="line-height: 0;"></div>\n ';if(this.options.includeTimeline&&(t+=`\n <div class="range-slider">\n <div id="axisTop"></div>\n <form style="margin: -5px;margin-left: 5px;">\n <input id="rangeSlider" class="range-slider__range" type="range" \n value="${this.services.dataService.firstYear}" min="${this.services.dataService.firstYear}" max="${this.services.dataService.lastYear}" name="foo">\n <output id="dynamicYear" for="foo"></output>\n </form>\n \n <div id="testTick"></div>\n \n <div class="container" style="margin-left: 10px;margin-top: 40px;margin-bottom: 15px;padding: 0;">\n `),this.options.includeControls&&(t+='\n <div class="sidebar" style="width: 90px; float: left;">\n <span id="play-button" class="playbutton" type="button"></span>\n <button id="jButton" style="display:none"></button>\n <button id="kButton" style="display:none"></button>\n </div>\n '),this.options.includeWasteToggle&&(t+='\n <div class="content switch_box box_1" style="float: right;">\n <label id="lbl_waste_hide_show" for="waste_required">Hide electricity waste heat</label>\n <input type="checkbox" id="waste_required" name="waste" class="switch_1">\n </div>\n '),this.options.includeTimeline&&(t+="\n </div>\n </div>\n "),t+="</div>",this.options.includeTimeline&&(t+='<div id="dialog" title="" style="display: none;"></div>'),this.container.innerHTML=t,!document.querySelector(".title_container")){const t=document.createElement("div");t.className="title_container",this.container.insertBefore(t,this.container.firstChild)}const e=this.container.querySelector(".sankey");e&&(this.wasteHeatVisible||e.classList.add("waste-heat-hidden"))}async performInitialRender(){if(!this.svg||!this.tooltip)throw new Sn("DOM elements not initialized");const t=this.services.summaryService.summary,e=this.services.graphService.graphs;console.log("graphService",JSON.stringify(e));const i=this.buildGraphNest(e,t);console.log("buildGraphNest",JSON.stringify(e)),this.services.renderingService.drawInitialChart(this.svg,this.tooltip),this.services.animationService.setupAnimation(e,i,this.svg,this.tooltip),console.log("setupAnimation",JSON.stringify(e)),this.services.interactionService.initializeInteractions(this.svg,this.tooltip),this.setupEventListeners(),this.options.autoPlay&&this.options.includeControls&&setTimeout(()=>{this.services.animationService.play()},500)}buildGraphNest(t,e){const i=this.services.configurationService.SCALE,n={strokes:{},tops:{},heights:{},waste:{}};for(let r=0;r<t.length;++r){let s=this.services.configurationService.TOP_Y;const a=t[r].year;n.strokes[a]={},n.tops[a]={},n.heights[a]={},n.waste[a]={},n.strokes[a].waste={};for(const o of this.services.configurationService.FUELS){const l=o.fuel;n.strokes[a][l]={},"elec"==l?n.tops[a][l]=this.services.configurationService.ELEC_BOX_Y-e.totals[r].elec*i:"heat"==l?n.tops[a][l]=this.services.configurationService.HEAT_BOX_Y-e.totals[r].heat*i:(n.tops[a][l]=s,s+=e.totals[r][l]*i+this.services.configurationService.LEFT_GAP);for(const s of this.services.configurationService.BOXES){const o=s.box;n.waste[a][o]=this.services.dataService.data[r].waste[o],n.heights[a][o]=e.totals[r][o]*i;const c=t[r].graph.find(t=>t.fuel===l&&t.box===o);c&&(n.strokes[a][l][o]=c.stroke)}const c=t[r].graph.filter(t=>"waste"===t.fuel);for(const t of c)n.strokes[a][t.fuel]||(n.strokes[a][t.fuel]={}),n.strokes[a][t.fuel][t.box]=t.stroke}}return n}setupEventListeners(){if(this.options.includeWasteToggle){const t=document.getElementById("waste_required");t&&(t.checked=this.wasteHeatVisible,t.addEventListener("change",()=>{this.toggleWasteHeat()}))}this.options.includeControls&&document.addEventListener("keypress",t=>{13!==t.which&&32!==t.which||(t.preventDefault(),this.services.animationService.isPlaying()?this.services.animationService.pause():this.services.animationService.play())})}setupSystemEventListeners(){const t=this.eventBus.subscribe("system.error",t=>{console.error("System Error:",t.data)}),e=this.eventBus.subscribe("year.changed",t=>{this.logger.log(`Year changed to ${t.data.year}`)});this.subscriptions.push(t,e)}handleInitializationError(t){throw console.error("SankeyVisualization: Initialization failed:",t),this.eventBus.emit({type:"system.error",timestamp:Date.now(),source:"SankeyVisualization",data:{error:t instanceof Error?t:new Error(String(t)),context:"initialization",recoverable:!1}}),this.destroy(),t}updateWasteLabel(){const t=document.getElementById("lbl_waste_hide_show");t&&(t.textContent=this.wasteHeatVisible?"Hide electricity waste heat":"Show electricity waste heat")}play(){var t;return this.initialized?(null===(t=this.services.animationService)||void 0===t||t.play(),this):(console.warn("SankeyVisualization: Cannot play animation before initialization"),this)}pause(){var t;return this.initialized?(null===(t=this.services.animationService)||void 0===t||t.pause(),this):(console.warn("SankeyVisualization: Cannot pause animation before initialization"),this)}setYear(t){var e;return this.initialized?(null===(e=this.services.animationService)||void 0===e||e.setYear(t),this):(console.warn("SankeyVisualization: Cannot set year before initialization"),this)}getCurrentYear(){var t;return this.services.animationService?this.services.animationService.getCurrentYear():this.services.dataService?this.services.dataService.firstYear:(null===(t=this.options.data[0])||void 0===t?void 0:t.year)||1800}setSpeed(t){var e;return this.initialized?(null===(e=this.services.animationService)||void 0===e||e.setSpeed(t),this):(console.warn("SankeyVisualization: Cannot set speed before initialization"),this)}isPlaying(){var t;return this.initialized&&(null===(t=this.services.animationService)||void 0===t?void 0:t.isPlaying())||!1}isInitialized(){return this.initialized}getYears(){return this.services.dataService.years}getDataService(){return this.services.dataService}toggleWasteHeat(){this.wasteHeatVisible=!this.wasteHeatVisible;const t=document.getElementById("waste_required");t&&(t.checked=this.wasteHeatVisible);const e=this.container.querySelector(".sankey");return e&&(this.wasteHeatVisible?e.classList.remove("waste-heat-hidden"):e.classList.add("waste-heat-hidden")),this.updateWasteLabel(),this}isWasteHeatVisible(){return this.wasteHeatVisible}destroy(){this.destroyed||(this.subscriptions.forEach(t=>this.eventBus.unsubscribe(t)),this.subscriptions=[],this.eventBus.clear(),this.svg&&(this.svg.remove(),this.svg=null),this.tooltip&&(this.tooltip.remove(),this.tooltip=null),this.services={},this.destroyed=!0,this.initialized=!1)}validateInputs(t,e){if(!t)throw new Sn("Container ID or element is required");if(!e)throw new Sn("Options are required");if(!e.data||!Array.isArray(e.data)||0===e.data.length)throw new _n("Data array is required and must not be empty","data");this.validateDataStructure(e.data)}validateDataStructure(t){for(let e=0;e<t.length;e++){const i=t[e];if(!i.year||"number"!=typeof i.year)throw new _n(`Invalid year at index ${e}`,"year");const n=["elec","waste","solar","nuclear","hydro","wind","geo","gas","coal","bio","petro"];for(const t of n)if(!(t in i))throw new _n(`Missing sector '${t}' in data point for year ${i.year}`,t)}}resolveContainer(t){if("string"==typeof t){const e=document.getElementById(t);if(!e)throw new Sn(`Container element not found: ${t}`);return e}if(t instanceof HTMLElement)return t;throw new Sn("Invalid container: must be string ID or HTMLElement")}mergeOptionsWithDefaults(t){return{data:t.data,country:t.country,includeControls:!1!==t.includeControls,includeTimeline:!1!==t.includeTimeline,includeWasteToggle:!1!==t.includeWasteToggle,autoPlay:t.autoPlay||!1,showWasteHeat:!1!==t.showWasteHeat,animationSpeed:t.animationSpeed||200,width:t.width||null,height:t.height||620,loopAnimation:void 0!==t.loopAnimation&&t.loopAnimation}}}});
|
|
2
|
+
//# sourceMappingURL=sankey.standalone.min.js.map
|