-
Notifications
You must be signed in to change notification settings - Fork 0
/
L.Control.Heightgraph.min.js
1 lines (1 loc) · 86.3 KB
/
L.Control.Heightgraph.min.js
1
!function(){function t(n){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(n)}function n(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function e(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function r(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(i,n))}))}return t}function i(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function o(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return i(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?i(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==e.return||e.return()}finally{if(u)throw a}}}}var a="http://www.w3.org/1999/xhtml",s={svg:"http://www.w3.org/2000/svg",xhtml:a,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function u(t){var n=t+="",e=n.indexOf(":");return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),s.hasOwnProperty(n)?{space:s[n],local:t}:t}function l(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===a&&n.documentElement.namespaceURI===a?n.createElement(t):n.createElementNS(e,t)}}function h(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function c(t){var n=u(t);return(n.local?h:l)(n)}function f(){}function d(t){return null==t?f:function(){return this.querySelector(t)}}function p(){return[]}function g(t){return null==t?p:function(){return this.querySelectorAll(t)}}function _(t){return function(){return this.matches(t)}}function v(t){return new Array(t.length)}function m(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}m.prototype={constructor:m,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function y(t,n,e,r,i,o){for(var a,s=0,u=n.length,l=o.length;s<l;++s)(a=n[s])?(a.__data__=o[s],r[s]=a):e[s]=new m(t,o[s]);for(;s<u;++s)(a=n[s])&&(i[s]=a)}function x(t,n,e,r,i,o,a){var s,u,l,h={},c=n.length,f=o.length,d=new Array(c);for(s=0;s<c;++s)(u=n[s])&&(d[s]=l="$"+a.call(u,u.__data__,s,n),l in h?i[s]=u:h[l]=u);for(s=0;s<f;++s)(u=h[l="$"+a.call(t,o[s],s,o)])?(r[s]=u,u.__data__=o[s],h[l]=null):e[s]=new m(t,o[s]);for(s=0;s<c;++s)(u=n[s])&&h[d[s]]===u&&(i[s]=u)}function w(t,n){return t<n?-1:t>n?1:t>=n?0:NaN}function b(t){return function(){this.removeAttribute(t)}}function k(t){return function(){this.removeAttributeNS(t.space,t.local)}}function M(t,n){return function(){this.setAttribute(t,n)}}function A(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function S(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function T(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function N(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function C(t){return function(){this.style.removeProperty(t)}}function E(t,n,e){return function(){this.style.setProperty(t,n,e)}}function H(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function D(t,n){return t.style.getPropertyValue(n)||N(t).getComputedStyle(t,null).getPropertyValue(n)}function F(t){return function(){delete this[t]}}function B(t,n){return function(){this[t]=n}}function P(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function z(t){return t.trim().split(/^|\s+/)}function O(t){return t.classList||new I(t)}function I(t){this._node=t,this._names=z(t.getAttribute("class")||"")}function j(t,n){for(var e=O(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function R(t,n){for(var e=O(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function q(t){return function(){j(this,t)}}function X(t){return function(){R(this,t)}}function G(t,n){return function(){(n.apply(this,arguments)?j:R)(this,t)}}function V(){this.textContent=""}function Y(t){return function(){this.textContent=t}}function $(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}function U(){this.innerHTML=""}function W(t){return function(){this.innerHTML=t}}function Z(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}function K(){this.nextSibling&&this.parentNode.appendChild(this)}function Q(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function J(){return null}function tt(){var t=this.parentNode;t&&t.removeChild(this)}function nt(){var t=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function et(){var t=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}I.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var rt={},it=null;"undefined"!=typeof document&&("onmouseenter"in document.documentElement||(rt={mouseenter:"mouseover",mouseleave:"mouseout"}));function ot(t,n,e){return t=at(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function at(t,n,e){return function(r){var i=it;it=r;try{t.call(this,this.__data__,n,e)}finally{it=i}}}function st(t){return t.trim().split(/^|\s+/).map((function(t){var n="",e=t.indexOf(".");return e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}}))}function ut(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;r<o;++r)e=n[r],t.type&&e.type!==t.type||e.name!==t.name?n[++i]=e:this.removeEventListener(e.type,e.listener,e.capture);++i?n.length=i:delete this.__on}}}function lt(t,n,e){var r=rt.hasOwnProperty(t.type)?ot:at;return function(i,o,a){var s,u=this.__on,l=r(n,o,a);if(u)for(var h=0,c=u.length;h<c;++h)if((s=u[h]).type===t.type&&s.name===t.name)return this.removeEventListener(s.type,s.listener,s.capture),this.addEventListener(s.type,s.listener=l,s.capture=e),void(s.value=n);this.addEventListener(t.type,l,e),s={type:t.type,name:t.name,value:n,listener:l,capture:e},u?u.push(s):this.__on=[s]}}function ht(t,n,e,r){var i=it;t.sourceEvent=it,it=t;try{return n.apply(e,r)}finally{it=i}}function ct(t,n,e){var r=N(t),i=r.CustomEvent;"function"==typeof i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}function ft(t,n){return function(){return ct(this,t,n)}}function dt(t,n){return function(){return ct(this,t,n.apply(this,arguments))}}var pt=[null];function gt(t,n){this._groups=t,this._parents=n}function _t(){return new gt([[document.documentElement]],pt)}function vt(t){return"string"==typeof t?new gt([[document.querySelector(t)]],[document.documentElement]):new gt([[t]],pt)}function mt(){for(var t,n=it;t=n.sourceEvent;)n=t;return n}function yt(t,n){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();return r.x=n.clientX,r.y=n.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}var i=t.getBoundingClientRect();return[n.clientX-i.left-t.clientLeft,n.clientY-i.top-t.clientTop]}function xt(t){var n=mt();return n.changedTouches&&(n=n.changedTouches[0]),yt(t,n)}function wt(t){return"string"==typeof t?new gt([document.querySelectorAll(t)],[document.documentElement]):new gt([null==t?[]:t],pt)}function bt(t,n,e){arguments.length<3&&(e=n,n=mt().changedTouches);for(var r,i=0,o=n?n.length:0;i<o;++i)if((r=n[i]).identifier===e)return yt(t,r);return null}gt.prototype=_t.prototype={constructor:gt,select:function(t){"function"!=typeof t&&(t=d(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a,s=n[i],u=s.length,l=r[i]=new Array(u),h=0;h<u;++h)(o=s[h])&&(a=t.call(o,o.__data__,h,s))&&("__data__"in o&&(a.__data__=o.__data__),l[h]=a);return new gt(r,this._parents)},selectAll:function(t){"function"!=typeof t&&(t=g(t));for(var n=this._groups,e=n.length,r=[],i=[],o=0;o<e;++o)for(var a,s=n[o],u=s.length,l=0;l<u;++l)(a=s[l])&&(r.push(t.call(a,a.__data__,l,s)),i.push(a));return new gt(r,i)},filter:function(t){"function"!=typeof t&&(t=_(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a=n[i],s=a.length,u=r[i]=[],l=0;l<s;++l)(o=a[l])&&t.call(o,o.__data__,l,a)&&u.push(o);return new gt(r,this._parents)},data:function(t,n){if(!t)return d=new Array(this.size()),l=-1,this.each((function(t){d[++l]=t})),d;var e=n?x:y,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var o=i.length,a=new Array(o),s=new Array(o),u=new Array(o),l=0;l<o;++l){var h=r[l],c=i[l],f=c.length,d=t.call(h,h&&h.__data__,l,r),p=d.length,g=s[l]=new Array(p),_=a[l]=new Array(p);e(h,c,g,_,u[l]=new Array(f),d,n);for(var v,m,w=0,b=0;w<p;++w)if(v=g[w]){for(w>=b&&(b=w+1);!(m=_[b])&&++b<p;);v._next=m||null}}return(a=new gt(a,r))._enter=s,a._exit=u,a},enter:function(){return new gt(this._enter||this._groups.map(v),this._parents)},exit:function(){return new gt(this._exit||this._groups.map(v),this._parents)},join:function(t,n,e){var r=this.enter(),i=this,o=this.exit();return r="function"==typeof t?t(r):r.append(t+""),null!=n&&(i=n(i)),null==e?o.remove():e(o),r&&i?r.merge(i).order():i},merge:function(t){for(var n=this._groups,e=t._groups,r=n.length,i=e.length,o=Math.min(r,i),a=new Array(r),s=0;s<o;++s)for(var u,l=n[s],h=e[s],c=l.length,f=a[s]=new Array(c),d=0;d<c;++d)(u=l[d]||h[d])&&(f[d]=u);for(;s<r;++s)a[s]=n[s];return new gt(a,this._parents)},order:function(){for(var t=this._groups,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,a=i[o];--o>=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=w);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o<r;++o){for(var a,s=e[o],u=s.length,l=i[o]=new Array(u),h=0;h<u;++h)(a=s[h])&&(l[h]=a);l.sort(n)}return new gt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){var t=new Array(this.size()),n=-1;return this.each((function(){t[++n]=this})),t},node:function(){for(var t=this._groups,n=0,e=t.length;n<e;++n)for(var r=t[n],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null},size:function(){var t=0;return this.each((function(){++t})),t},empty:function(){return!this.node()},each:function(t){for(var n=this._groups,e=0,r=n.length;e<r;++e)for(var i,o=n[e],a=0,s=o.length;a<s;++a)(i=o[a])&&t.call(i,i.__data__,a,o);return this},attr:function(t,n){var e=u(t);if(arguments.length<2){var r=this.node();return e.local?r.getAttributeNS(e.space,e.local):r.getAttribute(e)}return this.each((null==n?e.local?k:b:"function"==typeof n?e.local?T:S:e.local?A:M)(e,n))},style:function(t,n,e){return arguments.length>1?this.each((null==n?C:"function"==typeof n?H:E)(t,n,null==e?"":e)):D(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?F:"function"==typeof n?P:B)(t,n)):this.node()[t]},classed:function(t,n){var e=z(t+"");if(arguments.length<2){for(var r=O(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?G:n?q:X)(e,n))},text:function(t){return arguments.length?this.each(null==t?V:("function"==typeof t?$:Y)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?U:("function"==typeof t?Z:W)(t)):this.node().innerHTML},raise:function(){return this.each(K)},lower:function(){return this.each(Q)},append:function(t){var n="function"==typeof t?t:c(t);return this.select((function(){return this.appendChild(n.apply(this,arguments))}))},insert:function(t,n){var e="function"==typeof t?t:c(t),r=null==n?J:"function"==typeof n?n:d(n);return this.select((function(){return this.insertBefore(e.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(tt)},clone:function(t){return this.select(t?et:nt)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,n,e){var r,i,o=st(t+""),a=o.length;if(!(arguments.length<2)){for(s=n?lt:ut,null==e&&(e=!1),r=0;r<a;++r)this.each(s(o[r],n,e));return this}var s=this.node().__on;if(s)for(var u,l=0,h=s.length;l<h;++l)for(r=0,u=s[l];r<a;++r)if((i=o[r]).type===u.type&&i.name===u.name)return u.value},dispatch:function(t,n){return this.each(("function"==typeof n?dt:ft)(t,n))}};var kt={value:function(){}};function Mt(){for(var t,n=0,e=arguments.length,r={};n<e;++n){if(!(t=arguments[n]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new At(r)}function At(t){this._=t}function St(t,n){return t.trim().split(/^|\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))}function Tt(t,n){for(var e,r=0,i=t.length;r<i;++r)if((e=t[r]).name===n)return e.value}function Nt(t,n,e){for(var r=0,i=t.length;r<i;++r)if(t[r].name===n){t[r]=kt,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=e&&t.push({name:n,value:e}),t}At.prototype=Mt.prototype={constructor:At,on:function(t,n){var e,r=this._,i=St(t+"",r),o=-1,a=i.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++o<a;)if(e=(t=i[o]).type)r[e]=Nt(r[e],t.name,n);else if(null==n)for(e in r)r[e]=Nt(r[e],t.name,null);return this}for(;++o<a;)if((e=(t=i[o]).type)&&(e=Tt(r[e],t.name)))return e},copy:function(){var t={},n=this._;for(var e in n)t[e]=n[e].slice();return new At(t)},call:function(t,n){if((e=arguments.length-2)>0)for(var e,r,i=new Array(e),o=0;o<e;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,e=(r=this._[t]).length;o<e;++o)r[o].value.apply(n,i)},apply:function(t,n,e){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(n,e)}};var Ct,Et,Lt=0,Ht=0,Dt=0,Ft=0,Bt=0,Pt=0,zt="object"==typeof performance&&performance.now?performance:Date,Ot="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function It(){return Bt||(Ot(jt),Bt=zt.now()+Pt)}function jt(){Bt=0}function Rt(){this._call=this._time=this._next=null}function qt(t,n,e){var r=new Rt;return r.restart(t,n,e),r}function Xt(){Bt=(Ft=zt.now())+Pt,Lt=Ht=0;try{!function(){It(),++Lt;for(var t,n=Ct;n;)(t=Bt-n._time)>=0&&n._call.call(null,t),n=n._next;--Lt}()}finally{Lt=0,function(){var t,n,e=Ct,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Ct=n);Et=t,Vt(r)}(),Bt=0}}function Gt(){var t=zt.now(),n=t-Ft;n>1e3&&(Pt-=n,Ft=t)}function Vt(t){Lt||(Ht&&(Ht=clearTimeout(Ht)),t-Bt>24?(t<1/0&&(Ht=setTimeout(Xt,t-zt.now()-Pt)),Dt&&(Dt=clearInterval(Dt))):(Dt||(Ft=zt.now(),Dt=setInterval(Gt,1e3)),Lt=1,Ot(Xt)))}function Yt(t,n,e){var r=new Rt;return n=null==n?0:+n,r.restart((function(e){r.stop(),t(e+n)}),n,e),r}Rt.prototype=qt.prototype={constructor:Rt,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?It():+e)+(null==n?0:+n),this._next||Et===this||(Et?Et._next=this:Ct=this,Et=this),this._call=t,this._time=e,Vt()},stop:function(){this._call&&(this._call=null,this._time=1/0,Vt())}};var $t=Mt("start","end","cancel","interrupt"),Ut=[];function Wt(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(t){e.state=1,e.timer.restart(a,e.delay,e.time),e.delay<=t&&a(t-e.delay)}function a(o){var l,h,c,f;if(1!==e.state)return u();for(l in i)if((f=i[l]).name===e.name){if(3===f.state)return Yt(a);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[l]):+l<n&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[l])}if(Yt((function(){3===e.state&&(e.state=4,e.timer.restart(s,e.delay,e.time),s(o))})),e.state=2,e.on.call("start",t,t.__data__,e.index,e.group),2===e.state){for(e.state=3,r=new Array(c=e.tween.length),l=0,h=-1;l<c;++l)(f=e.tween[l].value.call(t,t.__data__,e.index,e.group))&&(r[++h]=f);r.length=h+1}}function s(n){for(var i=n<e.duration?e.ease.call(null,n/e.duration):(e.timer.restart(u),e.state=5,1),o=-1,a=r.length;++o<a;)r[o].call(t,i);5===e.state&&(e.on.call("end",t,t.__data__,e.index,e.group),u())}function u(){for(var r in e.state=6,e.timer.stop(),delete i[n],i)return;delete t.__transition}i[n]=e,e.timer=qt(o,0,e.time)}(t,e,{name:n,index:r,group:i,on:$t,tween:Ut,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function Zt(t,n){var e=Qt(t,n);if(e.state>0)throw new Error("too late; already scheduled");return e}function Kt(t,n){var e=Qt(t,n);if(e.state>3)throw new Error("too late; already running");return e}function Qt(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Jt(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function tn(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function nn(){}var en=.7,rn=1/en,on="\\s*([+-]?\\d+)\\s*",an="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",sn="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",un=/^#([0-9a-f]{3,8})$/,ln=new RegExp("^rgb\\("+[on,on,on]+"\\)$"),hn=new RegExp("^rgb\\("+[sn,sn,sn]+"\\)$"),cn=new RegExp("^rgba\\("+[on,on,on,an]+"\\)$"),fn=new RegExp("^rgba\\("+[sn,sn,sn,an]+"\\)$"),dn=new RegExp("^hsl\\("+[an,sn,sn]+"\\)$"),pn=new RegExp("^hsla\\("+[an,sn,sn,an]+"\\)$"),gn={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 _n(){return this.rgb().formatHex()}function vn(){return this.rgb().formatRgb()}function mn(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=un.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?yn(n):3===e?new kn(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?xn(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?xn(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=ln.exec(t))?new kn(n[1],n[2],n[3],1):(n=hn.exec(t))?new kn(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=cn.exec(t))?xn(n[1],n[2],n[3],n[4]):(n=fn.exec(t))?xn(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=dn.exec(t))?Tn(n[1],n[2]/100,n[3]/100,1):(n=pn.exec(t))?Tn(n[1],n[2]/100,n[3]/100,n[4]):gn.hasOwnProperty(t)?yn(gn[t]):"transparent"===t?new kn(NaN,NaN,NaN,0):null}function yn(t){return new kn(t>>16&255,t>>8&255,255&t,1)}function xn(t,n,e,r){return r<=0&&(t=n=e=NaN),new kn(t,n,e,r)}function wn(t){return t instanceof nn||(t=mn(t)),t?new kn((t=t.rgb()).r,t.g,t.b,t.opacity):new kn}function bn(t,n,e,r){return 1===arguments.length?wn(t):new kn(t,n,e,null==r?1:r)}function kn(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function Mn(){return"#"+Sn(this.r)+Sn(this.g)+Sn(this.b)}function An(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function Sn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Tn(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new Cn(t,n,e,r)}function Nn(t){if(t instanceof Cn)return new Cn(t.h,t.s,t.l,t.opacity);if(t instanceof nn||(t=mn(t)),!t)return new Cn;if(t instanceof Cn)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,s=o-i,u=(o+i)/2;return s?(a=n===o?(e-r)/s+6*(e<r):e===o?(r-n)/s+2:(n-e)/s+4,s/=u<.5?o+i:2-o-i,a*=60):s=u>0&&u<1?0:a,new Cn(a,s,u,t.opacity)}function Cn(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function En(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}function Ln(t){return function(){return t}}function Hn(t){return 1==(t=+t)?Dn:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):Ln(isNaN(n)?e:n)}}function Dn(t,n){var e=n-t;return e?function(t,n){return function(e){return t+e*n}}(t,e):Ln(isNaN(t)?n:t)}Jt(nn,mn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:_n,formatHex:_n,formatHsl:function(){return Nn(this).formatHsl()},formatRgb:vn,toString:vn}),Jt(kn,bn,tn(nn,{brighter:function(t){return t=null==t?rn:Math.pow(rn,t),new kn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?en:Math.pow(en,t),new kn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){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:Mn,formatHex:Mn,formatRgb:An,toString:An})),Jt(Cn,(function(t,n,e,r){return 1===arguments.length?Nn(t):new Cn(t,n,e,null==r?1:r)}),tn(nn,{brighter:function(t){return t=null==t?rn:Math.pow(rn,t),new Cn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?en:Math.pow(en,t),new Cn(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new kn(En(t>=240?t-240:t+120,i,r),En(t,i,r),En(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var Fn=function t(n){var e=Hn(n);function r(t,n){var r=e((t=bn(t)).r,(n=bn(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=Dn(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function Bn(t,n){n||(n=[]);var e,r=t?Math.min(n.length,t.length):0,i=n.slice();return function(o){for(e=0;e<r;++e)i[e]=t[e]*(1-o)+n[e]*o;return i}}function Pn(t,n){var e,r=n?n.length:0,i=t?Math.min(r,t.length):0,o=new Array(i),a=new Array(r);for(e=0;e<i;++e)o[e]=Xn(t[e],n[e]);for(;e<r;++e)a[e]=n[e];return function(t){for(e=0;e<i;++e)a[e]=o[e](t);return a}}function zn(t,n){var e=new Date;return t=+t,n=+n,function(r){return e.setTime(t*(1-r)+n*r),e}}function On(t,n){return t=+t,n=+n,function(e){return t*(1-e)+n*e}}function In(t,n){var e,r={},i={};for(e in null!==t&&"object"==typeof t||(t={}),null!==n&&"object"==typeof n||(n={}),n)e in t?r[e]=Xn(t[e],n[e]):i[e]=n[e];return function(t){for(e in r)i[e]=r[e](t);return i}}var jn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Rn=new RegExp(jn.source,"g");function qn(t,n){var e,r,i,o=jn.lastIndex=Rn.lastIndex=0,a=-1,s=[],u=[];for(t+="",n+="";(e=jn.exec(t))&&(r=Rn.exec(n));)(i=r.index)>o&&(i=n.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(e=e[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:On(e,r)})),o=Rn.lastIndex;return o<n.length&&(i=n.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?u[0]?function(t){return function(n){return t(n)+""}}(u[0].x):function(t){return function(){return t}}(n):(n=u.length,function(t){for(var e,r=0;r<n;++r)s[(e=u[r]).i]=e.x(t);return s.join("")})}function Xn(t,n){var e,r=typeof n;return null==n||"boolean"===r?Ln(n):("number"===r?On:"string"===r?(e=mn(n))?(n=e,Fn):qn:n instanceof mn?Fn:n instanceof Date?zn:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(n)?Bn:Array.isArray(n)?Pn:"function"!=typeof n.valueOf&&"function"!=typeof n.toString||isNaN(n)?In:On)(t,n)}function Gn(t,n){return t=+t,n=+n,function(e){return Math.round(t*(1-e)+n*e)}}var Vn,Yn,$n,Un,Wn=180/Math.PI,Zn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Kn(t,n,e,r,i,o){var a,s,u;return(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a),(u=t*e+n*r)&&(e-=t*u,r-=n*u),(s=Math.sqrt(e*e+r*r))&&(e/=s,r/=s,u/=s),t*r<n*e&&(t=-t,n=-n,u=-u,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(n,t)*Wn,skewX:Math.atan(u)*Wn,scaleX:a,scaleY:s}}function Qn(t,n,e,r){function i(t){return t.length?t.pop()+" ":""}return function(o,a){var s=[],u=[];return o=t(o),a=t(a),function(t,r,i,o,a,s){if(t!==i||r!==o){var u=a.push("translate(",null,n,null,e);s.push({i:u-4,x:On(t,i)},{i:u-2,x:On(r,o)})}else(i||o)&&a.push("translate("+i+n+o+e)}(o.translateX,o.translateY,a.translateX,a.translateY,s,u),function(t,n,e,o){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:On(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,s,u),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:On(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,s,u),function(t,n,e,r,o,a){if(t!==e||n!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:On(t,e)},{i:s-2,x:On(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,u),o=a=null,function(t){for(var n,e=-1,r=u.length;++e<r;)s[(n=u[e]).i]=n.x(t);return s.join("")}}}var Jn=Qn((function(t){return"none"===t?Zn:(Vn||(Vn=document.createElement("DIV"),Yn=document.documentElement,$n=document.defaultView),Vn.style.transform=t,t=$n.getComputedStyle(Yn.appendChild(Vn),null).getPropertyValue("transform"),Yn.removeChild(Vn),Kn(+(t=t.slice(7,-1).split(","))[0],+t[1],+t[2],+t[3],+t[4],+t[5]))}),"px, ","px)","deg)"),te=Qn((function(t){return null==t?Zn:(Un||(Un=document.createElementNS("http://www.w3.org/2000/svg","g")),Un.setAttribute("transform",t),(t=Un.transform.baseVal.consolidate())?Kn((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Zn)}),", ",")",")");function ne(t,n){var e,r;return function(){var i=Kt(this,t),o=i.tween;if(o!==e)for(var a=0,s=(r=e=o).length;a<s;++a)if(r[a].name===n){(r=r.slice()).splice(a,1);break}i.tween=r}}function ee(t,n,e){var r,i;if("function"!=typeof e)throw new Error;return function(){var o=Kt(this,t),a=o.tween;if(a!==r){i=(r=a).slice();for(var s={name:n,value:e},u=0,l=i.length;u<l;++u)if(i[u].name===n){i[u]=s;break}u===l&&i.push(s)}o.tween=i}}function re(t,n,e){var r=t._id;return t.each((function(){var t=Kt(this,r);(t.value||(t.value={}))[n]=e.apply(this,arguments)})),function(t){return Qt(t,r).value[n]}}function ie(t,n){var e;return("number"==typeof n?On:n instanceof mn?Fn:(e=mn(n))?(n=e,Fn):qn)(t,n)}function oe(t){return function(){this.removeAttribute(t)}}function ae(t){return function(){this.removeAttributeNS(t.space,t.local)}}function se(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttribute(t);return a===o?null:a===r?i:i=n(r=a,e)}}function ue(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===o?null:a===r?i:i=n(r=a,e)}}function le(t,n,e){var r,i,o;return function(){var a,s,u=e(this);if(null!=u)return(a=this.getAttribute(t))===(s=u+"")?null:a===r&&s===i?o:(i=s,o=n(r=a,u));this.removeAttribute(t)}}function he(t,n,e){var r,i,o;return function(){var a,s,u=e(this);if(null!=u)return(a=this.getAttributeNS(t.space,t.local))===(s=u+"")?null:a===r&&s===i?o:(i=s,o=n(r=a,u));this.removeAttributeNS(t.space,t.local)}}function ce(t,n){return function(e){this.setAttribute(t,n.call(this,e))}}function fe(t,n){return function(e){this.setAttributeNS(t.space,t.local,n.call(this,e))}}function de(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&fe(t,i)),e}return i._value=n,i}function pe(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&ce(t,i)),e}return i._value=n,i}function ge(t,n){return function(){Zt(this,t).delay=+n.apply(this,arguments)}}function _e(t,n){return n=+n,function(){Zt(this,t).delay=n}}function ve(t,n){return function(){Kt(this,t).duration=+n.apply(this,arguments)}}function me(t,n){return n=+n,function(){Kt(this,t).duration=n}}function ye(t,n){if("function"!=typeof n)throw new Error;return function(){Kt(this,t).ease=n}}function xe(t,n,e){var r,i,o=function(t){return(t+"").trim().split(/^|\s+/).every((function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||"start"===t}))}(n)?Zt:Kt;return function(){var a=o(this,t),s=a.on;s!==r&&(i=(r=s).copy()).on(n,e),a.on=i}}var we=_t.prototype.constructor;function be(t){return function(){this.style.removeProperty(t)}}function ke(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}function Me(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&ke(t,o,e)),r}return o._value=n,o}function Ae(t){return function(n){this.textContent=t.call(this,n)}}function Se(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&Ae(r)),n}return r._value=t,r}var Te=0;function Ne(t,n,e,r){this._groups=t,this._parents=n,this._name=e,this._id=r}function Ce(t){return _t().transition(t)}function Ee(){return++Te}var Le=_t.prototype;Ne.prototype=Ce.prototype={constructor:Ne,select:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=d(t));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a<i;++a)for(var s,u,l=r[a],h=l.length,c=o[a]=new Array(h),f=0;f<h;++f)(s=l[f])&&(u=t.call(s,s.__data__,f,l))&&("__data__"in s&&(u.__data__=s.__data__),c[f]=u,Wt(c[f],n,e,f,c,Qt(s,e)));return new Ne(o,this._parents,n,e)},selectAll:function(t){var n=this._name,e=this._id;"function"!=typeof t&&(t=g(t));for(var r=this._groups,i=r.length,o=[],a=[],s=0;s<i;++s)for(var u,l=r[s],h=l.length,c=0;c<h;++c)if(u=l[c]){for(var f,d=t.call(u,u.__data__,c,l),p=Qt(u,e),_=0,v=d.length;_<v;++_)(f=d[_])&&Wt(f,n,e,_,d,p);o.push(d),a.push(u)}return new Ne(o,a,n,e)},filter:function(t){"function"!=typeof t&&(t=_(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,a=n[i],s=a.length,u=r[i]=[],l=0;l<s;++l)(o=a[l])&&t.call(o,o.__data__,l,a)&&u.push(o);return new Ne(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var n=this._groups,e=t._groups,r=n.length,i=e.length,o=Math.min(r,i),a=new Array(r),s=0;s<o;++s)for(var u,l=n[s],h=e[s],c=l.length,f=a[s]=new Array(c),d=0;d<c;++d)(u=l[d]||h[d])&&(f[d]=u);for(;s<r;++s)a[s]=n[s];return new Ne(a,this._parents,this._name,this._id)},selection:function(){return new we(this._groups,this._parents)},transition:function(){for(var t=this._name,n=this._id,e=Ee(),r=this._groups,i=r.length,o=0;o<i;++o)for(var a,s=r[o],u=s.length,l=0;l<u;++l)if(a=s[l]){var h=Qt(a,n);Wt(a,t,e,l,s,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new Ne(r,this._parents,t,e)},call:Le.call,nodes:Le.nodes,node:Le.node,size:Le.size,empty:Le.empty,each:Le.each,on:function(t,n){var e=this._id;return arguments.length<2?Qt(this.node(),e).on.on(t):this.each(xe(e,t,n))},attr:function(t,n){var e=u(t),r="transform"===e?te:ie;return this.attrTween(t,"function"==typeof n?(e.local?he:le)(e,r,re(this,"attr."+t,n)):null==n?(e.local?ae:oe)(e):(e.local?ue:se)(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=u(t);return this.tween(e,(r.local?de:pe)(r,n))},style:function(t,n,e){var r="transform"==(t+="")?Jn:ie;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=D(this,t),a=(this.style.removeProperty(t),D(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,be(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=D(this,t),s=e(this),u=s+"";return null==s&&(this.style.removeProperty(t),u=s=D(this,t)),a===u?null:a===r&&u===i?o:(i=u,o=n(r=a,s))}}(t,r,re(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,s="end."+a;return function(){var u=Kt(this,t),l=u.on,h=null==u.value[a]?o||(o=be(n)):void 0;l===e&&i===h||(r=(e=l).copy()).on(s,i=h),u.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=D(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,Me(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(re(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,Se(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=Qt(this.node(),e).tween,o=0,a=i.length;o<a;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==n?ne:ee)(e,t,n))},delay:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?ge:_e)(n,t)):Qt(this.node(),n).delay},duration:function(t){var n=this._id;return arguments.length?this.each(("function"==typeof t?ve:me)(n,t)):Qt(this.node(),n).duration},ease:function(t){var n=this._id;return arguments.length?this.each(ye(n,t)):Qt(this.node(),n).ease},end:function(){var t,n,e=this,r=e._id,i=e.size();return new Promise((function(o,a){var s={value:a},u={value:function(){0==--i&&o()}};e.each((function(){var e=Kt(this,r),i=e.on;i!==t&&((n=(t=i).copy())._.cancel.push(s),n._.interrupt.push(s),n._.end.push(u)),e.on=n}))}))}};var He={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function De(t,n){for(var e;!(e=t.__transition)||!(e=e[n]);)if(!(t=t.parentNode))return He.time=It(),He;return e}function Fe(t,n){return t.each((function(){var t=n.apply(this,arguments),e=vt(this);for(var r in t)e.attr(r,t[r])}))}function Be(t,n){for(var e in n)t.attr(e,n[e]);return t}function Pe(t,n,e){return t.each((function(){var t=n.apply(this,arguments),r=vt(this);for(var i in t)r.style(i,t[i],e)}))}function ze(t,n,e){for(var r in n)t.style(r,n[r],e);return t}function Oe(t,n){return t.each((function(){var t=n.apply(this,arguments),e=vt(this);for(var r in t)e.property(r,t[r])}))}function Ie(t,n){for(var e in n)t.property(e,n[e]);return t}function je(t,n){return t.each((function(){var e=n.apply(this,arguments),r=vt(this).transition(t);for(var i in e)r.attr(i,e[i])}))}function Re(t,n){for(var e in n)t.attr(e,n[e]);return t}function qe(t,n,e){return t.each((function(){var r=n.apply(this,arguments),i=vt(this).transition(t);for(var o in r)i.style(o,r[o],e)}))}function Xe(t,n,e){for(var r in n)t.style(r,n[r],e);return t}function Ge(t,n){return t<n?-1:t>n?1:t>=n?0:NaN}function Ve(t){var n;return 1===t.length&&(n=t,t=function(t,e){return Ge(n(t),e)}),{left:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r<i;){var o=r+i>>>1;t(n[o],e)<0?r=o+1:i=o}return r},right:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r<i;){var o=r+i>>>1;t(n[o],e)>0?i=o:r=o+1}return r}}}_t.prototype.interrupt=function(t){return this.each((function(){!function(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>2&&e.state<5,e.state=6,e.timer.stop(),e.on.call(r?"interrupt":"cancel",t,t.__data__,e.index,e.group),delete o[i]):a=!1;a&&delete t.__transition}}(this,t)}))},_t.prototype.transition=function(t){var n,e;t instanceof Ne?(n=t._id,t=t._name):(n=Ee(),(e=He).time=It(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var a,s=r[o],u=s.length,l=0;l<u;++l)(a=s[l])&&Wt(a,t,n,l,s,e||De(a,n));return new Ne(r,this._parents,t,n)},_t.prototype.attrs=function(t){return("function"==typeof t?Fe:Be)(this,t)},_t.prototype.styles=function(t,n){return("function"==typeof t?Pe:ze)(this,t,null==n?"":n)},_t.prototype.properties=function(t){return("function"==typeof t?Oe:Ie)(this,t)},Ce.prototype.attrs=function(t){return("function"==typeof t?je:Re)(this,t)},Ce.prototype.styles=function(t,n){return("function"==typeof t?qe:Xe)(this,t,null==n?"":n)};var Ye=Ve(Ge).right,$e=Math.sqrt(50),Ue=Math.sqrt(10),We=Math.sqrt(2);function Ze(t,n,e){var r=(n-t)/Math.max(0,e),i=Math.floor(Math.log(r)/Math.LN10),o=r/Math.pow(10,i);return i>=0?(o>=$e?10:o>=Ue?5:o>=We?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=$e?10:o>=Ue?5:o>=We?2:1)}function Ke(t,n){var e,r,i=t.length,o=-1;if(null==n){for(;++o<i;)if(null!=(e=t[o])&&e>=e)for(r=e;++o<i;)null!=(e=t[o])&&e>r&&(r=e)}else for(;++o<i;)if(null!=(e=n(t[o],o,t))&&e>=e)for(r=e;++o<i;)null!=(e=n(t[o],o,t))&&e>r&&(r=e);return r}function Qe(t,n){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(n).domain(t)}return this}var Je="$";function tr(){}function nr(t,n){var e=new tr;if(t instanceof tr)t.each((function(t,n){e.set(n,t)}));else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==n)for(;++i<o;)e.set(i,t[i]);else for(;++i<o;)e.set(n(r=t[i],i,t),r)}else if(t)for(var a in t)e.set(a,t[a]);return e}function er(){}tr.prototype=nr.prototype={constructor:tr,has:function(t){return Je+t in this},get:function(t){return this[Je+t]},set:function(t,n){return this[Je+t]=n,this},remove:function(t){var n=Je+t;return n in this&&delete this[n]},clear:function(){for(var t in this)t[0]===Je&&delete this[t]},keys:function(){var t=[];for(var n in this)n[0]===Je&&t.push(n.slice(1));return t},values:function(){var t=[];for(var n in this)n[0]===Je&&t.push(this[n]);return t},entries:function(){var t=[];for(var n in this)n[0]===Je&&t.push({key:n.slice(1),value:this[n]});return t},size:function(){var t=0;for(var n in this)n[0]===Je&&++t;return t},empty:function(){for(var t in this)if(t[0]===Je)return!1;return!0},each:function(t){for(var n in this)n[0]===Je&&t(this[n],n.slice(1),this)}};var rr=nr.prototype;er.prototype=function(t,n){var e=new er;if(t instanceof er)t.each((function(t){e.add(t)}));else if(t){var r=-1,i=t.length;if(null==n)for(;++r<i;)e.add(t[r]);else for(;++r<i;)e.add(n(t[r],r,t))}return e}.prototype={constructor:er,has:rr.has,add:function(t){return this[Je+(t+="")]=t,this},remove:rr.remove,clear:rr.clear,values:rr.keys,size:rr.size,empty:rr.empty,each:rr.each};var ir=Array.prototype,or=ir.map,ar=ir.slice,sr={name:"implicit"};function ur(){var t=nr(),n=[],e=[],r=sr;function i(i){var o=i+"",a=t.get(o);if(!a){if(r!==sr)return r;t.set(o,a=n.push(i))}return e[(a-1)%e.length]}return i.domain=function(e){if(!arguments.length)return n.slice();n=[],t=nr();for(var r,o,a=-1,s=e.length;++a<s;)t.has(o=(r=e[a])+"")||t.set(o,n.push(r));return i},i.range=function(t){return arguments.length?(e=ar.call(t),i):e.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return ur(n,e).unknown(r)},Qe.apply(i,arguments),i}function lr(t){return+t}var hr=[0,1];function cr(t){return t}function fr(t,n){return(n-=t=+t)?function(e){return(e-t)/n}:function(t){return function(){return t}}(isNaN(n)?NaN:.5)}function dr(t){var n,e=t[0],r=t[t.length-1];return e>r&&(n=e,e=r,r=n),function(t){return Math.max(e,Math.min(r,t))}}function pr(t,n,e){var r=t[0],i=t[1],o=n[0],a=n[1];return i<r?(r=fr(i,r),o=e(a,o)):(r=fr(r,i),o=e(o,a)),function(t){return o(r(t))}}function gr(t,n,e){var r=Math.min(t.length,n.length)-1,i=new Array(r),o=new Array(r),a=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),n=n.slice().reverse());++a<r;)i[a]=fr(t[a],t[a+1]),o[a]=e(n[a],n[a+1]);return function(n){var e=Ye(t,n,1,r)-1;return o[e](i[e](n))}}function _r(t,n){return n.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function vr(t,n){return function(){var t,n,e,r,i,o,a=hr,s=hr,u=Xn,l=cr;function h(){return r=Math.min(a.length,s.length)>2?gr:pr,i=o=null,c}function c(n){return isNaN(n=+n)?e:(i||(i=r(a.map(t),s,u)))(t(l(n)))}return c.invert=function(e){return l(n((o||(o=r(s,a.map(t),On)))(e)))},c.domain=function(t){return arguments.length?(a=or.call(t,lr),l===cr||(l=dr(a)),h()):a.slice()},c.range=function(t){return arguments.length?(s=ar.call(t),h()):s.slice()},c.rangeRound=function(t){return s=ar.call(t),u=Gn,h()},c.clamp=function(t){return arguments.length?(l=t?dr(a):cr,c):l!==cr},c.interpolate=function(t){return arguments.length?(u=t,h()):u},c.unknown=function(t){return arguments.length?(e=t,c):e},function(e,r){return t=e,n=r,h()}}()(t,n)}function mr(t,n){if((e=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"))<0)return null;var e,r=t.slice(0,e);return[r.length>1?r[0]+r.slice(2):r,+t.slice(e+1)]}function yr(t){return(t=mr(Math.abs(t)))?t[1]:NaN}var xr,wr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function br(t){if(!(n=wr.exec(t)))throw new Error("invalid format: "+t);var n;return new kr({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}function kr(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 Mr(t,n){var e=mr(t,n);if(!e)return t+"";var r=e[0],i=e[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")}br.prototype=kr.prototype,kr.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 Ar={"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return Mr(100*t,n)},r:Mr,s:function(t,n){var e=mr(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(xr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+mr(t,Math.max(0,n+o-1))[0]},X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}};function Sr(t){return t}var Tr,Nr,Cr,Er=Array.prototype.map,Lr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Hr(t){var n,e,r=void 0===t.grouping||void 0===t.thousands?Sr:(n=Er.call(t.grouping,Number),e=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,s=n[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),o.push(t.substring(i-=s,i+s)),!((u+=s+1)>r));)s=n[a=(a+1)%n.length];return o.reverse().join(e)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?Sr:function(t){return function(n){return n.replace(/[0-9]/g,(function(n){return t[+n]}))}}(Er.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 n=(t=br(t)).fill,e=t.align,c=t.sign,f=t.symbol,d=t.zero,p=t.width,g=t.comma,_=t.precision,v=t.trim,m=t.type;"n"===m?(g=!0,m="g"):Ar[m]||(void 0===_&&(_=12),v=!0,m="g"),(d||"0"===n&&"="===e)&&(d=!0,n="0",e="=");var y="$"===f?i:"#"===f&&/[boxX]/.test(m)?"0"+m.toLowerCase():"",x="$"===f?o:/[%p]/.test(m)?u:"",w=Ar[m],b=/[defgprs%]/.test(m);function k(t){var i,o,u,f=y,k=x;if("c"===m)k=w(t)+k,t="";else{var M=(t=+t)<0||1/t<0;if(t=isNaN(t)?h:w(Math.abs(t),_),v&&(t=function(t){t:for(var n,e=t.length,r=1,i=-1;r<e;++r)switch(t[r]){case".":i=n=r;break;case"0":0===i&&(i=r),n=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(n+1):t}(t)),M&&0==+t&&"+"!==c&&(M=!1),f=(M?"("===c?c:l:"-"===c||"("===c?"":c)+f,k=("s"===m?Lr[8+xr/3]:"")+k+(M&&"("===c?")":""),b)for(i=-1,o=t.length;++i<o;)if(48>(u=t.charCodeAt(i))||u>57){k=(46===u?a+t.slice(i+1):t.slice(i))+k,t=t.slice(0,i);break}}g&&!d&&(t=r(t,1/0));var A=f.length+t.length+k.length,S=A<p?new Array(p-A+1).join(n):"";switch(g&&d&&(t=r(S+t,S.length?p-k.length:1/0),S=""),e){case"<":t=f+t+k+S;break;case"=":t=f+S+t+k;break;case"^":t=S.slice(0,A=S.length>>1)+f+t+k+S.slice(A);break;default:t=S+f+t+k}return s(t)}return _=void 0===_?6:/[gprs]/.test(m)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_)),k.toString=function(){return t+""},k}return{format:c,formatPrefix:function(t,n){var e=c(((t=br(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(yr(n)/3))),i=Math.pow(10,-r),o=Lr[8+r/3];return function(t){return e(i*t)+o}}}}function Dr(t,n,e,r){var i,o=function(t,n,e){var r=Math.abs(n-t)/Math.max(0,e),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=$e?i*=10:o>=Ue?i*=5:o>=We&&(i*=2),n<t?-i:i}(t,n,e);switch((r=br(null==r?",f":r)).type){case"s":var a=Math.max(Math.abs(t),Math.abs(n));return null!=r.precision||isNaN(i=function(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(yr(n)/3)))-yr(Math.abs(t)))}(o,a))||(r.precision=i),Cr(r,a);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,yr(n)-yr(t))+1}(o,Math.max(Math.abs(t),Math.abs(n))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-yr(Math.abs(t)))}(o))||(r.precision=i-2*("%"===r.type))}return Nr(r)}function Fr(t){var n=t.domain;return t.ticks=function(t){var e=n();return function(t,n,e){var r,i,o,a,s=-1;if(e=+e,(t=+t)==(n=+n)&&e>0)return[t];if((r=n<t)&&(i=t,t=n,n=i),0===(a=Ze(t,n,e))||!isFinite(a))return[];if(a>0)for(t=Math.ceil(t/a),n=Math.floor(n/a),o=new Array(i=Math.ceil(n-t+1));++s<i;)o[s]=(t+s)*a;else for(t=Math.floor(t*a),n=Math.ceil(n*a),o=new Array(i=Math.ceil(t-n+1));++s<i;)o[s]=(t-s)/a;return r&&o.reverse(),o}(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){var r=n();return Dr(r[0],r[r.length-1],null==t?10:t,e)},t.nice=function(e){null==e&&(e=10);var r,i=n(),o=0,a=i.length-1,s=i[o],u=i[a];return u<s&&(r=s,s=u,u=r,r=o,o=a,a=r),(r=Ze(s,u,e))>0?r=Ze(s=Math.floor(s/r)*r,u=Math.ceil(u/r)*r,e):r<0&&(r=Ze(s=Math.ceil(s*r)/r,u=Math.floor(u*r)/r,e)),r>0?(i[o]=Math.floor(s/r)*r,i[a]=Math.ceil(u/r)*r,n(i)):r<0&&(i[o]=Math.ceil(s*r)/r,i[a]=Math.floor(u*r)/r,n(i)),t},t}function Br(){var t=vr(cr,cr);return t.copy=function(){return _r(t,Br())},Qe.apply(t,arguments),Fr(t)}function Pr(){it.stopImmediatePropagation()}function zr(){it.preventDefault(),it.stopImmediatePropagation()}function Or(t){var n=t.document.documentElement,e=vt(t).on("dragstart.drag",zr,!0);"onselectstart"in n?e.on("selectstart.drag",zr,!0):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Ir(t){return function(){return t}}function jr(t,n,e,r,i,o,a,s,u,l){this.target=t,this.type=n,this.subject=e,this.identifier=r,this.active=i,this.x=o,this.y=a,this.dx=s,this.dy=u,this._=l}function Rr(){return!it.ctrlKey&&!it.button}function qr(){return this.parentNode}function Xr(t){return null==t?{x:it.x,y:it.y}:t}function Gr(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vr(){var t,n,e,r,i=Rr,o=qr,a=Xr,s=Gr,u={},l=Mt("start","drag","end"),h=0,c=0;function f(t){t.on("mousedown.drag",d).filter(s).on("touchstart.drag",_).on("touchmove.drag",v).on("touchend.drag touchcancel.drag",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(){if(!r&&i.apply(this,arguments)){var a=y("mouse",o.apply(this,arguments),xt,this,arguments);a&&(vt(it.view).on("mousemove.drag",p,!0).on("mouseup.drag",g,!0),Or(it.view),Pr(),e=!1,t=it.clientX,n=it.clientY,a("start"))}}function p(){if(zr(),!e){var r=it.clientX-t,i=it.clientY-n;e=r*r+i*i>c}u.mouse("drag")}function g(){vt(it.view).on("mousemove.drag mouseup.drag",null),function(t,n){var e=t.document.documentElement,r=vt(t).on("dragstart.drag",null);n&&(r.on("click.drag",zr,!0),setTimeout((function(){r.on("click.drag",null)}),0)),"onselectstart"in e?r.on("selectstart.drag",null):(e.style.MozUserSelect=e.__noselect,delete e.__noselect)}(it.view,e),zr(),u.mouse("end")}function _(){if(i.apply(this,arguments)){var t,n,e=it.changedTouches,r=o.apply(this,arguments),a=e.length;for(t=0;t<a;++t)(n=y(e[t].identifier,r,bt,this,arguments))&&(Pr(),n("start"))}}function v(){var t,n,e=it.changedTouches,r=e.length;for(t=0;t<r;++t)(n=u[e[t].identifier])&&(zr(),n("drag"))}function m(){var t,n,e=it.changedTouches,i=e.length;for(r&&clearTimeout(r),r=setTimeout((function(){r=null}),500),t=0;t<i;++t)(n=u[e[t].identifier])&&(Pr(),n("end"))}function y(t,n,e,r,i){var o,s,c,d=e(n,t),p=l.copy();if(ht(new jr(f,"beforestart",o,t,h,d[0],d[1],0,0,p),(function(){return null!=(it.subject=o=a.apply(r,i))&&(s=o.x-d[0]||0,c=o.y-d[1]||0,!0)})))return function a(l){var g,_=d;switch(l){case"start":u[t]=a,g=h++;break;case"end":delete u[t],--h;case"drag":d=e(n,t),g=h}ht(new jr(f,l,o,t,g,d[0]+s,d[1]+c,d[0]-_[0],d[1]-_[1],p),p.apply,p,[l,r,i])}}return f.filter=function(t){return arguments.length?(i="function"==typeof t?t:Ir(!!t),f):i},f.container=function(t){return arguments.length?(o="function"==typeof t?t:Ir(t),f):o},f.subject=function(t){return arguments.length?(a="function"==typeof t?t:Ir(t),f):a},f.touchable=function(t){return arguments.length?(s="function"==typeof t?t:Ir(!!t),f):s},f.on=function(){var t=l.on.apply(l,arguments);return t===l?f:t},f.clickDistance=function(t){return arguments.length?(c=(t=+t)*t,f):Math.sqrt(c)},f}Tr=Hr({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"}),Nr=Tr.format,Cr=Tr.formatPrefix,jr.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var Yr=Array.prototype.slice;function $r(t){return t}var Ur=1e-6;function Wr(t){return"translate("+(t+.5)+",0)"}function Zr(t){return"translate(0,"+(t+.5)+")"}function Kr(t){return function(n){return+t(n)}}function Qr(t){var n=Math.max(0,t.bandwidth()-1)/2;return t.round()&&(n=Math.round(n)),function(e){return+t(e)+n}}function Jr(){return!this.__axis}function ti(t,n){var e=[],r=null,i=null,o=6,a=6,s=3,u=1===t||4===t?-1:1,l=4===t||2===t?"x":"y",h=1===t||3===t?Wr:Zr;function c(c){var f=null==r?n.ticks?n.ticks.apply(n,e):n.domain():r,d=null==i?n.tickFormat?n.tickFormat.apply(n,e):$r:i,p=Math.max(o,0)+s,g=n.range(),_=+g[0]+.5,v=+g[g.length-1]+.5,m=(n.bandwidth?Qr:Kr)(n.copy()),y=c.selection?c.selection():c,x=y.selectAll(".domain").data([null]),w=y.selectAll(".tick").data(f,n).order(),b=w.exit(),k=w.enter().append("g").attr("class","tick"),M=w.select("line"),A=w.select("text");x=x.merge(x.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),w=w.merge(k),M=M.merge(k.append("line").attr("stroke","currentColor").attr(l+"2",u*o)),A=A.merge(k.append("text").attr("fill","currentColor").attr(l,u*p).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),c!==y&&(x=x.transition(c),w=w.transition(c),M=M.transition(c),A=A.transition(c),b=b.transition(c).attr("opacity",Ur).attr("transform",(function(t){return isFinite(t=m(t))?h(t):this.getAttribute("transform")})),k.attr("opacity",Ur).attr("transform",(function(t){var n=this.parentNode.__axis;return h(n&&isFinite(n=n(t))?n:m(t))}))),b.remove(),x.attr("d",4===t||2==t?a?"M"+u*a+","+_+"H0.5V"+v+"H"+u*a:"M0.5,"+_+"V"+v:a?"M"+_+","+u*a+"V0.5H"+v+"V"+u*a:"M"+_+",0.5H"+v),w.attr("opacity",1).attr("transform",(function(t){return h(m(t))})),M.attr(l+"2",u*o),A.attr(l,u*p).text(d),y.filter(Jr).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),y.each((function(){this.__axis=m}))}return c.scale=function(t){return arguments.length?(n=t,c):n},c.ticks=function(){return e=Yr.call(arguments),c},c.tickArguments=function(t){return arguments.length?(e=null==t?[]:Yr.call(t),c):e.slice()},c.tickValues=function(t){return arguments.length?(r=null==t?null:Yr.call(t),c):r&&r.slice()},c.tickFormat=function(t){return arguments.length?(i=t,c):i},c.tickSize=function(t){return arguments.length?(o=a=+t,c):o},c.tickSizeInner=function(t){return arguments.length?(o=+t,c):o},c.tickSizeOuter=function(t){return arguments.length?(a=+t,c):a},c.tickPadding=function(t){return arguments.length?(s=+t,c):s},c}function ni(t){return ti(3,t)}function ei(t){return ti(4,t)}var ri=Math.PI,ii=2*ri,oi=1e-6,ai=ii-oi;function si(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function ui(){return new si}function li(t){return function(){return t}}si.prototype=ui.prototype={constructor:si,moveTo:function(t,n){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)},closePath:function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,n){this._+="L"+(this._x1=+t)+","+(this._y1=+n)},quadraticCurveTo:function(t,n,e,r){this._+="Q"+ +t+","+ +n+","+(this._x1=+e)+","+(this._y1=+r)},bezierCurveTo:function(t,n,e,r,i,o){this._+="C"+ +t+","+ +n+","+ +e+","+ +r+","+(this._x1=+i)+","+(this._y1=+o)},arcTo:function(t,n,e,r,i){t=+t,n=+n,e=+e,r=+r,i=+i;var o=this._x1,a=this._y1,s=e-t,u=r-n,l=o-t,h=a-n,c=l*l+h*h;if(i<0)throw new Error("negative radius: "+i);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=n);else if(c>oi)if(Math.abs(h*s-u*l)>oi&&i){var f=e-o,d=r-a,p=s*s+u*u,g=f*f+d*d,_=Math.sqrt(p),v=Math.sqrt(c),m=i*Math.tan((ri-Math.acos((p+c-g)/(2*_*v)))/2),y=m/v,x=m/_;Math.abs(y-1)>oi&&(this._+="L"+(t+y*l)+","+(n+y*h)),this._+="A"+i+","+i+",0,0,"+ +(h*f>l*d)+","+(this._x1=t+x*s)+","+(this._y1=n+x*u)}else this._+="L"+(this._x1=t)+","+(this._y1=n);else;},arc:function(t,n,e,r,i,o){t=+t,n=+n,o=!!o;var a=(e=+e)*Math.cos(r),s=e*Math.sin(r),u=t+a,l=n+s,h=1^o,c=o?r-i:i-r;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+u+","+l:(Math.abs(this._x1-u)>oi||Math.abs(this._y1-l)>oi)&&(this._+="L"+u+","+l),e&&(c<0&&(c=c%ii+ii),c>ai?this._+="A"+e+","+e+",0,1,"+h+","+(t-a)+","+(n-s)+"A"+e+","+e+",0,1,"+h+","+(this._x1=u)+","+(this._y1=l):c>oi&&(this._+="A"+e+","+e+",0,"+ +(c>=ri)+","+h+","+(this._x1=t+e*Math.cos(i))+","+(this._y1=n+e*Math.sin(i))))},rect:function(t,n,e,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +r+"h"+-e+"Z"},toString:function(){return this._}};var hi=Math.PI,ci=2*hi;function fi(t){this._context=t}function di(t){return new fi(t)}function pi(t){return t[0]}function gi(t){return t[1]}function _i(){var t=pi,n=gi,e=li(!0),r=null,i=di,o=null;function a(a){var s,u,l,h=a.length,c=!1;for(null==r&&(o=i(l=ui())),s=0;s<=h;++s)!(s<h&&e(u=a[s],s,a))===c&&((c=!c)?o.lineStart():o.lineEnd()),c&&o.point(+t(u,s,a),+n(u,s,a));if(l)return o=null,l+""||null}return a.x=function(n){return arguments.length?(t="function"==typeof n?n:li(+n),a):t},a.y=function(t){return arguments.length?(n="function"==typeof t?t:li(+t),a):n},a.defined=function(t){return arguments.length?(e="function"==typeof t?t:li(!!t),a):e},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}fi.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,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._context.lineTo(t,n)}}};var vi={draw:function(t,n){var e=Math.sqrt(n/hi);t.moveTo(e,0),t.arc(0,0,e,0,ci)}},mi=Math.sqrt(3),yi={draw:function(t,n){var e=-Math.sqrt(n/(3*mi));t.moveTo(0,2*e),t.lineTo(-mi*e,-e),t.lineTo(mi*e,-e),t.closePath()}};function xi(){var t=li(vi),n=li(64),e=null;function r(){var r;if(e||(e=r=ui()),t.apply(this,arguments).draw(e,+n.apply(this,arguments)),r)return e=null,r+""||null}return r.type=function(n){return arguments.length?(t="function"==typeof n?n:li(n),r):t},r.size=function(t){return arguments.length?(n="function"==typeof t?t:li(+t),r):n},r.context=function(t){return arguments.length?(e=null==t?null:t,r):e},r}function wi(t,n,e){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+n)/6,(t._y0+4*t._y1+e)/6)}function bi(t){this._context=t}function ki(t){return new bi(t)}function Mi(t){for(var n=t.length/6|0,e=new Array(n),r=0;r<n;)e[r]="#"+t.slice(6*r,6*++r);return e}bi.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:wi(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:wi(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}};var Ai=Mi("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),Si=Mi("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"),Ti=Mi("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"),Ni=Mi("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),Ci=Mi("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"),Ei=Mi("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f");!function(n,e){"function"==typeof define&&define.amd?define(["leaflet"],n):"object"===("undefined"==typeof exports?"undefined":t(exports))&&(void 0!==e&&e.L?module.exports=n(L):module.exports=n(require("leaflet"))),void 0!==e&&e.L&&(e.L.Control.Heightgraph=n(L))}((function(t){return t.Control.Heightgraph=t.Control.extend({options:{position:"bottomright",width:800,height:280,margins:{top:10,right:30,bottom:55,left:50},mappings:void 0,expand:!0,expandControls:!0,translation:{},expandCallback:void 0,chooseSelectionCallback:void 0,selectedAttributeIdx:0,xTicks:void 0,yTicks:void 0,highlightStyle:void 0,graphStyle:void 0},_defaultTranslation:{distance:"Distance",elevation:"Elevation",segment_length:"Segment length",type:"Type",legend:"Legend"},_init_options:function(){this._margin=this.options.margins,this._width=this.options.width,this._height=this.options.height,this._mappings=this.options.mappings,this._svgWidth=this._width-this._margin.left-this._margin.right,this._svgHeight=this._height-this._margin.top-this._margin.bottom,this._highlightStyle=this.options.highlightStyle||{color:"red"},this._graphStyle=this.options.graphStyle||{},this._dragCache={}},onAdd:function(n){var e=this._container=t.DomUtil.create("div","heightgraph");t.DomEvent.disableClickPropagation(e);this._markerLabel=t.DomUtil.create("input","heightgraph-marker-label",e);if(this.options.expandControls){var r=this._button=t.DomUtil.create("div","heightgraph-toggle",e);t.DomUtil.create("a","heightgraph-toggle-icon",r),this._closeButton=t.DomUtil.create("a","heightgraph-close-icon",e)}return this._showState=!1,this._initToggle(),this._init_options(),this._svg=vt(this._container).append("svg").attr("class","heightgraph-container").attr("width",this._width).attr("height",this._height).append("g").attr("transform","translate("+this._margin.left+","+this._margin.top+")"),this.options.expand&&this._expand(),e},onRemove:function(t){this._removeMarkedSegmentsOnMap(),this._container=null,this._svg=void 0},addData:function(t){this._addData(t)},_addData:function(t){void 0!==this._svg&&this._svg.selectAll("*").remove(),(!t||this.options.selectedAttributeIdx>=t.length)&&(this.options.selectedAttributeIdx=0),this._removeMarkedSegmentsOnMap(),this._resetDrag(!0),this._data=t,this._init_options(),this._prepareData(),this._calculateElevationBounds(),this._appendScales(),this._appendGrid(),0!==Object.keys(t).length&&this._createChart(this.options.selectedAttributeIdx),this._createSelectionBox()},resize:function(t){t.width&&(this.options.width=t.width),t.height&&(this.options.height=t.height),vt(this._container).selectAll("svg").attr("width",this.options.width).attr("height",this.options.height),this._addData(this._data)},_initToggle:function(){t.Browser.touch?t.DomEvent.on(this._container,"click",t.DomEvent.stopPropagation):t.DomEvent.disableClickPropagation(this._container),this.options.expandControls&&(t.DomEvent.on(this._button,"click",this._expand,this),t.DomEvent.on(this._closeButton,"click",this._expand,this))},_dragHandler:function(){"undefined"!=typeof event&&(event.preventDefault(),event.stopPropagation()),this._gotDragged=!0,this._drawDragRectangle()},_drawDragRectangle:function(){if(this._dragStartCoords){var t=this._dragCurrentCoords=this._dragCache.end=xt(this._background.node()),n=Math.min(this._dragStartCoords[0],t[0]),e=Math.max(this._dragStartCoords[0],t[0]);if(this._dragRectangle||this._dragRectangleG)this._dragRectangle.attr("width",e-n).attr("x",n);else{var r=vt(this._container).select("svg").select("g");this._dragRectangleG=r.append("g"),this._dragRectangle=this._dragRectangleG.append("rect").attr("width",e-n).attr("height",this._svgHeight).attr("x",n).attr("class","mouse-drag").style("fill","grey").style("opacity",.5).style("pointer-events","none")}}},_resetDrag:function(t){if(this._dragRectangleG&&(this._dragRectangleG.remove(),this._dragRectangleG=null,this._dragRectangle=null,!0!==t)){var n=this._calculateFullExtent(this._areasFlattended);n&&this._map.fitBounds(n)}},_dragEndHandler:function(){if(!this._dragStartCoords||!this._gotDragged)return this._dragStartCoords=null,this._gotDragged=!1,void this._resetDrag();var t=this._findItemForX(this._dragStartCoords[0]),n=this._findItemForX(this._dragCurrentCoords[0]);this._fitSection(t,n),this._dragStartCoords=null,this._gotDragged=!1},_dragStartHandler:function(){event.preventDefault(),event.stopPropagation(),this._gotDragged=!1,this._dragStartCoords=this._dragCache.start=xt(this._background.node())},_calculateFullExtent:function(n){if(!n||n.length<1)return null;var e=new t.latLngBounds(n[0].latlng,n[0].latlng);return n.forEach((function(t){e.contains(t.latlng)||e.extend(t.latlng)})),e},_fitSection:function(t,n){var e,r=Math.min(t,n),i=Math.max(t,n);r!==i?e=this._calculateFullExtent(this._areasFlattended.slice(r,i+1)):this._areasFlattended.length>0&&(e=[this._areasFlattended[r].latlng,this._areasFlattended[i].latlng]),e&&this._map.fitBounds(e)},_expand:function(){!0!==this.options.expandControls&&(this._showState=!1),this._showState?(vt(this._button).style("display","block"),vt(this._container).selectAll("svg").style("display","none"),vt(this._closeButton).style("display","none"),vt(this._markerLabel).style("display","none")):(vt(this._button).style("display","none"),vt(this._container).selectAll("svg").style("display","block"),vt(this._closeButton).style("display","block"),vt(this._markerLabel).style("display","block")),this._showState=!this._showState,"function"==typeof this.options.expandCallback&&this.options.expandCallback(this._showState)},_removeChart:function(){void 0!==this._svg&&(this._svg.selectAll("path.area").remove(),this._svg.selectAll("path.border-top").remove(),this._svg.selectAll(".legend").remove(),this._svg.selectAll(".lineSelection").remove(),this._svg.selectAll(".horizontalLine").remove(),this._svg.selectAll(".horizontalLineText").remove())},_randomNumber:function(t){return Math.round(Math.random()*(t-0))},_d3ColorCategorical:[Si,Ti,Ci,Ai,Ei,Ni],_prepareData:function(){this._coordinates=[],this._elevations=[],this._cumulatedDistances=[],this._cumulatedDistances.push(0),this._categories=[];var n,e=this._data;if(void 0===this._mappings){var r=this._randomNumber(this._d3ColorCategorical.length-1);n=ur(this._d3ColorCategorical[r])}for(var i=0;i<e.length;i++){var o=0;this._categories[i]={info:{id:i,text:e[i].properties.label||e[i].properties.summary},distances:[],attributes:[],geometries:[],legend:{}};var a=void 0,s=0,u={},l=void 0!==this._mappings&&"function"==typeof this._mappings[e[i].properties.summary];for(a=0;a<e[i].features.length;a++){var h=void 0,c=void 0,f=void 0,d=[],p=e[i].features[a].geometry.coordinates.length,g=e[i].features[a].properties.attributeType,_=void 0,v=void 0;if(void 0===this._mappings)g in u?(_=g,v=u[g]):(_=g,v=n(a),u[g]=v);else if(l){var m=this._mappings[e[i].properties.summary](g);_=m.text,v=m.color}else _=this._mappings[e[i].properties.summary][g].text,v=this._mappings[e[i].properties.summary][g].color;var y={type:g,text:_,color:v};this._categories[i].attributes.push(y),g in this._categories[i].legend||(this._categories[i].legend[g]=y);for(var x=0;x<p;x++){c=new t.LatLng(e[i].features[a].geometry.coordinates[x][1],e[i].features[a].geometry.coordinates[x][0]),h=e[i].features[a].geometry.coordinates[x][2],x<p-1?(f=new t.LatLng(e[i].features[a].geometry.coordinates[x+1][1],e[i].features[a].geometry.coordinates[x+1][0]),o+=c.distanceTo(f)/1e3,0===i&&(this._elevations.push(h),this._coordinates.push(c),this._cumulatedDistances.push(o)),s+=1):x===p-1&&a===e[i].features.length-1&&(0===i&&(this._elevations.push(h),this._coordinates.push(f)),s+=1);var w=void 0;w=x===p-1&&a<e[i].features.length-1?this._cumulatedDistances[s]:this._cumulatedDistances[s-1],d.push({altitude:h,position:w,x:c.lng,y:c.lat,latlng:c,type:_,areaIdx:a})}this._categories[i].distances.push(o),this._categories[i].geometries.push(d)}i===e.length-1&&(this._totalDistance=o)}},_calculateElevationBounds:function(){var t=Ke(this._elevations)||10,n=function(t,n){var e,r,i=t.length,o=-1;if(null==n){for(;++o<i;)if(null!=(e=t[o])&&e>=e)for(r=e;++o<i;)null!=(e=t[o])&&r>e&&(r=e)}else for(;++o<i;)if(null!=(e=n(t[o],o,t))&&e>=e)for(r=e;++o<i;)null!=(e=n(t[o],o,t))&&r>e&&(r=e);return r}(this._elevations)||0,e=t-n;this._elevationBounds={min:e<10?n-10:n-.1*e,max:e<10?t+10:t+.1*e}},_showMapMarker:function(t,n,e){var r=this._map.latLngToLayerPoint(t),i=r.y-75;if(!this._mouseHeightFocus){var o=vt(".leaflet-overlay-pane svg").append("g");this._mouseHeightFocus=o.append("svg:line").attr("class","height-focus line").attr("x2","0").attr("y2","0").attr("x1","0").attr("y1","0"),this._mouseHeightFocusLabel=o.append("g").attr("class","height-focus label"),this._mouseHeightFocusLabelRect=this._mouseHeightFocusLabel.append("rect").attr("class","bBox"),this._mouseHeightFocusLabelTextElev=this._mouseHeightFocusLabel.append("text").attr("class","tspan"),this._mouseHeightFocusLabelTextType=this._mouseHeightFocusLabel.append("text").attr("class","tspan"),(this._pointG=o.append("g").attr("class","height-focus circle")).append("svg:circle").attr("r",5).attr("cx",0).attr("cy",0).attr("class","height-focus circle-lower")}this._mouseHeightFocusLabel.style("display","block"),this._mouseHeightFocus.attr("x1",r.x).attr("x2",r.x).attr("y1",r.y).attr("y2",i).style("display","block"),this._pointG.attr("transform","translate("+r.x+","+r.y+")").style("display","block"),this._mouseHeightFocusLabelRect.attr("x",r.x+3).attr("y",i).attr("class","bBox"),this._mouseHeightFocusLabelTextElev.attr("x",r.x+5).attr("y",i+12).text(n+" m").attr("class","tspan mouse-height-box-text"),this._mouseHeightFocusLabelTextType.attr("x",r.x+5).attr("y",i+24).text(e).attr("class","tspan mouse-height-box-text");var a=this._dynamicBoxSize("text.tspan")[1],s=""===e?18:30;wt(".bBox").attr("width",a+10).attr("height",s)},_createChart:function(t){var n=0===this._categories.length?[]:this._categories[t].geometries;this._areasFlattended=[].concat.apply([],n);for(var e=0;e<n.length;e++)this._appendAreas(n[e],t,e);this._createFocus(),this._appendBackground(),this._createBorderTopLine(),this._createLegend(),this._createHorizontalLine()},_createFocus:function(){var t=this._elevationBounds.min,n=15;this._focus&&(this._focus.remove(),this._focusLineGroup.remove()),this._focus=this._svg.append("g").attr("class","focusbox"),this._focusRect=this._focus.append("rect").attr("x",3).attr("y",-this._y(t)).attr("display","none"),this._focusDistance=this._focus.append("text").attr("x",7).attr("y",-this._y(t)+n).attr("id","heightgraph.distance").text(this._getTranslation("distance")+":"),this._focusHeight=this._focus.append("text").attr("x",7).attr("y",30-this._y(t)).attr("id","heightgraph.height").text(this._getTranslation("elevation")+":"),this._focusBlockDistance=this._focus.append("text").attr("x",7).attr("y",45-this._y(t)).attr("id","heightgraph.blockdistance").text(this._getTranslation("segment_length")+":"),this._focusType=this._focus.append("text").attr("x",7).attr("y",60-this._y(t)).attr("id","heightgraph.type").text(this._getTranslation("type")+":"),this._areaTspan=this._focusBlockDistance.append("tspan").attr("class","tspan"),this._typeTspan=this._focusType.append("tspan").attr("class","tspan");var e=this._dynamicBoxSize(".focusbox text")[0];wt(".focusbox rect").attr("height",e*n+7.5).attr("display","block"),this._focusLineGroup=this._svg.append("g").attr("class","focusLine"),this._focusLine=this._focusLineGroup.append("line").attr("y1",0).attr("y2",this._y(this._elevationBounds.min)),this._distTspan=this._focusDistance.append("tspan").attr("class","tspan"),this._altTspan=this._focusHeight.append("tspan").attr("class","tspan")},_createHorizontalLine:function(){var t=this;this._horizontalLine=this._svg.append("line").attr("class","horizontalLine").attr("x1",0).attr("x2",this._width-this._margin.left-this._margin.right).attr("y1",this._y(this._elevationBounds.min)).attr("y2",this._y(this._elevationBounds.min)).style("stroke","black"),this._elevationValueText=this._svg.append("text").attr("class","horizontalLineText").attr("x",this._width-this._margin.left-this._margin.right-20).attr("y",this._y(this._elevationBounds.min)-10).attr("fill","black");var n=[{x:this._width-this._margin.left-this._margin.right+7,y:this._y(this._elevationBounds.min),color:"black",type:yi,angle:-90,size:100}];this._svg.selectAll(".horizontal-symbol").data(n).enter().append("path").attr("class","lineSelection").attr("d",xi().type((function(t){return t.type})).size((function(t){return t.size}))).attr("transform",(function(t){return"translate("+t.x+","+t.y+") rotate("+t.angle+")"})).attr("id",(function(t){return t.id})).style("fill",(function(t){return t.color})).call(Vr().on("start",(function(t){vt(this).raise().classed("active",!0),vt(".horizontalLine").raise().classed("active",!0)})).on("drag",(function(n){var e=t._svgHeight,r=xt(t._container)[1]-10;vt(this).attr("transform",(function(t){return"translate("+t.x+","+(r<0?0:r>e?e:r)+") rotate("+t.angle+")"})),vt(".horizontalLine").attr("y1",r<0?0:r>e?e:r).attr("y2",r<0?0:r>e?e:r),t._highlightedCoords=r>=e?[]:t._findCoordsForY(r),vt(".horizontalLineText").attr("y",r<=10?0:r>e?e-10:r-10).text(Nr(".0f")(t._y.invert(r<0?0:r>e?e:r))+" m"),t._removeMarkedSegmentsOnMap(),t._markSegmentsOnMap(t._highlightedCoords)})).on("end",(function(n){vt(this).classed("active",!1),vt(".horizontalLine").classed("active",!1),t._removeMarkedSegmentsOnMap(),t._markSegmentsOnMap(t._highlightedCoords)})))},_markSegmentsOnMap:function(n){if(n)if(n.length>1){this._markedSegments=t.featureGroup();var e,i=o(n);try{for(i.s();!(e=i.n()).done;){var a=e.value;t.polyline(a,r(r({},this._highlightStyle),{interactive:!1})).addTo(this._markedSegments)}}catch(t){i.e(t)}finally{i.f()}this._markedSegments.addTo(this._map).bringToFront()}else this._markedSegments=t.polyline(n,this._highlightStyle).addTo(this._map)},_removeMarkedSegmentsOnMap:function(){void 0!==this._markedSegments&&this._map.removeLayer(this._markedSegments)},_appendScales:function(){var t=Boolean(this._totalDistance<=10);this._x=Br().range([0,this._svgWidth]),this._y=Br().range([this._svgHeight,0]),this._x.domain([0,this._totalDistance]),this._y.domain([this._elevationBounds.min,this._elevationBounds.max]),this._xAxis=ni().scale(this._x),!0===t?this._xAxis.tickFormat((function(t){return Nr(".2f")(t)+" km"})):this._xAxis.tickFormat((function(t){return Nr(".0f")(t)+" km"})),this._xAxis.ticks(this.options.xTicks?Math.pow(2,this.options.xTicks):Math.round(this._svgWidth/75),"s"),this._yAxis=ei().scale(this._y).tickFormat((function(t){return t+" m"})),this._yAxis.ticks(this.options.yTicks?Math.pow(2,this.options.yTicks):Math.round(this._svgHeight/30),"s")},_appendBackground:function(){var n=this._background=vt(this._container).select("svg").select("g").append("rect").attr("width",this._svgWidth).attr("height",this._svgHeight).style("fill","none").style("stroke","none").style("pointer-events","all").on("mousemove.focusbox",this._mousemoveHandler.bind(this)).on("mouseout.focusbox",this._mouseoutHandler.bind(this)).on("dblclick",this._mouseDblclickHandler.bind(this));t.Browser.android?(n.on("touchstart.drag",this._dragHandler.bind(this)).on("touchstart.drag",this._dragStartHandler.bind(this)).on("touchstart.focusbox",this._mousemoveHandler.bind(this)),t.DomEvent.on(this._container,"touchend",this._dragEndHandler,this)):(n.on("mousemove.focusbox",this._mousemoveHandler.bind(this)).on("mouseout.focusbox",this._mouseoutHandler.bind(this)).on("mousedown.drag",this._dragStartHandler.bind(this)).on("mousemove.drag",this._dragHandler.bind(this)),t.DomEvent.on(this._container,"mouseup",this._dragEndHandler,this))},_appendGrid:function(){this._svg.append("g").attr("class","grid").attr("transform","translate(0,"+this._svgHeight+")").call(this._make_x_axis().tickSize(-this._svgHeight,0,0).ticks(Math.round(this._svgWidth/75)).tickFormat("")),this._svg.append("g").attr("class","grid").call(this._make_y_axis().tickSize(-this._svgWidth,0,0).ticks(Math.round(this._svgHeight/30)).tickFormat("")),this._svg.append("g").attr("transform","translate(0,"+this._svgHeight+")").attr("class","x axis").call(this._xAxis),this._svg.append("g").attr("transform","translate(-2,0)").attr("class","y axis").call(this._yAxis)},_defined:function(t){return t&&void 0!==t.altitude&&null!==t.altitude},_appendAreas:function(t,n,e){var r=this._categories[n].attributes[e].color,i=this;this._area=function(){var t=pi,n=null,e=li(0),r=gi,i=li(!0),o=null,a=di,s=null;function u(u){var l,h,c,f,d,p=u.length,g=!1,_=new Array(p),v=new Array(p);for(null==o&&(s=a(d=ui())),l=0;l<=p;++l){if(!(l<p&&i(f=u[l],l,u))===g)if(g=!g)h=l,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),c=l-1;c>=h;--c)s.point(_[c],v[c]);s.lineEnd(),s.areaEnd()}g&&(_[l]=+t(f,l,u),v[l]=+e(f,l,u),s.point(n?+n(f,l,u):_[l],r?+r(f,l,u):v[l]))}if(d)return s=null,d+""||null}function l(){return _i().defined(i).curve(a).context(o)}return u.x=function(e){return arguments.length?(t="function"==typeof e?e:li(+e),n=null,u):t},u.x0=function(n){return arguments.length?(t="function"==typeof n?n:li(+n),u):t},u.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:li(+t),u):n},u.y=function(t){return arguments.length?(e="function"==typeof t?t:li(+t),r=null,u):e},u.y0=function(t){return arguments.length?(e="function"==typeof t?t:li(+t),u):e},u.y1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:li(+t),u):r},u.lineX0=u.lineY0=function(){return l().x(t).y(e)},u.lineY1=function(){return l().x(t).y(r)},u.lineX1=function(){return l().x(n).y(e)},u.defined=function(t){return arguments.length?(i="function"==typeof t?t:li(!!t),u):i},u.curve=function(t){return arguments.length?(a=t,null!=o&&(s=a(o)),u):a},u.context=function(t){return arguments.length?(null==t?o=s=null:s=a(o=t),u):o},u}().x((function(t){var n=i._x(t.position);return t.xDiagonalCoordinate=n,n})).y0(this._svgHeight).y1((function(t){return i._y(t.altitude)})).curve(di).defined(this._defined);this._areapath=this._svg.append("path").attr("class","area"),this._areapath.datum(t).attr("d",this._area).attr("stroke",r).styles(this._graphStyle).style("fill",r).style("pointer-events","none")},_make_x_axis:function(){return ni().scale(this._x)},_make_y_axis:function(){return ei().scale(this._y)},_createSelectionBox:function(){var t=this,n=vt(this._container).select("svg"),e=this._width-this._margin.right,r=this._height-this._margin.bottom+this._margin.bottom/2+6,i=[{x:e-25,y:r+3,color:"#000",type:yi,id:"leftArrowSelection",angle:0},{x:e-10,y:r,color:"#000",type:yi,id:"rightArrowSelection",angle:180}],o=n.selectAll(".select-symbol").data(i);o.remove(),o=n.selectAll(".select-symbol").data(i),t._data.length>1&&o.enter().append("path").merge(o).attr("class","select-symbol").attr("d",xi().type((function(t){return t.type}))).attr("transform",(function(t){return"translate("+t.x+","+t.y+") rotate("+t.angle+")"})).attr("id",(function(t){return t.id})).style("fill",(function(t){return t.color})).on("mousedown",(function(n){"rightArrowSelection"===n.id&&s(),"leftArrowSelection"===n.id&&u(),t._gotDragged=!0,t._dragStartCoords=t._dragCache.start,t._dragCurrentCoords=t._dragCache.end}));var a=function(i){if(t._selectionText&&t._selectionText.remove(),0!==t._categories.length){var o=t._categories[i].info;"function"==typeof t.options.chooseSelectionCallback&&t.options.chooseSelectionCallback(i,o);var a=[{selection:o.text}];t._selectionText=n.selectAll("selection_text").data(a).enter().append("text").attr("x",e-35).attr("y",r+4).text((function(t){return t.selection})).attr("class","select-info").attr("id","selectionText").attr("text-anchor","end")}};a(this.options.selectedAttributeIdx);var s=function(){var n=t.options.selectedAttributeIdx+=1;n===t._categories.length&&(t.options.selectedAttributeIdx=n=0),a(n),t._removeChart(),t._removeMarkedSegmentsOnMap(),t._createChart(n)},u=function(){var n=t.options.selectedAttributeIdx-=1;-1===n&&(t.options.selectedAttributeIdx=n=t._categories.length-1),a(n),t._removeChart(),t._removeMarkedSegmentsOnMap(),t._createChart(n)}},_createLegend:function(){var t=this,n=this,e=[];if(this._categories.length>0)for(var r in this._categories[this.options.selectedAttributeIdx].legend)e.push(this._categories[this.options.selectedAttributeIdx].legend[r]);var i=this._height-this._margin.bottom,o=i+this._margin.bottom/2,a=[{text:this._getTranslation("legend")}],s=this._svg.selectAll(".hlegend-hover").data(e).enter().append("g").attr("class","legend").style("display","none").attr("transform",(function(t,n){return"translate(-8,"+(14*n-28)+")"})),u=s.append("rect").attr("class","legend-rect").attr("x",15).attr("y",36).attr("width",6).attr("height",6);0!==Object.keys(this._graphStyle).length?u.styles(this._graphStyle).style("stroke",(function(t,n){return t.color})).style("fill",(function(t,n){return t.color})):u.style("stroke","black").style("fill",(function(t,n){return t.color})),s.append("text").attr("class","legend-text").attr("x",30).attr("y",42).text((function(t,e){var r=t.text;return n._boxBoundY=(i-2*i/3+7)*e,r}));var l=this._svg.selectAll(".legend-hover").data(a).enter().append("g").attr("class","legend-hover");this._showLegend=!1,l.append("text").attr("x",15).attr("y",o).attr("text-anchor","start").text((function(t,n){return t.text})).on("mouseover",(function(){wt(".legend").style("display","block")})).on("mouseleave",(function(){t._showLegend||wt(".legend").style("display","none")})).on("click",(function(){t._showLegend=!t._showLegend}))},_dynamicBoxSize:function(t){for(var n=wt(t).nodes().length,e=[],r=0;r<n;r++)e.push(wt(t).nodes()[r].getBoundingClientRect().width);return[n,Ke(e)]},_createBorderTopLine:function(){var t=this,n=this._areasFlattended,e=_i().x((function(n){return(0,t._x)(n.position)})).y((function(n){return(0,t._y)(n.altitude)})).curve(ki).defined(this._defined);this._svg.append("svg:path").attr("d",e(n)).attr("class","border-top")},_mouseoutHandler:function(){for(var t=0,n=["_focusLine","_focus","_pointG","_mouseHeightFocus","_mouseHeightFocusLabel"];t<n.length;t++){var e=n[t];this[e]&&this[e].style("display","none")}},mapMouseoutHandler:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;this.mouseoutDelay&&window.clearTimeout(this.mouseoutDelay),this.mouseoutDelay=window.setTimeout((function(){t._mouseoutHandler()}),n)},mapMousemoveHandler:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=n.showMapMarker,r=void 0===e||e;if(!1!==this._areasFlattended){var i,a=null,s=2*Math.pow(100,2),u=1.1/111111,l=o(this._areasFlattended);try{for(l.s();!(i=l.n()).done;){var h=i.value,c=t.latlng.lat-h.latlng.lat,f=t.latlng.lng-h.latlng.lng;if(Math.abs(c)<u&&Math.abs(f)<u){this._internalMousemoveHandler(h,r);break}var d=Math.pow(c,2)+Math.pow(f,2);d<s&&(a=h,s=d)}}catch(t){l.e(t)}finally{l.f()}a&&this._internalMousemoveHandler(a,r)}},_mousemoveHandler:function(t,n,e){var r=xt(this._svg.node()),i=this._areasFlattended[this._findItemForX(r[0])];i&&this._internalMousemoveHandler(i)},_internalMousemoveHandler:function(t){var n,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this._defined(t)?t.altitude:"-",i=t.position,o=t.latlng,a=t.areaIdx,s=t.type,u=this._dynamicBoxSize(".focusbox text")[1]+10;n=0===a?this._categories[this.options.selectedAttributeIdx].distances[a]:this._categories[this.options.selectedAttributeIdx].distances[a]-this._categories[this.options.selectedAttributeIdx].distances[a-1],e&&this._showMapMarker(o,r,s),this._distTspan.text(" "+i.toFixed(1)+" km"),this._altTspan.text(" "+r+" m"),this._areaTspan.text(" "+n.toFixed(1)+" km"),this._typeTspan.text(" "+s),this._focusRect.attr("width",u),this._focusLine.style("display","block").attr("x1",this._x(i)).attr("x2",this._x(i));var l=this._x(i)-(u+5),h=this._width-this._margin.left-this._margin.right;this._x(i)+u<h&&this._focus.style("display","initial").attr("transform","translate("+this._x(i)+","+this._y(this._elevationBounds.min)+")"),this._x(i)+u>h&&this._focus.style("display","initial").attr("transform","translate("+l+","+this._y(this._elevationBounds.min)+")")},_findItemForX:function(t){var n=Ve((function(t){return t.position})).left,e=this._x.invert(t);return n(this._areasFlattended,e)},_findCoordsForY:function(t){var n=this._y.invert(t);return function(t,n){for(var e=[],r=0;r<t.length;r++)t[r].altitude>=n&&e.push(r);for(var i=[],o=0,a=0;a<e.length-1;a++)e[a+1]!==e[a]+1&&(i.push(e.slice(o,a+1)),o=a+1);i.push(e.slice(o,e.length));for(var s=0;s<i.length;s++)for(var u=0;u<i[s].length;u++)i[s][u]=t[i[s][u]].latlng;return i}(this._areasFlattended,n)},_getTranslation:function(t){return this.options.translation[t]?this.options.translation[t]:this._defaultTranslation[t]?this._defaultTranslation[t]:(console.error("Unexpected error when looking up the translation for "+t),"No translation found")},_mouseDblclickHandler:function(){event.stopPropagation();const t=xt(this._svg.node())[0],n=this._findItemForX(t);if(-1==n)return;const e=window.heightgraphMarkers.findIndex((n=>{const e=n[0],r=this._areasFlattended[e];return Math.abs(r.xDiagonalCoordinate-t)<5}));if(e>-1){const t=window.heightgraphMarkers[e][0];this._svg.selectAll(".marker-group-"+t).remove(),window.heightgraphMarkers.splice(e,1)}else{const t=this._markerLabel.value.trim();this._markerLabel.value="",this.addPermanentMarker([n,t])}},addPermanentMarker:function(t){const n=t[0],e=t[1],r=this._areasFlattended[n],i=this._defined(r)?Math.round(r.altitude):"-",o=(r.position.toFixed(2),r.xDiagonalCoordinate),a=(window.heightgraphMarkers.push(t),this._svg.append("g").attr("class","marker-group marker-group-"+n));a.append("line").attr("y1",this._y(this._elevationBounds.max)).attr("y2",this._y(this._elevationBounds.min)).attr("x1",o).attr("x2",o);const s=a.append("g"),u=s.append("rect").attr("width",0).attr("height",14),l=s.append("text").attr("x",3).attr("y",11).text(e+(e?" , ":"")+r.position.toFixed(1)+" k , "+i+" m").classed("marker-group-text",!0),h=this._dynamicBoxSize(".marker-group-text")[1]+6;l.classed("marker-group-text",!1),u.attr("width",h);let c=o-14,f=h;c<0&&(c=o);const d=this._y(this._elevationBounds.min),p=this._y(this._elevationBounds.max),g=p+(d-p)/2;this._y(i)<g&&(f=d),s.attr("transform","translate("+c+","+f+"),rotate(-90)")}}),t.control.heightgraph=function(n){return new t.Control.Heightgraph(n)},t.Control.Heightgraph}),window)}();