@flourish/sdk
Version:
The Flourish SDK
1 lines • 125 kB
JavaScript
!function(t){"use strict";function e(t){return function(e,n){return ma(t(e),n)}}function n(){for(var t,e=0,n=arguments.length,i={};e<n;++e){if(!(t=arguments[e]+"")||t in i)throw new Error("illegal type: "+t);i[t]=[]}return new r(i)}function r(t){this._=t}function i(t,e){return t.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");if(r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}function o(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function a(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=ya,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function u(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===_a&&e.documentElement.namespaceURI===_a?e.createElement(t):e.createElementNS(n,t)}}function s(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function l(t,e,n){return t=c(t,e,n),function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t.call(this,e)}}function c(t,e,n){return function(r){var i=Sa;Sa=r;try{t.call(this,this.__data__,e,n)}finally{Sa=i}}}function f(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}function h(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r<o;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.capture);++i?e.length=i:delete this.__on}}}function d(t,e,n){var r=ka.hasOwnProperty(t.type)?l:c;return function(i,o,a){var u,s=this.__on,l=r(e,o,a);if(s)for(var c=0,f=s.length;c<f;++c)if((u=s[c]).type===t.type&&u.name===t.name)return this.removeEventListener(u.type,u.listener,u.capture),this.addEventListener(u.type,u.listener=l,u.capture=n),void(u.value=e);this.addEventListener(t.type,l,n),u={type:t.type,name:t.name,value:e,listener:l,capture:n},s?s.push(u):this.__on=[u]}}function p(){}function v(){return[]}function g(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function m(t,e,n,r,i,o){for(var a,u=0,s=e.length,l=o.length;u<l;++u)(a=e[u])?(a.__data__=o[u],r[u]=a):n[u]=new g(t,o[u]);for(;u<s;++u)(a=e[u])&&(i[u]=a)}function y(t,e,n,r,i,o,a){var u,s,l,c={},f=e.length,h=o.length,d=new Array(f);for(u=0;u<f;++u)(s=e[u])&&(d[u]=l=Ua+a.call(s,s.__data__,u,e),l in c?i[u]=s:c[l]=s);for(u=0;u<h;++u)(s=c[l=Ua+a.call(t,o[u],u,o)])?(r[u]=s,s.__data__=o[u],c[l]=null):n[u]=new g(t,o[u]);for(u=0;u<f;++u)(s=e[u])&&c[d[u]]===s&&(i[u]=s)}function _(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function w(t){return function(){this.removeAttribute(t)}}function b(t){return function(){this.removeAttributeNS(t.space,t.local)}}function x(t,e){return function(){this.setAttribute(t,e)}}function M(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function C(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function A(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function T(t){return function(){this.style.removeProperty(t)}}function k(t,e,n){return function(){this.style.setProperty(t,e,n)}}function S(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function D(t,e){return t.style.getPropertyValue(e)||La(t).getComputedStyle(t,null).getPropertyValue(e)}function E(t){return function(){delete this[t]}}function N(t,e){return function(){this[t]=e}}function F(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function U(t){return t.trim().split(/^|\s+/)}function L(t){return t.classList||new q(t)}function q(t){this._node=t,this._names=U(t.getAttribute("class")||"")}function H(t,e){for(var n=L(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function O(t,e){for(var n=L(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function Y(t){return function(){H(this,t)}}function B(t){return function(){O(this,t)}}function P(t,e){return function(){(e.apply(this,arguments)?H:O)(this,t)}}function j(){this.textContent=""}function R(t){return function(){this.textContent=t}}function $(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function z(){this.innerHTML=""}function I(t){return function(){this.innerHTML=t}}function W(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function X(){this.nextSibling&&this.parentNode.appendChild(this)}function Z(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function V(){return null}function J(){var t=this.parentNode;t&&t.removeChild(this)}function Q(t,e,n){var r=La(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function G(t,e){return function(){return Q(this,t,e)}}function K(t,e){return function(){return Q(this,t,e.apply(this,arguments))}}function tt(t,e){this._groups=t,this._parents=e}function et(){return new tt([[document.documentElement]],qa)}function nt(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function rt(){}function it(t){var e;return t=(t+"").trim().toLowerCase(),(e=Ra.exec(t))?(e=parseInt(e[1],16),new lt(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1)):(e=$a.exec(t))?ot(parseInt(e[1],16)):(e=za.exec(t))?new lt(e[1],e[2],e[3],1):(e=Ia.exec(t))?new lt(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Wa.exec(t))?at(e[1],e[2],e[3],e[4]):(e=Xa.exec(t))?at(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Za.exec(t))?ct(e[1],e[2]/100,e[3]/100,1):(e=Va.exec(t))?ct(e[1],e[2]/100,e[3]/100,e[4]):Ja.hasOwnProperty(t)?ot(Ja[t]):"transparent"===t?new lt(NaN,NaN,NaN,0):null}function ot(t){return new lt(t>>16&255,t>>8&255,255&t,1)}function at(t,e,n,r){return r<=0&&(t=e=n=NaN),new lt(t,e,n,r)}function ut(t){return t instanceof rt||(t=it(t)),t?(t=t.rgb(),new lt(t.r,t.g,t.b,t.opacity)):new lt}function st(t,e,n,r){return 1===arguments.length?ut(t):new lt(t,e,n,null==r?1:r)}function lt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ct(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new ht(t,e,n,r)}function ft(t){if(t instanceof ht)return new ht(t.h,t.s,t.l,t.opacity);if(t instanceof rt||(t=it(t)),!t)return new ht;if(t instanceof ht)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,u=o-i,s=(o+i)/2;return u?(a=e===o?(n-r)/u+6*(n<r):n===o?(r-e)/u+2:(e-n)/u+4,u/=s<.5?o+i:2-o-i,a*=60):u=s>0&&s<1?0:a,new ht(a,u,s,t.opacity)}function ht(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function dt(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function pt(t){if(t instanceof vt)return new vt(t.l,t.a,t.b,t.opacity);if(t instanceof bt){var e=t.h*Qa;return new vt(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}t instanceof lt||(t=ut(t));var n=_t(t.r),r=_t(t.g),i=_t(t.b),o=gt((.4124564*n+.3575761*r+.1804375*i)/Ka),a=gt((.2126729*n+.7151522*r+.072175*i)/tu);return new vt(116*a-16,500*(o-a),200*(a-gt((.0193339*n+.119192*r+.9503041*i)/eu)),t.opacity)}function vt(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}function gt(t){return t>ou?Math.pow(t,1/3):t/iu+nu}function mt(t){return t>ru?t*t*t:iu*(t-nu)}function yt(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function _t(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function wt(t){if(t instanceof bt)return new bt(t.h,t.c,t.l,t.opacity);t instanceof vt||(t=pt(t));var e=Math.atan2(t.b,t.a)*Ga;return new bt(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function bt(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}function xt(t){if(t instanceof Ct)return new Ct(t.h,t.s,t.l,t.opacity);t instanceof lt||(t=ut(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(du*r+fu*e-hu*n)/(du+fu-hu),o=r-i,a=(cu*(n-i)-su*o)/lu,u=Math.sqrt(a*a+o*o)/(cu*i*(1-i)),s=u?Math.atan2(a,o)*Ga-120:NaN;return new Ct(s<0?s+360:s,u,i,t.opacity)}function Mt(t,e,n,r){return 1===arguments.length?xt(t):new Ct(t,e,n,null==r?1:r)}function Ct(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function At(t,e){return function(n){return t+n*e}}function Tt(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function kt(t){return 1==(t=+t)?St:function(e,n){return n-e?Tt(e,n,t):yu(isNaN(e)?n:e)}}function St(t,e){var n=e-t;return n?At(t,n):yu(isNaN(t)?e:t)}function Dt(t){return function(){return t}}function Et(t){return function(e){return t(e)+""}}function Nt(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}function o(t,r,i,o,a,u){if(t!==i||r!==o){var s=a.push("translate(",null,e,null,n);u.push({i:s-4,x:xu(t,i)},{i:s-2,x:xu(r,o)})}else(i||o)&&a.push("translate("+i+e+o+n)}function a(t,e,n,o){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:xu(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}function u(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:xu(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}function s(t,e,n,r,o,a){if(t!==n||e!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:xu(t,n)},{i:u-2,x:xu(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}return function(e,n){var r=[],i=[];return e=t(e),n=t(n),o(e.translateX,e.translateY,n.translateX,n.translateY,r,i),a(e.rotate,n.rotate,r,i),u(e.skewX,n.skewX,r,i),s(e.scaleX,e.scaleY,n.scaleX,n.scaleY,r,i),e=n=null,function(t){for(var e,n=-1,o=i.length;++n<o;)r[(e=i[n]).i]=e.x(t);return r.join("")}}}function Ft(t){return function e(n){function r(e,r){var i=t((e=Mt(e)).h,(r=Mt(r)).h),o=St(e.s,r.s),a=St(e.l,r.l),u=St(e.opacity,r.opacity);return function(t){return e.h=i(t),e.s=o(t),e.l=a(Math.pow(t,n)),e.opacity=u(t),e+""}}return n=+n,r.gamma=e,r}(1)}function Ut(){return ju||(zu(Lt),ju=$u.now()+Ru)}function Lt(){ju=0}function qt(){this._call=this._time=this._next=null}function Ht(t,e,n){var r=new qt;return r.restart(t,e,n),r}function Ot(){Ut(),++Hu;for(var t,e=Uu;e;)(t=ju-e._time)>=0&&e._call.call(null,t),e=e._next;--Hu}function Yt(){ju=(Pu=$u.now())+Ru,Hu=Ou=0;try{Ot()}finally{Hu=0,Pt(),ju=0}}function Bt(){var t=$u.now(),e=t-Pu;e>Bu&&(Ru-=e,Pu=t)}function Pt(){for(var t,e,n=Uu,r=1/0;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Uu=e);Lu=t,jt(r)}function jt(t){Hu||(Ou&&(Ou=clearTimeout(Ou)),t-ju>24?(t<1/0&&(Ou=setTimeout(Yt,t-$u.now()-Ru)),Yu&&(Yu=clearInterval(Yu))):(Yu||(Pu=$u.now(),Yu=setInterval(Bt,Bu)),Hu=1,zu(Yt)))}function Rt(t,e){var n=t.__transition;if(!n||!(n=n[e])||n.state>Zu)throw new Error("too late");return n}function $t(t,e){var n=t.__transition;if(!n||!(n=n[e])||n.state>Ju)throw new Error("too late");return n}function zt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("too late");return n}function It(t,e,n){function r(s){var l,c,f,h;if(n.state!==Vu)return o();for(l in u)if((h=u[l]).name===n.name){if(h.state===Qu)return Iu(r);h.state===Gu?(h.state=ts,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete u[l]):+l<e&&(h.state=ts,h.timer.stop(),delete u[l])}if(Iu(function(){n.state===Qu&&(n.state=Gu,n.timer.restart(i,n.delay,n.time),i(s))}),n.state=Ju,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Ju){for(n.state=Qu,a=new Array(f=n.tween.length),l=0,c=-1;l<f;++l)(h=n.tween[l].value.call(t,t.__data__,n.index,n.group))&&(a[++c]=h);a.length=c+1}}function i(e){for(var r=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(o),n.state=Ku,1),i=-1,u=a.length;++i<u;)a[i].call(null,r);n.state===Ku&&(n.on.call("end",t,t.__data__,n.index,n.group),o())}function o(){n.state=ts,n.timer.stop(),delete u[e];for(var r in u)return;delete t.__transition}var a,u=t.__transition;u[e]=n,n.timer=Ht(function(t){n.state=Vu,n.timer.restart(r,n.delay,n.time),n.delay<=t&&r(t-n.delay)},0,n.time)}function Wt(t,e){var n,r;return function(){var i=$t(this,t),o=i.tween;if(o!==n)for(var a=0,u=(r=n=o).length;a<u;++a)if(r[a].name===e){(r=r.slice()).splice(a,1);break}i.tween=r}}function Xt(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var o=$t(this,t),a=o.tween;if(a!==r){i=(r=a).slice();for(var u={name:e,value:n},s=0,l=i.length;s<l;++s)if(i[s].name===e){i[s]=u;break}s===l&&i.push(u)}o.tween=i}}function Zt(t,e,n){var r=t._id;return t.each(function(){var t=$t(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return zt(t,r).value[e]}}function Vt(t){return function(){this.removeAttribute(t)}}function Jt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Qt(t,e,n){var r,i;return function(){var o=this.getAttribute(t);return o===n?null:o===r?i:i=e(r=o,n)}}function Gt(t,e,n){var r,i;return function(){var o=this.getAttributeNS(t.space,t.local);return o===n?null:o===r?i:i=e(r=o,n)}}function Kt(t,e,n){var r,i,o;return function(){var a,u=n(this);{if(null!=u)return(a=this.getAttribute(t))===u?null:a===r&&u===i?o:o=e(r=a,i=u);this.removeAttribute(t)}}}function te(t,e,n){var r,i,o;return function(){var a,u=n(this);{if(null!=u)return(a=this.getAttributeNS(t.space,t.local))===u?null:a===r&&u===i?o:o=e(r=a,i=u);this.removeAttributeNS(t.space,t.local)}}}function ee(t,e){function n(){var n=this,r=e.apply(n,arguments);return r&&function(e){n.setAttributeNS(t.space,t.local,r(e))}}return n._value=e,n}function ne(t,e){function n(){var n=this,r=e.apply(n,arguments);return r&&function(e){n.setAttribute(t,r(e))}}return n._value=e,n}function re(t,e){return function(){Rt(this,t).delay=+e.apply(this,arguments)}}function ie(t,e){return e=+e,function(){Rt(this,t).delay=e}}function oe(t,e){return function(){$t(this,t).duration=+e.apply(this,arguments)}}function ae(t,e){return e=+e,function(){$t(this,t).duration=e}}function ue(t,e){if("function"!=typeof e)throw new Error;return function(){$t(this,t).ease=e}}function se(t){return(t+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t})}function le(t,e,n){var r,i,o=se(e)?Rt:$t;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(e,n),a.on=i}}function ce(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function fe(t,e){var n,r,i;return function(){var o=D(this,t),a=(this.style.removeProperty(t),D(this,t));return o===a?null:o===n&&a===r?i:i=e(n=o,r=a)}}function he(t){return function(){this.style.removeProperty(t)}}function de(t,e,n){var r,i;return function(){var o=D(this,t);return o===n?null:o===r?i:i=e(r=o,n)}}function pe(t,e,n){var r,i,o;return function(){var a=D(this,t),u=n(this);return null==u&&(this.style.removeProperty(t),u=D(this,t)),a===u?null:a===r&&u===i?o:o=e(r=a,i=u)}}function ve(t,e,n){function r(){var r=this,i=e.apply(r,arguments);return i&&function(e){r.style.setProperty(t,i(e),n)}}return r._value=e,r}function ge(t){return function(){this.textContent=t}}function me(t){return function(){var e=t(this);this.textContent=null==e?"":e}}function ye(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function _e(){return++os}function we(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))return ss.time=Ut(),ss;return n}function be(t){return{type:t}}function xe(t){return function(e,n){return ls(t(e),n)}}function Me(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function Ce(){}function Ae(t,e){var n=new Ce;if(t instanceof Ce)t.each(function(t,e){n.set(e,t)});else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==e)for(;++i<o;)n.set(i,t[i]);else for(;++i<o;)n.set(e(r=t[i],i,t),r)}else if(t)for(var a in t)n.set(a,t[a]);return n}function Te(){}function ke(t){return new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}")}function Se(t,e){var n=ke(t);return function(r,i){return e(n(r),i,t)}}function De(t){var e=Object.create(null),n=[];return t.forEach(function(t){for(var r in t)r in e||n.push(e[r]=r)}),n}function Ee(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,u,s,l,c,f,h,d=t._root,p={data:r},v=t._x0,g=t._y0,m=t._x1,y=t._y1;if(!d)return t._root=p,t;for(;d.length;)if((l=e>=(o=(v+m)/2))?v=o:m=o,(c=n>=(a=(g+y)/2))?g=a:y=a,i=d,!(d=d[f=c<<1|l]))return i[f]=p,t;if(u=+t._x.call(null,d.data),s=+t._y.call(null,d.data),e===u&&n===s)return p.next=d,i?i[f]=p:t._root=p,t;do{i=i?i[f]=new Array(4):t._root=new Array(4),(l=e>=(o=(v+m)/2))?v=o:m=o,(c=n>=(a=(g+y)/2))?g=a:y=a}while((f=c<<1|l)==(h=(s>=a)<<1|u>=o));return i[h]=d,i[f]=p,t}function Ne(t){return t[0]}function Fe(t){return t[1]}function Ue(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Le(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}function qe(t){return new He(t)}function He(t){if(!(e=Ds.exec(t)))throw new Error("invalid format: "+t);var e,n=e[1]||" ",r=e[2]||">",i=e[3]||"-",o=e[4]||"",a=!!e[5],u=e[6]&&+e[6],s=!!e[7],l=e[8]&&+e[8].slice(1),c=e[9]||"";"n"===c?(s=!0,c="g"):Ss[c]||(c=""),(a||"0"===n&&"="===r)&&(a=!0,n="0",r="="),this.fill=n,this.align=r,this.sign=i,this.symbol=o,this.zero=a,this.width=u,this.comma=s,this.precision=l,this.type=c}function Oe(){this.reset()}function Ye(t,e,n){var r=t.s=e+n,i=r-e,o=r-i;t.t=e-o+(n-i)}function Be(t){return t>1?0:t<-1?Ys:Math.acos(t)}function Pe(t){return t>1?Bs:t<-1?-Bs:Math.asin(t)}function je(t){return function(e,n){var r=Rs(e),i=Rs(n),o=t(r*i);return[o*i*$s(e),o*$s(n)]}}function Re(t){return function(e,n){var r=zs(e*e+n*n),i=t(r),o=$s(i),a=Rs(i);return[js(e*o,r*a),Pe(r&&n*o/r)]}}function $e(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function ze(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;for(t=n.pop(),e=r.pop();t===e;)i=t,t=n.pop(),e=r.pop();return i}function Ie(t,e){var n,r,i,o,a,u=new Ve(t),s=+t.value&&(u.value=t.value),l=[u];for(null==e&&(e=We);n=l.pop();)if(s&&(n.value=+n.data.value),(i=e(n.data))&&(a=i.length))for(n.children=new Array(a),o=a-1;o>=0;--o)l.push(r=n.children[o]=new Ve(i[o])),r.parent=n,r.depth=n.depth+1;return u.eachBefore(Ze)}function We(t){return t.children}function Xe(t){t.data=t.data.data}function Ze(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Ve(t){this.data=t,this.depth=this.height=0,this.parent=null}function Je(t){if(!t._start)try{Qe(t)}catch(e){if(t._tasks[t._ended+t._active-1])Ke(t,e);else if(!t._data)throw e}}function Qe(t){for(;t._start=t._waiting&&t._active<t._size;){var e=t._ended+t._active,n=t._tasks[e],r=n.length-1,i=n[r];n[r]=Ge(t,e),--t._waiting,++t._active,n=i.apply(null,n),t._tasks[e]&&(t._tasks[e]=n||Is)}}function Ge(t,e){return function(n,r){t._tasks[e]&&(--t._active,++t._ended,t._tasks[e]=null,null==t._error&&(null!=n?Ke(t,n):(t._data[e]=r,t._waiting?Je(t):tn(t))))}}function Ke(t,e){var n,r=t._tasks.length;for(t._error=e,t._data=void 0,t._waiting=NaN;--r>=0;)if((n=t._tasks[r])&&(t._tasks[r]=null,n.abort))try{n.abort()}catch(e){}t._active=NaN,tn(t)}function tn(t){if(!t._active&&t._call){var e=t._data;t._data=void 0,t._call(t._error,e)}}function en(t,e,n,r){function i(e){return t(e=new Date(+e)),e}return i.floor=i,i.ceil=function(n){return t(n=new Date(n-1)),e(n,1),t(n),n},i.round=function(t){var e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=function(t,n){return e(t=new Date(+t),null==n?1:Math.floor(n)),t},i.range=function(n,r,o){var a=[];if(n=i.ceil(n),o=null==o?1:Math.floor(o),!(n<r&&o>0))return a;do{a.push(new Date(+n))}while(e(n,o),t(n),n<r);return a},i.filter=function(n){return en(function(e){if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)},function(t,r){if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););})},n&&(i.count=function(e,r){return Xs.setTime(+e),Zs.setTime(+r),t(Xs),t(Zs),Math.floor(n(Xs,Zs))},i.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?function(e){return r(e)%t==0}:function(e){return i.count(0,e)%t==0}):i:null}),i}function nn(t){return en(function(e){e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},function(t,e){t.setDate(t.getDate()+7*e)},function(t,e){return(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Js)/Qs})}function rn(t){return en(function(e){e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},function(t,e){t.setUTCDate(t.getUTCDate()+7*e)},function(t,e){return(e-t)/Qs})}function on(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function an(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function un(t){return{y:t,m:0,d:1,H:0,M:0,S:0,L:0}}function sn(t){function e(t,e){return function(n){var r,i,o,a=[],u=-1,s=0,l=t.length;for(n instanceof Date||(n=new Date(+n));++u<l;)37===t.charCodeAt(u)&&(a.push(t.slice(s,u)),null!=(i=dl[r=t.charAt(++u)])?r=t.charAt(++u):i="e"===r?" ":"0",(o=e[r])&&(r=o(n,i)),a.push(r),s=u+1);return a.push(t.slice(s,u)),a.join("")}}function n(t,e){return function(n){var i,o,a=un(1900);if(r(a,t,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("p"in a&&(a.H=a.H%12+12*a.p),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(i=(o=(i=an(un(a.y))).getUTCDay())>4||0===o?ol.ceil(i):ol(i),i=rl.offset(i,7*(a.V-1)),a.y=i.getUTCFullYear(),a.m=i.getUTCMonth(),a.d=i.getUTCDate()+(a.w+6)%7):(i=(o=(i=e(un(a.y))).getDay())>4||0===o?tl.ceil(i):tl(i),i=Gs.offset(i,7*(a.V-1)),a.y=i.getFullYear(),a.m=i.getMonth(),a.d=i.getDate()+(a.w+6)%7)}else("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),o="Z"in a?an(un(a.y)).getUTCDay():e(un(a.y)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(o+5)%7:a.w+7*a.U-(o+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,an(a)):e(a)}}function r(t,e,n,r){for(var i,o,a=0,u=e.length,s=n.length;a<u;){if(r>=s)return-1;if(37===(i=e.charCodeAt(a++))){if(i=e.charAt(a++),!(o=C[i in dl?e.charAt(a++):i])||(r=o(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}var i=t.dateTime,o=t.date,a=t.time,u=t.periods,s=t.days,l=t.shortDays,c=t.months,f=t.shortMonths,h=fn(u),d=hn(u),p=fn(s),v=hn(s),g=fn(l),m=hn(l),y=fn(c),_=hn(c),w=fn(f),b=hn(f),x={a:function(t){return l[t.getDay()]},A:function(t){return s[t.getDay()]},b:function(t){return f[t.getMonth()]},B:function(t){return c[t.getMonth()]},c:null,d:Fn,e:Fn,f:On,H:Un,I:Ln,j:qn,L:Hn,m:Yn,M:Bn,p:function(t){return u[+(t.getHours()>=12)]},Q:dr,s:pr,S:Pn,u:jn,U:Rn,V:$n,w:zn,W:In,x:null,X:null,y:Wn,Y:Xn,Z:Zn,"%":hr},M={a:function(t){return l[t.getUTCDay()]},A:function(t){return s[t.getUTCDay()]},b:function(t){return f[t.getUTCMonth()]},B:function(t){return c[t.getUTCMonth()]},c:null,d:Vn,e:Vn,f:tr,H:Jn,I:Qn,j:Gn,L:Kn,m:er,M:nr,p:function(t){return u[+(t.getUTCHours()>=12)]},Q:dr,s:pr,S:rr,u:ir,U:or,V:ar,w:ur,W:sr,x:null,X:null,y:lr,Y:cr,Z:fr,"%":hr},C={a:function(t,e,n){var r=g.exec(e.slice(n));return r?(t.w=m[r[0].toLowerCase()],n+r[0].length):-1},A:function(t,e,n){var r=p.exec(e.slice(n));return r?(t.w=v[r[0].toLowerCase()],n+r[0].length):-1},b:function(t,e,n){var r=w.exec(e.slice(n));return r?(t.m=b[r[0].toLowerCase()],n+r[0].length):-1},B:function(t,e,n){var r=y.exec(e.slice(n));return r?(t.m=_[r[0].toLowerCase()],n+r[0].length):-1},c:function(t,e,n){return r(t,i,e,n)},d:xn,e:xn,f:Sn,H:Cn,I:Cn,j:Mn,L:kn,m:bn,M:An,p:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.p=d[r[0].toLowerCase()],n+r[0].length):-1},Q:En,s:Nn,S:Tn,u:pn,U:vn,V:gn,w:dn,W:mn,x:function(t,e,n){return r(t,o,e,n)},X:function(t,e,n){return r(t,a,e,n)},y:_n,Y:yn,Z:wn,"%":Dn};return x.x=e(o,x),x.X=e(a,x),x.c=e(i,x),M.x=e(o,M),M.X=e(a,M),M.c=e(i,M),{format:function(t){var n=e(t+="",x);return n.toString=function(){return t},n},parse:function(t){var e=n(t+="",on);return e.toString=function(){return t},e},utcFormat:function(t){var n=e(t+="",M);return n.toString=function(){return t},n},utcParse:function(t){var e=n(t,an);return e.toString=function(){return t},e}}}function ln(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o<n?new Array(n-o+1).join(e)+i:i)}function cn(t){return t.replace(gl,"\\$&")}function fn(t){return new RegExp("^(?:"+t.map(cn).join("|")+")","i")}function hn(t){for(var e={},n=-1,r=t.length;++n<r;)e[t[n].toLowerCase()]=n;return e}function dn(t,e,n){var r=pl.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function pn(t,e,n){var r=pl.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function vn(t,e,n){var r=pl.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function gn(t,e,n){var r=pl.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function mn(t,e,n){var r=pl.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function yn(t,e,n){var r=pl.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function _n(t,e,n){var r=pl.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function wn(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function bn(t,e,n){var r=pl.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function xn(t,e,n){var r=pl.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Mn(t,e,n){var r=pl.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Cn(t,e,n){var r=pl.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function An(t,e,n){var r=pl.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Tn(t,e,n){var r=pl.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function kn(t,e,n){var r=pl.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Sn(t,e,n){var r=pl.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Dn(t,e,n){var r=vl.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function En(t,e,n){var r=pl.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Nn(t,e,n){var r=pl.exec(e.slice(n));return r?(t.Q=1e3*+r[0],n+r[0].length):-1}function Fn(t,e){return ln(t.getDate(),e,2)}function Un(t,e){return ln(t.getHours(),e,2)}function Ln(t,e){return ln(t.getHours()%12||12,e,2)}function qn(t,e){return ln(1+Gs.count(nl(t),t),e,3)}function Hn(t,e){return ln(t.getMilliseconds(),e,3)}function On(t,e){return Hn(t,e)+"000"}function Yn(t,e){return ln(t.getMonth()+1,e,2)}function Bn(t,e){return ln(t.getMinutes(),e,2)}function Pn(t,e){return ln(t.getSeconds(),e,2)}function jn(t){var e=t.getDay();return 0===e?7:e}function Rn(t,e){return ln(Ks.count(nl(t),t),e,2)}function $n(t,e){var n=t.getDay();return t=n>=4||0===n?el(t):el.ceil(t),ln(el.count(nl(t),t)+(4===nl(t).getDay()),e,2)}function zn(t){return t.getDay()}function In(t,e){return ln(tl.count(nl(t),t),e,2)}function Wn(t,e){return ln(t.getFullYear()%100,e,2)}function Xn(t,e){return ln(t.getFullYear()%1e4,e,4)}function Zn(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+ln(e/60|0,"0",2)+ln(e%60,"0",2)}function Vn(t,e){return ln(t.getUTCDate(),e,2)}function Jn(t,e){return ln(t.getUTCHours(),e,2)}function Qn(t,e){return ln(t.getUTCHours()%12||12,e,2)}function Gn(t,e){return ln(1+rl.count(ul(t),t),e,3)}function Kn(t,e){return ln(t.getUTCMilliseconds(),e,3)}function tr(t,e){return Kn(t,e)+"000"}function er(t,e){return ln(t.getUTCMonth()+1,e,2)}function nr(t,e){return ln(t.getUTCMinutes(),e,2)}function rr(t,e){return ln(t.getUTCSeconds(),e,2)}function ir(t){var e=t.getUTCDay();return 0===e?7:e}function or(t,e){return ln(il.count(ul(t),t),e,2)}function ar(t,e){var n=t.getUTCDay();return t=n>=4||0===n?al(t):al.ceil(t),ln(al.count(ul(t),t)+(4===ul(t).getUTCDay()),e,2)}function ur(t){return t.getUTCDay()}function sr(t,e){return ln(ol.count(ul(t),t),e,2)}function lr(t,e){return ln(t.getUTCFullYear()%100,e,2)}function cr(t,e){return ln(t.getUTCFullYear()%1e4,e,4)}function fr(){return"+0000"}function hr(){return"%"}function dr(t){return+t}function pr(t){return Math.floor(+t/1e3)}function vr(t){this._context=t}function gr(t){return t<0?-1:1}function mr(t,e,n){var r=t._x1-t._x0,i=e-t._x1,o=(t._y1-t._y0)/(r||i<0&&-0),a=(n-t._y1)/(i||r<0&&-0),u=(o*i+a*r)/(r+i);return(gr(o)+gr(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(u))||0}function yr(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function _r(t,e,n){var r=t._x0,i=t._y0,o=t._x1,a=t._y1,u=(o-r)/3;t._context.bezierCurveTo(r+u,i+u*e,o-u,a-u*n,o,a)}function wr(t){this._context=t}function br(t){this._context=t}function xr(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Mr(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Cr(t){return{y:t,m:0,d:1,H:0,M:0,S:0,L:0}}function Ar(t){function e(t,e){return function(n){var r,i,o,a=[],u=-1,s=0,l=t.length;for(n instanceof Date||(n=new Date(+n));++u<l;)37===t.charCodeAt(u)&&(a.push(t.slice(s,u)),null!=(i=Ml[r=t.charAt(++u)])?r=t.charAt(++u):i="e"===r?" ":"0",(o=e[r])&&(r=o(n,i)),a.push(r),s=u+1);return a.push(t.slice(s,u)),a.join("")}}function n(t,e){return function(n){var i=Cr(1900);if(r(i,t,n+="",0)!=n.length)return null;if("p"in i&&(i.H=i.H%12+12*i.p),"W"in i||"U"in i){"w"in i||(i.w="W"in i?1:0);var o="Z"in i?Mr(Cr(i.y)).getUTCDay():e(Cr(i.y)).getDay();i.m=0,i.d="W"in i?(i.w+6)%7+7*i.W-(o+5)%7:i.w+7*i.U-(o+6)%7}return"Z"in i?(i.H+=i.Z/100|0,i.M+=i.Z%100,Mr(i)):e(i)}}function r(t,e,n,r){for(var i,o,a=0,u=e.length,s=n.length;a<u;){if(r>=s)return-1;if(37===(i=e.charCodeAt(a++))){if(i=e.charAt(a++),!(o=C[i in Ml?e.charAt(a++):i])||(r=o(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}var i=t.dateTime,o=t.date,a=t.time,u=t.periods,s=t.days,l=t.shortDays,c=t.months,f=t.shortMonths,h=Sr(u),d=Dr(u),p=Sr(s),v=Dr(s),g=Sr(l),m=Dr(l),y=Sr(c),_=Dr(c),w=Sr(f),b=Dr(f),x={a:function(t){return l[t.getDay()]},A:function(t){return s[t.getDay()]},b:function(t){return f[t.getMonth()]},B:function(t){return c[t.getMonth()]},c:null,d:zr,e:zr,H:Ir,I:Wr,j:Xr,L:Zr,m:Vr,M:Jr,p:function(t){return u[+(t.getHours()>=12)]},S:Qr,U:Gr,w:Kr,W:ti,x:null,X:null,y:ei,Y:ni,Z:ri,"%":yi},M={a:function(t){return l[t.getUTCDay()]},A:function(t){return s[t.getUTCDay()]},b:function(t){return f[t.getUTCMonth()]},B:function(t){return c[t.getUTCMonth()]},c:null,d:ii,e:ii,H:oi,I:ai,j:ui,L:si,m:li,M:ci,p:function(t){return u[+(t.getUTCHours()>=12)]},S:fi,U:hi,w:di,W:pi,x:null,X:null,y:vi,Y:gi,Z:mi,"%":yi},C={a:function(t,e,n){var r=g.exec(e.slice(n));return r?(t.w=m[r[0].toLowerCase()],n+r[0].length):-1},A:function(t,e,n){var r=p.exec(e.slice(n));return r?(t.w=v[r[0].toLowerCase()],n+r[0].length):-1},b:function(t,e,n){var r=w.exec(e.slice(n));return r?(t.m=b[r[0].toLowerCase()],n+r[0].length):-1},B:function(t,e,n){var r=y.exec(e.slice(n));return r?(t.m=_[r[0].toLowerCase()],n+r[0].length):-1},c:function(t,e,n){return r(t,i,e,n)},d:Or,e:Or,H:Br,I:Br,j:Yr,L:Rr,m:Hr,M:Pr,p:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.p=d[r[0].toLowerCase()],n+r[0].length):-1},S:jr,U:Nr,w:Er,W:Fr,x:function(t,e,n){return r(t,o,e,n)},X:function(t,e,n){return r(t,a,e,n)},y:Lr,Y:Ur,Z:qr,"%":$r};return x.x=e(o,x),x.X=e(a,x),x.c=e(i,x),M.x=e(o,M),M.X=e(a,M),M.c=e(i,M),{format:function(t){var n=e(t+="",x);return n.toString=function(){return t},n},parse:function(t){var e=n(t+="",xr);return e.toString=function(){return t},e},utcFormat:function(t){var n=e(t+="",M);return n.toString=function(){return t},n},utcParse:function(t){var e=n(t,Mr);return e.toString=function(){return t},e}}}function Tr(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o<n?new Array(n-o+1).join(e)+i:i)}function kr(t){return t.replace(Tl,"\\$&")}function Sr(t){return new RegExp("^(?:"+t.map(kr).join("|")+")","i")}function Dr(t){for(var e={},n=-1,r=t.length;++n<r;)e[t[n].toLowerCase()]=n;return e}function Er(t,e,n){var r=Cl.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Nr(t,e,n){var r=Cl.exec(e.slice(n));return r?(t.U=+r[0],n+r[0].length):-1}function Fr(t,e,n){var r=Cl.exec(e.slice(n));return r?(t.W=+r[0],n+r[0].length):-1}function Ur(t,e,n){var r=Cl.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Lr(t,e,n){var r=Cl.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function qr(t,e,n){var r=/^(Z)|([+-]\d\d)(?:\:?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Hr(t,e,n){var r=Cl.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Or(t,e,n){var r=Cl.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Yr(t,e,n){var r=Cl.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Br(t,e,n){var r=Cl.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Pr(t,e,n){var r=Cl.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function jr(t,e,n){var r=Cl.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Rr(t,e,n){var r=Cl.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function $r(t,e,n){var r=Al.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function zr(t,e){return Tr(t.getDate(),e,2)}function Ir(t,e){return Tr(t.getHours(),e,2)}function Wr(t,e){return Tr(t.getHours()%12||12,e,2)}function Xr(t,e){return Tr(1+Gs.count(nl(t),t),e,3)}function Zr(t,e){return Tr(t.getMilliseconds(),e,3)}function Vr(t,e){return Tr(t.getMonth()+1,e,2)}function Jr(t,e){return Tr(t.getMinutes(),e,2)}function Qr(t,e){return Tr(t.getSeconds(),e,2)}function Gr(t,e){return Tr(Ks.count(nl(t),t),e,2)}function Kr(t){return t.getDay()}function ti(t,e){return Tr(tl.count(nl(t),t),e,2)}function ei(t,e){return Tr(t.getFullYear()%100,e,2)}function ni(t,e){return Tr(t.getFullYear()%1e4,e,4)}function ri(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Tr(e/60|0,"0",2)+Tr(e%60,"0",2)}function ii(t,e){return Tr(t.getUTCDate(),e,2)}function oi(t,e){return Tr(t.getUTCHours(),e,2)}function ai(t,e){return Tr(t.getUTCHours()%12||12,e,2)}function ui(t,e){return Tr(1+rl.count(ul(t),t),e,3)}function si(t,e){return Tr(t.getUTCMilliseconds(),e,3)}function li(t,e){return Tr(t.getUTCMonth()+1,e,2)}function ci(t,e){return Tr(t.getUTCMinutes(),e,2)}function fi(t,e){return Tr(t.getUTCSeconds(),e,2)}function hi(t,e){return Tr(il.count(ul(t),t),e,2)}function di(t){return t.getUTCDay()}function pi(t,e){return Tr(ol.count(ul(t),t),e,2)}function vi(t,e){return Tr(t.getUTCFullYear()%100,e,2)}function gi(t,e){return Tr(t.getUTCFullYear()%1e4,e,4)}function mi(){return"+0000"}function yi(){return"%"}function _i(t){Nl=t,Ha("body").classed("full-screen",Nl)}function wi(){Oa(".toggle-full-screen").on("click",function(){var t=document.querySelector(".full-screen-ready");t.requestFullScreen?Nl?document.exitFullScreen():t.requestFullScreen():t.webkitRequestFullScreen?Nl?document.webkitExitFullscreen():t.webkitRequestFullScreen():t.msRequestFullScreen?Nl?document.msExitFullscreen():t.msRequestFullScreen():t.mozRequestFullScreen&&(Nl?document.mozExitFullScreen():t.mozRequestFullScreen())}),document.addEventListener("fullscreenchange",function(){_i(document.mozFullScreen||document.webkitIsFullScreen)},!1),document.addEventListener("mozfullscreenchange",function(){_i(document.mozIsFullScreen)},!1),document.addEventListener("webkitfullscreenchange",function(){_i(document.webkitIsFullScreen)},!1)}function bi(t){El=t,"custom"===t?Ha(".preview-holder").style("width",Dl.nodes()[0].value+"px").style("height",Dl.nodes()[1].value+"px"):Ha(".preview-holder").attr("style",null),Oa("#preview-menu .preview-mode").classed("selected",function(){return this.id=="editor-"+t}),Ha("#editor-rotate").classed("active",function(){return"auto"!==t}),Ha(".row.editor").classed("mobile",function(){return"mobile"==t}),Ha(".row.editor").classed("tablet",function(){return"tablet"==t}),Ha(".preview-holder").on("webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd transitionend",Mi),kl=t}function xi(){Dl=Oa("#editor-custom input"),Mi(),Oa("#preview-menu .preview-mode").on("click",function(){bi(this.getAttribute("data-target"))}),Dl.on("change",function(){bi(this.getAttribute("data-target"))}),Ha("#editor-rotate").on("click",function(){if("custom"===El){var t=Dl.nodes()[0].value,e=Dl.nodes()[1].value;Dl.nodes()[0].value=e,Dl.nodes()[1].value=t,bi("custom")}else Ha(".row.editor").classed("landscape",function(){return!Ha(".row.editor").classed("landscape")})}),bi("auto"),Ci(),window.innerWidth<=768&&(Sl="auto"),window.addEventListener("resize",function(){kl&&Mi(),window.innerWidth<=768?Sl||(Sl=kl,bi("auto")):Sl&&(bi(Sl),Sl=null)})}function Mi(){var t=Ha(".preview-holder").node().getBoundingClientRect();Dl.nodes()[0].value=Math.round(t.width),Dl.nodes()[1].value=Math.round(t.height)}function Ci(){function t(t){var e=t.clientX-a,i=t.clientY-u;o.style.width=n+2*e+"px",o.style.height=r+i+"px",Mi()}function e(){n=o.getBoundingClientRect().width,r=o.getBoundingClientRect().height,Ha(".preview-holder").style("transition",null),i.parentElement.querySelector("#resize-overlay").classList.remove("dragging"),Mi(),document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",e)}var n,r,i=document.querySelector("#resize-handle"),o=document.querySelector(".preview-holder");i.addEventListener("mousedown",function(s){n=o.getBoundingClientRect().width,r=o.getBoundingClientRect().height,i.parentElement.querySelector("#resize-overlay").classList.add("dragging"),a=s.clientX,u=s.clientY,Ha(".preview-holder").style("transition","none"),bi("custom"),document.addEventListener("mousemove",t),document.addEventListener("mouseup",e),s.preventDefault()});var a,u}function Ai(){this.unique_id=Fl++,this._container=document.body,this._maxWidth="70%",this._point=null,this._html=null,this._directions=Ol,this._fallbackFit="horizontal",this.handlers={click:[]}}function Ti(t){return t.replace(/[&<>]/g,function(t){return{"&":"&","<":"<",">":">"}[t]})}function ki(t,e,n){var r,i=document.createElementNS("http://www.w3.org/2000/svg",t);if(e)for(r in e)i.setAttribute(r,e[r]);var o=i.style;if(n)for(r in n)o[r]=n[r];return i}function Si(t,e,n,r,i,o,a){var u,s=n-t/2-Hl,l=n+t/2+Hl,c=t/2+Math.min(0,s-i.left)+Math.max(0,l-i.right);return u=c-ql<Ll?[-c,(-Hl-Ll)*o,Math.max(ql,Ll-c),-Hl*o]:c+ql>t-Ll?[Math.min(-ql,t-c-Ll),-Hl*o,Math.min(ql,t-c),(-Hl-Ll)*o]:[-ql,-Hl*o,ql,-Hl*o],{pos:[c,a],shape:u}}function Di(t,e,n,r,i,o,a){var u,s=r-e/2-Hl,l=r+e/2+Hl,c=e/2+Math.min(0,s-i.top)+Math.max(0,l-i.bottom);return u=c-ql<Ll?[(-Hl-Ll)*o,-c,-Hl*o,Math.max(ql,Ll-c)]:c+ql>e-Ll?[-Hl*o,Math.min(-ql,e-c-Ll),(-Hl-Ll)*o,Math.min(ql,e-c)]:[-Hl*o,-ql,-Hl*o,ql],{pos:[a,c],shape:u}}function Ei(t,e,n,r,i,o){var a=Bl[t](e,n,r,i,o),u=r-Ul-a.pos[0],s=i-Ul-a.pos[1];return{left:u,top:s,right:u+e+2*Ul,bottom:s+n+2*Ul}}function Ni(t,e,n,r,i,o,a,u,s,l){var c=Bl[t](r,i,u,s,l);e.left=o-Ul-c.pos[0]+"px",e.top=a-Ul-c.pos[1]+"px",n.setAttribute("d","M0,0L"+c.shape.join(",")+"Z"),n.setAttribute("transform","translate("+(c.pos[0]+Ul)+","+(c.pos[1]+Ul)+")")}function Fi(){return new Ai}function Ui(){Pl=Fi().container(document.body),Li(Oa(".popup"))}function Li(t){t.on("mouseover",function(){if(this.getAttribute("data-popup-head")||this.getAttribute("data-popup-body")){var t=this.getAttribute("data-popup-position"),e=this.getBoundingClientRect(),n=e.left+e.width/2,r=e.top+e.height,i=this.getAttribute("data-popup-head")||null,o=this.getAttribute("data-popup-body")||null,a="",u=["top","topFlexible"];i&&(a+="<h1>"+i+"</h1>"),o&&(a+="<p>"+o+"</p>"),t&&("left"===t?(u=["right","rightFlexible"],n=e.left,r=e.top+e.height/2):"right"===t?(u=["left","leftFlexible"],n=e.right,r=e.top+e.height/2):"top"===t?(u=["bottom","bottomFlexible"],n=e.left+e.width/2,r=e.top):"bottom"===t&&(u=["top","topFlexible"],n=e.left+e.width/2,r=e.top+e.height)),Pl.point(n,r).html(a).directions(u).draw()}}).on("mouseout",function(){Pl.hide()})}function qi(){Kl?Oi():Hi()}function Hi(){Pl.hide(),Ha(".side-panel").classed("closed",!1),Ha(".side-panel-close").classed("opener",!1).select("i").classed("fa-close",!0).classed("fa-cog",!1),Kl=!0}function Oi(){Pl.hide(),Ha(".side-panel").classed("closed",!0),Ha(".side-panel-close").classed("opener",!0).select("i").classed("fa-close",!1).classed("fa-cog",!0),Kl=!1}function Yi(){Ha(".side-panel .side-panel-close").on("click",qi),Ha(".side-panel .side-panel-scrollbox").on("scroll",function(){this.scrollTop>0?Ha(".current-template").classed("shadow",!0):Ha(".current-template").classed("shadow",!1)})}function Bi(t){if(t=t.toUpperCase(),!/^[A-Z]+$/.test(t))throw new Error("Invalid column spec: "+t);for(var e=0,n=0;n<t.length;n++)e=26*e+(t.charCodeAt(n)-64);return e-1}function Pi(t){t+=1;for(var e="";t>0;){var n=Math.floor(t/26),r=t%26;0==r&&(n-=1,r+=26),e=String.fromCharCode(64+r)+e,t=n}return e}function ji(t){var e=t.match(/\s*(?:[-–—:]|\.\.)\s*/);if(!e)throw new Error("Failed to parse column range: "+t);for(var n=t.substr(0,e.index),r=t.substr(e.index+e[0].length),i=Bi(n),o=Bi(r),a=Array(Math.max(0,o-i+1)),u=0;u<=o-i;u++)a[u]=u+i;return a}function Ri(t,e){return Pi(t)+"-"+Pi(e)}function $i(t){var e=[],n=(t=t.replace(/^\s+|\s+$/g,"")).split(/\s*,\s*/);1==n.length&&""===n[0]&&(n=[]);for(var r=0;r<n.length;r++){var i=n[r];/^[A-Za-z]+$/.test(i)?e.push(Bi(i)):Array.prototype.push.apply(e,ji(i))}return e}function zi(t){for(var e,n,r=[],i=0;i<t.length;i++)i>0&&t[i]==t[i-1]+1?n=t[i]:(void 0!==e&&r.push([e,n]),e=n=t[i]);return void 0!==e&&r.push([e,n]),r}function Ii(t){for(var e=zi(t),n=[],r=0;r<e.length;r++){var i=e[r];i[0]==i[1]?n.push(Pi(i[0])):n.push(Ri(i[0],i[1]))}return n.join(",")}function Wi(t,e){var n={};if(!(t.type in t))throw new Error("Data binding must specify '"+t.type+"': "+JSON.stringify(t));var r=t[t.type].indexOf("::");if(-1==r)throw new Error("Invalid data binding: "+t[t.type]);var i=t[t.type].substr(0,r);n.data_table_id=e[i];var o=t[t.type].substr(r+2);if("column"==t.type)n.column=Bi(o);else{if("columns"!=t.type)throw new Error("Unknown data binding type: "+t.type);n.columns=$i(o)}return n}function Xi(t,e,n){var r=n?e[t.data_table_id]+"::":"";if("column"in t)return r+Pi(t.column);if("columns"in t)return r+Ii(t.columns);throw new Error("Data binding must have .column or .columns")}function Zi(){Ha(".add-data-binding h2").on("click",Vi)}function Vi(){Ha(this.parentNode).classed("open",function(){return!Ha(this).classed("open")})}function Ji(t,e){nc={},rc=0,t.template_id&&t.dataTables(function(n){if(n)return console.error("Failed to get data tables: "+n);var r=t.dataBindingsForCurrentTemplate(),i=t.getDataTableNames();Rl.html("");var o,a=null;"string"!=typeof e[0]&&(e=["Data"].concat(e));for(var u=0;u<e.length;u++){var s,l=e[u];if("string"!=typeof l){var c=r[l.dataset]&&r[l.dataset][l.key];!o&&c&&(o=c.data_table_id,s.selectAll("option").property("selected",function(){return this.getAttribute("data-id")==o}));var f=o&&c&&c.data_table_id!==o;nc[l.dataset+"-"+l.key]=l.type;Qi(a?a.append("div"):Rl.append("div"),l,c,i,f)}else{if((a=Rl.append("div").attr("class","data-block open")).append("h2").attr("class","no-select").text(l).on("click",Vi),u!==e.length-1){var h=e[u+1];"string"==typeof h&&(a.append("p").text(h),u+=1)}a.append("div").attr("class","datatable-selector-container").append("h4").text("Sheet"),(s=a.select(".datatable-selector-container").append("select").attr("class","datatable-selector").attr("data-index",u).attr("disabled",!jl.visualisation.can_edit||null)).on("change",function(){Pl.hide();for(var t=+this.dataset.index+1;t<e.length&&"string"!=typeof e[t];t++){var n=e[t];to(Rl.select("input#data-binding-"+n.dataset+"-"+n.key).node(),n)}});for(var d in jl.visualisation.getDataTableNames())s.append("option").attr("data-id",d).html(jl.visualisation.getDataTableNames()[d]);o=null}}jl.spreadsheet&&jl.spreadsheet.updateHighlights()})}function Qi(t,e,n,r,i){tc[rc]||(rc=0),t.attr("class","settings-option option-type-"+e.type);var o=void 0===n?"":Xi(n,r,i,e.optional);ec[e.dataset]||(ec[e.dataset]={}),ec[e.dataset][e.key]=rc,t.append("h3").text(e.name),"column"!=e.type||e.optional||t.append("span").attr("class","required").text("REQUIRED"),t.append("input").attr("id","data-binding-"+e.dataset+"-"+e.key).attr("name",e.dataset+"-"+e.key).attr("disabled",!jl.visualisation.can_edit||null).each(function(){this.value=o}).attr("data-value",o).attr("type","text").call(Gi(e)).style("background",tc[rc].light).style("border-color",tc[rc].full),t.append("p").html(e.description),rc++}function Gi(t){return function(e){e.on("change",function(){Pl.hide(),to(this,t)}).on("keydown",function(){jl.confirm.blank()}).on("blur",function(){Pl.hide()})}}function Ki(t,e){jl.confirm.saving(),jl.visualisation.updateDataBindings(t,function(t){if(t)return jl.confirm.error(t.message||t),console.error("Failed to save data binding:",t),void jl.analytics("send","exception",{exDescription:t.message||t,exFatal:!0});jl.analytics("send","event","visualisation","change_data_binding",jl.visualisation.id),jl.confirm.saved(),e&&e()})}function to(t,e){var n=t.parentElement.parentElement.querySelector(".datatable-selector").value,r=t.value.indexOf("::")>-1,i={type:e.type};"column"==i.type?i.column=r?t.value:n+"::"+t.value:i.columns=r?t.value:n+"::"+t.value;var o;if(e.optional&&!t.value)o=null;else{try{o=Wi(i,jl.visualisation.getDataTableIds())}catch(e){return console.error("Failed to parse data binding",e),t.value=t.getAttribute("data-value"),void Pl.point(t).text("Invalid column specification").draw()}if(!o.data_table_id)return t.value=t.getAttribute("data-value"),void Pl.point(t).text("No such data table").draw()}var a={};a[e.dataset]={},a[e.dataset][e.key]=o,jl.tour.fireEvent("data-binding-change",{changed_data_bindings:a}),Ki(a,function(){t.setAttribute("data-value",t.value),jl.preview_pane.updateData(function(e){if(e){var n=t.value&&-1!==t.value.indexOf(/[,-]/)?"these columns":"this column";Pl.point(t).text("One or more values in "+n+" are causing an error").draw(),t.value=t.getAttribute("data-value")}}),jl.spreadsheet&&jl.spreadsheet.updateHighlights()})}function eo(t){jl=t,Rl=Ha(".side-panel .data-bindings"),jl.data_bindings={update:function(t){t&&(jl.template_data_bindings=t),Ji(jl.visualisation,jl.template_data_bindings)},modify:function(t){Ki(t,function(){Ji(jl.visualisation,jl.template_data_bindings)})}},Zi()}function no(t,e,n){var r=t.template_id;return function(){Xl&&Xl.template_id==r&&($l.on("load",null),so(e,function(){Xl&&Xl.template_id==r&&co(function(t,e){t?console.error("Failed to call hasData"):Xl&&Xl.template_id==r&&(e?Xl.refreshDataBindings(function(t){t?console.error("Failed to refresh data bindings"):Xl&&Xl.template_id==r&&Xl.prepareData(function(t,e){t?console.error("Failed to prepare data for template"):Xl&&Xl.template_id==r&&fo(e,function(){po(n)})})}):po(n))})}))}}function ro(t,e,n){return Wl=!1,Xl=t,t&&t.template_id?$l.on("load",no(t,e,n)).attr("src","/template/"+t.template_id+"/embed/?environment="+Il):$l.on("load",null).attr("src","about:blank")}function io(t,e,n,r){if(Wl=!1,!e)return $l.on("load",null).attr("src","about:blank");var i=t[e]||"/template/"+e+"/embed";return i+="?environment="+Il,r&&(i+="&auto=1"),$l.on("load",n).attr("src",i)}function oo(t,e){var n=t.template_id;t.refreshDataBindings(function(r){r?console.error("Failed to fetch data bindings"):t.prepareData(function(t,r){Xl&&Xl.template_id==n&&(t?console.error("Failed to prepare data for template"):fo(r,function(){vo(e)}))})})}function ao(t,e,n){so(e,function(){oo(t,n)})}function uo(t,e,n){var r=new MessageChannel;r.port1.onmessage=function(t){var e=t.data;if("string"==typeof e){if(!n)return;return n(void 0,JSON.parse(e))}if("object"==typeof e){if("result"in e){if(!n)return;return n(void 0,e.result)}if("error"in e){if(!n)return;return n(e.error)}console.error("Unrecognised response to message",e)}else console.error("Unrecognised response to message",e)},zl.contentWindow.postMessage({sender:"Flourish",method:t,argument:e},"*",[r.port2])}function so(t,e){uo("setState",t,e)}function lo(t,e){"function"!=typeof t?uo("getState",t,e):uo("getState",void 0,t)}function co(t){uo("hasData",void 0,t)}function fo(t,e){uo("setData",t,e)}function ho(t){uo("getData",void 0,t)}function po(t){uo("draw",void 0,t),Wl=!0}function vo(t){Wl&&uo("update",void 0,t)}function go(t,e){uo("snapshot",t,e)}function mo(t,e){return $l=Ha(t),zl=$l.node(),Il=e,{loadVisualisation:ro,loadTemplate:io,updateData:oo,updateDataAndState:ao,setState:so,getState:lo,hasData:co,setData:fo,getData:ho,draw:po,update:vo,snapshot:go}}function yo(){function t(){var t=Zl.template_settings.getSettingsForCurrentTemplate(),e=Zl.visualisation.settingsForCurrentTemplate(),n={};for(var r in e)r in t&&(n[r]=e[r]);Vl.loadVisualisation(Zl.visualisation,n,function(){Zl.template_settings.populate(),ic.clear()}),Mi()}var e=Zl.visualisation,n=e.getTemplate(),r=!1,i=!1,o=!1;n.getSettings(function(e,n){e?console.error("Failed to get template settings: "+e):(Zl.template_settings.update(n),r=!0,i&&o&&t())}),n.getDataBindings(function(e,n){e?console.error("Failed to get template data bindings: "+e):(Zl.data_bindings.update(n),i=!0,r&&o&&t())}),e.refreshDataBindings(function(e){e?console.error("Failed to get template data bindings: "+e):(o=!0,i&&r&&t())})}function _o(t){Vl.updateData(Zl.visualisation,t)}function wo(t){return Zl=t,Vl=mo("iframe#preview","editor"),{loadTemplate:yo,updateData:_o,setState:Vl.setState,getState:Vl.getState,hasData:Vl.hasData,setData:Vl.setData,getData:Vl.getData,draw:Vl.draw,update:Vl.update,snapshot:Vl.snapshot}}function bo(t,e,n,r){function i(t){if(1===t.length)return"dropdown-category";var e="dropdown-item";return s&&t[0]===s&&(e+=" current"),e}function o(t){c.selectAll("div").remove(),c.selectAll("div").data(t).enter().append("div").attr("class",i).attr("data-value",function(t){return"string"==typeof t?t||null:t[1]}).text(function(t){return"