/**
 * Minified by jsDelivr using Terser v5.48.0.
 * Original file: /npm/energy-visualization-stacked-area-chart@2.1.0/dist/stacked-area-chart.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).StackedAreaChart={})}(this,function(t){"use strict";const e={dimensions:{width:800,height:200,margin:{top:10,right:10,bottom:10,left:10}},mode:"fuel",representation:"perCapita",tooltip:{background:"#e8e8e8",color:"black",borderColor:"#cccccc",borderWidth:1,format:"n1",offset:{x:10,y:-10}},animations:{duration:300,easing:"ease-in-out",enabled:!0},colors:{Solar:"#fed530",Nuclear:"#ca0813",Water:"#0b24fb",Wind:"#901d8f",Geothermal:"#905a1c","Natural Gas":"#4cabf2",Coal:"#000000",Biomass:"#46be48",Petroleum:"#095f0b"},cssPrefix:"stacked-area-chart",interactive:!0};function n(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function r(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function i(t){let e,i,s;function a(t,n,r=0,o=t.length){if(r<o){if(0!==e(n,n))return o;do{const e=r+o>>>1;i(t[e],n)<0?r=e+1:o=e}while(r<o)}return r}return 2!==t.length?(e=n,i=(e,r)=>n(t(e),r),s=(e,n)=>t(e)-n):(e=t===n||t===r?t:o,i=t,s=t),{left:a,center:function(t,e,n=0,r=t.length){const i=a(t,e,n,r-1);return i>n&&s(t[i-1],e)>-s(t[i],e)?i-1:i},right:function(t,n,r=0,o=t.length){if(r<o){if(0!==e(n,n))return o;do{const e=r+o>>>1;i(t[e],n)<=0?r=e+1:o=e}while(r<o)}return r}}}function o(){return 0}const s=i(n).right;i(function(t){return null===t?NaN:+t}).center;var a=s;const u=Math.sqrt(50),l=Math.sqrt(10),h=Math.sqrt(2);function c(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),s=o>=u?10:o>=l?5:o>=h?2:1;let a,f,d;return i<0?(d=Math.pow(10,-i)/s,a=Math.round(t*d),f=Math.round(e*d),a/d<t&&++a,f/d>e&&--f,d=-d):(d=Math.pow(10,i)*s,a=Math.round(t/d),f=Math.round(e/d),a*d<t&&++a,f*d>e&&--f),f<a&&.5<=n&&n<2?c(t,e,2*n):[a,f,d]}function f(t,e,n){return c(t=+t,e=+e,n=+n)[2]}var d={value:()=>{}};function p(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new g(r)}function g(t){this._=t}function y(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function m(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=d,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}g.prototype=p.prototype={constructor:g,on:function(t,e){var n,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),s=-1,a=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<a;)if(n=(t=o[s]).type)i[n]=m(i[n],t.name,e);else if(null==e)for(n in i)i[n]=m(i[n],t.name,null);return this}for(;++s<a;)if((n=(t=o[s]).type)&&(n=y(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new g(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var v="http://www.w3.org/1999/xhtml",w={svg:"http://www.w3.org/2000/svg",xhtml:v,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),w.hasOwnProperty(e)?{space:w[e],local:t}:t}function b(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===v&&e.documentElement.namespaceURI===v?e.createElement(t):e.createElementNS(n,t)}}function x(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function C(t){var e=_(t);return(e.local?x:b)(e)}function M(){}function $(t){return null==t?M:function(){return this.querySelector(t)}}function S(){return[]}function k(t){return null==t?S:function(){return this.querySelectorAll(t)}}function A(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function E(t){return function(){return this.matches(t)}}function N(t){return function(e){return e.matches(t)}}var D=Array.prototype.find;function I(){return this.firstElementChild}var T=Array.prototype.filter;function z(){return Array.from(this.children)}function P(t){return new Array(t.length)}function R(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function F(t,e,n,r,i,o){for(var s,a=0,u=e.length,l=o.length;a<l;++a)(s=e[a])?(s.__data__=o[a],r[a]=s):n[a]=new R(t,o[a]);for(;a<u;++a)(s=e[a])&&(i[a]=s)}function L(t,e,n,r,i,o,s){var a,u,l,h=new Map,c=e.length,f=o.length,d=new Array(c);for(a=0;a<c;++a)(u=e[a])&&(d[a]=l=s.call(u,u.__data__,a,e)+"",h.has(l)?i[a]=u:h.set(l,u));for(a=0;a<f;++a)l=s.call(t,o[a],a,o)+"",(u=h.get(l))?(r[a]=u,u.__data__=o[a],h.delete(l)):n[a]=new R(t,o[a]);for(a=0;a<c;++a)(u=e[a])&&h.get(d[a])===u&&(i[a]=u)}function q(t){return t.__data__}function W(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function B(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function H(t){return function(){this.removeAttribute(t)}}function O(t){return function(){this.removeAttributeNS(t.space,t.local)}}function X(t,e){return function(){this.setAttribute(t,e)}}function j(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function G(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function V(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Y(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function U(t){return function(){this.style.removeProperty(t)}}function K(t,e,n){return function(){this.style.setProperty(t,e,n)}}function Z(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function Q(t,e){return t.style.getPropertyValue(e)||Y(t).getComputedStyle(t,null).getPropertyValue(e)}function J(t){return function(){delete this[t]}}function tt(t,e){return function(){this[t]=e}}function et(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function nt(t){return t.trim().split(/^|\s+/)}function rt(t){return t.classList||new it(t)}function it(t){this._node=t,this._names=nt(t.getAttribute("class")||"")}function ot(t,e){for(var n=rt(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function st(t,e){for(var n=rt(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function at(t){return function(){ot(this,t)}}function ut(t){return function(){st(this,t)}}function lt(t,e){return function(){(e.apply(this,arguments)?ot:st)(this,t)}}function ht(){this.textContent=""}function ct(t){return function(){this.textContent=t}}function ft(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function dt(){this.innerHTML=""}function pt(t){return function(){this.innerHTML=t}}function gt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function yt(){this.nextSibling&&this.parentNode.appendChild(this)}function mt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function vt(){return null}function wt(){var t=this.parentNode;t&&t.removeChild(this)}function _t(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function bt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function xt(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r<o;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function Ct(t,e,n){return function(){var r,i=this.__on,o=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var s=0,a=i.length;s<a;++s)if((r=i[s]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),void(r.value=e);this.addEventListener(t.type,o,n),r={type:t.type,name:t.name,value:e,listener:o,options:n},i?i.push(r):this.__on=[r]}}function Mt(t,e,n){var r=Y(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function $t(t,e){return function(){return Mt(this,t,e)}}function St(t,e){return function(){return Mt(this,t,e.apply(this,arguments))}}R.prototype={constructor:R,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)}},it.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 kt=[null];function At(t,e){this._groups=t,this._parents=e}function Et(){return new At([[document.documentElement]],kt)}function Nt(t){return"string"==typeof t?new At([[document.querySelector(t)]],[document.documentElement]):new At([[t]],kt)}function Dt(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function It(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Tt(){}At.prototype=Et.prototype={constructor:At,select:function(t){"function"!=typeof t&&(t=$(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s,a=e[i],u=a.length,l=r[i]=new Array(u),h=0;h<u;++h)(o=a[h])&&(s=t.call(o,o.__data__,h,a))&&("__data__"in o&&(s.__data__=o.__data__),l[h]=s);return new At(r,this._parents)},selectAll:function(t){t="function"==typeof t?A(t):k(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var s,a=e[o],u=a.length,l=0;l<u;++l)(s=a[l])&&(r.push(t.call(s,s.__data__,l,a)),i.push(s));return new At(r,i)},selectChild:function(t){return this.select(null==t?I:function(t){return function(){return D.call(this.children,t)}}("function"==typeof t?t:N(t)))},selectChildren:function(t){return this.selectAll(null==t?z:function(t){return function(){return T.call(this.children,t)}}("function"==typeof t?t:N(t)))},filter:function(t){"function"!=typeof t&&(t=E(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s=e[i],a=s.length,u=r[i]=[],l=0;l<a;++l)(o=s[l])&&t.call(o,o.__data__,l,s)&&u.push(o);return new At(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,q);var n=e?L:F,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var o=i.length,s=new Array(o),a=new Array(o),u=new Array(o),l=0;l<o;++l){var h=r[l],c=i[l],f=c.length,d=W(t.call(h,h&&h.__data__,l,r)),p=d.length,g=a[l]=new Array(p),y=s[l]=new Array(p);n(h,c,g,y,u[l]=new Array(f),d,e);for(var m,v,w=0,_=0;w<p;++w)if(m=g[w]){for(w>=_&&(_=w+1);!(v=y[_])&&++_<p;);m._next=v||null}}return(s=new At(s,r))._enter=a,s._exit=u,s},enter:function(){return new At(this._enter||this._groups.map(P),this._parents)},exit:function(){return new At(this._exit||this._groups.map(P),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,o=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?o.remove():n(o),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,o=r.length,s=Math.min(i,o),a=new Array(i),u=0;u<s;++u)for(var l,h=n[u],c=r[u],f=h.length,d=a[u]=new Array(f),p=0;p<f;++p)(l=h[p]||c[p])&&(d[p]=l);for(;u<i;++u)a[u]=n[u];return new At(a,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],o=i.length-1,s=i[o];--o>=0;)(r=i[o])&&(s&&4^r.compareDocumentPosition(s)&&s.parentNode.insertBefore(r,s),s=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=B);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var s,a=n[o],u=a.length,l=i[o]=new Array(u),h=0;h<u;++h)(s=a[h])&&(l[h]=s);l.sort(e)}return new At(i,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,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length;i<o;++i){var s=r[i];if(s)return s}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,n=0,r=e.length;n<r;++n)for(var i,o=e[n],s=0,a=o.length;s<a;++s)(i=o[s])&&t.call(i,i.__data__,s,o);return this},attr:function(t,e){var n=_(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?O:H:"function"==typeof e?n.local?V:G:n.local?j:X)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?U:"function"==typeof e?Z:K)(t,e,null==n?"":n)):Q(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?J:"function"==typeof e?et:tt)(t,e)):this.node()[t]},classed:function(t,e){var n=nt(t+"");if(arguments.length<2){for(var r=rt(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?lt:e?at:ut)(n,e))},text:function(t){return arguments.length?this.each(null==t?ht:("function"==typeof t?ft:ct)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?dt:("function"==typeof t?gt:pt)(t)):this.node().innerHTML},raise:function(){return this.each(yt)},lower:function(){return this.each(mt)},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 n="function"==typeof t?t:C(t),r=null==e?vt:"function"==typeof e?e:$(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(wt)},clone:function(t){return this.select(t?bt:_t)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,o=function(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),s=o.length;if(!(arguments.length<2)){for(a=e?Ct:xt,r=0;r<s;++r)this.each(a(o[r],e,n));return this}var a=this.node().__on;if(a)for(var u,l=0,h=a.length;l<h;++l)for(r=0,u=a[l];r<s;++r)if((i=o[r]).type===u.type&&i.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?St:$t)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],o=0,s=i.length;o<s;++o)(r=i[o])&&(yield r)}};var zt=.7,Pt=1/zt,Rt="\\s*([+-]?\\d+)\\s*",Ft="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Lt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",qt=/^#([0-9a-f]{3,8})$/,Wt=new RegExp(`^rgb\\(${Rt},${Rt},${Rt}\\)$`),Bt=new RegExp(`^rgb\\(${Lt},${Lt},${Lt}\\)$`),Ht=new RegExp(`^rgba\\(${Rt},${Rt},${Rt},${Ft}\\)$`),Ot=new RegExp(`^rgba\\(${Lt},${Lt},${Lt},${Ft}\\)$`),Xt=new RegExp(`^hsl\\(${Ft},${Lt},${Lt}\\)$`),jt=new RegExp(`^hsla\\(${Ft},${Lt},${Lt},${Ft}\\)$`),Gt={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 Vt(){return this.rgb().formatHex()}function Yt(){return this.rgb().formatRgb()}function Ut(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=qt.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Kt(e):3===n?new Jt(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?Zt(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?Zt(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=Wt.exec(t))?new Jt(e[1],e[2],e[3],1):(e=Bt.exec(t))?new Jt(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Ht.exec(t))?Zt(e[1],e[2],e[3],e[4]):(e=Ot.exec(t))?Zt(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Xt.exec(t))?oe(e[1],e[2]/100,e[3]/100,1):(e=jt.exec(t))?oe(e[1],e[2]/100,e[3]/100,e[4]):Gt.hasOwnProperty(t)?Kt(Gt[t]):"transparent"===t?new Jt(NaN,NaN,NaN,0):null}function Kt(t){return new Jt(t>>16&255,t>>8&255,255&t,1)}function Zt(t,e,n,r){return r<=0&&(t=e=n=NaN),new Jt(t,e,n,r)}function Qt(t,e,n,r){return 1===arguments.length?((i=t)instanceof Tt||(i=Ut(i)),i?new Jt((i=i.rgb()).r,i.g,i.b,i.opacity):new Jt):new Jt(t,e,n,null==r?1:r);var i}function Jt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function te(){return`#${ie(this.r)}${ie(this.g)}${ie(this.b)}`}function ee(){const t=ne(this.opacity);return`${1===t?"rgb(":"rgba("}${re(this.r)}, ${re(this.g)}, ${re(this.b)}${1===t?")":`, ${t})`}`}function ne(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function re(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ie(t){return((t=re(t))<16?"0":"")+t.toString(16)}function oe(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new ae(t,e,n,r)}function se(t){if(t instanceof ae)return new ae(t.h,t.s,t.l,t.opacity);if(t instanceof Tt||(t=Ut(t)),!t)return new ae;if(t instanceof ae)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),s=NaN,a=o-i,u=(o+i)/2;return a?(s=e===o?(n-r)/a+6*(n<r):n===o?(r-e)/a+2:(e-n)/a+4,a/=u<.5?o+i:2-o-i,s*=60):a=u>0&&u<1?0:s,new ae(s,a,u,t.opacity)}function ae(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function ue(t){return(t=(t||0)%360)<0?t+360:t}function le(t){return Math.max(0,Math.min(1,t||0))}function he(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Dt(Tt,Ut,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Vt,formatHex:Vt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return se(this).formatHsl()},formatRgb:Yt,toString:Yt}),Dt(Jt,Qt,It(Tt,{brighter(t){return t=null==t?Pt:Math.pow(Pt,t),new Jt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?zt:Math.pow(zt,t),new Jt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Jt(re(this.r),re(this.g),re(this.b),ne(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:te,formatHex:te,formatHex8:function(){return`#${ie(this.r)}${ie(this.g)}${ie(this.b)}${ie(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:ee,toString:ee})),Dt(ae,function(t,e,n,r){return 1===arguments.length?se(t):new ae(t,e,n,null==r?1:r)},It(Tt,{brighter(t){return t=null==t?Pt:Math.pow(Pt,t),new ae(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?zt:Math.pow(zt,t),new ae(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,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Jt(he(t>=240?t-240:t+120,i,r),he(t,i,r),he(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new ae(ue(this.h),le(this.s),le(this.l),ne(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=ne(this.opacity);return`${1===t?"hsl(":"hsla("}${ue(this.h)}, ${100*le(this.s)}%, ${100*le(this.l)}%${1===t?")":`, ${t})`}`}}));var ce=t=>()=>t;function fe(t){return 1===(t=+t)?de:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):ce(isNaN(e)?n:e)}}function de(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):ce(isNaN(t)?e:t)}var pe=function t(e){var n=fe(e);function r(t,e){var r=n((t=Qt(t)).r,(e=Qt(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),s=de(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=s(e),t+""}}return r.gamma=t,r}(1);function ge(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(o){for(n=0;n<r;++n)i[n]=t[n]*(1-o)+e[n]*o;return i}}function ye(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,o=new Array(i),s=new Array(r);for(n=0;n<i;++n)o[n]=Ce(t[n],e[n]);for(;n<r;++n)s[n]=e[n];return function(t){for(n=0;n<i;++n)s[n]=o[n](t);return s}}function me(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function ve(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function we(t,e){var n,r={},i={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?r[n]=Ce(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var _e=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,be=new RegExp(_e.source,"g");function xe(t,e){var n,r,i,o=_e.lastIndex=be.lastIndex=0,s=-1,a=[],u=[];for(t+="",e+="";(n=_e.exec(t))&&(r=be.exec(e));)(i=r.index)>o&&(i=e.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,u.push({i:s,x:ve(n,r)})),o=be.lastIndex;return o<e.length&&(i=e.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,r=0;r<e;++r)a[(n=u[r]).i]=n.x(t);return a.join("")})}function Ce(t,e){var n,r=typeof e;return null==e||"boolean"===r?ce(e):("number"===r?ve:"string"===r?(n=Ut(e))?(e=n,pe):xe:e instanceof Ut?pe:e instanceof Date?me:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?ge:Array.isArray(e)?ye:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?we:ve)(t,e)}function Me(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var $e,Se=180/Math.PI,ke={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ae(t,e,n,r,i,o){var s,a,u;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,u/=a),t*r<e*n&&(t=-t,e=-e,u=-u,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*Se,skewX:Math.atan(u)*Se,scaleX:s,scaleY:a}}function Ee(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(o,s){var a=[],u=[];return o=t(o),s=t(s),function(t,r,i,o,s,a){if(t!==i||r!==o){var u=s.push("translate(",null,e,null,n);a.push({i:u-4,x:ve(t,i)},{i:u-2,x:ve(r,o)})}else(i||o)&&s.push("translate("+i+e+o+n)}(o.translateX,o.translateY,s.translateX,s.translateY,a,u),function(t,e,n,o){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:ve(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,s.rotate,a,u),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:ve(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,s.skewX,a,u),function(t,e,n,r,o,s){if(t!==n||e!==r){var a=o.push(i(o)+"scale(",null,",",null,")");s.push({i:a-4,x:ve(t,n)},{i:a-2,x:ve(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,s.scaleX,s.scaleY,a,u),o=s=null,function(t){for(var e,n=-1,r=u.length;++n<r;)a[(e=u[n]).i]=e.x(t);return a.join("")}}}var Ne,De,Ie=Ee(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?ke:Ae(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),Te=Ee(function(t){return null==t?ke:($e||($e=document.createElementNS("http://www.w3.org/2000/svg","g")),$e.setAttribute("transform",t),(t=$e.transform.baseVal.consolidate())?Ae((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):ke)},", ",")",")"),ze=0,Pe=0,Re=0,Fe=0,Le=0,qe=0,We="object"==typeof performance&&performance.now?performance:Date,Be="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function He(){return Le||(Be(Oe),Le=We.now()+qe)}function Oe(){Le=0}function Xe(){this._call=this._time=this._next=null}function je(t,e,n){var r=new Xe;return r.restart(t,e,n),r}function Ge(){Le=(Fe=We.now())+qe,ze=Pe=0;try{!function(){He(),++ze;for(var t,e=Ne;e;)(t=Le-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ze}()}finally{ze=0,function(){var t,e,n=Ne,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Ne=e);De=t,Ye(r)}(),Le=0}}function Ve(){var t=We.now(),e=t-Fe;e>1e3&&(qe-=e,Fe=t)}function Ye(t){ze||(Pe&&(Pe=clearTimeout(Pe)),t-Le>24?(t<1/0&&(Pe=setTimeout(Ge,t-We.now()-qe)),Re&&(Re=clearInterval(Re))):(Re||(Fe=We.now(),Re=setInterval(Ve,1e3)),ze=1,Be(Ge)))}function Ue(t,e,n){var r=new Xe;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}Xe.prototype=je.prototype={constructor:Xe,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?He():+n)+(null==e?0:+e),this._next||De===this||(De?De._next=this:Ne=this,De=this),this._call=t,this._time=n,Ye()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ye())}};var Ke=p("start","end","cancel","interrupt"),Ze=[];function Qe(t,e,n,r,i,o){var s=t.__transition;if(s){if(n in s)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(t){n.state=1,n.timer.restart(s,n.delay,n.time),n.delay<=t&&s(t-n.delay)}function s(o){var l,h,c,f;if(1!==n.state)return u();for(l in i)if((f=i[l]).name===n.name){if(3===f.state)return Ue(s);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[l]):+l<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[l])}if(Ue(function(){3===n.state&&(n.state=4,n.timer.restart(a,n.delay,n.time),a(o))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(c=n.tween.length),l=0,h=-1;l<c;++l)(f=n.tween[l].value.call(t,t.__data__,n.index,n.group))&&(r[++h]=f);r.length=h+1}}function a(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=5,1),o=-1,s=r.length;++o<s;)r[o].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=je(o,0,n.time)}(t,n,{name:e,index:r,group:i,on:Ke,tween:Ze,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function Je(t,e){var n=en(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function tn(t,e){var n=en(t,e);if(n.state>3)throw new Error("too late; already running");return n}function en(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function nn(t,e){var n,r;return function(){var i=tn(this,t),o=i.tween;if(o!==n)for(var s=0,a=(r=n=o).length;s<a;++s)if(r[s].name===e){(r=r.slice()).splice(s,1);break}i.tween=r}}function rn(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var o=tn(this,t),s=o.tween;if(s!==r){i=(r=s).slice();for(var a={name:e,value:n},u=0,l=i.length;u<l;++u)if(i[u].name===e){i[u]=a;break}u===l&&i.push(a)}o.tween=i}}function on(t,e,n){var r=t._id;return t.each(function(){var t=tn(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return en(t,r).value[e]}}function sn(t,e){var n;return("number"==typeof e?ve:e instanceof Ut?pe:(n=Ut(e))?(e=n,pe):xe)(t,e)}function an(t){return function(){this.removeAttribute(t)}}function un(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ln(t,e,n){var r,i,o=n+"";return function(){var s=this.getAttribute(t);return s===o?null:s===r?i:i=e(r=s,n)}}function hn(t,e,n){var r,i,o=n+"";return function(){var s=this.getAttributeNS(t.space,t.local);return s===o?null:s===r?i:i=e(r=s,n)}}function cn(t,e,n){var r,i,o;return function(){var s,a,u=n(this);if(null!=u)return(s=this.getAttribute(t))===(a=u+"")?null:s===r&&a===i?o:(i=a,o=e(r=s,u));this.removeAttribute(t)}}function fn(t,e,n){var r,i,o;return function(){var s,a,u=n(this);if(null!=u)return(s=this.getAttributeNS(t.space,t.local))===(a=u+"")?null:s===r&&a===i?o:(i=a,o=e(r=s,u));this.removeAttributeNS(t.space,t.local)}}function dn(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,i)),n}return i._value=e,i}function pn(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,i)),n}return i._value=e,i}function gn(t,e){return function(){Je(this,t).delay=+e.apply(this,arguments)}}function yn(t,e){return e=+e,function(){Je(this,t).delay=e}}function mn(t,e){return function(){tn(this,t).duration=+e.apply(this,arguments)}}function vn(t,e){return e=+e,function(){tn(this,t).duration=e}}var wn=Et.prototype.constructor;function _n(t){return function(){this.style.removeProperty(t)}}var bn=0;function xn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Cn(){return++bn}var Mn=Et.prototype;xn.prototype={constructor:xn,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=$(t));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var a,u,l=r[s],h=l.length,c=o[s]=new Array(h),f=0;f<h;++f)(a=l[f])&&(u=t.call(a,a.__data__,f,l))&&("__data__"in a&&(u.__data__=a.__data__),c[f]=u,Qe(c[f],e,n,f,c,en(a,n)));return new xn(o,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=k(t));for(var r=this._groups,i=r.length,o=[],s=[],a=0;a<i;++a)for(var u,l=r[a],h=l.length,c=0;c<h;++c)if(u=l[c]){for(var f,d=t.call(u,u.__data__,c,l),p=en(u,n),g=0,y=d.length;g<y;++g)(f=d[g])&&Qe(f,e,n,g,d,p);o.push(d),s.push(u)}return new xn(o,s,e,n)},selectChild:Mn.selectChild,selectChildren:Mn.selectChildren,filter:function(t){"function"!=typeof t&&(t=E(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s=e[i],a=s.length,u=r[i]=[],l=0;l<a;++l)(o=s[l])&&t.call(o,o.__data__,l,s)&&u.push(o);return new xn(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),s=new Array(r),a=0;a<o;++a)for(var u,l=e[a],h=n[a],c=l.length,f=s[a]=new Array(c),d=0;d<c;++d)(u=l[d]||h[d])&&(f[d]=u);for(;a<r;++a)s[a]=e[a];return new xn(s,this._parents,this._name,this._id)},selection:function(){return new wn(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Cn(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s,a=r[o],u=a.length,l=0;l<u;++l)if(s=a[l]){var h=en(s,e);Qe(s,t,n,l,a,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new xn(r,this._parents,t,n)},call:Mn.call,nodes:Mn.nodes,node:Mn.node,size:Mn.size,empty:Mn.empty,each:Mn.each,on:function(t,e){var n=this._id;return arguments.length<2?en(this.node(),n).on.on(t):this.each(function(t,e,n){var r,i,o=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)?Je:tn;return function(){var s=o(this,t),a=s.on;a!==r&&(i=(r=a).copy()).on(e,n),s.on=i}}(n,t,e))},attr:function(t,e){var n=_(t),r="transform"===n?Te:sn;return this.attrTween(t,"function"==typeof e?(n.local?fn:cn)(n,r,on(this,"attr."+t,e)):null==e?(n.local?un:an)(n):(n.local?hn:ln)(n,r,e))},attrTween:function(t,e){var n="attr."+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;var r=_(t);return this.tween(n,(r.local?dn:pn)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Ie:sn;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var o=Q(this,t),s=(this.style.removeProperty(t),Q(this,t));return o===s?null:o===n&&s===r?i:i=e(n=o,r=s)}}(t,r)).on("end.style."+t,_n(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,o;return function(){var s=Q(this,t),a=n(this),u=a+"";return null==a&&(this.style.removeProperty(t),u=a=Q(this,t)),s===u?null:s===r&&u===i?o:(i=u,o=e(r=s,a))}}(t,r,on(this,"style."+t,e))).each(function(t,e){var n,r,i,o,s="style."+e,a="end."+s;return function(){var u=tn(this,t),l=u.on,h=null==u.value[s]?o||(o=_n(e)):void 0;l===n&&i===h||(r=(n=l).copy()).on(a,i=h),u.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,o=n+"";return function(){var s=Q(this,t);return s===o?null:s===r?i:i=e(r=s,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,o,n)),r}return o._value=e,o}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(on(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,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=en(this.node(),n).tween,o=0,s=i.length;o<s;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==e?nn:rn)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?gn:yn)(e,t)):en(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?mn:vn)(e,t)):en(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(){tn(this,t).ease=e}}(e,t)):en(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;tn(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(o,s){var a={value:s},u={value:function(){0===--i&&o()}};n.each(function(){var n=tn(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(a),e._.interrupt.push(a),e._.end.push(u)),n.on=e}),0===i&&o()})},[Symbol.iterator]:Mn[Symbol.iterator]};var $n={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Sn(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}Et.prototype.interrupt=function(t){return this.each(function(){!function(t,e){var n,r,i,o=t.__transition,s=!0;if(o){for(i in e=null==e?null:e+"",o)(n=o[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[i]):s=!1;s&&delete t.__transition}}(this,t)})},Et.prototype.transition=function(t){var e,n;t instanceof xn?(e=t._id,t=t._name):(e=Cn(),(n=$n).time=He(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s,a=r[o],u=a.length,l=0;l<u;++l)(s=a[l])&&Qe(s,t,e,l,a,n||Sn(s,e));return new xn(r,this._parents,t,e)};const kn=Math.PI,An=2*kn,En=1e-6,Nn=An-En;function Dn(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}class In{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?Dn:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Dn;const n=10**e;return function(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=Math.round(arguments[e]*n)/n+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,n,r){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(t,e,n,r,i,o){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+o}`}arcTo(t,e,n,r,i){if(t=+t,e=+e,n=+n,r=+r,(i=+i)<0)throw new Error(`negative radius: ${i}`);let o=this._x1,s=this._y1,a=n-t,u=r-e,l=o-t,h=s-e,c=l*l+h*h;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(c>En)if(Math.abs(h*a-u*l)>En&&i){let f=n-o,d=r-s,p=a*a+u*u,g=f*f+d*d,y=Math.sqrt(p),m=Math.sqrt(c),v=i*Math.tan((kn-Math.acos((p+c-g)/(2*y*m)))/2),w=v/m,_=v/y;Math.abs(w-1)>En&&this._append`L${t+w*l},${e+w*h}`,this._append`A${i},${i},0,0,${+(h*f>l*d)},${this._x1=t+_*a},${this._y1=e+_*u}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,o){if(t=+t,e=+e,o=!!o,(n=+n)<0)throw new Error(`negative radius: ${n}`);let s=n*Math.cos(r),a=n*Math.sin(r),u=t+s,l=e+a,h=1^o,c=o?r-i:i-r;null===this._x1?this._append`M${u},${l}`:(Math.abs(this._x1-u)>En||Math.abs(this._y1-l)>En)&&this._append`L${u},${l}`,n&&(c<0&&(c=c%An+An),c>Nn?this._append`A${n},${n},0,1,${h},${t-s},${e-a}A${n},${n},0,1,${h},${this._x1=u},${this._y1=l}`:c>En&&this._append`A${n},${n},0,${+(c>=kn)},${h},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}}function Tn(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function zn(t){return(t=Tn(Math.abs(t)))?t[1]:NaN}var Pn,Rn=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Fn(t){if(!(e=Rn.exec(t)))throw new Error("invalid format: "+t);var e;return new Ln({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 Ln(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 qn(t,e){var n=Tn(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}Fn.prototype=Ln.prototype,Ln.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 Wn={"%":(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)=>qn(100*t,e),r:qn,s:function(t,e){var n=Tn(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(Pn=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,s=r.length;return o===s?r:o>s?r+new Array(o-s+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Tn(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Bn(t){return t}var Hn,On,Xn,jn=Array.prototype.map,Gn=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Vn(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Bn:(e=jn.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,o=[],s=0,a=e[0],u=0;i>0&&a>0&&(u+a+1>r&&(a=Math.max(1,r-u)),o.push(t.substring(i-=a,i+a)),!((u+=a+1)>r));)a=e[s=(s+1)%e.length];return o.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",s=void 0===t.decimal?".":t.decimal+"",a=void 0===t.numerals?Bn:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(jn.call(t.numerals,String)),u=void 0===t.percent?"%":t.percent+"",l=void 0===t.minus?"−":t.minus+"",h=void 0===t.nan?"NaN":t.nan+"";function c(t){var e=(t=Fn(t)).fill,n=t.align,c=t.sign,f=t.symbol,d=t.zero,p=t.width,g=t.comma,y=t.precision,m=t.trim,v=t.type;"n"===v?(g=!0,v="g"):Wn[v]||(void 0===y&&(y=12),m=!0,v="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var w="$"===f?i:"#"===f&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",_="$"===f?o:/[%p]/.test(v)?u:"",b=Wn[v],x=/[defgprs%]/.test(v);function C(t){var i,o,u,f=w,C=_;if("c"===v)C=b(t)+C,t="";else{var M=(t=+t)<0||1/t<0;if(t=isNaN(t)?h:b(Math.abs(t),y),m&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),M&&0===+t&&"+"!==c&&(M=!1),f=(M?"("===c?c:l:"-"===c||"("===c?"":c)+f,C=("s"===v?Gn[8+Pn/3]:"")+C+(M&&"("===c?")":""),x)for(i=-1,o=t.length;++i<o;)if(48>(u=t.charCodeAt(i))||u>57){C=(46===u?s+t.slice(i+1):t.slice(i))+C,t=t.slice(0,i);break}}g&&!d&&(t=r(t,1/0));var $=f.length+t.length+C.length,S=$<p?new Array(p-$+1).join(e):"";switch(g&&d&&(t=r(S+t,S.length?p-C.length:1/0),S=""),n){case"<":t=f+t+C+S;break;case"=":t=f+S+t+C;break;case"^":t=S.slice(0,$=S.length>>1)+f+t+C+S.slice($);break;default:t=S+f+t+C}return a(t)}return y=void 0===y?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),C.toString=function(){return t+""},C}return{format:c,formatPrefix:function(t,e){var n=c(((t=Fn(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(zn(e)/3))),i=Math.pow(10,-r),o=Gn[8+r/3];return function(t){return n(i*t)+o}}}}function Yn(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Un(t){return+t}Hn=Vn({thousands:",",grouping:[3],currency:["$",""]}),On=Hn.format,Xn=Hn.formatPrefix;var Kn=[0,1];function Zn(t){return t}function Qn(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function Jn(t,e,n){var r=t[0],i=t[1],o=e[0],s=e[1];return i<r?(r=Qn(i,r),o=n(s,o)):(r=Qn(r,i),o=n(o,s)),function(t){return o(r(t))}}function tr(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)i[s]=Qn(t[s],t[s+1]),o[s]=n(e[s],e[s+1]);return function(e){var n=a(t,e,1,r)-1;return o[n](i[n](e))}}function er(){var t,e,n,r,i,o,s=Kn,a=Kn,u=Ce,l=Zn;function h(){var t,e,n,u=Math.min(s.length,a.length);return l!==Zn&&(t=s[0],e=s[u-1],t>e&&(n=t,t=e,e=n),l=function(n){return Math.max(t,Math.min(e,n))}),r=u>2?tr:Jn,i=o=null,c}function c(e){return null==e||isNaN(e=+e)?n:(i||(i=r(s.map(t),a,u)))(t(l(e)))}return c.invert=function(n){return l(e((o||(o=r(a,s.map(t),ve)))(n)))},c.domain=function(t){return arguments.length?(s=Array.from(t,Un),h()):s.slice()},c.range=function(t){return arguments.length?(a=Array.from(t),h()):a.slice()},c.rangeRound=function(t){return a=Array.from(t),u=Me,h()},c.clamp=function(t){return arguments.length?(l=!!t||Zn,h()):l!==Zn},c.interpolate=function(t){return arguments.length?(u=t,h()):u},c.unknown=function(t){return arguments.length?(n=t,c):n},function(n,r){return t=n,e=r,h()}}function nr(t,e,n,r){var i,o=function(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?f(e,t,n):f(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}(t,e,n);switch((r=Fn(null==r?",f":r)).type){case"s":var s=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(zn(e)/3)))-zn(Math.abs(t)))}(o,s))||(r.precision=i),Xn(r,s);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,zn(e)-zn(t))+1}(o,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-zn(Math.abs(t)))}(o))||(r.precision=i-2*("%"===r.type))}return On(r)}function rr(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)===(e=+e))return[t];const r=e<t,[i,o,s]=r?c(e,t,n):c(t,e,n);if(!(o>=i))return[];const a=o-i+1,u=new Array(a);if(r)if(s<0)for(let t=0;t<a;++t)u[t]=(o-t)/-s;else for(let t=0;t<a;++t)u[t]=(o-t)*s;else if(s<0)for(let t=0;t<a;++t)u[t]=(i+t)/-s;else for(let t=0;t<a;++t)u[t]=(i+t)*s;return u}(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return nr(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,o=e(),s=0,a=o.length-1,u=o[s],l=o[a],h=10;for(l<u&&(i=u,u=l,l=i,i=s,s=a,a=i);h-- >0;){if((i=f(u,l,n))===r)return o[s]=u,o[a]=l,e(o);if(i>0)u=Math.floor(u/i)*i,l=Math.ceil(l/i)*i;else{if(!(i<0))break;u=Math.ceil(u*i)/i,l=Math.floor(l*i)/i}r=i}return t},t}function ir(){var t=er()(Zn,Zn);return t.copy=function(){return e=t,ir().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},Yn.apply(t,arguments),rr(t)}function or(t){return function(){return t}}function sr(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(null==n)e=null;else{const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new In(e)}function ar(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function ur(t){this._context=t}function lr(t){return new ur(t)}function hr(t){return t[0]}function cr(t){return t[1]}function fr(t,e,n){var r=null,i=or(!0),o=null,s=lr,a=null,u=sr(l);function l(l){var h,c,f,d,p,g=(l=ar(l)).length,y=!1,m=new Array(g),v=new Array(g);for(null==o&&(a=s(p=u())),h=0;h<=g;++h){if(!(h<g&&i(d=l[h],h,l))===y)if(y=!y)c=h,a.areaStart(),a.lineStart();else{for(a.lineEnd(),a.lineStart(),f=h-1;f>=c;--f)a.point(m[f],v[f]);a.lineEnd(),a.areaEnd()}y&&(m[h]=+t(d,h,l),v[h]=+e(d,h,l),a.point(r?+r(d,h,l):m[h],n?+n(d,h,l):v[h]))}if(p)return a=null,p+""||null}function h(){return function(t,e){var n=or(!0),r=null,i=lr,o=null,s=sr(a);function a(a){var u,l,h,c=(a=ar(a)).length,f=!1;for(null==r&&(o=i(h=s())),u=0;u<=c;++u)!(u<c&&n(l=a[u],u,a))===f&&((f=!f)?o.lineStart():o.lineEnd()),f&&o.point(+t(l,u,a),+e(l,u,a));if(h)return o=null,h+""||null}return t="function"==typeof t?t:void 0===t?hr:or(t),e="function"==typeof e?e:void 0===e?cr:or(e),a.x=function(e){return arguments.length?(t="function"==typeof e?e:or(+e),a):t},a.y=function(t){return arguments.length?(e="function"==typeof t?t:or(+t),a):e},a.defined=function(t){return arguments.length?(n="function"==typeof t?t:or(!!t),a):n},a.curve=function(t){return arguments.length?(i=t,null!=r&&(o=i(r)),a):i},a.context=function(t){return arguments.length?(null==t?r=o=null:o=i(r=t),a):r},a}().defined(i).curve(s).context(o)}return t="function"==typeof t?t:void 0===t?hr:or(+t),e="function"==typeof e?e:or(void 0===e?0:+e),n="function"==typeof n?n:void 0===n?cr:or(+n),l.x=function(e){return arguments.length?(t="function"==typeof e?e:or(+e),r=null,l):t},l.x0=function(e){return arguments.length?(t="function"==typeof e?e:or(+e),l):t},l.x1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:or(+t),l):r},l.y=function(t){return arguments.length?(e="function"==typeof t?t:or(+t),n=null,l):e},l.y0=function(t){return arguments.length?(e="function"==typeof t?t:or(+t),l):e},l.y1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:or(+t),l):n},l.lineX0=l.lineY0=function(){return h().x(t).y(e)},l.lineY1=function(){return h().x(t).y(n)},l.lineX1=function(){return h().x(r).y(e)},l.defined=function(t){return arguments.length?(i="function"==typeof t?t:or(!!t),l):i},l.curve=function(t){return arguments.length?(s=t,null!=o&&(a=s(o)),l):s},l.context=function(t){return arguments.length?(null==t?o=a=null:a=s(o=t),l):o},l}function dr(t,e,n){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-e),t._y2+t._k*(t._y1-n),t._x2,t._y2)}function pr(t,e){this._context=t,this._k=(1-e)/6}ur.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)}}},pr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:dr(this,this._x1,this._y1)}(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,this._x1=t,this._y1=e;break;case 2:this._point=3;default:dr(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var gr=function t(e){function n(t){return new pr(t,e)}return n.tension=function(e){return t(+e)},n}(0);function yr(t,e){if((i=t.length)>1)for(var n,r,i,o=1,s=t[e[0]],a=s.length;o<i;++o)for(r=s,s=t[e[o]],n=0;n<a;++n)s[n][1]+=s[n][0]=isNaN(r[n][1])?r[n][0]:r[n][1]}function mr(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function vr(t,e){return t[e]}function wr(t){const e=[];return e.key=t,e}function _r(t,e,n){this.k=t,this.x=e,this.y=n}_r.prototype={constructor:_r,scale:function(t){return 1===t?this:new _r(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new _r(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+")"}},_r.prototype;const br="stacked-area-chart",xr="area-path",Cr="tooltip",Mr={fuel:{fractional:"fuel-fractional",perCapita:"fuel-perCapita",total:"fuel-total"},sector:{fractional:"sectoral-fractional",perCapita:"sectoral-perCapita",total:"sectoral-total"}};class $r{static extractDatasetFromMulti(t,e,n){const r=Mr[e][n],i=t[r];if(!i||!Array.isArray(i))throw new Error(`Dataset '${r}' not found or invalid in multi-dataset format`);return i}static transformKendoToD3(t){if(!t||0===t.length)throw new Error("Raw data is empty or invalid");const e=t[0];if(!e||!e.year||!Array.isArray(e.year))throw new Error("First object must contain years array");const n=e.year,r=t.slice(1),i=r.map(t=>t.name);r.forEach(t=>{if(!t.data||t.data.length!==n.length)throw new Error(`Data length mismatch for source: ${t.name}`)});return{data:n.map((t,e)=>{const n={year:t};return r.forEach(t=>{n[t.name]=t.data[e]||0}),n}),energySources:i,years:n}}static createStackedData(t,e){const n=function(){var t=or([]),e=mr,n=yr,r=vr;function i(i){var o,s,a=Array.from(t.apply(this,arguments),wr),u=a.length,l=-1;for(const t of i)for(o=0,++l;o<u;++o)(a[o][l]=[0,+r(t,a[o].key,l,i)]).data=t;for(o=0,s=ar(e(a));o<u;++o)a[s[o]].index=o;return n(a,s),a}return i.keys=function(e){return arguments.length?(t="function"==typeof e?e:or(Array.from(e)),i):t},i.value=function(t){return arguments.length?(r="function"==typeof t?t:or(+t),i):r},i.order=function(t){return arguments.length?(e=null==t?mr:"function"==typeof t?t:or(Array.from(t)),i):e},i.offset=function(t){return arguments.length?(n=null==t?yr:t,i):n},i}().keys(e).order(mr).offset(yr);return n(t)}static calculateDomains(t,e){const n=function(t,e){let n,r;if(void 0===e)for(const e of t)null!=e&&(void 0===n?e>=e&&(n=r=e):(n>e&&(n=e),r<e&&(r=e)));else{let i=-1;for(let o of t)null!=(o=e(o,++i,t))&&(void 0===n?o>=o&&(n=r=o):(n>o&&(n=o),r<o&&(r=o)))}return[n,r]}(t,t=>t.year),r=function(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n<e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n<i||void 0===n&&i>=i)&&(n=i)}return n}(t,t=>e.reduce((e,n)=>e+(t[n]||0),0))||0;return{xDomain:n,yDomain:[0,r]}}static calculateBounds(t,e,n){return{width:t,height:e,innerWidth:Math.max(0,t-n.left-n.right),innerHeight:Math.max(0,e-n.top-n.bottom)}}static getDataAtPoint(t,e,n){const r=t.find(t=>t.year===e);return(null==r?void 0:r[n])||0}static findClosestDataPoint(t,e){return 0===t.length?null:t.reduce((t,n)=>Math.abs(n.year-e)<Math.abs(t.year-e)?n:t)}static extractColors(t){const e={};return t.slice(1).forEach(t=>{t.name&&t.color&&(e[t.name]=t.color)}),e}static validateProcessedData(t,e){return!(!t||0===t.length)&&(!(!e||0===e.length)&&t.every(t=>e.every(e=>"number"==typeof t[e]&&!isNaN(t[e]))))}}class Sr{constructor(){this.listeners=new Map}on(t,e){return this.addListener(t,e,!1)}once(t,e){return this.addListener(t,e,!0)}off(t,e){const n=this.listeners.get(t);n&&(e?(Array.from(n).forEach(t=>{t.handler===e&&n.delete(t)}),0===n.size&&this.listeners.delete(t)):this.listeners.delete(t))}emit(t,e){const n=this.listeners.get(t);n&&0!==n.size&&(Array.from(n).forEach(r=>{r.once&&n.delete(r);try{r.handler(e)}catch(e){console.error(`StackedAreaChart: listener for '${String(t)}' threw`,e)}}),0===n.size&&this.listeners.delete(t))}listenerCount(t){var e,n;return null!==(n=null===(e=this.listeners.get(t))||void 0===e?void 0:e.size)&&void 0!==n?n:0}clear(){this.listeners.clear()}addListener(t,e,n){var r;const i=null!==(r=this.listeners.get(t))&&void 0!==r?r:new Set,o=Array.from(i).find(t=>t.handler===e&&t.once===n),s=null!=o?o:{handler:e,once:n};i.add(s),this.listeners.set(t,i);let a=!1;return()=>{if(a)return;a=!0;const e=this.listeners.get(t);e&&(e.delete(s),0===e.size&&this.listeners.delete(t))}}}function kr(t,e,n,r=!1){const i=function(t,e=1,n=!1){const r=[{value:1,symbol:" W"},{value:1e3,symbol:" kW"},{value:1e6,symbol:" MW"},{value:1e9,symbol:" GW"},{value:1e12,symbol:" TW"},{value:1e15,symbol:" PW"},{value:1e18,symbol:" EW"}],i=/\.0+$|(\.[0-9]*[1-9])0+$/;let o;for(o=r.length-1;o>0;o--){const e=r[o];if(e&&t>=e.value)break}const s=r[o];return s?n?(t/s.value).toFixed(e):(t/s.value).toFixed(e).replace(i,"$1")+s.symbol:t.toString()}(n,1,r);return`${t} - ${e}<br/>${i}`}function Ar(t){return"fractional"===t}class Er{constructor(t,e,n){this.config=n,this.representation="perCapita",this.chartContainer=e;const r="string"==typeof t?document.querySelector(t):t;if(r){"static"===window.getComputedStyle(r).position&&(r.style.position="relative")}const i=Nt(t);this.element=i.append("div").attr("class",Cr),this.element.style("position","absolute").style("visibility","hidden").style("background-color",n.background).style("color",n.color).style("border",`${n.borderWidth}px solid ${n.borderColor}`).style("border-radius","3px").style("padding","8px").style("font-size","12px").style("font-family","Arial, sans-serif").style("pointer-events","none").style("z-index","9999").style("box-shadow","0 2px 4px rgba(0,0,0,0.1)")}show(t,e){const{year:n,energySource:r,value:i}=t,o=kr(n,r,i,Ar(this.representation));this.element.html(o).style("visibility","visible"),this.updatePosition(e)}showAtPosition(t,e,n){const{year:r,energySource:i,value:o}=t,s=kr(r,i,o,Ar(this.representation));this.element.html(s).style("visibility","visible");const a=this.convertToContainerCoordinates(e,n);this.updatePositionFromCoords(a.x,a.y)}showCenteredWithCircle(t,e,n){const{year:r,energySource:i,value:o}=t,s=kr(r,i,o,Ar(this.representation));this.element.html(s).style("visibility","visible"),this.updatePositionWithCenterAlignedToCircle(e,n)}showCenteredWithChartCoordinates(t,e,n){const{year:r,energySource:i,value:o}=t,s=kr(r,i,o,Ar(this.representation));this.element.html(s).style("visibility","visible"),this.updatePositionUsingActualCirclePosition()}updatePositionUsingActualCirclePosition(){const t=this.element.node();if(!t)return;const e=this.chartContainer.querySelector("svg"),n=null==e?void 0:e.querySelector("circle.hover-circle");if(!n)return;const r=n.getBoundingClientRect(),i=this.chartContainer.getBoundingClientRect(),o=t.getBoundingClientRect(),s=r.left+r.width/2,a=r.top+r.height/2,u=s-i.left;let l=u+15,h=a-i.top-o.height/2;const c=this.getContainerBounds();l+o.width>c.width&&(l=u-o.width-15),h<0?h=10:h+o.height>c.height&&(h=c.height-o.height-10),l=Math.max(0,Math.min(l,c.width-o.width)),h=Math.max(0,Math.min(h,c.height-o.height)),this.element.style("left",`${l}px`).style("top",`${h}px`)}showAtCirclePosition(t,e,n){const{year:r,energySource:i,value:o}=t,s=kr(r,i,o,Ar(this.representation));this.element.html(s).style("visibility","visible");const a=this.convertToContainerCoordinates(e,n);this.updatePositionCenteredWithCircle(a.x,a.y)}hide(){this.element.style("visibility","hidden")}updatePosition(t){const e=this.convertToContainerCoordinates(t.pageX,t.pageY);this.updatePositionFromCoords(e.x,e.y)}convertToContainerCoordinates(t,e){const n=this.chartContainer.getBoundingClientRect(),r=t-window.pageXOffset,i=e-window.pageYOffset;let o=r-n.left,s=i-n.top;const a=window.getComputedStyle(this.chartContainer).transform;if(a&&"none"!==a){const t=this.parseTransformMatrix(a);if(t){const e=this.applyInverseTransform(o,s,t);o=e.x,s=e.y}}return{x:o,y:s}}parseTransformMatrix(t){if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(",").map(t=>parseFloat(t.trim()));if(6===e.length)return{a:e[0],b:e[1],c:e[2],d:e[3],e:e[4],f:e[5]}}else if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(",").map(t=>parseFloat(t.trim()));if(16===e.length)return{a:e[0],b:e[1],c:e[4],d:e[5],e:e[12],f:e[13]}}return null}applyInverseTransform(t,e,n){const r=n.a*n.d-n.b*n.c;if(Math.abs(r)<1e-10)return{x:t,y:e};const i=n.d/r,o=-n.b/r,s=-n.c/r,a=n.a/r;return{x:i*t+s*e+(n.c*n.f-n.d*n.e)/r,y:o*t+a*e+(n.b*n.e-n.a*n.f)/r}}updatePositionFromCoords(t,e){const n=this.element.node();if(!n)return;const r=n.getBoundingClientRect();let i=t+this.config.offset.x,o=e+this.config.offset.y;const s=this.getContainerBounds();i+r.width>s.width&&(i=t-r.width-Math.abs(this.config.offset.x)),o+r.height>s.height&&(o=e-r.height-Math.abs(this.config.offset.y)),i=Math.max(0,Math.min(i,s.width-r.width)),o=Math.max(0,Math.min(o,s.height-r.height)),this.element.style("left",`${i}px`).style("top",`${o}px`)}getContainerBounds(){const t=this.chartContainer.getBoundingClientRect(),e=window.getComputedStyle(this.chartContainer),n=parseFloat(e.paddingLeft)||0,r=parseFloat(e.paddingRight)||0,i=parseFloat(e.paddingTop)||0,o=parseFloat(e.paddingBottom)||0;return{width:t.width-n-r,height:t.height-i-o}}updatePositionWithCenterAlignedToCircle(t,e){const n=this.convertToContainerCoordinates(t,e);this.updatePositionCenteredWithCircle(n.x,n.y)}updatePositionCenteredWithCircle(t,e){const n=this.element.node();if(!n)return;const r=n.getBoundingClientRect(),i=this.chartContainer.querySelector("svg"),o=null==i?void 0:i.querySelector("g[transform]");let s=0,a=0;if(o){const t=o.getAttribute("transform");if(t){const e=t.match(/translate\(([^,]+),\s*([^)]+)\)/);e&&e[1]&&e[2]&&(s=parseFloat(e[1])||0,a=parseFloat(e[2])||0)}}const u=t+s;let l=u+15,h=e+a-r.height/2;const c=this.getContainerBounds();l+r.width>c.width&&(l=u-r.width-15),h<0?h=10:h+r.height>c.height&&(h=c.height-r.height-10),l=Math.max(0,Math.min(l,c.width-r.width)),h=Math.max(0,Math.min(h,c.height-r.height)),this.element.style("left",`${l}px`).style("top",`${h}px`)}setRepresentation(t){this.representation=t}updateConfig(t){this.config={...this.config,...t},this.element.style("background-color",this.config.background).style("color",this.config.color).style("border",`${this.config.borderWidth}px solid ${this.config.borderColor}`)}isVisible(){return"visible"===this.element.style("visibility")}destroy(){this.element.remove()}getElement(){return this.element.node()}}const Nr={Solar:"#fed530",Nuclear:"#ca0813",Water:"#0b24fb",Wind:"#901d8f",Geothermal:"#905a1c","Natural Gas":"#4cabf2",Coal:"#000000",Biomass:"#46be48",Petroleum:"#095f0b"};class Dr{constructor(t,e){this.tooltip=null,this.currentData=[],this.currentEnergySources=[],this.currentColors={},this.hoverIndicator=null,this.hoverCircle=null,this.config=e,this.bounds=$r.calculateBounds(e.dimensions.width,e.dimensions.height,e.dimensions.margin),this.chartContainer="string"==typeof t?document.getElementById(t)||document.body:t,this.initializeSVG(t),this.initializeScales(),this.initializeAreaGenerator(),e.interactive&&this.initializeTooltip(t)}initializeSVG(t){const e=Nt(t);e.selectAll("*").remove(),this.svg=e.append("svg").attr("class",br),this.svg.attr("width",this.config.dimensions.width).attr("height",this.config.dimensions.height).style("display","block"),this.chartGroup=this.svg.append("g").attr("transform",`translate(${this.config.dimensions.margin.left}, ${this.config.dimensions.margin.top})`)}initializeScales(){this.xScale=ir().range([0,this.bounds.innerWidth]),this.yScale=ir().range([this.bounds.innerHeight,0])}initializeAreaGenerator(){this.area=fr().x(t=>this.xScale(t.data.year)).y0(t=>this.yScale(t[0])).y1(t=>this.yScale(t[1])).curve(gr.tension(.1))}initializeTooltip(t){if(!this.config.interactive)return;const e="string"==typeof t?document.querySelector(t):t;e&&(this.tooltip=new Er(e,this.chartContainer,this.config.tooltip),this.tooltip.setRepresentation(this.config.representation))}initializeHoverIndicator(){this.config.interactive&&(this.hoverIndicator&&this.hoverIndicator.remove(),this.hoverIndicator=this.chartGroup.append("g").attr("class","hover-indicator").style("opacity",0).style("pointer-events","none"),this.hoverCircle=this.hoverIndicator.append("circle").attr("class","hover-circle").attr("r",4).attr("fill","white").attr("stroke","white").attr("stroke-width",2).style("filter","drop-shadow(0px 1px 2px rgba(0,0,0,0.5))"))}render(t,e,n){if(this.currentData=t,this.currentEnergySources=e,n&&(this.currentColors=n),0===t.length||0===e.length)return void this.clearChart();this.updateScales(t,e);const r=$r.createStackedData(t,e);this.renderAreas(r),this.initializeHoverIndicator()}update(t,e,n){if(this.currentData=t,this.currentEnergySources=e,n&&(this.currentColors=n),0===t.length||0===e.length)return void this.clearChart();this.updateScales(t,e);const r=$r.createStackedData(t,e);this.updateAreas(r),this.hoverIndicator&&this.hoverIndicator.raise()}updateScales(t,e){const n=$r.calculateDomains(t,e);this.xScale.domain(n.xDomain),this.yScale.domain(n.yDomain),this.area.x(t=>this.xScale(t.data.year)).y0(t=>this.yScale(t[0])).y1(t=>this.yScale(t[1]))}renderAreas(t){const e=this.chartGroup.selectAll("."+xr).data(t,t=>t.key),n=e.enter().append("path").attr("class",xr).attr("fill",t=>this.getColorForSource(t.key)).attr("opacity",1).attr("d",this.area).style("cursor",this.config.interactive?"pointer":"default");e.attr("fill",t=>this.getColorForSource(t.key)).transition().duration(this.config.animations.enabled?this.config.animations.duration:0).attr("d",this.area),e.exit().transition().duration(this.config.animations.enabled?this.config.animations.duration:0).attr("opacity",0).remove(),this.config.interactive&&(this.addInteractions(n),this.addInteractions(e))}updateAreas(t){const e=this.chartGroup.selectAll("."+xr).data(t,t=>t.key),n=e.enter().append("path").attr("class",xr).attr("fill",t=>this.getColorForSource(t.key)).attr("opacity",0).attr("d",this.area).style("cursor",this.config.interactive?"pointer":"default");n.transition().duration(this.config.animations.enabled?this.config.animations.duration:0).attr("opacity",1),e.attr("fill",t=>this.getColorForSource(t.key)).transition().duration(this.config.animations.enabled?this.config.animations.duration:0).attr("d",this.area),e.exit().transition().duration(this.config.animations.enabled?this.config.animations.duration:0).attr("opacity",0).remove(),this.config.interactive&&(this.addInteractions(n),this.addInteractions(e))}addInteractions(t){this.tooltip&&this.config.interactive&&(t.on("mouseover",null).on("mousemove",null).on("mouseout",null),t.on("mouseover",t=>{Nt(t.target).transition().duration(100).attr("opacity",1.1),this.showHoverIndicator()}).on("mousemove",(t,e)=>{if(!this.tooltip)return;const[n]=function(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}(t,this.chartGroup.node()),r=Math.round(this.xScale.invert(n)),i=this.getColorForSource(e.key),o=this.updateHoverIndicatorForLayer(n,e,i),s=this.currentData.find(t=>t.year===r);if(s&&e.key&&o){const t=s[e.key]||0;this.tooltip.showCenteredWithChartCoordinates({year:r,energySource:e.key,value:t},o.x,o.y)}}).on("mouseout",t=>{Nt(t.target).transition().duration(100).attr("opacity",1),this.tooltip&&this.tooltip.hide(),this.hideHoverIndicator(),this.hoverCircle&&this.hoverCircle.attr("fill","white")}))}clearChart(){this.chartGroup.selectAll("*").remove()}resize(t,e){this.config.dimensions.width=t,this.config.dimensions.height=e,this.bounds=$r.calculateBounds(t,e,this.config.dimensions.margin),this.svg.attr("width",t).attr("height",e),this.xScale.range([0,this.bounds.innerWidth]),this.yScale.range([this.bounds.innerHeight,0]),this.currentData.length>0&&this.render(this.currentData,this.currentEnergySources)}updateConfig(t){this.config={...this.config,...t},this.tooltip&&(this.tooltip.setRepresentation(this.config.representation),t.tooltip&&this.tooltip.updateConfig(t.tooltip))}destroy(){this.svg.remove(),this.tooltip&&this.tooltip.destroy()}showHoverIndicator(){this.hoverIndicator&&this.config.interactive&&this.hoverIndicator.transition().duration(100).style("opacity",1)}hideHoverIndicator(){this.hoverIndicator&&this.config.interactive&&this.hoverIndicator.transition().duration(100).style("opacity",0)}updateHoverIndicatorForLayer(t,e,n){if(!this.hoverIndicator||!this.hoverCircle||!this.config.interactive)return null;const r=Math.max(0,Math.min(this.bounds.innerWidth,t)),i=Math.round(this.xScale.invert(r)),o=e.find(t=>t.data.year===i);if(o){const t=this.yScale(o[1]);return this.hoverCircle.attr("cx",r).attr("cy",t).attr("fill",n),{x:r,y:t}}return null}getColorForSource(t){return this.currentColors[t]||function(t){return Nr[t]||"#cccccc"}(t)}getSVG(){return this.svg.node()}}class Ir{constructor(t,n){var r,i;this.currentData=[],this.currentEnergySources=[],this.currentColors={},this.multiDataset=null,this.emitter=new Sr,this.resizeObserver=null,this.windowResizeHandler=null,this.controlInputs=[],this.destroyed=!1,this.onControlChange=()=>{this.handleControlChange()};const o=document.getElementById(t);if(!o)throw new Error(`Container element with ID '${t}' not found`);this.containerId=t,this.containerElement=o,this.config=this.mergeConfig(e,n),(null==n?void 0:n.events)&&this.registerConfiguredListeners(n.events),(null===(r=null==n?void 0:n.dimensions)||void 0===r?void 0:r.width)||(this.config.dimensions.width=this.calculateContainerWidth()),(null===(i=null==n?void 0:n.dimensions)||void 0===i?void 0:i.height)||(this.config.dimensions.height=this.calculateOptimalHeight()),this.setupChartStructure(),this.renderer=new Dr(this.getChartContainer(),this.config),this.setupEmbeddedControls(),this.setupResponsiveBehavior(),(null==n?void 0:n.data)&&(this.multiDataset=n.data,this.loadDataForCurrentSettings(),this.render())}setupChartStructure(){this.containerElement.innerHTML="";const t=document.createElement("div");t.className="stacked-chart-wrapper",t.setAttribute("data-stacked-area-chart",""),t.style.width="100%",t.style.fontFamily="Arial, sans-serif";const e=document.createElement("div");e.id=`${this.containerId}-chart`,e.className="stacked-chart-svg-container",e.style.width="100%",e.style.height=`${this.config.dimensions.height}px`,e.style.overflow="hidden";const n=document.createElement("div");n.className="stacked-chart-controls",n.style.display="flex",n.style.justifyContent="space-between",n.style.alignItems="center",n.style.padding="15px",n.style.fontSize="14px",t.appendChild(e),t.appendChild(n),this.containerElement.appendChild(t)}getChartContainer(){const t=document.getElementById(`${this.containerId}-chart`);if(!t)throw new Error("Chart container not found");return t}setupEmbeddedControls(){const t=this.containerElement.querySelector(".stacked-chart-controls");if(!t)return;const e=`mode-${this.containerId}`,n=`repr-${this.containerId}`,r=document.createElement("div");r.className="control-group view-type-group",r.style.display="flex",r.style.gap="15px",r.innerHTML=`\n            <label style="cursor: pointer;">\n                <input type="radio" name="${e}" value="fuel" ${"fuel"===this.config.mode?"checked":""} style="margin-right: 5px;"> By Fuel\n            </label>\n            <label style="cursor: pointer;">\n                <input type="radio" name="${e}" value="sector" ${"sector"===this.config.mode?"checked":""} style="margin-right: 5px;"> By Sector\n            </label>\n        `;const i=document.createElement("div");i.className="control-group representation-group",i.style.display="flex",i.style.gap="15px",i.innerHTML=`\n            <label style="cursor: pointer;">\n                <input type="radio" name="${n}" value="fractional" ${"fractional"===this.config.representation?"checked":""} style="margin-right: 5px;"> Fractional\n            </label>\n            <label style="cursor: pointer;">\n                <input type="radio" name="${n}" value="perCapita" ${"perCapita"===this.config.representation?"checked":""} style="margin-right: 5px;"> Per Capita\n            </label>\n            <label style="cursor: pointer;">\n                <input type="radio" name="${n}" value="total" ${"total"===this.config.representation?"checked":""} style="margin-right: 5px;"> Total\n            </label>\n        `,t.appendChild(r),t.appendChild(i),this.attachControlEventListeners(e,n)}attachControlEventListeners(t,e){[...Array.from(this.containerElement.querySelectorAll(`input[name="${t}"]`)),...Array.from(this.containerElement.querySelectorAll(`input[name="${e}"]`))].forEach(t=>{t.addEventListener("change",this.onControlChange),this.controlInputs.push(t)})}handleControlChange(){if(this.destroyed)return;const t=`mode-${this.containerId}`,e=`repr-${this.containerId}`,n=this.containerElement.querySelector(`input[name="${t}"]:checked`),r=this.containerElement.querySelector(`input[name="${e}"]:checked`);if(n&&r){const t=n.value,e=r.value;try{this.applyView(t,e,"user")}catch(t){this.emitError(t,"view-change")}}}applyView(t,e,n){const r=this.config.mode,i=this.config.representation;this.config.mode=t,this.config.representation=e,this.renderer.updateConfig({mode:t,representation:e}),this.loadDataForCurrentSettings(),this.update(),this.emitter.emit("view.changed",{mode:t,representation:e,previousMode:r,previousRepresentation:i,trigger:n})}emitError(t,e){const n=t instanceof Error?t:new Error(String(t));if(0===this.emitter.listenerCount("chart.error"))throw n;this.emitter.emit("chart.error",{error:n,phase:e})}registerConfiguredListeners(t){t["view.changed"]&&this.emitter.on("view.changed",t["view.changed"]),t["chart.error"]&&this.emitter.on("chart.error",t["chart.error"])}loadDataForCurrentSettings(){if(!this.multiDataset)throw new Error("No data available. Provide data via data() method or config.");const t=$r.extractDatasetFromMulti(this.multiDataset,this.config.mode,this.config.representation);this.processAndStoreData(t)}calculateContainerWidth(){const t=window.getComputedStyle(this.containerElement),e=parseInt(t.width,10)-(parseInt(t.paddingLeft,10)||0)-(parseInt(t.paddingRight,10)||0)-(parseInt(t.borderLeftWidth,10)||0)-(parseInt(t.borderRightWidth,10)||0);return Math.max(e||800,200)}calculateOptimalHeight(){const t=this.config.dimensions.width,e=Math.round(.25*t);return Math.max(150,Math.min(e,400))}setupResponsiveBehavior(){"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(t=>{if(!this.destroyed)for(const e of t){const t=e.contentRect.width;if(t>0&&Math.abs(t-this.config.dimensions.width)>10){this.config.dimensions.width=Math.max(t,200);try{this.renderer.resize(this.config.dimensions.width,this.config.dimensions.height),this.updateChartContainerWidth()}catch(t){this.emitError(t,"resize")}}}}),this.resizeObserver.observe(this.containerElement)):(this.windowResizeHandler=()=>{setTimeout(()=>{if(this.destroyed)return;const t=this.calculateContainerWidth();if(Math.abs(t-this.config.dimensions.width)>10){this.config.dimensions.width=t;try{this.renderer.resize(this.config.dimensions.width,this.config.dimensions.height),this.updateChartContainerWidth()}catch(t){this.emitError(t,"resize")}}},100)},window.addEventListener("resize",this.windowResizeHandler))}updateChartContainerWidth(){this.getChartContainer().style.width="100%"}width(t){return this.config.dimensions.width=t,this.renderer.resize(t,this.config.dimensions.height),this}height(t){return this.config.dimensions.height=t,this.renderer.resize(this.config.dimensions.width,t),this}data(t){return this.isMultiDatasetFormat(t)?(this.multiDataset=t,this.loadDataForCurrentSettings()):this.processAndStoreData(t),this}isMultiDatasetFormat(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"fuel-fractional"in t&&"fuel-perCapita"in t&&"fuel-total"in t}mode(t){return this.config.mode=t,this.renderer.updateConfig({mode:t}),this}representation(t){return this.config.representation=t,this.renderer.updateConfig({representation:t}),this}configure(t){return this.config=this.mergeConfig(this.config,t),this.renderer.updateConfig(this.config),t.events&&this.registerConfiguredListeners(t.events),this}render(){return this.currentData.length>0&&this.currentEnergySources.length>0&&this.renderer.render(this.currentData,this.currentEnergySources,this.currentColors),this}update(){return this.currentData.length>0&&this.currentEnergySources.length>0&&this.renderer.update(this.currentData,this.currentEnergySources,this.currentColors),this}updateData(t){return this.data(t),this.update(),this}switchDataSource(t,e){return this.applyView(t,e,"api"),this}resize(t,e){const n=null!=t?t:this.config.dimensions.width,r=null!=e?e:this.config.dimensions.height;return this.config.dimensions.width=n,this.config.dimensions.height=r,this.renderer.resize(n,r),this}on(t,e){return this.emitter.on(t,e)}once(t,e){return this.emitter.once(t,e)}off(t,e){return this.emitter.off(t,e),this}destroy(){this.destroyed||(this.destroyed=!0,this.controlInputs.forEach(t=>{t.removeEventListener("change",this.onControlChange)}),this.controlInputs=[],this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.windowResizeHandler&&(window.removeEventListener("resize",this.windowResizeHandler),this.windowResizeHandler=null),this.renderer.destroy(),this.emitter.clear())}getConfig(){return{...this.config}}getData(){return[...this.currentData]}getEnergySources(){return[...this.currentEnergySources]}getSVG(){return this.renderer.getSVG()}hasData(){return this.currentData.length>0&&this.currentEnergySources.length>0}processAndStoreData(t){const e=$r.transformKendoToD3(t);this.currentData=e.data,this.currentEnergySources=e.energySources,this.currentColors=$r.extractColors(t),Object.keys(this.currentColors).length>0&&(this.config.colors={...this.config.colors,...this.currentColors},this.renderer.updateConfig({colors:this.config.colors}))}mergeConfig(t,e){if(!e)return{...t};const n={...t};return e.dimensions&&(n.dimensions={...t.dimensions,...e.dimensions},e.dimensions.margin&&(n.dimensions.margin={...t.dimensions.margin,...e.dimensions.margin})),e.tooltip&&(n.tooltip={...t.tooltip,...e.tooltip},e.tooltip.offset&&(n.tooltip.offset={...t.tooltip.offset,...e.tooltip.offset})),e.animations&&(n.animations={...t.animations,...e.animations}),e.colors&&(n.colors={...t.colors,...e.colors}),Object.keys(e).forEach(t=>{"dimensions"!==t&&"tooltip"!==t&&"animations"!==t&&"colors"!==t&&"events"!==t&&(n[t]=e[t])}),n}}t.DEFAULT_CONFIG=e,t.StackedAreaChart=Ir,t.default=Ir,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=/sm/f1a851107ef13e026cbf34a1887cfc726203f8bab1013c44d2566d7724ccf9bd.map