1"use strict";(self.webpackChunkecotricity=self.webpackChunkecotricity||[]).push([[1621],{1621:function(t,e,n){n.r(e),n.d(e,{eco_gen_mix_legend:function(){return g},eco_gen_mix_pie:function(){return W}});var i,a,r=n(4883),s=n(8154),o=n(2305);!function(t){t.Solar="solar",t.Wind="wind",t.Hydro="hydro",t.Gas="gas",t.Oil="oil",t.Coal="coal",t.Other="other",t.Imports="imports",t.Nuclear="nuclear",t.Biomass="biomass"}(i||(i={})),function(t){t.Green="greenCat",t.Other="otherCat",t.Brown="brownCat"}(a||(a={}));const l={solar:1,wind:2,hydro:3,biomass:4,nuclear:5,imports:6,other:7,coal:8,oil:9,gas:10},h={solar:"Sun",wind:"Wind",hydro:"Hydro",gas:"Gas",coal:"Coal",oil:"Oil",imports:"Imports",nuclear:"Nuclear",biomass:"Biomass",other:"Other"},c={solar:a.Green,wind:a.Green,hydro:a.Green,biomass:a.Green,gas:a.Brown,coal:a.Brown,oil:a.Brown,imports:a.Other,nuclear:a.Other,other:a.Other},u={[a.Green]:"Green",[a.Other]:"Other",[a.Brown]:"Fossil"},d={nuclear:{width:40,height:40,scale:.25,background:"#004e68",shape:'<path d="M11 6a5 5 0 01-5 5 5 5 0 01-5-5 5 5 0 015-5 5 5 0 015 5" stroke-width="1" stroke="none" fill="#ffffff"/>'},biomass:{width:70,height:8,scale:.25,background:"#4375cb",shape:'<path d="M-.02 22c8.373 0 11.938-4.695 16.32-9.662C20.785 7.258 25.728 2 35 2c9.272 0 14.215 5.258 18.7 10.338C58.082 17.305 61.647 22 70.02 22M-.02 14.002C8.353 14 11.918 9.306 16.3 4.339 20.785-.742 25.728-6 35-6 44.272-6 49.215-.742 53.7 4.339c4.382 4.967 7.947 9.661 16.32 9.664M70 6.004c-8.373-.001-11.918-4.698-16.3-9.665C49.215-8.742 44.272-14 35-14c-9.272 0-14.215 5.258-18.7 10.339C11.918 1.306 8.353 6-.02 6.002" stroke-width="1" stroke="#151515" fill="none"/>'},hydro:{width:20,height:20,scale:.25,background:"#066b5f",shape:'<path d="M 10,-2.55e-7 V 20 Z M -1.1677362e-8,10 H 20 Z" stroke-width="1" stroke="#ffffff" fill="none"/>'},wind:{width:40,height:40,scale:.25,background:"#2aaf28",shape:'<path d="M0 0h10v20H0zM30 0v10H10V0zM10 10h10v20H10zM40 10v10H20V10zM20 20h10v20H20zM50 20v10H30V20zM30 30h10v20H30zM20 30v10H0V30zM10 20v10h-20V20zM30-10h10v20H30z" stroke-width="1" stroke="#151515" fill="none"/>'},coal:{width:20,height:20,scale:.25,background:"#151515",shape:'<path d="M 10,-2.55e-7 V 20 Z M -1.1677362e-8,10 H 20 Z" stroke-width="1" stroke="#ffffff" fill="none"/>'},gas:{width:60,height:60,scale:.25,background:"#9c4f03",shape:'<path d="M6.13-.002.005 6.125v1.059L6.59 13.77l.013-.014 16.243 16.24L6.617 46.23.535 40.15l10.147-10.153L.004 19.318v1.037l9.644 9.641-9.646 9.65v1.03L12.73 53.402l-6.082 6.082-6.127-6.127.014-.015-.533-.531v1.06l6.127 6.127h1.055l6.586-6.584-.012-.012 16.246-16.246L46.236 53.39l-6.082 6.082-10.15-10.15-10.68 10.677h1.033l9.647-9.644 9.646 9.644h1.034l12.722-12.723 6.082 6.082-6.125 6.125-.013-.011-.528.527h1.057l6.123-6.123V52.81l-6.58-6.58-.016.015L37.16 29.996 53.393 13.77l6.082 6.082-10.15 10.144 10.677 10.678v-1.031l-9.647-9.647 9.647-9.64v-1.038L47.279 6.596 53.361.514l6.13 6.127-.016.013.527.53V6.123L53.879-.002h-1.057l-6.586 6.586.014.012-16.244 16.246L13.77 6.607l6.082-6.08 10.153 10.15L40.684-.001H39.65l-9.646 9.647-9.647-9.647h-1.03L6.601 12.723.52 6.64 6.646.514l.012.013.528-.529H6.13zm7.114 7.113 16.76 16.76 16.762-16.76 6.127 6.127-16.764 16.758 16.764 16.762-6.127 6.127-16.76-16.76-16.762 16.76-6.127-6.127 16.758-16.762L7.117 13.238l6.127-6.127z" stroke-width="1" stroke="none" fill="#ffffff"/>'},solar:{width:35.783,height:83.523,scale:.25,background:"#ffd600",shape:'<path d="m14.13 80.123 3.694-8.621-3.694-8.621-3.694 8.62zM7.597 78.13l6.533 15.25 6.533-15.25-2.84-6.628-3.693 8.621-3.694-8.621zm0 0-2.84 6.628 9.373 21.878 9.372-21.878-2.84-6.628-6.532 15.25zm24.425-39.768 3.693-8.622-3.693-8.62-3.694 8.62zm-6.534-1.993 6.534 15.249 6.532-15.25-2.839-6.628-3.693 8.622-3.694-8.622zm0 0-2.84 6.628 9.374 21.877 9.372-21.877-2.84-6.628-6.532 15.249zM19.81 49.625 32.022 78.13l12.212-28.505-2.84-6.628-9.372 21.877-9.373-21.877zm0 0-2.84 6.628 15.053 35.133 15.051-35.133-2.839-6.628L32.022 78.13zM14.13 62.88l17.892 41.761 17.89-41.761-2.839-6.628-15.051 35.133L16.97 56.253zM-.067 29.74l-3.694-8.622-3.694 8.621 3.694 8.622zm-7.388 0-2.84 6.628 6.534 15.249 6.533-15.25-2.84-6.628-3.693 8.622zm3.694 21.877-6.533-15.25-2.84 6.629 9.373 21.877L5.61 42.997l-2.84-6.628zm-9.373-8.621-2.84 6.628L-3.76 78.13 8.45 49.625l-2.84-6.628-9.372 21.877zm9.373 35.133-12.213-28.505-2.84 6.628L-3.76 91.386 11.29 56.253l-2.839-6.628zm-15.052-21.877-2.84 6.628 17.892 41.761L14.13 62.881l-2.84-6.628L-3.76 91.386zm38.622-90.151-2.84 6.628L32.023 7.863 47.073-27.27l-2.839-6.628L32.022-5.392zM14.13-20.642l17.892 41.761 17.89-41.761-2.839-6.628L32.022 7.863
116.97-27.27zM-3.761-5.392l-12.213-28.506-2.84 6.628L-3.76 7.863 11.29-27.27l-2.839-6.628zM-18.813-27.27l-2.84 6.628L-3.76 21.119 14.13-20.642l-2.84-6.628L-3.76 7.863zm29.25 15.249-2.84 6.628 6.533 15.25 6.533-15.25-2.84-6.628L14.13-3.4zM14.13 9.856 7.597-5.393l-2.84 6.628 9.373 21.878 9.372-21.878-2.84-6.628zm-9.373-8.62-2.84 6.627L14.13 36.37 26.342 7.863l-2.84-6.628-9.372 21.878zm9.373 35.133L1.918 7.863l-2.84 6.629L14.13 49.625l15.052-35.133-2.84-6.629zM-.922 14.492l-2.84 6.627L14.13 62.881l17.891-41.762-2.84-6.627L14.13 49.625zM40.54 1.235 37.7 7.863 49.914 36.37 62.126 7.863l-2.84-6.628-9.373 21.878zm9.373 35.134L37.701 7.863l-2.84 6.629 15.052 35.133 15.052-35.133-2.84-6.629zM34.861 14.492l-2.84 6.627 17.892 41.762 17.891-41.762-2.84-6.627-15.05 35.133z" stroke-linecap="square" stroke-width="1" stroke="#757575" fill="none"/>'},other:{width:20,height:20,scale:.25,background:"#757575",shape:'<path d="M3.25 10h13.5M10 3.25v13.5" stroke-linecap="square" stroke-width="1" stroke="#ffffff" fill="none"/>'},oil:{width:20,height:20,scale:.25,background:"#a52a2a",shape:'<path d="M-2 22L22-2" stroke-width="2" stroke="#d9a3a3" fill="none"/>'},imports:{width:20,height:20,scale:.25,background:"#8e9492",shape:'<path d="M-2 22L22-2" stroke-width="2" stroke-dasharray="4 3" stroke="#ffffff" fill="none"/>'}};function f(t){const{width:e,height:n,scale:i,background:a,shape:r}=d[t];return`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${e*i}" height="${n*i}" viewBox="0 0 ${e} ${n}"><rect width="${e}" height="${n}" fill="${a}"/>`+r+"</svg>")}`}const p=Object.entries(l).sort(([,t],[,e])=>t-e).map(([t])=>t),g=class{constructor(t){(0,r.r)(this,t),this.volumes=void 0}handleKeyDown(t){if("ArrowDown"!==t.key&&"ArrowUp"!==t.key)return;t.preventDefault();const e=t.currentTarget,n="ArrowDown"===t.key?e.nextElementSibling:e.previousElementSibling;n instanceof HTMLElement&&n.focus()}render(){const t=this.volumes?p.filter(t=>this.volumes[t]>0):p,e=this.volumes?Object.values(this.volumes).reduce((t,e)=>t+("number"==typeof e?e:0),0):0;return(0,r.h)(r.H,{key:"23aef9b7af1bdd03f24b19828da0300a3a50312a"},(0,r.h)("div",{key:"d8386a4681eebad214abb60632967051bc373f6c",class:"legend-list"},t.map(t=>{const{width:n,height:i}=function(t){const{width:e,height:n,scale:i}=d[t];return{width:e*i,height:n*i}}(t),a=e?(0,s.a)(this.volumes[t],e,1,0):"";return(0,r.h)("div",{class:"legend-item",tabindex:"0",onKeyDown:this.handleKeyDown},(0,r.h)("div",{class:"legend-icon","aria-hidden":"true",style:{backgroundImage:`url("${f(t)}")`,backgroundSize:`${n}px ${i}px`}}),(0,r.h)("div",{class:"legend-label"},h[t]," ",a))})))}get element(){return(0,r.g)(this)}};function v(t){return function(){return t}}g.style=":host{--font-family:'Open sans', Arial, Helvetica, sans-serif;--font-size:16px;--font-weight:400;--icon-width:24px;--icon-height:24px;display:block;font-family:var(--font-family);font-size:var(--font-size);font-weight:var(--font-weight)}.legend-list{display:grid;grid-template-columns:repeat(3, max-content);justify-content:center;column-gap:24px;row-gap:12px}.legend-item{display:flex;flex-direction:row;align-items:center;gap:8px}.legend-label{line-height:1;letter-spacing:0;text-align:center;white-space:nowrap}.legend-icon{box-sizing:border-box;width:var(--icon-width);height:var(--icon-height);border:0.5px solid #151515;border-radius:3px;flex-shrink:0}";const y=Math.abs,m=Math.atan2,w=Math.cos,x=Math.max,b=Math.min,$=Math.sin,k=Math.sqrt,T=1e-12,M=Math.PI,_=M/2,A=2*M;function z(t){return t>=1?_:t<=-1?-_:Math.asin(t)}const C=Math.PI,L=2*C,V=1e-6,H=L-V;function R(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}class O{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?R:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return R;const n=10**e;return function(t){this._+=t[0];for(let e=1,i=t.length;e<i;++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,i){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+i}`}bezierCurveTo(t,e,n,i,a,r){this._append`C${+t},${+e},${+n},${+i},${this._x1=+a},${this._y1=+r}`}arcTo(t,e,n,i,a){if(t=+t,e=+e,n=+n,i=+i,(a=+a)<0)throw new Error(`negative radius: ${a}`);let r=this._x1,s=this._y1,o=n-t,l=i-e,h=r-t,c=s-e,u=h*h+c*c;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(u>V)if(Math.abs(c*o-l*h)>V&&a){let d=n-r,f=i-s,p=o*o+l*l,g=d*d+f*f,v=Math.sqrt(p),y=Math.sqrt(u),m=a*Math.tan((C-Math.acos((p+u-g)/(2*v*y))
vendor: 5,073 bytes, line 1
1)/2),w=m/y,x=m/v;Math.abs(w-1)>V&&this._append`L${t+w*h},${e+w*c}`,this._append`A${a},${a},0,0,${+(c*d>h*f)},${this._x1=t+x*o},${this._y1=e+x*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,i,a,r){if(t=+t,e=+e,r=!!r,(n=+n)<0)throw new Error(`negative radius: ${n}`);let s=n*Math.cos(i),o=n*Math.sin(i),l=t+s,h=e+o,c=1^r,u=r?i-a:a-i;null===this._x1?this._append`M${l},${h}`:(Math.abs(this._x1-l)>V||Math.abs(this._y1-h)>V)&&this._append`L${l},${h}`,n&&(u<0&&(u=u%L+L),u>H?this._append`A${n},${n},0,1,${c},${t-s},${e-o}A${n},${n},0,1,${c},${this._x1=l},${this._y1=h}`:u>V&&this._append`A${n},${n},0,${+(u>=C)},${c},${this._x1=t+n*Math.cos(a)},${this._y1=e+n*Math.sin(a)}`)}rect(t,e,n,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+i}h${-n}Z`}toString(){return this._}}function S(t){return t.innerRadius}function G(t){return t.outerRadius}function P(t){return t.startAngle}function j(t){return t.endAngle}function B(t){return t&&t.padAngle}function D(t,e,n,i,a,r,s){var o=t-n,l=e-i,h=(s?r:-r)/k(o*o+l*l),c=h*l,u=-h*o,d=t+c,f=e+u,p=n+c,g=i+u,v=(d+p)/2,y=(f+g)/2,m=p-d,w=g-f,b=m*m+w*w,$=a-r,T=d*g-p*f,M=(w<0?-1:1)*k(x(0,$*$*b-T*T)),_=(T*w-m*M)/b,A=(-T*m-w*M)/b,z=(T*w+m*M)/b,C=(-T*m+w*M)/b,L=_-v,V=A-y,H=z-v,R=C-y;return L*L+V*V>H*H+R*R&&(_=z,A=C),{cx:_,cy:A,x01:-c,y01:-u,x11:_*(a/$-1),y11:A*(a/$-1)}}function E(){var t=S,e=G,n=v(0),i=null,a=P,r=j,s=B,o=null,l=function(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 O(e)}(h);function h(){var h,c,u,d=+t.apply(this,arguments),f=+e.apply(this,arguments),p=a.apply(this,arguments)-_,g=r.apply(this,arguments)-_,v=y(g-p),x=g>p;if(o||(o=h=l()),f<d&&(c=f,f=d,d=c),f>T)if(v>A-T)o.moveTo(f*w(p),f*$(p)),o.arc(0,0,f,p,g,!x),d>T&&(o.moveTo(d*w(g),d*$(g)),o.arc(0,0,d,g,p,x));else{var C,L,V=p,H=g,R=p,O=g,S=v,G=v,P=s.apply(this,arguments)/2,j=P>T&&(i?+i.apply(this,arguments):k(d*d+f*f)),B=b(y(f-d)/2,+n.apply(this,arguments)),E=B,F=B;if(j>T){var q=z(j/d*$(P)),U=z(j/f*$(P));(S-=2*q)>T?(R+=q*=x?1:-1,O-=q):(S=0,R=O=(p+g)/2),(G-=2*U)>T?(V+=U*=x?1:-1,H-=U):(G=0,V=H=(p+g)/2)}var I=f*w(V),Z=f*$(V),W=d*w(O),N=d*$(O);if(B>T){var K,Q=f*w(H),J=f*$(H),X=d*w(R),Y=d*$(R);if(v<M)if(K=function(t,e,n,i,a,r,s,o){var l=n-t,h=i-e,c=s-a,u=o-r,d=u*l-c*h;if(!(d*d<T))return[t+(d=(c*(e-r)-u*(t-a))/d)*l,e+d*h]}(I,Z,X,Y,Q,J,W,N)){var tt=I-K[0],et=Z-K[1],nt=Q-K[0],it=J-K[1],at=1/$(((u=(tt*nt+et*it)/(k(tt*tt+et*et)*k(nt*nt+it*it)))>1?0:u<-1?M:Math.acos(u))/2),rt=k(K[0]*K[0]+K[1]*K[1]);E=b(B,(d-rt)/(at-1)),F=b(B,(f-rt)/(at+1))}else E=F=0}G>T?F>T?(C=D(X,Y,I,Z,f,F,x),L=D(Q,J,W,N,f,F,x),o.moveTo(C.cx+C.x01,C.cy+C.y01),F<B?o.arc(C.cx,C.cy,F,m(C.y01,C.x01),m(L.y01,L.x01),!x):(o.arc(C.cx,C.cy,F,m(C.y01,C.x01),m(C.y11,C.x11),!x),o.arc(0,0,f,m(C.cy+C.y11,C.cx+C.x11),m(L.cy+L.y11,L.cx+L.x11),!x),o.arc(L.cx,L.cy,F,m(L.y11,L.x11),m(L.y01,L.x01),!x))):(o.moveTo(I,Z),o.arc(0,0,f,V,H,!x)):o.moveTo(I,Z),d>T&&S>T?E>T?(C=D(W,N,Q,J,d,-E,x),L=D(I,Z,X,Y,d,-E,x),o.lineTo(C.cx+C.x01,C.cy+C.y01),E<B?o.arc(C.cx,C.cy,E,m(C.y01,C.x01),m(L.y01,L.x01),!x):(o.arc(C.cx,C.cy,E,m(C.y01,C.x01),m(C.y11,C.x11),!x),o.arc(0,0,d,m(C.cy+C.y11,C.cx+C.x11),m(L.cy+L.y11,L.cx+L.x11),x),o.arc(L.cx,L.cy,E,m(L.y11,L.x11),m(L.y01,L.x01),!x))):o.arc(0,0,d,O,R,x):o.lineTo(W,N)}else o.moveTo(0,0);if(o.closePath(),h)return o=null,h+""||null}return h.centroid=function(){var n=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,i=(+a.apply(this,arguments)+ +r.apply(this,arguments))/2-M/2;return[w(i)*n,$(i)*n]},h.innerRadius=function(e){return arguments.length?(t="function"==typeof e?e:v(+e),h):t},h.outerRadius=function(t){return arguments.length?(e="function"==typeof t?t:v(+t),h):e},h.cornerRadius=function(t){return arguments.length?(n="function"==typeof t?t:v(+t),h):n},h.padRadius=function(t){return arguments.length?(i=null==t?null:"function"==typeof t?t:v(+t),h):i},h.startAngle=function(t){return arguments.length?(a="function"==typeof t?t:v(+t),h):a},h.endAngle=function(t){return arguments.length?(r="function"==typeof t?t:v(+t),h):r},h.padAngle=function(t){return arguments.length?(s="function"==typeof t?t:v(+t),h):s},h.context=function(t){return arguments.length?(o=null==t?null:t,h):o},h}function F(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function q(t){return t}function U(){var t=q,e=F,n=null,i=v(0),a=v(A),r=v(0);function s(s){var o,l,h,c,u,d,f=(d=s,s="object"==typeof d&&"length"in d?d:Array.from(d)).length,p=0,g=new Array(f),v=new Array(f),y=+i.apply(this,arguments),m=Math.min(A,Math.max(-A,a.apply(this,arguments)-y)),w=Math.min(Math.abs(m)/f,r.apply(this,arguments)),x=w*(m<0?-1:1);for(o=0;o<f;++o)(u=v[g[o]=o]=+t(s[o],o,s))>0&&(p+=u);for(null!=e?g.sort(function(t,n){return e(v[t],v[n])}):null!=n&&g.sort(function(t,e){return n(s[t],s[e])}),o=0,h=p?(m-f*x)/p:0;o<f;++o,y=c)l=g[o],c=y+((u=v[l])>0?u*h:0)+x,v[l]={data:s[l],index:o,value:u,startAngle:y,endAngle:c,padAngle:w};return v}return s.value=function(e){return arguments.length?(t="function"==typeof e?e:v(+e),s):t}
1,s.sortValues=function(t){return arguments.length?(e=t,n=null,s):e},s.sort=function(t){return arguments.length?(n=t,e=null,s):n},s.startAngle=function(t){return arguments.length?(i="function"==typeof t?t:v(+t),s):i},s.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:v(+t),s):a},s.padAngle=function(t){return arguments.length?(r="function"==typeof t?t:v(+t),s):r},s}const I=750,Z={solar:0,wind:0,other:0,hydro:0,nuclear:0,biomass:0,coal:0,gas:0,imports:0},W=class{constructor(t){(0,r.r)(this,t),this.fuelMix=this.convertToArray(this.volumes||Z),this.totalGeneration=0,this.minPercentage=1,this.volumes=Z,this.units="Wh",this.defaultTitle="Total Generation",this.showCategories=!1,this.showPercentages="never",this.showTitle=!1,this.showLegend="never",this.showValue=!1,this.innerRadius=.55,this.categoryRadius=.1,this.liveText="",this.svg=null,this.formatMW=(0,s.b)(this.units),this.formatCentreValue=(0,s.b)(this.units,0)}componentDidLoad(){const t=(0,o.s)(this.element.shadowRoot.querySelectorAll(".chart")[0]).attr("viewBox","0 0 400 400");t.append("defs").html(Object.keys(d).map(t=>{const{width:e,height:n,scale:i,background:a,shape:r}=d[t];return`<pattern id="pattern-${t}" patternUnits="userSpaceOnUse" width="${e}" height="${n}" patternTransform="scale(${i})"><rect x="0" y="0" width="100%" height="100%" fill="${a}"/>`+r+"</pattern>"}).join("")),this.svg=t.append("g").attr("transform","translate(200,200)"),this.showTitle&&(this.centreTitle=this.element.shadowRoot.querySelectorAll(".centre-title")[0]),this.showValue&&(this.centreValue=this.element.shadowRoot.querySelectorAll(".centre-value")[0]),this.fuelMix=this.convertToArray(this.volumes),this.totalGeneration=this.fuelMix.reduce((t,{value:e})=>t+e,0),this.minPercentage="hover"===this.showPercentages?0:1,this.buildChart()}updateUnits(){this.formatMW=(0,s.b)(this.units),this.formatCentreValue=(0,s.b)(this.units,0)}updateFuelMix(t){const e=this.convertToArray(Object.assign(Object.assign({},Z),t));this.totalGeneration=e.reduce((t,{value:e})=>t+e,0),this.fuelMix=e}buildChart(){if(!this.svg)return;this.updateFuelMix(this.volumes),this.setStats();const t=200,e=E().innerRadius(t*this.innerRadius).outerRadius(t*(this.innerRadius+this.categoryRadius)),n=this.showCategories?this.innerRadius+this.categoryRadius:this.innerRadius,i=E().innerRadius(t*n).outerRadius(t),a=U().sort(null).value(t=>t.value),r=this.getCategoryData(this.fuelMix),l=a(this.fuelMix),h=a(r),u=this.fuelMix.reduce((t,{value:e})=>t+e,0),d=t=>{const e=i.centroid(t);return`translate(${.9*e[0]}, ${.9*e[1]})`};this.svg.selectAll(".outerArc").data(l).join(t=>t.append("path").attr("class",t=>`outerArc ${c[t.data.key]} ${t.data.key}`).attr("aria-hidden","true").attr("d",i).each(function(t){this._current=t}).transition("outerEntry").duration(I).attrTween("d",function(t){var e=(0,o.i)(this._current,t);return this._current=e(0),function(t){return i(e(t))}}),t=>t.transition("outherUpdate").duration(I).attrTween("d",function(t){var e=(0,o.i)(this._current,t);return this._current=e(0),function(t){return i(e(t))}})).on("mouseover",(t,e)=>this.activateFuel(e.data.key,e.data.value)).on("mouseout",()=>this.deactivate()),this.showCategories&&this.svg.selectAll(".innerArc").data(h).join(t=>t.append("path").attr("class",t=>`innerArc ${t.data.key}`).attr("aria-hidden","true").attr("d",e).each(function(t){this._current=t}).transition("innerEnter").duration(I).attrTween("d",function(t){var n=(0,o.i)(this._current,t);return this._current=n(0),function(t){return e(n(t))}}),t=>t.transition("innerUpdate").duration(I).attrTween("d",function(t){var n=(0,o.i)(this._current,t);return this._current=n(0),function(t){return e(n(t))}})).on("mouseover",(t,e)=>this.activateCategory(e.data.key,e.data.value)).on("mouseout",()=>this.deactivate()),"never"!==this.showPercentages&&(this.svg.selectAll(".outerArcText").data(l).join(t=>t.append("text").attr("class",t=>`outerArcText ${t.data.key}`).attr("aria-hidden","true").attr("transform",t=>`translate(${i.centroid(t)})`).attr("dy","0.35em").text(t=>(0,s.a)(t.data.value,u,this.minPercentage)),t=>t.attr("transform",t=>`translate(${i.centroid(t)})`).text(t=>(0,s.a)(t.data.value,u,this.minPercentage)),t=>t.call(t=>t.transition().duration(200)).remove()).style("opacity","always"===this.showPercentages?1:0),this.svg.selectAll(".innerArcText").data(h).join(t=>t.append("text").attr("class",t=>`innerArcText ${t.data.key}`).attr("aria-hidden","true").attr("transform",d).attr("dy","0.35em").text(t=>(0,s.a)(t.data.value,u,this.minPercentage)),t=>t.attr("transform",d).text(t=>(0,s.a)(t.data.value,u,this.minPercentage)),t=>t.call(t=>
1t.transition().duration(200)).remove()).style("opacity",0));const f=this.showValue?`Total: ${this.formatCentreValue(this.totalGeneration)}`:this.showTitle?this.defaultTitle:"";f&&this.svg.selectAll(".centreHotspot").data([null]).join(e=>e.append("circle").attr("class","centreHotspot").attr("fill","transparent").attr("r",t*this.innerRadius)).on("mouseover",()=>{window.clearTimeout(this.liveTextTimer),this.liveTextTimer=window.setTimeout(()=>{this.liveText=f},300)}).on("mouseout",()=>{window.clearTimeout(this.liveTextTimer),this.liveText=""})}activateFuel(t,e){if(this.svg.selectAll(".outerArc").classed("is-active",e=>e.data.key===t).classed("is-inactive",e=>e.data.key!==t),this.showCategories){const e=c[t];this.svg.selectAll(".innerArc").classed("is-active",t=>t.data.key===e).classed("is-inactive",t=>t.data.key!==e)}"hover"===this.showPercentages&&(this.svg.selectAll(".innerArcText").style("opacity",0),this.svg.select(`.${t}.outerArcText`).style("opacity",1)),this.setStats(h[t],this.formatCentreValue(e)),window.clearTimeout(this.liveTextTimer),this.liveTextTimer=window.setTimeout(()=>{this.liveText=`${h[t]}: ${this.formatCentreValue(e)}`},300)}activateCategory(t,e){this.svg.selectAll(".innerArc").classed("is-active",e=>e.data.key===t).classed("is-inactive",e=>e.data.key!==t),this.svg.selectAll(".outerArc").classed("is-active",e=>c[e.data.key]===t).classed("is-inactive",e=>c[e.data.key]!==t),"hover"===this.showPercentages&&(this.svg.selectAll(".outerArcText").style("opacity",0),this.svg.select(`.${t}.innerArcText`).style("opacity",1)),this.setStats(u[t],this.formatCentreValue(e)),window.clearTimeout(this.liveTextTimer),this.liveTextTimer=window.setTimeout(()=>{this.liveText=`${u[t]}: ${this.formatCentreValue(e)}`},300)}deactivate(){this.svg.selectAll(".outerArc, .innerArc").classed("is-active",!1).classed("is-inactive",!1),"hover"===this.showPercentages&&this.svg.selectAll(".outerArcText, .innerArcText").style("opacity",0),this.setStats(),window.clearTimeout(this.liveTextTimer),this.liveText=""}getCategoryData(t){return Object.keys(u).map(e=>({key:e,value:t.reduce((t,{key:n,value:i})=>c[n]===e?t+i:t,0)}))}convertToArray(t){return Object.entries(t).map(([t,e])=>({key:t,value:"number"==typeof e?e:0})).sort(({key:t},{key:e})=>l[t]-l[e])}setStats(t="",e=""){this.showTitle&&(this.centreTitle.innerHTML=t||this.defaultTitle),this.showValue&&(this.centreValue.innerHTML=e||this.formatCentreValue(this.totalGeneration))}render(){const t=this.convertToArray(this.volumes||Z),e=t.filter(({value:t})=>t>0),n=this.showCategories?this.getCategoryData(t).filter(({value:t})=>t>0):[];return(0,r.h)(r.H,{key:"3ed9dc0e9379e36a800c418cc9ef2ddf03f0abec"},(0,r.h)("div",{key:"e8325e57b9bb790bbd3d7dace7b5d951c2b7fe54","aria-live":"polite","aria-atomic":"true",class:"sr-only"},this.liveText),(0,r.h)("div",{key:"1ecc2a3a8a7a235ce52ff1bbe2b45556a1fa4d8e",class:"sr-only"},e.map(({key:t,value:e})=>(0,r.h)("div",{tabindex:"0",onFocus:()=>this.activateFuel(t,e),onBlur:()=>this.deactivate()},h[t],", ",this.formatCentreValue(e))),n.map(({key:t,value:e})=>(0,r.h)("div",{tabindex:"0",onFocus:()=>this.activateCategory(t,e),onBlur:()=>this.deactivate()},u[t],", ",this.formatCentreValue(e)))),(0,r.h)("div",{key:"dfb210c38b61d37cc94c4a88997dbb90f070a57b",class:"pie-container"},(0,r.h)("svg",{key:"e0a380a251230e209a0d22f0dc80b81b3a615e0b",class:"chart","aria-hidden":"true"}),(0,r.h)("div",{key:"54fc7ac4365c75e95a84919a381d3653004b7036",class:"centre-content"},this.showTitle&&(0,r.h)("div",{key:"2e40dd228267c684ce73a5ad9bd160e723a2a533",class:"centre-title"},this.defaultTitle),this.showValue&&(0,r.h)("div",{key:"2b93225b9fc4c624a46c15803a63a9e713f7f86f",class:"centre-value"},this.formatCentreValue(this.totalGeneration)))),"never"!==this.showLegend&&(0,r.h)("eco-gen-mix-legend",{key:"82d49845ffb5bc1fe6c71dd4d2dac6b3217cb85f",volumes:"dynamic"===this.showLegend?this.volumes:void 0}))}get element(){return(0,r.g)(this)}static get watchers(){return{units:["updateUnits"],volumes:["buildChart"]}}};W.style=":host {\n --font-family: 'Lubalin Graph', Arial, Helvetica, sans-serif;\n --font-size-primary: 16px;\n --font-size-secondary: 20px;\n --font-size-label-fuel: 20px;\n --font-size-label-category: 22px;\n --color-cat-green: #9AD43A;\n --color-cat-other: #a19b00;\n --color-cat-brown: #643200;\n --color-solar: #ffd600;\n --color-wind: #2AAF28;\n --color-hydro: #066b5f;\n --color-gas: #9C4F03;\n --color-coal: #151515;\n --color-oil: brown;\n --color-nuclear: #004E68;\n --color-biomass: #4375CB;\n --color-other: #757575;\n --color-imports: #8e9492;\n display: flex;\n font-family: var(--font-family);\n flex-direction: column;\n align-items: stretch;\n gap: 16px;\n width: 100%;\n}\n\neco-gen-mix-legend {\n /* Sized to its own content rather than stretched to the pie's exact\n width, so it can be slightly wider than the donut (per the design)\n without the donut itself shrinking to make room. */\n align-self: center;\n}\n\n.greenCat {\n fill: var(--color-cat-green);\n}\n\n.otherCat {\n fill: var(--color-cat-other);\n}\n\n.brownCat {\n fill: var(--color-cat-brown);\n}\n\n.solar {\n fill: url(#pattern-solar);\n}\n\n.wind {\n fill: url(#pattern-wind);\n}\n\n.hydro {\n fill: url(#pattern-hydro);\n}\n\n.gas {\n fill: url(#pattern-gas);\n}\n\n.coal {\n fill: url(#pattern-coal);\n}\n\n.oil {\n fill: url(#pattern-oil);\n}\n\n.nuclear {\n fill: url(#pattern-nuclear);\n}\n\n.biomass {\n fill: url(#pattern-biomass)\n}\n\n.other {\n fill: url(#pattern-other)\n}\n\n.imports {\n fill: url(#pattern-imports)\n}\n\n.outerArc, .innerArc {\n cursor: pointer;\n}\n\n.is-active {\n stroke: #151515;\n stroke-width: 0.5px;\n}\n\n.is-inactive {\n opacity: 0.5;\n}\n\n.outerArcText {\n text-anchor: middle;\n fill: white;\n pointer-events: none;\n font-size: var(--font-size-label-fuel);\n font-family: 'Open sans';\n font-weight: 700;\n &.solar,&.wind,&.hydro,&.biomass {\n fill: var(--color-coal)\n }\n}\n\n.innerArcText {\n text-anchor: middle;\n fill: white;\n pointer-events: none;\n font-size: var(--font-size-label-category);\n font-family: 'Open sans';\n font-weight: 700;\n &.greenCat {\n fill: var(--color-coal)\n }\n}\n\n.sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n\n.pie-container {\n position: relative;\n width: 100%;\n aspect-ratio: 1 / 1;\n}\n\nsvg {\n width: 100%;\n height: 100%;\n}\n\n.centre-content {\n position: absolute;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 0;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n pointer-events: none;\n text-align: center;\n}\n\n.centre-title {\n font-family: 'Open Sans', Arial, Helvetica, sans-serif;\n font-size: var(--font-size-primary);\n font-weight: 400;\n line-height: 20px;\n letter-spacing: 0;\n text-align: center;\n width: 50%;\n text-transform: uppercase;\n text-wrap: wrap;\n}\n\n.centre-value {\n font-family: 'Open Sans', Arial, Helvetica, sans-serif;\n font-size: var(--font-size-secondary);\n font-weight: 700;\n line-height: 24px;\n letter-spacing: 0;\n text-align: center;\n}\n"}}]); 2//# sourceMappingURL=1621-a56bfc559b00d78788d2.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.