@flourish/sdk 3.19.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/site/script.js CHANGED
@@ -1,3 +1,3 @@
1
- var Flourish=function(t){"use strict";function e(t){return parseInt(t).toString()===""+t&&t>=0}function n(t,e,n){return t.map((function(t){var r={};return Object.keys(e).forEach((function(n){r[n]=t[e[n]]})),Object.keys(n).forEach((function(e){var i=n[e];Array.isArray(i)||(i=[i]),r[e]=i.map((function(e){return t[e]}))})),r}))}function r(t,e,r){var i=n(t,e=e||{},r=r||{});return i.column_names={},Object.keys(e).forEach((function(t){i.column_names[t]=e[t]})),Object.keys(r).forEach((function(t){var e=r[t];i.column_names[t]=Array.isArray(e)?e:[e]})),i}function i(t,r,i){!function(t,n){var r;if(!Object.keys(t).every((function(n){return e(t[n])})))throw r="All column_bindings values should be non-negative integers",new TypeError(r);if(!Object.keys(n).every((function(t){var r=n[t];return Array.isArray(r)?r.every(e):e(r)})))throw r="All columns_bindings values should be non-negative integers or arrays thereof",new TypeError(r)}(r=r||{},i=i||{});var a=t[0],o=n(t.slice(1),r,i);return o.column_names={},Object.keys(r).forEach((function(t){o.column_names[t]=a[r[t]]})),Object.keys(i).forEach((function(t){var e=i[t];o.column_names[t]=(Array.isArray(e)?e:[e]).map((function(t){return a[t]}))})),o}function a(t,e,n){return(Array.isArray(t[0])?i:r)(t,e,n)}var o="http://www.w3.org/1999/xhtml",s={svg:"http://www.w3.org/2000/svg",xhtml:o,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 e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),s.hasOwnProperty(e)?{space:s[e],local:t}:t}function l(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===o&&e.documentElement.namespaceURI===o?e.createElement(t):e.createElementNS(n,t)}}function c(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function d(t){var e=u(t);return(e.local?c:l)(e)}function f(){}function p(t){return null==t?f:function(){return this.querySelector(t)}}function h(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function m(){return[]}function v(t){return null==t?m:function(){return this.querySelectorAll(t)}}function g(t){return function(){return this.matches(t)}}function y(t){return function(e){return e.matches(t)}}var _=Array.prototype.find;function b(){return this.firstElementChild}var w=Array.prototype.filter;function x(){return this.children}function A(t){return new Array(t.length)}function E(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function T(t){return function(){return t}}function C(t,e,n,r,i,a){for(var o,s=0,u=e.length,l=a.length;s<l;++s)(o=e[s])?(o.__data__=a[s],r[s]=o):n[s]=new E(t,a[s]);for(;s<u;++s)(o=e[s])&&(i[s]=o)}function k(t,e,n,r,i,a,o){var s,u,l,c=new Map,d=e.length,f=a.length,p=new Array(d);for(s=0;s<d;++s)(u=e[s])&&(p[s]=l=o.call(u,u.__data__,s,e)+"",c.has(l)?i[s]=u:c.set(l,u));for(s=0;s<f;++s)l=o.call(t,a[s],s,a)+"",(u=c.get(l))?(r[s]=u,u.__data__=a[s],c.delete(l)):n[s]=new E(t,a[s]);for(s=0;s<d;++s)(u=e[s])&&c.get(p[s])===u&&(i[s]=u)}function D(t){return t.__data__}function F(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function S(t){return function(){this.removeAttribute(t)}}function M(t){return function(){this.removeAttributeNS(t.space,t.local)}}function N(t,e){return function(){this.setAttribute(t,e)}}function L(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function O(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function U(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 R(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function B(t){return function(){this.style.removeProperty(t)}}function j(t,e,n){return function(){this.style.setProperty(t,e,n)}}function H(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function I(t,e){return t.style.getPropertyValue(e)||R(t).getComputedStyle(t,null).getPropertyValue(e)}function z(t){return function(){delete this[t]}}function P(t,e){return function(){this[t]=e}}function q(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function $(t){return t.trim().split(/^|\s+/)}function Y(t){return t.classList||new V(t)}function V(t){this._node=t,this._names=$(t.getAttribute("class")||"")}function W(t,e){for(var n=Y(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function G(t,e){for(var n=Y(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function X(t){return function(){W(this,t)}}function J(t){return function(){G(this,t)}}function Z(t,e){return function(){(e.apply(this,arguments)?W:G)(this,t)}}function K(){this.textContent=""}function Q(t){return function(){this.textContent=t}}function tt(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function et(){this.innerHTML=""}function nt(t){return function(){this.innerHTML=t}}function rt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function it(){this.nextSibling&&this.parentNode.appendChild(this)}function at(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ot(){return null}function st(){var t=this.parentNode;t&&t.removeChild(this)}function ut(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function lt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function ct(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 dt(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,a=e.length;r<a;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function ft(t,e,n){return function(){var r,i=this.__on,a=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var o=0,s=i.length;o<s;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),void(r.value=e);this.addEventListener(t.type,a,n),r={type:t.type,name:t.name,value:e,listener:a,options:n},i?i.push(r):this.__on=[r]}}function pt(t,e,n){var r=R(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 ht(t,e){return function(){return pt(this,t,e)}}function mt(t,e){return function(){return pt(this,t,e.apply(this,arguments))}}E.prototype={constructor:E,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},V.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var vt,gt,yt,_t,bt,wt=[null];function xt(t,e){this._groups=t,this._parents=e}function At(){return new xt([[document.documentElement]],wt)}function Et(t){return"string"==typeof t?new xt([[document.querySelector(t)]],[document.documentElement]):new xt([[t]],wt)}function Tt(t){return Et(d(t).call(document.documentElement))}function Ct(t){return"string"==typeof t?new xt([document.querySelectorAll(t)],[document.documentElement]):new xt([null==t?[]:h(t)],wt)}function kt(){if(!yt)return null;var t=yt.nodes()[1].value;if("custom"===_t&&""!=t){var e=parseInt(t,10);return isNaN(e)?null:e}return null}function Dt(){bt&&bt.preview_pane&&bt.preview_pane.setFixedHeight&&bt.preview_pane.setFixedHeight(kt())}function Ft(t,e=!1){_t=t,Dt(),"custom"===t?(Et("#editor-custom-inputs").style("opacity",1),Et(".preview-holder").style("width",yt.nodes()[0].value+"px").select("iframe").style("width",yt.nodes()[0].value+"px")):(Et("#editor-custom-inputs").style("opacity",0),Et(".preview-holder").attr("style",null).select("iframe").style("width",null)),e||Et(".preview-holder").style("max-width","none"),Ct("#preview-menu .preview-mode").classed("selected",(function(){return this.id=="editor-"+t})),Et("#editor-rotate").classed("active",(function(){return"auto"!==t})),Et(".row.editor").classed("mobile",(function(){return"mobile"==t})),Et(".row.editor").classed("tablet",(function(){return"tablet"==t})),Et(".preview-holder").on("webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd transitionend",Mt),vt=t}function St(t){return bt=t,yt=Ct("#editor-custom-inputs input"),Mt(),Ct("#preview-menu .preview-mode").on("click",(function(){Ft(this.getAttribute("data-target"))})),yt.on("change",(function(){Ft(this.getAttribute("data-target"))})),Ft("auto",!0),function(){var t,e,n=document.querySelector("#resize-handle"),r=document.querySelector(".preview-holder");function i(i){"editor-custom"!==i.target.parentElement.id&&(t=r.getBoundingClientRect().width,n.parentElement.parentElement.querySelector("#resize-overlay").classList.add("dragging"),n.parentElement.classList.add("dragging"),e=i.clientX,Et(".preview-holder").style("transition","none"),Ft("custom"),document.addEventListener("mousemove",a),document.addEventListener("mouseup",o),i.preventDefault())}function a(n){var i=n.clientX-e,a=t+2*i;r.style.width=a+"px",r.querySelector("iframe").style.width=a-4+"px",Mt(),bt.preview_pane.resize()}function o(){t=r.getBoundingClientRect().width,Et(".preview-holder").style("transition",null),n.parentElement.parentElement.querySelector("#resize-overlay").classList.remove("dragging"),n.parentElement.classList.remove("dragging"),Mt(),bt.preview_pane.resize(),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",o)}n.addEventListener("mousedown",i)}
2
- /*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */(),window.innerWidth<=768&&(gt="auto"),window.addEventListener("resize",(function(){vt&&Mt(),window.innerWidth<=768?gt||(gt=vt,Ft("auto")):gt&&(Ft(gt),gt=null),bt.preview_pane.resize()})),{getHeightSetting:kt}}function Mt(){var t=Et(".preview-holder").node().getBoundingClientRect();yt.nodes()[0].value=Math.round(t.width),""!==yt.nodes()[1].value&&"custom"===_t&&(yt.nodes()[1].value=Math.round(t.height))}xt.prototype=At.prototype={constructor:xt,select:function(t){"function"!=typeof t&&(t=p(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o,s=e[i],u=s.length,l=r[i]=new Array(u),c=0;c<u;++c)(a=s[c])&&(o=t.call(a,a.__data__,c,s))&&("__data__"in a&&(o.__data__=a.__data__),l[c]=o);return new xt(r,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);return null==e?[]:h(e)}}(t):v(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o,s=e[a],u=s.length,l=0;l<u;++l)(o=s[l])&&(r.push(t.call(o,o.__data__,l,s)),i.push(o));return new xt(r,i)},selectChild:function(t){return this.select(null==t?b:function(t){return function(){return _.call(this.children,t)}}("function"==typeof t?t:y(t)))},selectChildren:function(t){return this.selectAll(null==t?x:function(t){return function(){return w.call(this.children,t)}}("function"==typeof t?t:y(t)))},filter:function(t){"function"!=typeof t&&(t=g(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,u=r[i]=[],l=0;l<s;++l)(a=o[l])&&t.call(a,a.__data__,l,o)&&u.push(a);return new xt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,D);var n=e?k:C,r=this._parents,i=this._groups;"function"!=typeof t&&(t=T(t));for(var a=i.length,o=new Array(a),s=new Array(a),u=new Array(a),l=0;l<a;++l){var c=r[l],d=i[l],f=d.length,p=h(t.call(c,c&&c.__data__,l,r)),m=p.length,v=s[l]=new Array(m),g=o[l]=new Array(m),y=u[l]=new Array(f);n(c,d,v,g,y,p,e);for(var _,b,w=0,x=0;w<m;++w)if(_=v[w]){for(w>=x&&(x=w+1);!(b=g[x])&&++x<m;);_._next=b||null}}return(o=new xt(o,r))._enter=s,o._exit=u,o},enter:function(){return new xt(this._enter||this._groups.map(A),this._parents)},exit:function(){return new xt(this._exit||this._groups.map(A),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,a=this.exit();return r="function"==typeof t?t(r):r.append(t+""),null!=e&&(i=e(i)),null==n?a.remove():n(a),r&&i?r.merge(i).order():i},merge:function(t){if(!(t instanceof xt))throw new Error("invalid merge");for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var u,l=e[s],c=n[s],d=l.length,f=o[s]=new Array(d),p=0;p<d;++p)(u=l[p]||c[p])&&(f[p]=u);for(;s<r;++s)o[s]=e[s];return new xt(o,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],a=i.length-1,o=i[a];--a>=0;)(r=i[a])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=F);for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o,s=n[a],u=s.length,l=i[a]=new Array(u),c=0;c<u;++c)(o=s[c])&&(l[c]=o);l.sort(e)}return new xt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,a=e[n],o=0,s=a.length;o<s;++o)(i=a[o])&&t.call(i,i.__data__,o,a);return this},attr:function(t,e){var n=u(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?M:S:"function"==typeof e?n.local?U:O:n.local?L:N)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?B:"function"==typeof e?H:j)(t,e,null==n?"":n)):I(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?z:"function"==typeof e?q:P)(t,e)):this.node()[t]},classed:function(t,e){var n=$(t+"");if(arguments.length<2){for(var r=Y(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?Z:e?X:J)(n,e))},text:function(t){return arguments.length?this.each(null==t?K:("function"==typeof t?tt:Q)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?et:("function"==typeof t?rt:nt)(t)):this.node().innerHTML},raise:function(){return this.each(it)},lower:function(){return this.each(at)},append:function(t){var e="function"==typeof t?t:d(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:d(t),r=null==e?ot:"function"==typeof e?e:p(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(st)},clone:function(t){return this.select(t?lt:ut)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,a=ct(t+""),o=a.length;if(!(arguments.length<2)){for(s=e?ft:dt,r=0;r<o;++r)this.each(s(a[r],e,n));return this}var s=this.node().__on;if(s)for(var u,l=0,c=s.length;l<c;++l)for(r=0,u=s[l];r<o;++r)if((i=a[r]).type===u.type&&i.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?mt:ht)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],a=0,o=i.length;a<o;++a)(r=i[a])&&(yield r)}};var Nt=Object.hasOwnProperty,Lt=Object.setPrototypeOf,Ot=Object.isFrozen,Ut=Object.getPrototypeOf,Rt=Object.getOwnPropertyDescriptor,Bt=Object.freeze,jt=Object.seal,Ht=Object.create,It="undefined"!=typeof Reflect&&Reflect,zt=It.apply,Pt=It.construct;zt||(zt=function(t,e,n){return t.apply(e,n)}),Bt||(Bt=function(t){return t}),jt||(jt=function(t){return t}),Pt||(Pt=function(t,e){return new(Function.prototype.bind.apply(t,[null].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(e))))});var qt,$t=te(Array.prototype.forEach),Yt=te(Array.prototype.pop),Vt=te(Array.prototype.push),Wt=te(String.prototype.toLowerCase),Gt=te(String.prototype.match),Xt=te(String.prototype.replace),Jt=te(String.prototype.indexOf),Zt=te(String.prototype.trim),Kt=te(RegExp.prototype.test),Qt=(qt=TypeError,function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return Pt(qt,e)});function te(t){return function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return zt(t,e,r)}}function ee(t,e){Lt&&Lt(t,null);for(var n=e.length;n--;){var r=e[n];if("string"==typeof r){var i=Wt(r);i!==r&&(Ot(e)||(e[n]=i),r=i)}t[r]=!0}return t}function ne(t){var e=Ht(null),n=void 0;for(n in t)zt(Nt,t,[n])&&(e[n]=t[n]);return e}function re(t,e){for(;null!==t;){var n=Rt(t,e);if(n){if(n.get)return te(n.get);if("function"==typeof n.value)return te(n.value)}t=Ut(t)}return function(t){return console.warn("fallback value for",t),null}}var ie=Bt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ae=Bt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),oe=Bt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),se=Bt(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ue=Bt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),le=Bt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ce=Bt(["#text"]),de=Bt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),fe=Bt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),pe=Bt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),he=Bt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),me=jt(/\{\{[\s\S]*|[\s\S]*\}\}/gm),ve=jt(/<%[\s\S]*|[\s\S]*%>/gm),ge=jt(/^data-[\-\w.\u00B7-\uFFFF]/),ye=jt(/^aria-[\-\w]+$/),_e=jt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),be=jt(/^(?:\w+script|data):/i),we=jt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),xe="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};function Ae(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}var Ee=function(){return"undefined"==typeof window?null:window},Te=function(t,e){if("object"!==(void 0===t?"undefined":xe(t))||"function"!=typeof t.createPolicy)return null;var n=null,r="data-tt-policy-suffix";e.currentScript&&e.currentScript.hasAttribute(r)&&(n=e.currentScript.getAttribute(r));var i="dompurify"+(n?"#"+n:"");try{return t.createPolicy(i,{createHTML:function(t){return t}})}catch(t){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};var Ce,ke,De=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ee(),n=function(e){return t(e)};if(n.version="2.2.8",n.removed=[],!e||!e.document||9!==e.document.nodeType)return n.isSupported=!1,n;var r=e.document,i=e.document,a=e.DocumentFragment,o=e.HTMLTemplateElement,s=e.Node,u=e.Element,l=e.NodeFilter,c=e.NamedNodeMap,d=void 0===c?e.NamedNodeMap||e.MozNamedAttrMap:c,f=e.Text,p=e.Comment,h=e.DOMParser,m=e.trustedTypes,v=u.prototype,g=re(v,"cloneNode"),y=re(v,"nextSibling"),_=re(v,"childNodes"),b=re(v,"parentNode");if("function"==typeof o){var w=i.createElement("template");w.content&&w.content.ownerDocument&&(i=w.content.ownerDocument)}var x=Te(m,r),A=x&&tt?x.createHTML(""):"",E=i,T=E.implementation,C=E.createNodeIterator,k=E.createDocumentFragment,D=r.importNode,F={};try{F=ne(i).documentMode?i.documentMode:{}}catch(t){}var S={};n.isSupported="function"==typeof b&&T&&void 0!==T.createHTMLDocument&&9!==F;var M=me,N=ve,L=ge,O=ye,U=be,R=we,B=_e,j=null,H=ee({},[].concat(Ae(ie),Ae(ae),Ae(oe),Ae(ue),Ae(ce))),I=null,z=ee({},[].concat(Ae(de),Ae(fe),Ae(pe),Ae(he))),P=null,q=null,$=!0,Y=!0,V=!1,W=!1,G=!1,X=!1,J=!1,Z=!1,K=!1,Q=!0,tt=!1,et=!0,nt=!0,rt=!1,it={},at=ee({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ot=null,st=ee({},["audio","video","img","source","image","track"]),ut=null,lt=ee({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),ct="http://www.w3.org/1998/Math/MathML",dt="http://www.w3.org/2000/svg",ft="http://www.w3.org/1999/xhtml",pt=ft,ht=null,mt=i.createElement("form"),vt=function(t){ht&&ht===t||(t&&"object"===(void 0===t?"undefined":xe(t))||(t={}),t=ne(t),j="ALLOWED_TAGS"in t?ee({},t.ALLOWED_TAGS):H,I="ALLOWED_ATTR"in t?ee({},t.ALLOWED_ATTR):z,ut="ADD_URI_SAFE_ATTR"in t?ee(ne(lt),t.ADD_URI_SAFE_ATTR):lt,ot="ADD_DATA_URI_TAGS"in t?ee(ne(st),t.ADD_DATA_URI_TAGS):st,P="FORBID_TAGS"in t?ee({},t.FORBID_TAGS):{},q="FORBID_ATTR"in t?ee({},t.FORBID_ATTR):{},it="USE_PROFILES"in t&&t.USE_PROFILES,$=!1!==t.ALLOW_ARIA_ATTR,Y=!1!==t.ALLOW_DATA_ATTR,V=t.ALLOW_UNKNOWN_PROTOCOLS||!1,W=t.SAFE_FOR_TEMPLATES||!1,G=t.WHOLE_DOCUMENT||!1,Z=t.RETURN_DOM||!1,K=t.RETURN_DOM_FRAGMENT||!1,Q=!1!==t.RETURN_DOM_IMPORT,tt=t.RETURN_TRUSTED_TYPE||!1,J=t.FORCE_BODY||!1,et=!1!==t.SANITIZE_DOM,nt=!1!==t.KEEP_CONTENT,rt=t.IN_PLACE||!1,B=t.ALLOWED_URI_REGEXP||B,pt=t.NAMESPACE||pt,W&&(Y=!1),K&&(Z=!0),it&&(j=ee({},[].concat(Ae(ce))),I=[],!0===it.html&&(ee(j,ie),ee(I,de)),!0===it.svg&&(ee(j,ae),ee(I,fe),ee(I,he)),!0===it.svgFilters&&(ee(j,oe),ee(I,fe),ee(I,he)),!0===it.mathMl&&(ee(j,ue),ee(I,pe),ee(I,he))),t.ADD_TAGS&&(j===H&&(j=ne(j)),ee(j,t.ADD_TAGS)),t.ADD_ATTR&&(I===z&&(I=ne(I)),ee(I,t.ADD_ATTR)),t.ADD_URI_SAFE_ATTR&&ee(ut,t.ADD_URI_SAFE_ATTR),nt&&(j["#text"]=!0),G&&ee(j,["html","head","body"]),j.table&&(ee(j,["tbody"]),delete P.tbody),Bt&&Bt(t),ht=t)},gt=ee({},["mi","mo","mn","ms","mtext"]),yt=ee({},["foreignobject","desc","title","annotation-xml"]),_t=ee({},ae);ee(_t,oe),ee(_t,se);var bt=ee({},ue);ee(bt,le);var wt=function(t){var e=b(t);e&&e.tagName||(e={namespaceURI:ft,tagName:"template"});var n=Wt(t.tagName),r=Wt(e.tagName);if(t.namespaceURI===dt)return e.namespaceURI===ft?"svg"===n:e.namespaceURI===ct?"svg"===n&&("annotation-xml"===r||gt[r]):Boolean(_t[n]);if(t.namespaceURI===ct)return e.namespaceURI===ft?"math"===n:e.namespaceURI===dt?"math"===n&&yt[r]:Boolean(bt[n]);if(t.namespaceURI===ft){if(e.namespaceURI===dt&&!yt[r])return!1;if(e.namespaceURI===ct&&!gt[r])return!1;var i=ee({},["title","style","font","a","script"]);return!bt[n]&&(i[n]||!_t[n])}return!1},xt=function(t){Vt(n.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=A}catch(e){t.remove()}}},At=function(t,e){try{Vt(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){Vt(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t&&!I[t])if(Z||K)try{xt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Et=function(t){var e=void 0,n=void 0;if(J)t="<remove></remove>"+t;else{var r=Gt(t,/^[\r\n\t ]+/);n=r&&r[0]}var a=x?x.createHTML(t):t;if(pt===ft)try{e=(new h).parseFromString(a,"text/html")}catch(t){}e&&e.documentElement||((e=T.createDocument(pt,"template",null)).documentElement.innerHTML=a);var o=e.body||e.documentElement;return t&&n&&o.insertBefore(i.createTextNode(n),o.childNodes[0]||null),G?e.documentElement:o},Tt=function(t){return C.call(t.ownerDocument||t,t,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT,(function(){return l.FILTER_ACCEPT}),!1)},Ct=function(t){return!(t instanceof f||t instanceof p)&&!("string"==typeof t.nodeName&&"string"==typeof t.textContent&&"function"==typeof t.removeChild&&t.attributes instanceof d&&"function"==typeof t.removeAttribute&&"function"==typeof t.setAttribute&&"string"==typeof t.namespaceURI&&"function"==typeof t.insertBefore)},kt=function(t){return"object"===(void 0===s?"undefined":xe(s))?t instanceof s:t&&"object"===(void 0===t?"undefined":xe(t))&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Dt=function(t,e,r){S[t]&&$t(S[t],(function(t){t.call(n,e,r,ht)}))},Ft=function(t){var e=void 0;if(Dt("beforeSanitizeElements",t,null),Ct(t))return xt(t),!0;if(Gt(t.nodeName,/[\u0080-\uFFFF]/))return xt(t),!0;var r=Wt(t.nodeName);if(Dt("uponSanitizeElement",t,{tagName:r,allowedTags:j}),!kt(t.firstElementChild)&&(!kt(t.content)||!kt(t.content.firstElementChild))&&Kt(/<[/\w]/g,t.innerHTML)&&Kt(/<[/\w]/g,t.textContent))return xt(t),!0;if(!j[r]||P[r]){if(nt&&!at[r]){var i=b(t)||t.parentNode,a=_(t)||t.childNodes;if(a&&i)for(var o=a.length-1;o>=0;--o)i.insertBefore(g(a[o],!0),y(t))}return xt(t),!0}return t instanceof u&&!wt(t)?(xt(t),!0):"noscript"!==r&&"noembed"!==r||!Kt(/<\/no(script|embed)/i,t.innerHTML)?(W&&3===t.nodeType&&(e=t.textContent,e=Xt(e,M," "),e=Xt(e,N," "),t.textContent!==e&&(Vt(n.removed,{element:t.cloneNode()}),t.textContent=e)),Dt("afterSanitizeElements",t,null),!1):(xt(t),!0)},St=function(t,e,n){if(et&&("id"===e||"name"===e)&&(n in i||n in mt))return!1;if(Y&&Kt(L,e));else if($&&Kt(O,e));else{if(!I[e]||q[e])return!1;if(ut[e]);else if(Kt(B,Xt(n,R,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==Jt(n,"data:")||!ot[t]){if(V&&!Kt(U,Xt(n,R,"")));else if(n)return!1}else;}return!0},Mt=function(t){var e=void 0,r=void 0,i=void 0,a=void 0;Dt("beforeSanitizeAttributes",t,null);var o=t.attributes;if(o){var s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:I};for(a=o.length;a--;){var u=e=o[a],l=u.name,c=u.namespaceURI;if(r=Zt(e.value),i=Wt(l),s.attrName=i,s.attrValue=r,s.keepAttr=!0,s.forceKeepAttr=void 0,Dt("uponSanitizeAttribute",t,s),r=s.attrValue,!s.forceKeepAttr&&(At(l,t),s.keepAttr))if(Kt(/\/>/i,r))At(l,t);else{W&&(r=Xt(r,M," "),r=Xt(r,N," "));var d=t.nodeName.toLowerCase();if(St(d,i,r))try{c?t.setAttributeNS(c,l,r):t.setAttribute(l,r),Yt(n.removed)}catch(t){}}}Dt("afterSanitizeAttributes",t,null)}},Nt=function t(e){var n=void 0,r=Tt(e);for(Dt("beforeSanitizeShadowDOM",e,null);n=r.nextNode();)Dt("uponSanitizeShadowNode",n,null),Ft(n)||(n.content instanceof a&&t(n.content),Mt(n));Dt("afterSanitizeShadowDOM",e,null)};return n.sanitize=function(t,i){var o=void 0,u=void 0,l=void 0,c=void 0,d=void 0;if(t||(t="\x3c!--\x3e"),"string"!=typeof t&&!kt(t)){if("function"!=typeof t.toString)throw Qt("toString is not a function");if("string"!=typeof(t=t.toString()))throw Qt("dirty is not a string, aborting")}if(!n.isSupported){if("object"===xe(e.toStaticHTML)||"function"==typeof e.toStaticHTML){if("string"==typeof t)return e.toStaticHTML(t);if(kt(t))return e.toStaticHTML(t.outerHTML)}return t}if(X||vt(i),n.removed=[],"string"==typeof t&&(rt=!1),rt);else if(t instanceof s)1===(u=(o=Et("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===u.nodeName||"HTML"===u.nodeName?o=u:o.appendChild(u);else{if(!Z&&!W&&!G&&-1===t.indexOf("<"))return x&&tt?x.createHTML(t):t;if(!(o=Et(t)))return Z?null:A}o&&J&&xt(o.firstChild);for(var f=Tt(rt?t:o);l=f.nextNode();)3===l.nodeType&&l===c||Ft(l)||(l.content instanceof a&&Nt(l.content),Mt(l),c=l);if(c=null,rt)return t;if(Z){if(K)for(d=k.call(o.ownerDocument);o.firstChild;)d.appendChild(o.firstChild);else d=o;return Q&&(d=D.call(r,d,!0)),d}var p=G?o.outerHTML:o.innerHTML;return W&&(p=Xt(p,M," "),p=Xt(p,N," ")),x&&tt?x.createHTML(p):p},n.setConfig=function(t){vt(t),X=!0},n.clearConfig=function(){ht=null,X=!1},n.isValidAttribute=function(t,e,n){ht||vt({});var r=Wt(t),i=Wt(e);return St(r,i,n)},n.addHook=function(t,e){"function"==typeof e&&(S[t]=S[t]||[],Vt(S[t],e))},n.removeHook=function(t){S[t]&&Yt(S[t])},n.removeHooks=function(t){S[t]&&(S[t]=[])},n.removeAllHooks=function(){S={}},n}(),Fe=25,Se=10,Me=10,Ne={};function Le(t,e,n,r,i,a,o){var s=n-t/2-Me,u=n+t/2+Me,l=t/2+Math.min(0,s-i.left)+Math.max(0,u-i.right);return{pos:[l,o],shape:l-Se<5?[-l,-15*a,Math.max(Se,5-l),-10*a]:l+Se>t-5?[Math.min(-10,t-l-5),-10*a,Math.min(Se,t-l),-15*a]:[-10,-10*a,Se,-10*a]}}function Oe(t,e,n,r,i,a,o){var s=r-e/2-Me,u=r+e/2+Me,l=e/2+Math.min(0,s-i.top)+Math.max(0,u-i.bottom);return{pos:[o,l],shape:l-Se<5?[-15*a,-l,-10*a,Math.max(Se,5-l)]:l+Se>e-5?[-10*a,Math.min(-10,e-l-5),-15*a,Math.min(Se,e-l)]:[-10*a,-10,-10*a,Se]}}function Ue(t,e,n,r,i,a){var o=Ne[t](e,n,r,i,a),s=r-Fe-o.pos[0],u=i-Fe-o.pos[1];return{left:s,top:u,right:s+e+50,bottom:u+n+50}}function Re(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 a=i.style;if(n)for(r in n)a[r]=n[r];return i}function Be(){return Ce||((Ce=document.createElement("div")).id="flourish-popup-constrainer",(ke=Ce.style).overflow="hidden",ke.pointerEvents="none",ke.position="absolute",ke.left="0",ke.top="0",ke.margin="0",ke.padding="0",document.body.appendChild(Ce),this._resizeConstrainer(),Ce)}Ne.bottom=function(t,e){return{shape:[-10,-10,Se,-10],pos:[t/2,e+Me]}},Ne.top=function(t,e){return{shape:[-10,Me,Se,Me],pos:[t/2,-10]}},Ne.left=function(t,e){return{shape:[Me,Se,Me,-10],pos:[-10,e/2]}},Ne.right=function(t,e){return{shape:[-10,Se,-10,-10],pos:[t+Me,e/2]}},Ne.topLeft=function(t,e){return{shape:[15,Me,Me,15],pos:[-10,-10]}},Ne.bottomLeft=function(t,e){return{shape:[15,-10,Me,-15],pos:[-10,e+Me]}},Ne.topRight=function(t,e){return{shape:[-15,Me,-10,15],pos:[t+Me,-10]}},Ne.bottomRight=function(t,e){return{shape:[-15,-10,-10,-15],pos:[t+Me,e+Me]}},Ne.bottomFlexible=function(t,e,n,r,i){return Le(t,0,n,0,i,1,e+Me)},Ne.topFlexible=function(t,e,n,r,i){return Le(t,0,n,0,i,-1,-10)},Ne.rightFlexible=function(t,e,n,r,i){return Oe(0,e,0,r,i,1,t+Me)},Ne.leftFlexible=function(t,e,n,r,i){return Oe(0,e,0,r,i,-1,-10)};var je,He=1,Ie={container:document.body,maxWidth:"70%",point:null,html:null,directions:["bottom","top","left","right","topLeft","bottomLeft","topRight","bottomRight","bottomFlexible","topFlexible","leftFlexible","rightFlexible"],fallbackFit:"horizontal"};function ze(){for(var t in this.unique_id=He++,this.is_visible=!0,Ie)this["_"+t]=Ie[t];this.handlers={click:[]}}function Pe(t){ze.prototype[t]=function(e){return void 0===e?this["_"+t]:(this["_"+t]=e,this)}}for(var qe in Ie)Pe(qe);function $e(){return new ze}function Ye(){je=$e().container(document.body),function(t){t.on("mouseover",Ve).on("mouseout",We)}(Ct(".popup"))}function Ve(){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,a=this.getAttribute("data-popup-body")||null,o="",s=["top","topFlexible"];i&&(o+=Tt("h1").html(De.sanitize(i)).node().outerHTML),a&&(o+=Tt("p").html(De.sanitize(a)).node().outerHTML),t&&("left"===t?(s=["right","rightFlexible"],n=e.left,r=e.top+e.height/2):"right"===t?(s=["left","leftFlexible"],n=e.right,r=e.top+e.height/2):"top"===t?(s=["bottom","bottomFlexible"],n=e.left+e.width/2,r=e.top):"bottom"===t&&(s=["top","topFlexible"],n=e.left+e.width/2,r=e.top+e.height)),je.point(n,r).html(o).directions(s).draw()}}function We(){je.hide()}ze.prototype.point=function(t,e){if(void 0===t)return this._point;if(Array.isArray(t))this._point=[t[0],t[1]];else if(void 0!==e)this._point=[t,e];else if(t instanceof HTMLElement||t instanceof SVGElement){var n=t.getBoundingClientRect();this._point=[Math.floor(n.left+n.width/2),Math.floor(n.top+n.height/2)]}else console.error("Popup: could not understand argument");return this},ze.prototype.directions=function(t){return void 0===t?this._directions:("string"==typeof t&&(t=[t]),this._directions=t.slice(),this)},ze.prototype.text=function(t){return this._html=function(t){return t.replace(/[&<>]/g,(function(t){return{"&":"&amp;","<":"&lt;",">":"&gt;"}[t]}))}(t),this},ze.prototype.on=function(t,e){if(!(t in this.handlers))throw new Error("Popup.on: No such event: "+t);return this.handlers[t].push(e),this},ze.prototype.fire=function(t,e){if(!(t in this.handlers))throw new Error("Popup.fire: No such event: "+t);for(var n=this.handlers[t],r=0;r<n.length;r++)n[r].call(this,e);return this},ze.prototype._getElement=function(){var t=this,e="flourish-popup-"+t.unique_id,n=document.getElementById(e);if(!n){(n=document.createElement("div")).className="flourish-popup",n.id=e;var r=n.style;r.display="none",r.margin=r.padding=0,r.position="absolute",r.width="80px",r.height="40px",r.boxSizing="border-box",n.addEventListener("click",(function(e){t.fire("click",e)}),!1);var i=Re("svg",{class:"flourish-popup-svg"},{position:"absolute",top:0,left:0,bottom:0,right:0}),a=Re("filter",{id:"dropshadow-"+t.unique_id,height:"130%"});a.appendChild(Re("feGaussianBlur",{in:"SourceAlpha",stdDeviation:5})),a.appendChild(Re("feOffset",{dx:0,dy:2,result:"offsetblur"}));var o=Re("feComponentTransfer");o.appendChild(Re("feFuncA",{type:"linear",slope:.2})),a.appendChild(o);var s=Re("feMerge");a.appendChild(s),s.appendChild(Re("feMergeNode")),s.appendChild(Re("feMergeNode",{in:"SourceGraphic"})),i.appendChild(a);var u=Re("g",{filter:"url(#dropshadow-"+t.unique_id+")",fill:"white",stroke:"none"});u.appendChild(Re("rect",{x:Fe,y:Fe,rx:5})),u.appendChild(Re("path")),i.appendChild(u),n.appendChild(i);var l=document.createElement("div");l.className="flourish-popup-content",(r=l.style).position="absolute",r.top=r.left="25px",r.padding="10px",n.appendChild(l),t._getConstrainer().appendChild(n)}return t._resizeConstrainer(),n},ze.prototype._getConstrainer=Be,ze.prototype._resizeConstrainer=function(){Ce||Be.call(this);var t=ke.display;ke.display="none",ke.width=document.documentElement.scrollWidth+"px",ke.height=document.documentElement.scrollHeight+"px",ke.display=t},ze.prototype.draw=function(){var t=this;if(t.is_visible=!0,t._point){var e=document.documentElement.getBoundingClientRect(),n=t._point[0],r=t._point[1],i=t._container.getBoundingClientRect();n<i.left?n=i.left:n>i.right&&(n=i.right),r<i.top?r=i.top:r>i.bottom&&(r=i.bottom);var a=n-e.left,o=r-e.top,s=t._getElement(),u=s.style,l=s.querySelector(".flourish-popup-svg"),c=l.querySelector("g"),d=c.querySelector("rect"),f=c.querySelector("path"),p=s.querySelector(".flourish-popup-content");u.display="block",p.style.maxWidth=function(e){return t._maxWidth.match(/^\d+(?:\.\d+)?%$/)?e.width*parseFloat(t._maxWidth)/100:t._maxWidth.match(/^\d+(?:\.\d+)?(?:px)?$/)?parseFloat(t._maxWidth):(null!=t._maxWidth&&console.error("Popup: Unknown value for maxWidth: "+t._maxWidth),e.width)}(i)+"px",t._inner_html!=t._html&&(p.innerHTML=t._inner_html=t._html);var h,m,v=p.getBoundingClientRect();do{h=Math.ceil(v.width),m=Math.ceil(v.height),u.width=h+50+"px",u.height=m+50+"px",v=p.getBoundingClientRect()}while(h!=Math.ceil(v.width)||m!=Math.ceil(v.height));d.setAttribute("width",h),d.setAttribute("height",m),l.setAttribute("width",h+50),l.setAttribute("height",m+50);for(var g,y,_=null,b=null,w=null,x=1/0,A=1/0,E=0;E<t._directions.length;E++){var T=t._directions[E],C=Ue(T,h,m,n,r,i),k=Math.max(0,Math.floor(i.left)-C.left-15)+Math.max(0,C.right-Math.ceil(i.right)-15),D=Math.max(0,Math.floor(i.top)-C.top-15)+Math.max(0,C.bottom-Math.ceil(i.bottom)-15);if(0==k&&0==D){_=T;break}(k<x||k==x&&D<g)&&(x=k,g=D,b=T),(D<A||D==A&&k<y)&&(A=D,y=k,w=T)}return _?T=_:"horizontal"==t._fallbackFit?T=b:"vertical"==t._fallbackFit?T=w:(console.warn("Popup: failed to point box of size ("+h+", "+m+") at ("+n+", "+r+") within ("+i.left+", "+i.top+", "+i.right+", "+i.bottom+")"),T=t._directions[0]),function(t,e,n,r,i,a,o,s,u,l){var c=Ne[t](r,i,s,u,l);e.left=a-Fe-c.pos[0]+"px",e.top=o-Fe-c.pos[1]+"px",n.setAttribute("d","M0,0L"+c.shape.join(",")+"Z"),n.setAttribute("transform","translate("+(c.pos[0]+Fe)+","+(c.pos[1]+Fe)+")")}(T,u,f,h,m,a,o,n,r,i),t}console.error("Popup: cannot draw popup till point() has been specified")},ze.prototype.hide=function(){return this.is_visible?(this.is_visible=!1,this._getElement().style.display="none",this):this},$e.version="2.1.5";const Ge=Math.pow(2,31)-1,Xe=Math.pow(2,15);function Je(t,e){if(t=t.toUpperCase(),!/^[A-Z]+$/.test(t)){if(!t){if(e)return-1;throw new Error("Non-optional data binding must specify column")}throw function(t){try{tn(t)}catch(t){return!1}return!0}(t)?new Error("You can only select one column"):new Error("Invalid column specification: "+t)}for(var n=0,r=0;r<t.length;r++)n=26*n+(t.charCodeAt(r)-64);return n-1>Ge&&console.warn("Column index out of range"),Math.min(n-1,Ge)}function Ze(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 Ke(t){var e=t.match(/\s*(?:[-–—:]|\.\.)\s*/);if(!e)throw new Error("Failed to parse column range: "+t);var n=t.substr(0,e.index),r=t.substr(e.index+e[0].length),i=Je(n),a=Je(r),o=[],s=a>=i?1:-1,u=Math.abs(a-i)+1;u>Xe&&(console.warn("Truncating excessively long range"),u=Xe);for(var l=0;l<u;l++)o.push(i+l*s);return o}function Qe(t,e){return Ze(t)+"-"+Ze(e)}function tn(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(Je(i)):Array.prototype.push.apply(e,Ke(i))}return e}function en(t){for(var e=function(t){if(!t.length)return[];for(var e=[],n=t[0],r=t[0],i=null,a=0;a<t.length-1;a++){var o=t[a+1]-t[a];null!==i||1!==Math.abs(o)?o!==i?(e.push([n,r]),n=r=t[a+1],i=null):r=t[a+1]:(r=t[a+1],i=o)}return e.push([n,r]),e}(t),n=[],r=0;r<e.length;r++){var i=e[r];i[0]==i[1]?n.push(Ze(i[0])):n.push(Qe(i[0],i[1]))}return n.join(",")}function nn(t,e,n,r){var i=n?e[t.data_table_id]+"::":"";if("column"in t)return i+Ze(t.column);if("columns"in t)return i+en(t.columns);if(r)return"";throw new Error("Data binding must have .column or .columns")}var rn=new Date,an=new Date;function on(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=function(e){return t(e=new Date(+e)),e},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,a){var o,s=[];if(n=i.ceil(n),a=null==a?1:Math.floor(a),!(n<r&&a>0))return s;do{s.push(o=new Date(+n)),e(n,a),t(n)}while(o<n&&n<r);return s},i.filter=function(n){return on((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 rn.setTime(+e),an.setTime(+r),t(rn),t(an),Math.floor(n(rn,an))},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}var sn=864e5,un=6048e5,ln=on((function(t){t.setHours(0,0,0,0)}),(function(t,e){t.setDate(t.getDate()+e)}),(function(t,e){return(e-t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/sn}),(function(t){return t.getDate()-1}));function cn(t){return on((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-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/un}))}var dn=cn(0),fn=cn(1);cn(2),cn(3);var pn=cn(4);cn(5),cn(6);var hn=on((function(t){t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,e){t.setFullYear(t.getFullYear()+e)}),(function(t,e){return e.getFullYear()-t.getFullYear()}),(function(t){return t.getFullYear()}));hn.every=function(t){return isFinite(t=Math.floor(t))&&t>0?on((function(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,n){e.setFullYear(e.getFullYear()+n*t)})):null};var mn=on((function(t){t.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCDate(t.getUTCDate()+e)}),(function(t,e){return(e-t)/sn}),(function(t){return t.getUTCDate()-1}));function vn(t){return on((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)/un}))}var gn=vn(0),yn=vn(1);vn(2),vn(3);var _n=vn(4);vn(5),vn(6);var bn=on((function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCFullYear(t.getUTCFullYear()+e)}),(function(t,e){return e.getUTCFullYear()-t.getUTCFullYear()}),(function(t){return t.getUTCFullYear()}));function wn(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 xn(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 An(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}bn.every=function(t){return isFinite(t=Math.floor(t))&&t>0?on((function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n*t)})):null};var En,Tn,Cn,kn={"-":"",_:" ",0:"0"},Dn=/^\s*\d+/,Fn=/^%/,Sn=/[\\^$*+?|[\]().{}]/g;function Mn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function Nn(t){return t.replace(Sn,"\\$&")}function Ln(t){return new RegExp("^(?:"+t.map(Nn).join("|")+")","i")}function On(t){for(var e={},n=-1,r=t.length;++n<r;)e[t[n].toLowerCase()]=n;return e}function Un(t,e,n){var r=Dn.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Rn(t,e,n){var r=Dn.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Bn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function jn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Hn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function In(t,e,n){var r=Dn.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function zn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Pn(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 qn(t,e,n){var r=Dn.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function $n(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Yn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Vn(t,e,n){var r=Dn.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Wn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Gn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Xn(t,e,n){var r=Dn.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Jn(t,e,n){var r=Dn.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Zn(t,e,n){var r=Dn.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Kn(t,e,n){var r=Fn.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Qn(t,e,n){var r=Dn.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function tr(t,e,n){var r=Dn.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function er(t,e){return Mn(t.getDate(),e,2)}function nr(t,e){return Mn(t.getHours(),e,2)}function rr(t,e){return Mn(t.getHours()%12||12,e,2)}function ir(t,e){return Mn(1+ln.count(hn(t),t),e,3)}function ar(t,e){return Mn(t.getMilliseconds(),e,3)}function or(t,e){return ar(t,e)+"000"}function sr(t,e){return Mn(t.getMonth()+1,e,2)}function ur(t,e){return Mn(t.getMinutes(),e,2)}function lr(t,e){return Mn(t.getSeconds(),e,2)}function cr(t){var e=t.getDay();return 0===e?7:e}function dr(t,e){return Mn(dn.count(hn(t)-1,t),e,2)}function fr(t){var e=t.getDay();return e>=4||0===e?pn(t):pn.ceil(t)}function pr(t,e){return t=fr(t),Mn(pn.count(hn(t),t)+(4===hn(t).getDay()),e,2)}function hr(t){return t.getDay()}function mr(t,e){return Mn(fn.count(hn(t)-1,t),e,2)}function vr(t,e){return Mn(t.getFullYear()%100,e,2)}function gr(t,e){return Mn((t=fr(t)).getFullYear()%100,e,2)}function yr(t,e){return Mn(t.getFullYear()%1e4,e,4)}function _r(t,e){var n=t.getDay();return Mn((t=n>=4||0===n?pn(t):pn.ceil(t)).getFullYear()%1e4,e,4)}function br(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Mn(e/60|0,"0",2)+Mn(e%60,"0",2)}function wr(t,e){return Mn(t.getUTCDate(),e,2)}function xr(t,e){return Mn(t.getUTCHours(),e,2)}function Ar(t,e){return Mn(t.getUTCHours()%12||12,e,2)}function Er(t,e){return Mn(1+mn.count(bn(t),t),e,3)}function Tr(t,e){return Mn(t.getUTCMilliseconds(),e,3)}function Cr(t,e){return Tr(t,e)+"000"}function kr(t,e){return Mn(t.getUTCMonth()+1,e,2)}function Dr(t,e){return Mn(t.getUTCMinutes(),e,2)}function Fr(t,e){return Mn(t.getUTCSeconds(),e,2)}function Sr(t){var e=t.getUTCDay();return 0===e?7:e}function Mr(t,e){return Mn(gn.count(bn(t)-1,t),e,2)}function Nr(t){var e=t.getUTCDay();return e>=4||0===e?_n(t):_n.ceil(t)}function Lr(t,e){return t=Nr(t),Mn(_n.count(bn(t),t)+(4===bn(t).getUTCDay()),e,2)}function Or(t){return t.getUTCDay()}function Ur(t,e){return Mn(yn.count(bn(t)-1,t),e,2)}function Rr(t,e){return Mn(t.getUTCFullYear()%100,e,2)}function Br(t,e){return Mn((t=Nr(t)).getUTCFullYear()%100,e,2)}function jr(t,e){return Mn(t.getUTCFullYear()%1e4,e,4)}function Hr(t,e){var n=t.getUTCDay();return Mn((t=n>=4||0===n?_n(t):_n.ceil(t)).getUTCFullYear()%1e4,e,4)}function Ir(){return"+0000"}function zr(){return"%"}function Pr(t){return+t}function qr(t){return Math.floor(+t/1e3)}function $r(t){throw new TypeError("Expected a value of type string but got a value of type "+typeof t)}function Yr(t){return function(e){return"string"!=typeof e&&$r(e),(e=e.trim())?t(e):null}}En=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,s=t.months,u=t.shortMonths,l=Ln(i),c=On(i),d=Ln(a),f=On(a),p=Ln(o),h=On(o),m=Ln(s),v=On(s),g=Ln(u),y=On(u),_={a:function(t){return o[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:null,d:er,e:er,f:or,g:gr,G:_r,H:nr,I:rr,j:ir,L:ar,m:sr,M:ur,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Pr,s:qr,S:lr,u:cr,U:dr,V:pr,w:hr,W:mr,x:null,X:null,y:vr,Y:yr,Z:br,"%":zr},b={a:function(t){return o[t.getUTCDay()]},A:function(t){return a[t.getUTCDay()]},b:function(t){return u[t.getUTCMonth()]},B:function(t){return s[t.getUTCMonth()]},c:null,d:wr,e:wr,f:Cr,g:Br,G:Hr,H:xr,I:Ar,j:Er,L:Tr,m:kr,M:Dr,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Pr,s:qr,S:Fr,u:Sr,U:Mr,V:Lr,w:Or,W:Ur,x:null,X:null,y:Rr,Y:jr,Z:Ir,"%":zr},w={a:function(t,e,n){var r=p.exec(e.slice(n));return r?(t.w=h[r[0].toLowerCase()],n+r[0].length):-1},A:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=f[r[0].toLowerCase()],n+r[0].length):-1},b:function(t,e,n){var r=g.exec(e.slice(n));return r?(t.m=y[r[0].toLowerCase()],n+r[0].length):-1},B:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=v[r[0].toLowerCase()],n+r[0].length):-1},c:function(t,n,r){return E(t,e,n,r)},d:Yn,e:Yn,f:Zn,g:zn,G:In,H:Wn,I:Wn,j:Vn,L:Jn,m:$n,M:Gn,p:function(t,e,n){var r=l.exec(e.slice(n));return r?(t.p=c[r[0].toLowerCase()],n+r[0].length):-1},q:qn,Q:Qn,s:tr,S:Xn,u:Rn,U:Bn,V:jn,w:Un,W:Hn,x:function(t,e,r){return E(t,n,e,r)},X:function(t,e,n){return E(t,r,e,n)},y:zn,Y:In,Z:Pn,"%":Kn};function x(t,e){return function(n){var r,i,a,o=[],s=-1,u=0,l=t.length;for(n instanceof Date||(n=new Date(+n));++s<l;)37===t.charCodeAt(s)&&(o.push(t.slice(u,s)),null!=(i=kn[r=t.charAt(++s)])?r=t.charAt(++s):i="e"===r?" ":"0",(a=e[r])&&(r=a(n,i)),o.push(r),u=s+1);return o.push(t.slice(u,s)),o.join("")}}function A(t,e){return function(n){var r,i,a=An(1900,void 0,1);if(E(a,t,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("s"in a)return new Date(1e3*a.s+("L"in a?a.L:0));if(e&&!("Z"in a)&&(a.Z=0),"p"in a&&(a.H=a.H%12+12*a.p),void 0===a.m&&(a.m="q"in a?a.q:0),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(i=(r=xn(An(a.y,0,1))).getUTCDay(),r=i>4||0===i?yn.ceil(r):yn(r),r=mn.offset(r,7*(a.V-1)),a.y=r.getUTCFullYear(),a.m=r.getUTCMonth(),a.d=r.getUTCDate()+(a.w+6)%7):(i=(r=wn(An(a.y,0,1))).getDay(),r=i>4||0===i?fn.ceil(r):fn(r),r=ln.offset(r,7*(a.V-1)),a.y=r.getFullYear(),a.m=r.getMonth(),a.d=r.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),i="Z"in a?xn(An(a.y,0,1)).getUTCDay():wn(An(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(i+5)%7:a.w+7*a.U-(i+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,xn(a)):wn(a)}}function E(t,e,n,r){for(var i,a,o=0,s=e.length,u=n.length;o<s;){if(r>=u)return-1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(a=w[i in kn?e.charAt(o++):i])||(r=a(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return _.x=x(n,_),_.X=x(r,_),_.c=x(e,_),b.x=x(n,b),b.X=x(r,b),b.c=x(e,b),{format:function(t){var e=x(t+="",_);return e.toString=function(){return t},e},parse:function(t){var e=A(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=x(t+="",b);return e.toString=function(){return t},e},utcParse:function(t){var e=A(t+="",!0);return e.toString=function(){return t},e}}}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),Tn=En.format,Cn=En.parse,En.utcFormat,En.utcParse;var Vr=new Date(1972,3,27,19,45,5),Wr={"%b %d":[{regex:/^june\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(t){return new Date(null,5,t.split(/\s/)[1])}},{regex:/^july\s(3[01]|[12][0-9]|0?[1-9])$/i,toDate:function(t){return new Date(null,6,t.split(/\s/)[1])}},{regex:/^sept\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(t){return new Date(null,8,t.split(/\s/)[1])}}],"%d %b":[{regex:/^(0?[1-9]|[1-9][0-9])\sjune$/i,toDate:function(t){return new Date(null,5,t.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\sjuly$/i,toDate:function(t){return new Date(null,6,t.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\ssept$/i,toDate:function(t){return new Date(null,8,t.split(/\s/)[0])}}]};function Gr(t){return function(e){var n=null;return t.forEach((function(t){e.match(t.regex)&&(n=t.toDate(e))})),n}}function Xr(t,e){var n,r=Cn(t),i=Tn(t);return n=Yr("function"==typeof e?function(t){return e(t,null!==r(t))}:function(t){return null!==r(t)}),Object.freeze({test:n,parse:Yr((function(e){return r(e)||(Wr[t]?Gr(Wr[t])(e):null)})),format:function(t){return i(t)},type:"datetime",description:t,id:"datetime$"+t,example:i(Vr)})}var Jr=Object.freeze([Xr("%Y-%m-%dT%H:%M:%S.%LZ"),Xr("%d/%m/%Y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&n[2]>=1e3})),Xr("%d/%m/%y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&!isNaN(n[2])})),Xr("%m/%d/%Y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&n[2]>=1e3})),Xr("%m/%d/%y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&!isNaN(n[2])})),Xr("%Y/%m/%d",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>=1e3&&n[1]>0&&n[1]<=12&&n[2]>0&&n[2]<=31})),Xr("%d-%m-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&n[2]>=1e3})),Xr("%d-%m-%y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&!isNaN(n[2])})),Xr("%m-%d-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&n[2]>=1e3})),Xr("%m-%d-%y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&!isNaN(n[2])})),Xr("%Y-%m-%d",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>=1e3&&n[1]>0&&n[1]<=12&&n[2]>0&&n[2]<=31})),Xr("%d %b %Y",(function(t,e){if(!e)return!1;var n=t.split(" ").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),Xr("%d %B %Y",(function(t,e){if(!e)return!1;var n=t.split(" ").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),Xr("%d %b %y"),Xr("%d %B %y"),Xr("%d-%b-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),Xr("%d-%B-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),Xr("%d-%b-%y"),Xr("%d-%B-%y"),Xr("%m/%Y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>=1e3})),Xr("%m/%y"),Xr("%b %Y",(function(t,e){return!!e&&t.split(" ").map(parseFloat)[1]>=1e3})),Xr("%B %Y",(function(t,e){return!!e&&t.split(" ").map(parseFloat)[1]>=1e3})),Xr("%b %y"),Xr("%B %y"),Xr("%d %b",(function(t,e){return!!e||!!Gr(Wr["%d %b"])(t)})),Xr("%d %B"),Xr("%b %d",(function(t,e){return!!e||!!Gr(Wr["%b %d"])(t)})),Xr("%B %d"),Xr("%d-%m",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12})),Xr("%m-%d"),Xr("%d/%m"),Xr("%m/%d"),Xr("%Y",(function(t,e){if(!e)return!1;var n=parseFloat(t);return n>1499&&n<2200})),Xr("%B"),Xr("%b"),Xr("%X"),Xr("%I:%M %p"),Xr("%H:%M"),Xr("%H:%M:%S"),Xr("%-I%p"),Xr("Q%q %Y",(function(t,e){return!!e&&6===t.replace(/\s/g,"").length})),Xr("%Y Q%q",(function(t,e){return!!e&&6===t.replace(/\s/g,"").length}))]);function Zr(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}var Kr,Qr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ti(t){if(!(e=Qr.exec(t)))throw new Error("invalid format: "+t);var e;return new ei({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function ei(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 ni(t,e){var n=Zr(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}ti.prototype=ei.prototype,ei.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 ri={"%":function(t,e){return(100*t).toFixed(e)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},g:function(t,e){return t.toPrecision(e)},o:function(t){return Math.round(t).toString(8)},p:function(t,e){return ni(100*t,e)},r:ni,s:function(t,e){var n=Zr(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(Kr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Zr(t,Math.max(0,e+a-1))[0]},X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}};function ii(t){return t}var ai=Array.prototype.map,oi=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function si(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?ii:(e=ai.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,a=[],o=0,s=e[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),a.push(t.substring(i-=s,i+s)),!((u+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?ii:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(ai.call(t.numerals,String)),u=void 0===t.percent?"%":t.percent+"",l=void 0===t.minus?"-":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function d(t){var e=(t=ti(t)).fill,n=t.align,d=t.sign,f=t.symbol,p=t.zero,h=t.width,m=t.comma,v=t.precision,g=t.trim,y=t.type;"n"===y?(m=!0,y="g"):ri[y]||(void 0===v&&(v=12),g=!0,y="g"),(p||"0"===e&&"="===n)&&(p=!0,e="0",n="=");var _="$"===f?i:"#"===f&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",b="$"===f?a:/[%p]/.test(y)?u:"",w=ri[y],x=/[defgprs%]/.test(y);function A(t){var i,a,u,f=_,A=b;if("c"===y)A=w(t)+A,t="";else{var E=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:w(Math.abs(t),v),g&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),E&&0==+t&&"+"!==d&&(E=!1),f=(E?"("===d?d:l:"-"===d||"("===d?"":d)+f,A=("s"===y?oi[8+Kr/3]:"")+A+(E&&"("===d?")":""),x)for(i=-1,a=t.length;++i<a;)if(48>(u=t.charCodeAt(i))||u>57){A=(46===u?o+t.slice(i+1):t.slice(i))+A,t=t.slice(0,i);break}}m&&!p&&(t=r(t,1/0));var T=f.length+t.length+A.length,C=T<h?new Array(h-T+1).join(e):"";switch(m&&p&&(t=r(C+t,C.length?h-A.length:1/0),C=""),n){case"<":t=f+t+A+C;break;case"=":t=f+C+t+A;break;case"^":t=C.slice(0,T=C.length>>1)+f+t+A+C.slice(T);break;default:t=C+f+t+A}return s(t)}return v=void 0===v?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v)),A.toString=function(){return t+""},A}return{format:d,formatPrefix:function(t,e){var n,r=d(((t=ti(t)).type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor((n=e,((n=Zr(Math.abs(n)))?n[1]:NaN)/3)))),a=Math.pow(10,-i),o=oi[8+i/3];return function(t){return r(a*t)+o}}}}var ui={test:Yr((function(t){return/^(\+|-)?\d{1,3}(,\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:Yr((function(t){return parseFloat(t.replace(/,/g,""))})),description:"Comma thousand separator, point decimal mark",thousand_separator:",",decimal_mark:".",id:"number$comma_point",example:"12,235.56"},li={test:Yr((function(t){return/^(\+|-)?\d{1,3}(\s\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:Yr((function(t){return parseFloat(t.replace(/\s/g,""))})),description:"Space thousand separator, point decimal mark",thousand_separator:" ",decimal_mark:".",id:"number$space_point",example:"12 235.56"},ci={test:Yr((function(t){return/^(\+|-)?\d+(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:Yr((function(t){return parseFloat(t)})),description:"No thousand separator, point decimal mark",thousand_separator:"",decimal_mark:".",id:"number$none_point",example:"12235.56"},di={test:Yr((function(t){return/^(\+|-)?\d{1,3}(\.\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:Yr((function(t){return parseFloat(t.replace(/\./g,"").replace(/,/,"."))})),description:"Point thousand separator, comma decimal mark",thousand_separator:".",decimal_mark:",",id:"number$point_comma",example:"12.235,56"},fi={test:Yr((function(t){return/^(\+|-)?\d{1,3}(\s\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:Yr((function(t){return parseFloat(t.replace(/\s/g,"").replace(/,/,"."))})),description:"Space thousand separator, comma decimal mark",thousand_separator:" ",decimal_mark:",",id:"number$space_comma",example:"12 235,56"},pi={test:Yr((function(t){return/^(\+|-)?\d+(,\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:Yr((function(t){return parseFloat(t.replace(/,/,"."))})),description:"No thousand separator, comma decimal mark",thousand_separator:"",decimal_mark:",",id:"number$none_comma",example:"12235,56"},hi=Object.freeze([ui,li,di,fi,ci,pi]);hi.forEach((function(t){t.type="number",t.format=function(t){var e,n,r=si({decimal:t.decimal_mark,thousands:t.thousand_separator,grouping:[3],currency:["",""]});return function(t,i){return i||(i=",.2f"),i!==n&&(n=i,e=r.format(n)),e(t)}}(t),Object.freeze(t)}));var mi,vi=Object.freeze({test:function(t){return"string"==typeof t||$r(t)},parse:function(t){return"string"==typeof t?t:$r(t)},format:function(t){if("string"==typeof t)return t},type:"string",description:"Arbitrary string",id:"string$arbitrary_string"}),gi=Object.freeze({datetime:Jr,number:hi}),yi=Object.freeze(["datetime","number","string"]),_i=Object.freeze({n_max:250,n_failing_values:0,failure_fraction:.05,sort:!0}),bi=Object.freeze(Object.keys(_i));function wi(t,e){return t.index-e.index}function xi(t,e){return e.n_success-t.n_success||wi(t,e)}function Ai(t){return(""+t).trim()}function Ei(t){return void 0===t?function(t){return Ai(t)}:"function"==typeof t?function(e,n){return Ai(t(e,n))}:function(e){return Ai(e[""+t])}}function Ti(t){t?Array.isArray(t)||(t=[t]):t=yi;var e=t.reduce((function(t,e){var n=gi[e];return n&&Array.prototype.push.apply(t,n),t}),[]),n=-1!==t.indexOf("string"),r=bi.reduce((function(t,e){return t[e]=_i[e],t}),{}),i=function(t,i){i=Ei(i);var a=t.map(i).filter((function(t){return t}));if(!a.length)return n?[vi]:[];var o=Math.min(r.n_max,a.length),s=Math.floor(o*r.failure_fraction),u=r.n_failing_values,l=r.sort?xi:wi,c=e.slice().reduce((function(t,e,n){for(var r=c=0,i=[],l=!1,c=0;c<o;c++){var d=a[c];if(!e.test(d)&&(++r>s?l=!0:-1===i.indexOf(d)&&(i.push(d),i.length>u&&(l=!0)),l))break}return l||t.push({interp:e,n_success:o-r,index:n}),t}),[]).sort(l).map((function(t){return t.interp}));return n&&c.push(vi),c};return bi.forEach((function(t){var e;i[(e=t,e.replace(/_(\w)/g,(function(t,e){return e.toUpperCase()})))]=function(e){return void 0===e?r[t]:(r[t]=e,i)}})),i}function Ci(t,e,n,r){var i=[],a=[],o=0,s=[],u={};function l(t,e){if(!u[t])return{};var n=u[t];return n[e]?n[e]:{}}for(var c in s.column_names={},s.metadata={},n){var d={},f=n[c];if(f){for(let t=0;t<f.length;t++){const e=f[t].type_id,n=f[t].output_format_id,r=n&&"auto"!==n?n:e;d[f[t].index]={type_id:e,output_format_id:r}}u[c]=d}}for(var p in t)if(null!==t[p]&&(void 0!==t[p].columns||void 0!==t[p].column)){var h=t[p];if(h.template_data_binding=r[p],h.key=p,h.data_table_id in e){var m=e[h.data_table_id];if(0!=m.length){if("columns"in h&&null!=h.columns){var v=m[0].length;h.columns=h.columns.filter((function(t){return t<v})),s.column_names[p]=h.columns.map((function(t){return m[0][t]})),s.metadata[p]=h.columns.map((function(t){const{type_id:e,output_format_id:n}=l(h.data_table_id,t);return e?{type:e.split("$")[0],type_id:e,output_format_id:n}:null}))}else{if(!("column"in h)||null==h.column)throw new Error("Data binding includes no column(s) specification: "+JSON.stringify(h));{s.column_names[p]=m[0][h.column];const{type_id:t,output_format_id:e}=l(h.data_table_id,h.column);t&&(s.metadata[p]={type:t.split("$")[0],type_id:t,output_format_id:e})}}-1==a.indexOf(h.data_table_id)&&(a.push(h.data_table_id),o=Math.max(o,m.length-1)),i.push(h)}else console.warn("Empty data table")}else{var g=[];for(var y in e)g.push(y);console.error("Data table id "+h.data_table_id+" not in "+JSON.stringify(g))}}function _(t,e,n){if(!t.template_data_binding.data_type)return n;var r=function(t,e){const{type_id:n}=l(t,e);if(n)return Ti.getInterpretation(n)}(t.data_table_id,e),i=r?r.parse(n):n;return Number.isNaN(i)&&(i=null),i}for(var b=0;b<o;b++){for(var w={},x=0;x<i.length;x++){var A=e[(h=i[x]).data_table_id];b+1>=A.length||("columns"in h&&null!=h.columns?w[h.key]=h.columns.filter((function(t){return t<A[b+1].length})).map((function(t){return _(h,t,A[b+1][t])})):"column"in h&&null!=h.column&&(h.column>=A[b+1].length?w[h.key]=_(h,h.column,""):w[h.key]=_(h,h.column,A[b+1][h.column])))}s.push(w)}return s}function ki(t){return function(t){for(var e=t.length,n=t[0].length,r=[],i=0;i<n;i++){for(var a=[],o=0;o<e;o++)a.push(t[o][i]);r.push(a)}return r}(t).map((function(t,e){const n=function(t){const e=t.length;return e>100?t.slice(10,e-10):e>50?t.slice(5,e-5):e>30?t.slice(4,e-4):e>20?t.slice(3,e-3):e>10?t.slice(2,e-2):e>1?t.slice(1,e):t.slice(0,1)}(t);let r;r=n.length>2e3?function(t,e){if(t.length<=2*e)return t;const n=function(t){let e=t;return function(){e|=0,e=e+1831565813|0;var t=Math.imul(e^e>>>15,1|e);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}(t.length);for(;t.length>e;){const e=Math.floor(n()*t.length);t.splice(e,1)}return t}(n,1e3):n;const i=(a=r,o=a.filter((function(t){return t&&!Fi.includes(t.trim())})).map(Mi),Si(o))[0].id;var a,o;return{type_id:i,index:e,output_format_id:i}}))}function Di(t){for(var e=t.length;e-- >1&&(!t[e]||!t[e].length||Array.isArray(t[e])&&-1==t[e].findIndex((function(t){return null!==t&&""!==t})));)t.splice(e,1);return t}Ti.DATETIME_IDS=Object.freeze(Jr.map((function(t){return t.id}))),Ti.NUMBER_IDS=Object.freeze(hi.map((function(t){return t.id}))),Ti.STRING_IDS=Object.freeze([vi.id]),Ti.getInterpretation=(mi=Jr.concat(hi,vi).reduce((function(t,e){return t[e.id]=e,t}),{}),function(t){return mi[t]}),Ti._createAccessorFunction=Ei,Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError("this is null or not defined");var e=Object(this),n=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var r=arguments[1],i=0;i<n;){var a=e[i];if(t.call(r,a,i,e))return i;i++}return-1},configurable:!0,writable:!0});var Fi=["#DIV/0","#N/A","#NAME?","#NULL!","#NUM!","#REF!","#VALUE!","#ERROR!"],Si=Ti().nMax(1/0).nFailingValues(8).failureFraction(.1);function Mi(t){return(t=t||"").replace(/[€£$¥%º]/g,"")}let Ni,Li={};const Oi=t=>{const e=Et(".dialog");if(t.which in Li){var n=Li[t.which];n.callback&&n.callback(Ni.node().value),e.remove(),t.preventDefault()}};function Ui(t,e,{buttons:n=[{text:"Okay",keyCode:13}],is_html:r=!1,upgrade:i=null,is_loading:a=!1,width:o="420px"}={}){var s=Et("body").append("div").attr("class","dialog").attr("tabindex",0).on("click",(function(){s.remove()})),u=s.append("div").attr("class","dialog-inner").style("width",o).on("click",(function(t){t.stopPropagation()})),l=u.append("div").attr("class","text"+(a?" loading":""));if("string"==typeof t?l.append("h1").text(t):t instanceof HTMLElement&&l.append("h1").append((()=>t)),"string"==typeof e)Ni=r?l.append("div").classed("loading-spinner",a).html(e):l.append("p").text(e);else if(e instanceof HTMLElement)Ni=l.append((()=>e));else if("object"==typeof e){if(Ni=l.append(e.type),e.value&&(Ni.node().value=e.value),e.attributes)for(var c in e.attributes)Ni.attr(c,e.attributes[c]);Ni.node().focus()}var d=u;null!=i&&"object"==typeof i&&function(t,e,n,r){r&&t.classed("business",!0);var i=t.append("div").attr("class","text");i.append("p").text(e),i.append("ul").selectAll("li").data(n).enter().append("li").html((function(t){return t})).append("i").attr("class","fa fa-check")}(d=d.append("div").attr("class","upgrade"),i.message,i.list,i.is_business);var f=d.append("div").attr("class","btns"+(a?" loading":""));return Li={},n.forEach((function(t){var e=f.append(t.tag_name||"div").attr("class","btn").attr("data-testid","dialog-button").style("margin-right",a?"0":"0.75em").text(t.text).on("click",(function(){t.callback&&t.callback(Ni.node().value,s),s.remove()}));t.class&&e.classed(t.class,!0),t.keyCode&&(Li[t.keyCode]=t),t.href&&e.attr("href",t.href),t.fa_icon&&e.append("i").lower().attr("class","fa "+t.fa_icon)})),s.node().addEventListener("keydown",Oi),s.node().focus(),s}var Ri="Add new value: ";function Bi(t,e,n,{allow_other_option:r=!1,custom_renderer:i=null,match_anywhere:a=!1}={}){if(t.setAttribute("data-autocomplete",e),t.setAttribute("autocomplete","off"),!document.getElementById(e)){const n=Tt("i").classed("fa fa-chevron-down clickable",!0),r=Tt("div").classed("dropdown autocomplete",!0).attr("id",e);t.insertAdjacentHTML("afterend",n.node().outerHTML+r.node().outerHTML)}var o,s=Et(document.getElementById(e));s.classed("click-to-open",!0);var u=s.append("div").attr("class","dropdown-list");function l(t){if(1===t.length)return"dropdown-category";var e="dropdown-item";return o&&t[0]===o&&(e+=" current"),e}function c(t){u.selectAll("div").remove(),u.selectAll("div").data(t).enter().append("div").attr("class",l).attr("data-value",(function(t){return"string"==typeof t?t||null:t[1]})).each((function(t){const e=Et(this);if(!i){const n=Array.isArray(t)?t[0]:t;return void e.text(n)}let n=i(t,this);if(n){if(Array.isArray(n)||(n=[n]),n.find((t=>"string"!=typeof t&&!(t instanceof HTMLElement))))throw new Error("Autocomplete elements must be strings or HTMLElements");e.node().append(...n)}})),t.length||u.append("div").attr("class","dropdown-item disabled").text("No matches found")}function d(){s.classed("open",!1)}function f(t){var e=t.textContent;return 0===e.indexOf(Ri)&&(e=e.substr(Ri.length)),e}return s.on("mousedown",(function(e){var n=e.target;n.hasAttribute("data-value")?(t.value=f(n),t.setAttribute("data-value",n.getAttribute("data-value")),d(),Et(t).dispatch("change")):e.preventDefault()})),Et(t).on("keydown.autocomplete",(function(e){var n,r;9==e.keyCode||13==e.keyCode?(n=u.select(".selected")).empty()||(t.value=f(n.node()),t.setAttribute("data-value",n.attr("data-value")),d(),Et(t).dispatch("change"),t.blur()):40==e.keyCode?((n=u.select(".selected")).empty()||(r=n.node().nextSibling),r||(r=u.select(".dropdown-item[data-value]").node()),u.selectAll(".selected").classed("selected",!1),Et(r).classed("selected",!0)):38==e.keyCode&&((n=u.select(".selected")).empty()||(r=n.node().previousSibling),r||(r=u.select(".dropdown-item:last-child").node()),u.selectAll(".selected").classed("selected",!1),Et(r).classed("selected",!0))})).on("input.autocomplete",(function(){var e,i,o=t.value,s=o.toLowerCase(),u=!1;if(Et(t).attr("data-value",o),i=a?(t,e)=>t.includes(e):(t,e)=>0===t.indexOf(e),o){e=[];for(var l=0;l<n.length;l++){var d=("string"==typeof n[l]?n[l]:n[l][0]).toLowerCase();d==s&&(u=!0),i(d,s)&&e.push(n[l])}r&&!u&&e.unshift([Ri+o,o])}else e=n;c(e)})).on("focus.autocomplete",(function(){o=t.value,c(n),s.classed("open",!0)})).on("blur.autocomplete",d),{options:function(t){if(!arguments.length)return n;c(n=t)}}}var ji={number:{text:"Number",symbol:"/images/data_type_number.svg"},datetime:{text:"Date/time",symbol:"/images/data_type_date.svg"},string:{text:"Text",symbol:"/images/data_type_string.svg"}};Ti.STRING_IDS[0];var Hi,Ii,zi,Pi=[{full:"#F4B1C5",light:"#FFDDE7"},{full:"#967EC6",light:"#D0C5E5"},{full:"#C67EBD",light:"#E5C5E1"},{full:"#7E91C6",light:"#C5CDE5"},{full:"#7EB0C6",light:"#C5DBE5"},{full:"#7EC69B",light:"#C5E5D2"},{full:"#B3C67E",light:"#DDE5C5"},{full:"#C69B7E",light:"#E5D2C5"}],qi={},$i={},Yi=0;function Vi(t,e){Yi=0;var n=!1;t.template_id&&t.dataTables((function(r,i){if(r)return console.error("Failed to get data tables: "+r);$i={};var a=t.dataBindingsForCurrentTemplate(),o=t.getDataTableNames(),s=Et(".sheet-tab.selected").size()>0?Et(".sheet-tab.selected").datum().id:null;Ii.html("");var u=null;"string"!=typeof e[0]&&(e=["Data"].concat(e));for(var l,c=[],d=0;d<e.length;d++){const t=e[d],n=e[d-1],r=!(!n||"string"==typeof n||n.dataset===t.dataset),i=(t.columns||t.column||"").split("::")[0],s="string"==typeof t;if((s||r)&&(void 0!==l&&c.push(l),l={title:s?t:i,description:null,bindings:[],template_sheet:null,visualisation_sheet:null}),s){if(d<e.length-1){var f=e[d+1];"string"==typeof f&&(l.description=f,d+=1)}}else{if(null===l.template_sheet&&i)for(var p in o)if(o[p]===i){l.template_sheet=+p;break}if(null===l.visualisation_sheet){var h=a[t.dataset]&&a[t.dataset][t.key];h&&(l.visualisation_sheet=h.data_table_id)}l.bindings.push(t),d===e.length-1&&c.push(l)}}for(d=0;d<c.length;d++){var m=c[d],v=m.bindings,g=m.visualisation_sheet||m.template_sheet||i[0].id,y=(u=Ii.append("div").attr("class","data-block").attr("data-sheet",o[g]).style("display",g===s?null:"none")).append("h2").attr("class","no-select");y.append("i").attr("class","fa fa-table"),y.append("span").text(" "+m.title),m.description&&u.append("p").text(m.description);var _=u.append("div").attr("class","data-bindings-header");_.append("p").attr("class","data-bindings-title").text("Select columns to visualise");for(var b=0;b<v.length;b++){var w=v[b];w.data_type&&(n=!0);var x=a[w.dataset]&&a[w.dataset][w.key],A=x?x.data_table_id:g;$i[w.dataset]||($i[w.dataset]={}),$i[w.dataset][w.key]=A,A!==g&&A===s&&u.style("display",null),Wi(u.append("div"),w,x,o,A!==s)}n&&_.append("p").attr("class","data-bindings-reset clickable").html("<i class='fa fa-magic'></i> Auto set columns").on("click",(function(){Ui("Automatically choose your columns","<i class='fa fa-magic'></i> Flourish will interpret your data to determine which columns to visualize",{is_html:!0,buttons:[{text:"Continue",keyCode:13,class:"primary",callback:function(){Hi.spreadsheet.inferDataBindings()}},{text:"Cancel",keyCode:27,class:"secondary"}]})}))}Hi.spreadsheet&&(Hi.spreadsheet.updateHighlights(),Hi.spreadsheet.updateTabs())}))}function Wi(t,e,n,r,i){Pi[Yi]||(Yi=0),t.attr("class","settings-option option-type-"+e.type).style("display",i?"none":null);var a=null==n?"":nn(n,r,!1,e.optional);qi[e.dataset]||(qi[e.dataset]={}),qi[e.dataset][e.key]=Yi;var o="column"===e.type&&!e.optional,s=o&&!n;t.classed("empty-required-binding",s);var u=t.append("div").attr("class","data-binding-title").on("click",(function(){Et(this).select("input").node().focus()}));u.append("h3").text(e.name).append("i").attr("class","fa fa-question setting-tooltip").style("display",e.description||e.data_type?null:"none"),"column"!=e.type||e.optional||u.select("h3").append("span").attr("class","required").text("Required"),u.append("input").attr("id","data-binding-"+e.dataset+"-"+e.key).attr("name",e.dataset+"-"+e.key).attr("disabled",!Hi.visualisation.can_edit||null).attr("autocomplete","off").attr("title",'Type in column IDs here, for example "A" or "A,B,D" or "A-D"').each((function(){this.value=a})).attr("data-value",a).attr("type","text").call(function(t){return function(e){e.on("change",(function(){je.hide(),function(t,e){var n=t.parentElement.parentElement.parentElement.getAttribute("data-sheet"),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 a,o=t.getBoundingClientRect(),s=[o.left-5,o.top+.5*o.height];if(t.value||"column"!=i.type){try{var u=nn(a=function(t,e){var n={};if(!(t.type in t)){if(t.optional)return n;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 a=t[t.type].substr(r+2);if("column"==t.type)n.column=Je(a,t.optional);else{if("columns"!=t.type)throw new Error("Unknown data binding type: "+t.type);n.columns=tn(a)}return n}(i,Hi.visualisation.getDataTableIds()),Hi.visualisation.getDataTableNames(),!1,e.optional);t.value.toUpperCase()!==u&&(t.value=u)}catch(e){return console.error("Failed to parse data binding",e),je.point(s).text(e.message).draw(),t.value=t.getAttribute("data-value"),void(zi=!0)}if(Et(t.parentElement.parentElement).classed("empty-required-binding",!1),!a.data_table_id)return t.value=t.getAttribute("data-value"),je.point(s).text("No such data table").draw(),void(zi=!0);if(e.data_type){const n=Hi.spreadsheet.getTypeAnnotatedColumns();if("column"===i.type){const r=n[a.column];if(!r)return je.point(s).html(`<h1>Column '${t.value}' does not exist</h1><p>Choose a column from the data table</p>`).draw(),t.value=t.getAttribute("data-value"),void(zi=!0);if(Xi(e,r))return t.value=t.getAttribute("data-value"),je.point(s).html(`\n\t\t\t\t\t\t<h1>This column selection does not accept ${Ji([r.type])} columns</h1>\n\t\t\t\t\t\t<p style="font-size:1em; margin-top:0.75em;">Choose a different column or check/change the column’s type in the header row with the following types:</p>\n\t\t\t\t\t\t<div style="font-size: 1em; margin-top: 0.75em;">${Ji(e.data_type)}</div>\n\t\t\t\t\t`).draw(),void(zi=!0)}else{const r=n.filter((t=>a.columns.includes(t.index))).filter((t=>Xi(e,t)));if(r.length){t.value=t.getAttribute("data-value");var l=r.map((t=>t.type)).reduce(((t,e)=>t.includes(e)?t:[...t,e]),[]).reduce(((t,e,n,r)=>1===r.length?Ji([e]):(n<r.length-1?t+=`${n>0?",":""} ${Ji([e])}`:t+=`or ${Ji([e])}`,t)),"");return je.point(s).html(`\n\t\t\t\t\t\t<h1>This column selection does not accept ${l} columns</h1>\n\t\t\t\t\t\t<p style="font-size:1em; margin-top:0.75em;">Choose a different column or check/change the column’s type in the header row with the following types:</p>\n\t\t\t\t\t\t<div style="font-size: 1em; margin-top: 0.75em;">${Ji(e.data_type)}</div>\n\t\t\t\t\t`).draw(),void(zi=!0)}}}}else if(a=null,!e.optional)return t.value=t.getAttribute("data-value"),je.point(s).text("This column selection is required").draw(),void(zi=!0);Hi.spreadsheet.updateTabs();var c={};c[e.dataset]={},c[e.dataset][e.key]=a,Gi(c,(function(){t.setAttribute("data-value",t.value);var e=Zi();e?(Et(".publish-btn").classed("disabled",!0),Et(".republish-btn").classed("disabled",!0),Ct(".download-btn").classed("disabled",!0),Et("body").classed("impossible",!0)):(Et(".publish-btn").classed("disabled",!1),Et(".republish-btn").classed("disabled",!1),Ct(".download-btn").classed("disabled",!1),Et("body").classed("impossible",!1),Hi.visualisation.getState((function(t){Hi.visualisation.prepareData((function(e,n){e?console.error("Failed to prepare data for template"):Hi.preview_pane.getDrawCalled()?Hi.preview_pane.sync({data:n,state:t,update:!0}):(Hi.preview_pane.sync({data:n,state:t,draw:!0}),Hi.preview_pane.setDrawCalled(!0))}))}))),Hi.spreadsheet&&Hi.spreadsheet.updateHighlights(),Hi.template_settings&&(e?Hi.template_settings.setReadOnly():Hi.template_settings.unsetReadOnly(),Hi.template_settings.populate()),Hi.theme_chooser.enableOrDisable()}))}(this,t)})).on("keydown",(function(){Hi.confirm.blank()})).on("focus",(function(){zi||je.hide(),zi=!1,Ct(".data-bindings .settings-option").classed("open",!1),Et(this.parentElement.parentElement).classed("open",!0)}))}}(e)).style("background",Pi[Yi].light).style("border-color",Pi[Yi].full),s&&Hi.template_settings.setReadOnly(),o&&t.append("div").attr("class","data-binding-required").append("p").text("This column selection is required. The visualisation will not update while this field is empty.");var l,c=t.append("div").attr("class","data-binding-description");if(e.description&&c.append("p").text(e.description),e.data_type){var d=c.append("div").attr("class","data-binding-data-types");d.append("p").text("Accepted column types");for(var f=Array.isArray(e.data_type)?e.data_type:[e.data_type],p=0;p<f.length;p++)l="string"==typeof f[p]?f[p]:f[p].type,d.append("span").attr("class","type-symbol data-binding-type-symbol").attr("title",ji[l].text+" column.").style("background-image","url("+ji[l].symbol+")")}Yi++}function Gi(t,e){Hi.confirm.saving(),Hi.visualisation.updateDataBindings(t,(function(t){if(t)return Hi.confirm.error(t.message||t),console.error("Failed to save data binding:",t),void Hi.analytics("send","exception",{exDescription:t.message||t,exFatal:!0});Hi.analytics("send","event","visualisation","change_data_binding",Hi.visualisation.id),Hi.confirm.saved(),Ki(),e&&e()}))}function Xi(t,e){return!(Array.isArray(t.data_type)?t.data_type:[t.data_type]).some((t=>"string"==typeof t?t===e.type:t.type===e.type))}function Ji(t){return t.map((t=>`\n\t\t<span class="column-type">\n\t\t<span class="type-symbol" title="${ji[t].text} column" style="background-image: url(${ji[t].symbol});"></span>\n\t\t<h2>${ji[t].text}</h2>\n\t\t</span>\n\t\t`)).join("")}function Zi(){var t=Hi.visualisation.dataBindingsForCurrentTemplate(),e=Hi.template_data_bindings,n={};return e.forEach((function(t){"string"!=typeof t&&(n[t.dataset]||(n[t.dataset]={}),n[t.dataset][t.key]=t)})),e.some((function(e){if("string"!=typeof e&&"column"===e.type&&!n[e.dataset][e.key].optional)return!t[e.dataset]||null==t[e.dataset][e.key]}))}function Ki(t=!0){if(Zi())Et("body").classed("impossible",!0),Et(".empty-label").html("<i class='fa fa-exclamation-triangle'></i> Oops! It looks like one of the required column selections is empty."),Et(".empty-details").html("Head over to the <span class='data-tab-icon'><i class='fa fa-table'></i> Data</span> tab to choose a suitable column.");else if(Et("body").classed("impossible")){const e=Hi.visualisation?Hi.visualisation:Hi.story;e.status&&e.status.requested_by?Hi.confirm_published.awaitingReview(e.status,e.can_review,Hi.user):Hi.visualisation.embed_url&&t?Hi.confirm_published.edited():(Hi.confirm_published.unpublished(),Et("body").classed("impossible",!1),Et(".empty-label").text(""),Et(".empty-details").text(""))}}var Qi,ta,ea,na,ra,ia,aa,oa,sa,ua=!1;function la(t){if(ua&&window.top!==window.self){var e=window;"srcdoc"===e.location.pathname&&(e=e.parent);var n,r=(n={},window._Flourish_template_id&&(n.template_id=window._Flourish_template_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_template_id&&(n.template_id=window.Flourish.app.loaded_template_id),window._Flourish_visualisation_id&&(n.visualisation_id=window._Flourish_visualisation_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_visualisation&&(n.visualisation_id=window.Flourish.app.loaded_visualisation.id),window.Flourish&&window.Flourish.app&&window.Flourish.app.story&&(n.story_id=window.Flourish.app.story.id,n.slide_count=window.Flourish.app.story.slides.length),window.Flourish&&window.Flourish.app&&window.Flourish.app.current_slide&&(n.slide_index=window.Flourish.app.current_slide.index+1),n),i={sender:"Flourish",method:"customerAnalytics"};for(var a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);for(var a in t)t.hasOwnProperty(a)&&(i[a]=t[a]);e.parent.postMessage(JSON.stringify(i),"*")}}function ca(t){if("function"!=typeof t)throw new Error("Analytics callback is not a function");window.Flourish._analytics_listeners.push(t)}function da(){ua=!0;[{event_name:"click",action_name:"click",use_capture:!0},{event_name:"keydown",action_name:"key_down",use_capture:!0},{event_name:"mouseenter",action_name:"mouse_enter",use_capture:!1},{event_name:"mouseleave",action_name:"mouse_leave",use_capture:!1}].forEach((function(t){document.body.addEventListener(t.event_name,(function(){la({action:t.action_name})}),t.use_capture)}))}function fa(){if(null==Qi){var t=function(){var t=window.location;"about:srcdoc"==t.href&&(t=window.parent.location);var e={};return function(t,n,r){for(;r=n.exec(t);)e[decodeURIComponent(r[1])]=decodeURIComponent(r[2])}(t.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),e}();Qi="referrer"in t?/^https:\/\/medium.com\//.test(t.referrer):!("auto"in t)}return Qi}function pa(t){var e=t||window.innerWidth;return e>999?650:e>599?575:400}function ha(t,e){if(window.top!==window.self){var n=window;if("srcdoc"==n.location.pathname&&(n=n.parent),ta)return t=parseInt(t,10),void n.parent.postMessage({sentinel:"amp",type:"embed-size",height:t},"*");var r={sender:"Flourish",context:"iframe.resize",method:"resize",height:t,src:n.location.toString()};if(e)for(var i in e)r[i]=e[i];n.parent.postMessage(JSON.stringify(r),"*")}}function ma(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function va(t){return"string"==typeof t||t instanceof String}function ga(t){return"warn"!==t.method?(console.warn("BUG: validateWarnMessage called for method"+t.method),!1):!(null!=t.message&&!va(t.message))&&!(null!=t.explanation&&!va(t.explanation))}function ya(t){return"resize"!==t.method?(console.warn("BUG: validateResizeMessage called for method"+t.method),!1):!!va(t.src)&&(!!va(t.context)&&!!("number"==typeof(e=t.height)?!isNaN(e)&&e>=0:va(e)&&/\d/.test(e)&&/^[0-9]*(\.[0-9]*)?(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|vw|vh|vmin|vmax|%)?$/i.test(e)));var e}function _a(t){throw new Error("Validation for setSetting is not implemented yet; see issue #4328")}function ba(t){return"customerAnalytics"===t.method||(console.warn("BUG: validateCustomerAnalyticsMessage called for method"+t.method),!1)}function wa(t){return"request-upload"!==t.method?(console.warn("BUG: validateResizeMessage called for method"+t.method),!1):!!va(t.name)&&!(null!=t.accept&&!va(t.accept))}function xa(t,e){var n=function(t){for(var e={warn:ga,resize:ya,setSetting:_a,customerAnalytics:ba,"request-upload":wa},n={},r=0;r<t.length;r++){var i=t[r];if(!e[i])throw new Error("No validator found for method "+i);n[i]=e[i]}return n}(e);window.addEventListener("message",(function(e){if(null!=e.source&&(e.origin===document.location.origin||e.origin.match(/\/\/localhost:\d+$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$|\/\/flourish-user-templates\.com$/))){var r;try{r=JSON.parse(e.data)}catch(t){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(e.data))}if("Flourish"===r.sender)if(r.method)if(Object.prototype.hasOwnProperty.call(n,r.method))if(n[r.method](r)){for(var i=document.querySelectorAll("iframe"),a=0;a<i.length;a++)if(i[a].contentWindow==e.source||i[a].contentWindow==e.source.parent)return void t(r,i[a]);console.warn("could not find frame",r)}else console.warn("Validation failed for the message",r);else console.warn("No validator implemented for message",r);else console.warn("The 'method' property was missing from message",r)}})),ma()&&(window.addEventListener("resize",Aa),Aa())}function Aa(){for(var t=document.querySelectorAll(".flourish-embed"),e=0;e<t.length;e++){var n=t[e];if(!n.getAttribute("data-width")){var r=n.querySelector("iframe");if(r){var i=window.getComputedStyle(n),a=n.offsetWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight);r.style.width=a+"px"}}}}function Ea(t,e,n,r,i){var a=document.createElement("iframe");if(a.setAttribute("scrolling","no"),a.setAttribute("frameborder","0"),a.setAttribute("title","Interactive or visual content"),a.setAttribute("sandbox","allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"),e.appendChild(a),a.offsetParent||"fixed"===getComputedStyle(a).position)Ta(t,e,a,n,r,i);else{var o={embed_url:t,container:e,iframe:a,width:n,height:r,play_on_load:i};if(window._flourish_poll_items?window._flourish_poll_items.push(o):window._flourish_poll_items=[o],window._flourish_poll_items.length>1)return a;var s=setInterval((function(){window._flourish_poll_items=window._flourish_poll_items.filter((function(t){return!t.iframe.offsetParent||(Ta(t.embed_url,t.container,t.iframe,t.width,t.height,t.play_on_load),!1)})),window._flourish_poll_items.length||clearInterval(s)}),500)}return a}function Ta(t,e,n,r,i,a){var o;return r&&"number"==typeof r?(o=r,r+="px"):r&&r.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(o=parseFloat(r)),i&&"number"==typeof i&&(i+="px"),r?n.style.width=r:ma()?n.style.width=e.offsetWidth+"px":n.style.width="100%",!!i||(t.match(/\?/)?t+="&auto=1":t+="?auto=1",i=pa(o||n.offsetWidth)+"px"),i&&("%"===i.charAt(i.length-1)&&(i=parseFloat(i)/100*e.parentNode.offsetHeight+"px"),n.style.height=i),n.setAttribute("src",t+(a?"#play-on-load":"")),n}function Ca(t,e,n){for(var r in e||(e=[]),n||(n={}),t)e.push(r),"object"==typeof t[r]&&Ca(t[r],e,n),n[e.join(".")]=t[r],e.pop();return n}function ka(t){var e={};for(var n in t){for(var r=e,i=n.indexOf("."),a=0;i>=0;i=n.indexOf(".",a=i+1)){var o=n.substring(a,i);o in r||(r[o]={}),r=r[o]}r[n.substring(a)]=t[n]}return e}function Da(t){if(null==t)return t;var e,n={};for(var r in t)Array.isArray(t[r])?n[r]=t[r].slice():(e=t[r],Array.isArray(e)||"object"!=typeof e||null==e?n[r]=t[r]:n[r]=Da(t[r]));return n}var Fa,Sa=null;function Ma(){return"MessageChannel"in window}var Na=null;function La(){Na&&ea.removeEventListener("load",Na),Na=null}function Oa(t){La(),ea.addEventListener("load",t),Na=t}var Ua=null;function Ra(){Ua&&(cancelAnimationFrame(Ua),Ua=null)}function Ba(t,e){Ra();var n=null,r=function(i){null==n&&(n=i);var a=i-n,o=Math.min(1,Math.max(0,a/t));ea.style.opacity=1-o,1==o?(Ua=null,e()):Ua=requestAnimationFrame(r)};Ua=requestAnimationFrame(r)}function ja(t,e,n){return io(!1),sa=t?t.visualisation?t.visualisation:t.current_slide.visualisation:null,Sa=null,sa&&sa.template_id?(Oa(function(t,e,n){var r=t.visualisation?t.visualisation.template_id:t.current_slide.visualisation.template_id,i=t.current_slide?t.current_slide.id:null;return function(){Dt(),!sa||sa.template_id!=r||t.current_slide&&t.current_slide.id!==i||(La(),Va((function(a,o){a?console.error("Failed to get default state"):!sa||sa.template_id!=r||t.current_slide&&t.current_slide.id!==i||Wa((function(a,s){if(a)console.error("Failed to call hasData");else if(sa&&sa.template_id==r&&(!t.current_slide||t.current_slide.id===i)){var u=!1;t.visualisation&&(u=t.data_bindings.requiredBindingsAreUnset()),s?sa.refreshDataBindings((function(a){a?console.error("Failed to refresh data bindings"):!sa||sa.template_id!=r||t.current_slide&&t.current_slide.id!==i||sa.prepareData((function(a,s){a?console.error("Failed to prepare data for template"):!sa||sa.template_id!=r||t.current_slide&&t.current_slide.id!==i||no({data:s,state:e,draw:!u},(function(t,e){Sa=o,n(t,e)}))}))})):no({state:e,draw:!u},(function(t,e){Sa=o,n(t,e)}))}}))})))}}(t,e,n)),ea.src="/template/"+sa.template_id+"/embed/?auto=1&environment="+na+"&is_read_only="+(t.is_read_only?"1":"0"),ea):(La(),ea.src="about:blank",ea)}function Ha(t,e,n,r){var i="about:blank"===ea.src;if(io(!1),e){var a=t[e]||"/template/"+e+"/embed";a+="?environment="+na,r&&(a+="&auto=1"),i?o():Ba(250,o)}else Ba(250,(function(){La(),ea.src="about:blank"}));function o(){Oa(function(t){return function(){Va((function(e,n){e?console.error("Failed to get default state"):(Sa=n,t())}))}}((function(){n(),i||function(t){Ra();var e=null,n=function(r){null==e&&(e=r);var i=r-e,a=Math.min(1,Math.max(0,i/t));ea.style.opacity=a,Ua=1==a?null:requestAnimationFrame(n)};Ua=requestAnimationFrame(n)}(250)}))),ea.src=a}}function Ia(t,e){var n=t.template_id;t.refreshDataBindings((function(r){r?console.error("Failed to fetch data bindings"):t.prepareData((function(t,r){if(sa&&sa.template_id==n)return t?(console.error("Failed to prepare data for template"),void e(t)):void e(void 0,r)}))}))}function za(t,e){Ia(t,(function(t,n){if(t)return e(t);no({data:n,update:!0},e)}))}function Pa(t,e){Ia(t,(function(t,n){if(t)return e(t);no({data:n,update:!1},e)}))}function qa(t,e,n){Ia(t,(function(t,r){if(t)return n(t);no({data:r,state:e,overwrite_state:!0,update:!0},n)}))}function $a(t,e,n){if(Ma()){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)},ea.contentWindow.postMessage({sender:"Flourish",method:t,argument:e},"*",[r.port2])}}function Ya(t,e){$a("setState",ka(t),e)}function Va(t,e){"function"!=typeof t?$a("getState",t,e):$a("getState",void 0,t)}function Wa(t){$a("hasData",void 0,t)}function Ga(t,e){$a("setData",t,e)}function Xa(t){$a("getData",void 0,t)}function Ja(t){$a("draw",void 0,t),io(!0)}function Za(t){aa&&aa.clear(),ro()&&$a("update",void 0,t)}function Ka(t,e){$a("snapshot",t,e)}function Qa(){return Da(Sa)}function to(t,e){$a("setFixedHeight",t,e)}function eo(t){if(ea.parentNode.offsetWidth){if(void 0!==t)Fa=null!=t;else if(Fa)return;var e=t||ia&&ia.responsive_menu&&ia.responsive_menu.getHeightSetting()||ra.getHeightForBreakpoint(ea.offsetWidth),n=typeof e;("number"===n||"string"===n&&!isNaN(e))&&(e+="px"),ea.style.height=e}}function no(t,e){ro()?delete t.draw:t.draw&&io(!0),t.state&&(t.state=ka(t.state)),aa&&aa.clear(),$a("sync",t,(function(n,r){null!=n||"success"!==r?(t.draw&&io(!1),function n(r){r?e&&e(r):function(t,e){return t.data?(Ga(t.data,e),delete t.data,!1):t.state?(Ya(t.state,e),delete t.state,!1):t.draw?(Ja(e),delete t.draw,!1):!t.update||(Za(e),delete t.update,!1)}(t,n)&&e&&e(void 0)}(n)):e&&e(void 0)}))}function ro(){return oa}function io(t){oa=t}function ao(t,e,n,r,i){return ea=document.querySelector(t),na=e,ia=n,aa=r,i||(i={}),ta="#amp=1"==window.location.hash,ra={createEmbedIframe:Ea,isFixedHeight:fa,getHeightForBreakpoint:pa,startEventListeners:xa,notifyParentWindow:ha,isSafari:ma,initCustomerAnalytics:da,addAnalyticsListener:ca,sendCustomerAnalyticsMessage:la},ea.style.height=ra.getHeightForBreakpoint(ea.offsetWidth)+"px",ra.startEventListeners((function(t){"resize"==t.method?eo(t.height):"warn"==t.method?(aa&&aa.warn(t),console.warn("Warning from template:",t.message,t.explanation)):t.method in i&&i[t.method](t)}),["resize","warn","customerAnalytics","setSetting","request-upload"]),Ma()||function(t){if(t){var e=document.createElement("div");e.className="unsupported-notice",e.innerHTML="<h3>Please update your browser</h3><p>This page only works with newer versions of your browser.</p>",t.appendChild(e)}}(ea.parentNode),{loadVisualisation:ja,loadTemplate:Ha,updateData:za,updateDataAndState:qa,updateDataNotPreview:Pa,setState:Ya,getState:Va,getDefaultState:Qa,hasData:Wa,setData:Ga,getData:Xa,draw:Ja,update:Za,snapshot:Ka,setFixedHeight:to,resize:eo,sync:no,getDrawCalled:ro,setDrawCalled:io}}var oo=function(t=document.body){t.classList.add("loading")},so=function(t=document.body){t.classList.remove("loading")},uo="/api/file/upload";function lo(t){(t||document).querySelectorAll("input[type=url]").forEach((function(t){co(t)}))}function co(t,e){var n=t.ownerDocument.createElement("button");n.type="button",n.className="upload",n.setAttribute("title","Upload a file from your computer"),n.innerHTML="⬆︎",t.insertAdjacentElement("afterend",n),e||(n.onclick=fo)}function fo(){var t=this.previousSibling,e=t.getAttribute("accept");t.disabled=!0,t.classList.toggle("uploading",!0),po({accept:e,success:function(e){var n;t.disabled=!1,t.classList.toggle("uploading",!1),t.value=e,"createEvent"in document?(n=document.createEvent("Event")).initEvent("change",!0,!0):n=new Event("change",{bubbles:!0}),t.dispatchEvent(n)},failure:function(){t.disabled=!1,t.classList.toggle("uploading",!1)}})}function po(t){var e=document.getElementById("file-uploader");e||((e=document.createElement("input")).type="file",e.setAttribute("id","file-uploader"),e.style.display="none",document.body.appendChild(e)),t.accept?e.setAttribute("accept",t.accept):e.removeAttribute("accept"),e.onchange=function(){var n,r,i,a;oo(),n=e.files,r=t.success,i=t.failure,function(t,e){var n={filename:t.name,content_type:t.type,size:t.size};ho(uo,n,(function(t,n){return t?e(t):e(null,JSON.parse(n.responseText))}))}(a=n[0],(function(t,e){if(t)return so(),Ui("Upload error","There was a problem uploading your file: "+t),void console.error(t);var n=function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}({file:a},e.fields);ho(e.upload_url,n,(function(t,n){so(),t?(Ui("Upload error","There was a problem uploading your file ("+n.status+")."),console.error(t),i&&i()):r(e.file_url)}))})),e.parentNode.removeChild(e)},e.click()}function ho(t,e,n){var r=new XMLHttpRequest,i=new FormData;if("object"==typeof e){for(var a in e)e.hasOwnProperty(a)&&"file"!==a&&i.append(a,e[a]);e.hasOwnProperty("file")&&i.append("file",e.file)}window.Flourish.csrf_token&&i.append("csrf_token",window.Flourish.csrf_token),r.onload=function(){if(r.status>=200&&r.status<300)n(null,r);else try{var e=JSON.parse(r.responseText).error;n(e,r)}catch(e){n(new Error("POST "+t+" received status code: "+r.status),r)}},r.open("POST",t,!0),r.send(i)}var mo="https://fonts.googleapis.com/css?family=",vo=["Source Sans Pro","Roboto Condensed","Merriweather","Lora","Playfair Display","Coda","Lobster","Cabin Sketch"],go="Same as parent",yo=[],_o=[],bo={};function wo(t){return mo+t.replace(/ /g,"+")+":400,700"}function xo(t){var e=_o.concat(yo,vo.map((function(t){return{name:t,url:wo(t)}})));return t&&e.unshift({name:go}),e}function Ao(t){return xo(!0).find((function(e){return e.name==t}))}var Eo=!1;function To(t){return t.substr(t.lastIndexOf("=")+1).replace(/\+/g," ")}function Co(t){var e=t.target,n=e.value;if(n&&(0==n.indexOf(mo)&&(n=e.value=To(n)),!Ao(n))){if(/^https?:\/\//.test(n)){Eo||(ko(n),e.value="");var r=n;return n=e.value=To(r),_o.push({name:n,url:r}),void Do()}var i=wo(n);try{var a=new XMLHttpRequest;if(a.open("HEAD",i,!1),a.send(),404==a.status)throw"Font not found";_o.push({name:n,url:i}),Do()}catch(t){ko(n),e.value=""}}}function ko(t){Ui("Unrecognised font “"+t+"”","Fonts must be chosen from Google Fonts. Visit <a href='https://fonts.google.com'>fonts.google.com</a> to find more",{is_html:!0})}function Do(){var t,e,n=Object.keys(bo);for(t=0;t<n.length;++t)(e=bo[n[t]]).autocomplete.options(xo(e.can_inherit).map((function(t){return t.name})))}var Fo={initialize:function(t,e,n){var r=!!e.optional;Eo=n,t.classList.add("font-menu"),bo[e.property]={autocomplete:Bi(t,e.property+"-dropdown",xo(r).map((function(t){return t.name})),{allow_other_option:!0}),can_inherit:r},t.addEventListener("change",Co)},update:function(t,e){var n=e?e.name:go;t.value=n,Ao(n)||(n!=go&&_o.push({name:n,url:e.url}),Do())},getValue:function(t){if(/^https?:\/\//.test(t.value))return{name:To(t.value),url:t.value};var e=t.value;if(e==go)return null;var n=Ao(e);return n||{name:e,url:wo(e)}},replaceThemeFonts:function(t){yo=(t||[]).map((function(t){return{name:t.name,url:t.url}})),Do()}},So="$";function Mo(){}function No(t,e){var n=new Mo;if(t instanceof Mo)t.each((function(t,e){n.set(e,t)}));else if(Array.isArray(t)){var r,i=-1,a=t.length;if(null==e)for(;++i<a;)n.set(i,t[i]);else for(;++i<a;)n.set(e(r=t[i],i,t),r)}else if(t)for(var o in t)n.set(o,t[o]);return n}function Lo(){}Mo.prototype=No.prototype={constructor:Mo,has:function(t){return So+t in this},get:function(t){return this[So+t]},set:function(t,e){return this[So+t]=e,this},remove:function(t){var e=So+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===So&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===So&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===So&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===So&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===So&&++t;return t},empty:function(){for(var t in this)if(t[0]===So)return!1;return!0},each:function(t){for(var e in this)e[0]===So&&t(this[e],e.slice(1),this)}};var Oo=No.prototype;Lo.prototype={constructor:Lo,has:Oo.has,add:function(t){return this[So+(t+="")]=t,this},remove:Oo.remove,clear:Oo.clear,values:Oo.keys,size:Oo.size,empty:Oo.empty,each:Oo.each};var Uo={value:function(){}};function Ro(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Bo(r)}function Bo(t){this._=t}function jo(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 Ho(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Io(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Uo,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function zo(t,e,n,r,i){for(var a in t.getVersionNumber=function(){return t.version_number},t.setVersionNumber=function(e){t.version_number=e},t.id=e,t.version_number=n||0,r)t[a]=r[a];if(i)for(var a in i)t[a]=i[a]}Bo.prototype=Ro.prototype={constructor:Bo,on:function(t,e){var n,r=this._,i=jo(t+"",r),a=-1,o=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<o;)if(n=(t=i[a]).type)r[n]=Io(r[n],t.name,e);else if(null==e)for(n in r)r[n]=Io(r[n],t.name,null);return this}for(;++a<o;)if((n=(t=i[a]).type)&&(n=Ho(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Bo(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};var Po={};function qo(t){t.running||(t.running=!0,$o(t,(function(){t.running=!1})))}function $o(t,e){t.request=function(t,e){var n="method"in t?t.method:"POST",r="request_type"in t?t.request_type:"application/json",i="response_type"in t?t.response_type:"application/json",a=t.url,o=t.payload,s=t.callback;!o&&Yo(n)&&(o=function(){return{}});if(o){if("function"!=typeof o)throw new Error("Internal error: processRequestThen: payload must be a function, not "+typeof o,o);"object"==typeof(o=o())&&Yo(n)&&(window.Flourish&&window.Flourish.csrf_token||console.trace("window.Flourish.csrf_token missing"),o.csrf_token=window.Flourish.csrf_token),"string"!=typeof o&&(o=JSON.stringify(o))}var u=function(t,e){var n,r,i,a,o=Ro("beforesend","progress","load","error"),s=No(),u=new XMLHttpRequest,l=null,c=null,d=0;function f(t){var e,r=u.status;if(!r&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(u)||r>=200&&r<300||304===r){if(i)try{e=i.call(n,u)}catch(t){return void o.call("error",n,t)}else e=u;o.call("load",n,e)}else o.call("error",n,t)}if("undefined"!=typeof XDomainRequest&&!("withCredentials"in u)&&/^(http(s)?:)?\/\//.test(t)&&(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=u.ontimeout=f:u.onreadystatechange=function(t){u.readyState>3&&f(t)},u.onprogress=function(t){o.call("progress",n,t)},n={header:function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s.get(t):(null==e?s.remove(t):s.set(t,e+""),n)},mimeType:function(t){return arguments.length?(r=null==t?null:t+"",n):r},responseType:function(t){return arguments.length?(a=t,n):a},timeout:function(t){return arguments.length?(d=+t,n):d},user:function(t){return arguments.length<1?l:(l=null==t?null:t+"",n)},password:function(t){return arguments.length<1?c:(c=null==t?null:t+"",n)},response:function(t){return i=t,n},get:function(t,e){return n.send("GET",t,e)},post:function(t,e){return n.send("POST",t,e)},send:function(e,i,f){return u.open(e,t,!0,l,c),null==r||s.has("accept")||s.set("accept",r+",*/*"),u.setRequestHeader&&s.each((function(t,e){u.setRequestHeader(e,t)})),null!=r&&u.overrideMimeType&&u.overrideMimeType(r),null!=a&&(u.responseType=a),d>0&&(u.timeout=d),null==f&&"function"==typeof i&&(f=i,i=null),null!=f&&1===f.length&&(f=function(t){return function(e,n){t(null==e?n:null)}}(f)),null!=f&&n.on("error",f).on("load",(function(t){f(null,t)})),o.call("beforesend",n,u),u.send(null==i?null:i),n},abort:function(){return u.abort(),n},on:function(){var t=o.on.apply(o,arguments);return t===o?n:t}},null!=e){if("function"!=typeof e)throw new Error("invalid callback: "+e);return n.get(e)}return n}(a);r&&"GET"!==n&&u.header("Content-Type",r);i&&u.mimeType(i);return u.on("error",(function(t){var n;try{n=JSON.parse(t.target.responseText),s(n.error)}catch(e){s("Internal error: "+t.target.responseText)}e()})),u.on("load",(function(t){var n=t.responseText;"application/json"===i&&(n=JSON.parse(n));try{s(void 0,n)}catch(t){console.error(t.stack)}e()})),u.send(n,o),u}(t.items.shift(),(function(){t.request=null,0==t.items.length?e():$o(t,e)}))}function Yo(t){return["POST","PUT","DELETE"].includes(t)}function Vo(t,e){void 0===e&&(e="default"),e in Po||(Po[e]={items:[],running:!1,name:e}),Po[e].items.push(t),qo(Po[e])}function Wo(t,e){for(var n in e)t[n]=e[n];return t}function Go(t,e,n,r){"function"==typeof n&&(r=n,n=!1),n&&Wo(t,e),Vo({url:t.api_prefix+"/"+t.id,payload:function(){return{version_number:t.getVersionNumber(),fields:e}},callback:function(i,a){if(i)return r(i);n||Wo(t,e),t.setVersionNumber(a.version_number),r(void 0)}})}function Xo(t,e){t.delete_requested=!0,Vo({url:t.api_prefix+"/"+t.id,method:"DELETE",payload:function(){return{version_number:t.getVersionNumber()}},callback:function(n,r){if(n)return e(n);t.setVersionNumber(r.version_number),t.is_deleted=!0,e(void 0,r)}})}var Jo={update:function(t,e){Vo({url:"/api/user",method:"POST",payload:function(){return{fields:t}},callback:e})},isUsernameAvailable:function(t,e){Vo({url:"/api/user/username?u="+encodeURIComponent(t),method:"GET",callback:e})},getReviewCount:function(t){Vo({url:"/api/reviews/count",method:"GET",callback:t})},logHistory:function(t){Vo({url:"/api/history",method:"POST",payload:function(){return t},callback:function(){}})},addApiKey:function(t){Vo({url:"/api/user/api_keys",method:"PUT",callback:t})},getApiKeys:function(t){Vo({url:"/api/user/api_keys",method:"GET",callback:t})},deleteApiKey:function(t,e){Vo({url:"/api/user/api_keys/"+t,method:"DELETE",callback:e})},fetchProjects:function(t,e,n,r,i,a,o,s){var u="";e&&(u+="&folder="+encodeURIComponent(e)),n&&(u+="&sort="+encodeURIComponent(n)),r&&(u+="&filter="+encodeURIComponent(r)),i&&(u+="&offset="+encodeURIComponent(i)),a&&(u+="&limit="+encodeURIComponent(a)),o&&(u+="&search="+encodeURIComponent(o)),s&&(u+="&is_recent=true"),Vo({url:"/api/user/projects?"+u,method:"GET",callback:t})},addTag:function(t,e){Vo({url:"/api/user/tag/"+encodeURIComponent(t),method:"PUT",callback:e})},renameTag:function(t,e,n){Vo({url:"/api/user/tag/"+encodeURIComponent(t)+"/"+encodeURIComponent(e),method:"PUT",callback:n})},removeTag:function(t,e){Vo({url:"/api/user/tag/"+encodeURIComponent(t),method:"DELETE",callback:e})},fetchFolders:function(t){Vo({url:"/api/user/folders",method:"GET",callback:t})},setSamlProviderId:function(t,e,n){Vo({url:"/api/user/"+encodeURIComponent(t)+"/change_saml_provider_id",method:"POST",payload:function(){return{saml_provider_id:e}},callback:n})}};function Zo(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Ko(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Qo(){}var ts=.7,es=1/ts,ns="\\s*([+-]?\\d+)\\s*",rs="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",is="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",as=/^#([0-9a-f]{3,8})$/,os=new RegExp("^rgb\\("+[ns,ns,ns]+"\\)$"),ss=new RegExp("^rgb\\("+[is,is,is]+"\\)$"),us=new RegExp("^rgba\\("+[ns,ns,ns,rs]+"\\)$"),ls=new RegExp("^rgba\\("+[is,is,is,rs]+"\\)$"),cs=new RegExp("^hsl\\("+[rs,is,is]+"\\)$"),ds=new RegExp("^hsla\\("+[rs,is,is,rs]+"\\)$"),fs={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 ps(){return this.rgb().formatHex()}function hs(){return this.rgb().formatRgb()}function ms(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=as.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?vs(e):3===n?new bs(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?gs(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?gs(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=os.exec(t))?new bs(e[1],e[2],e[3],1):(e=ss.exec(t))?new bs(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=us.exec(t))?gs(e[1],e[2],e[3],e[4]):(e=ls.exec(t))?gs(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=cs.exec(t))?Es(e[1],e[2]/100,e[3]/100,1):(e=ds.exec(t))?Es(e[1],e[2]/100,e[3]/100,e[4]):fs.hasOwnProperty(t)?vs(fs[t]):"transparent"===t?new bs(NaN,NaN,NaN,0):null}function vs(t){return new bs(t>>16&255,t>>8&255,255&t,1)}function gs(t,e,n,r){return r<=0&&(t=e=n=NaN),new bs(t,e,n,r)}function ys(t){return t instanceof Qo||(t=ms(t)),t?new bs((t=t.rgb()).r,t.g,t.b,t.opacity):new bs}function _s(t,e,n,r){return 1===arguments.length?ys(t):new bs(t,e,n,null==r?1:r)}function bs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ws(){return"#"+As(this.r)+As(this.g)+As(this.b)}function xs(){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 As(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Es(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Cs(t,e,n,r)}function Ts(t){if(t instanceof Cs)return new Cs(t.h,t.s,t.l,t.opacity);if(t instanceof Qo||(t=ms(t)),!t)return new Cs;if(t instanceof Cs)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,s=a-i,u=(a+i)/2;return s?(o=e===a?(n-r)/s+6*(n<r):n===a?(r-e)/s+2:(e-n)/s+4,s/=u<.5?a+i:2-a-i,o*=60):s=u>0&&u<1?0:o,new Cs(o,s,u,t.opacity)}function Cs(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function ks(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 Ds(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(6*r,6*++r);return n}Zo(Qo,ms,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:ps,formatHex:ps,formatHsl:function(){return Ts(this).formatHsl()},formatRgb:hs,toString:hs}),Zo(bs,_s,Ko(Qo,{brighter:function(t){return t=null==t?es:Math.pow(es,t),new bs(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?ts:Math.pow(ts,t),new bs(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:ws,formatHex:ws,formatRgb:xs,toString:xs})),Zo(Cs,(function(t,e,n,r){return 1===arguments.length?Ts(t):new Cs(t,e,n,null==r?1:r)}),Ko(Qo,{brighter:function(t){return t=null==t?es:Math.pow(es,t),new Cs(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?ts:Math.pow(ts,t),new Cs(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new bs(ks(t>=240?t-240:t+120,i,r),ks(t,i,r),ks(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 Fs=Ds("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"),Ss=Ds("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"),Ms=Ds("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),Ns=Ds("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2");function Ls(t){return function(){return t}}function Os(t){return 1==(t=+t)?Us:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):Ls(isNaN(e)?n:e)}}function Us(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Ls(isNaN(t)?e:t)}var Rs=function t(e){var n=Os(e);function r(t,e){var r=n((t=_s(t)).r,(e=_s(e)).r),i=n(t.g,e.g),a=n(t.b,e.b),o=Us(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);function Bs(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var js=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Hs=new RegExp(js.source,"g");function Is(t,e){var n,r,i,a=js.lastIndex=Hs.lastIndex=0,o=-1,s=[],u=[];for(t+="",e+="";(n=js.exec(t))&&(r=Hs.exec(e));)(i=r.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,u.push({i:o,x:Bs(n,r)})),a=Hs.lastIndex;return a<e.length&&(i=e.slice(a),s[o]?s[o]+=i:s[++o]=i),s.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,r=0;r<e;++r)s[(n=u[r]).i]=n.x(t);return s.join("")})}var zs,Ps,qs,$s,Ys=180/Math.PI,Vs={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ws(t,e,n,r,i,a){var o,s,u;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,u/=s),t*r<e*n&&(t=-t,e=-e,u=-u,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(e,t)*Ys,skewX:Math.atan(u)*Ys,scaleX:o,scaleY:s}}function Gs(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(a,o){var s=[],u=[];return a=t(a),o=t(o),function(t,r,i,a,o,s){if(t!==i||r!==a){var u=o.push("translate(",null,e,null,n);s.push({i:u-4,x:Bs(t,i)},{i:u-2,x:Bs(r,a)})}else(i||a)&&o.push("translate("+i+e+a+n)}(a.translateX,a.translateY,o.translateX,o.translateY,s,u),function(t,e,n,a){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Bs(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(a.rotate,o.rotate,s,u),function(t,e,n,a){t!==e?a.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Bs(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(a.skewX,o.skewX,s,u),function(t,e,n,r,a,o){if(t!==n||e!==r){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:Bs(t,n)},{i:s-2,x:Bs(e,r)})}else 1===n&&1===r||a.push(i(a)+"scale("+n+","+r+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,u),a=o=null,function(t){for(var e,n=-1,r=u.length;++n<r;)s[(e=u[n]).i]=e.x(t);return s.join("")}}}var Xs,Js,Zs=Gs((function(t){return"none"===t?Vs:(zs||(zs=document.createElement("DIV"),Ps=document.documentElement,qs=document.defaultView),zs.style.transform=t,t=qs.getComputedStyle(Ps.appendChild(zs),null).getPropertyValue("transform"),Ps.removeChild(zs),Ws(+(t=t.slice(7,-1).split(","))[0],+t[1],+t[2],+t[3],+t[4],+t[5]))}),"px, ","px)","deg)"),Ks=Gs((function(t){return null==t?Vs:($s||($s=document.createElementNS("http://www.w3.org/2000/svg","g")),$s.setAttribute("transform",t),(t=$s.transform.baseVal.consolidate())?Ws((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Vs)}),", ",")",")"),Qs=0,tu=0,eu=0,nu=0,ru=0,iu=0,au="object"==typeof performance&&performance.now?performance:Date,ou="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function su(){return ru||(ou(uu),ru=au.now()+iu)}function uu(){ru=0}function lu(){this._call=this._time=this._next=null}function cu(t,e,n){var r=new lu;return r.restart(t,e,n),r}function du(){ru=(nu=au.now())+iu,Qs=tu=0;try{!function(){su(),++Qs;for(var t,e=Xs;e;)(t=ru-e._time)>=0&&e._call.call(null,t),e=e._next;--Qs}()}finally{Qs=0,function(){var t,e,n=Xs,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Xs=e);Js=t,pu(r)}(),ru=0}}function fu(){var t=au.now(),e=t-nu;e>1e3&&(iu-=e,nu=t)}function pu(t){Qs||(tu&&(tu=clearTimeout(tu)),t-ru>24?(t<1/0&&(tu=setTimeout(du,t-au.now()-iu)),eu&&(eu=clearInterval(eu))):(eu||(nu=au.now(),eu=setInterval(fu,1e3)),Qs=1,ou(du)))}function hu(t,e,n){var r=new lu;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}lu.prototype=cu.prototype={constructor:lu,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?su():+n)+(null==e?0:+e),this._next||Js===this||(Js?Js._next=this:Xs=this,Js=this),this._call=t,this._time=n,pu()},stop:function(){this._call&&(this._call=null,this._time=1/0,pu())}};var mu=Ro("start","end","cancel","interrupt"),vu=[];function gu(t,e,n,r,i,a){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function a(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(a){var l,c,d,f;if(1!==n.state)return u();for(l in i)if((f=i[l]).name===n.name){if(3===f.state)return hu(o);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[l]):+l<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[l])}if(hu((function(){3===n.state&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))})),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(d=n.tween.length),l=0,c=-1;l<d;++l)(f=n.tween[l].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=f);r.length=c+1}}function s(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=5,1),a=-1,o=r.length;++a<o;)r[a].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=cu(a,0,n.time)}(t,n,{name:e,index:r,group:i,on:mu,tween:vu,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function yu(t,e){var n=bu(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function _u(t,e){var n=bu(t,e);if(n.state>3)throw new Error("too late; already running");return n}function bu(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function wu(t,e){var n,r;return function(){var i=_u(this,t),a=i.tween;if(a!==n)for(var o=0,s=(r=n=a).length;o<s;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r}}function xu(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var a=_u(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:e,value:n},u=0,l=i.length;u<l;++u)if(i[u].name===e){i[u]=s;break}u===l&&i.push(s)}a.tween=i}}function Au(t,e,n){var r=t._id;return t.each((function(){var t=_u(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)})),function(t){return bu(t,r).value[e]}}function Eu(t,e){var n;return("number"==typeof e?Bs:e instanceof ms?Rs:(n=ms(e))?(e=n,Rs):Is)(t,e)}function Tu(t){return function(){this.removeAttribute(t)}}function Cu(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ku(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=e(r=o,n)}}function Du(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=e(r=o,n)}}function Fu(t,e,n){var r,i,a;return function(){var o,s,u=n(this);if(null!=u)return(o=this.getAttribute(t))===(s=u+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,u));this.removeAttribute(t)}}function Su(t,e,n){var r,i,a;return function(){var o,s,u=n(this);if(null!=u)return(o=this.getAttributeNS(t.space,t.local))===(s=u+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,u));this.removeAttributeNS(t.space,t.local)}}function Mu(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function Nu(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function Lu(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Nu(t,i)),n}return i._value=e,i}function Ou(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Mu(t,i)),n}return i._value=e,i}function Uu(t,e){return function(){yu(this,t).delay=+e.apply(this,arguments)}}function Ru(t,e){return e=+e,function(){yu(this,t).delay=e}}function Bu(t,e){return function(){_u(this,t).duration=+e.apply(this,arguments)}}function ju(t,e){return e=+e,function(){_u(this,t).duration=e}}function Hu(t,e){if("function"!=typeof e)throw new Error;return function(){_u(this,t).ease=e}}function Iu(t,e,n){var r,i,a=function(t){return(t+"").trim().split(/^|\s+/).every((function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?yu:_u;return function(){var o=a(this,t),s=o.on;s!==r&&(i=(r=s).copy()).on(e,n),o.on=i}}var zu=At.prototype.constructor;function Pu(t){return function(){this.style.removeProperty(t)}}function qu(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function $u(t,e,n){var r,i;function a(){var a=e.apply(this,arguments);return a!==i&&(r=(i=a)&&qu(t,a,n)),r}return a._value=e,a}function Yu(t){return function(e){this.textContent=t.call(this,e)}}function Vu(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&Yu(r)),e}return r._value=t,r}var Wu=0;function Gu(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Xu(){return++Wu}var Ju=At.prototype;Gu.prototype={constructor:Gu,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=p(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s,u,l=r[o],c=l.length,d=a[o]=new Array(c),f=0;f<c;++f)(s=l[f])&&(u=t.call(s,s.__data__,f,l))&&("__data__"in s&&(u.__data__=s.__data__),d[f]=u,gu(d[f],e,n,f,d,bu(s,n)));return new Gu(a,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=v(t));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var u,l=r[s],c=l.length,d=0;d<c;++d)if(u=l[d]){for(var f,p=t.call(u,u.__data__,d,l),h=bu(u,n),m=0,g=p.length;m<g;++m)(f=p[m])&&gu(f,e,n,m,p,h);a.push(p),o.push(u)}return new Gu(a,o,e,n)},filter:function(t){"function"!=typeof t&&(t=g(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,u=r[i]=[],l=0;l<s;++l)(a=o[l])&&t.call(a,a.__data__,l,o)&&u.push(a);return new Gu(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var u,l=e[s],c=n[s],d=l.length,f=o[s]=new Array(d),p=0;p<d;++p)(u=l[p]||c[p])&&(f[p]=u);for(;s<r;++s)o[s]=e[s];return new Gu(o,this._parents,this._name,this._id)},selection:function(){return new zu(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Xu(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],u=s.length,l=0;l<u;++l)if(o=s[l]){var c=bu(o,e);gu(o,t,n,l,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Gu(r,this._parents,t,n)},call:Ju.call,nodes:Ju.nodes,node:Ju.node,size:Ju.size,empty:Ju.empty,each:Ju.each,on:function(t,e){var n=this._id;return arguments.length<2?bu(this.node(),n).on.on(t):this.each(Iu(n,t,e))},attr:function(t,e){var n=u(t),r="transform"===n?Ks:Eu;return this.attrTween(t,"function"==typeof e?(n.local?Su:Fu)(n,r,Au(this,"attr."+t,e)):null==e?(n.local?Cu:Tu)(n):(n.local?Du:ku)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=u(t);return this.tween(n,(r.local?Lu:Ou)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Zs:Eu;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var a=I(this,t),o=(this.style.removeProperty(t),I(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}(t,r)).on("end.style."+t,Pu(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,a;return function(){var o=I(this,t),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(t),u=s=I(this,t)),o===u?null:o===r&&u===i?a:(i=u,a=e(r=o,s))}}(t,r,Au(this,"style."+t,e))).each(function(t,e){var n,r,i,a,o="style."+e,s="end."+o;return function(){var u=_u(this,t),l=u.on,c=null==u.value[o]?a||(a=Pu(e)):void 0;l===n&&i===c||(r=(n=l).copy()).on(s,i=c),u.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,a=n+"";return function(){var o=I(this,t);return o===a?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,$u(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Au(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,Vu(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=bu(this.node(),n).tween,a=0,o=i.length;a<o;++a)if((r=i[a]).name===t)return r.value;return null}return this.each((null==e?wu:xu)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Uu:Ru)(e,t)):bu(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Bu:ju)(e,t)):bu(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(Hu(e,t)):bu(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;_u(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise((function(a,o){var s={value:o},u={value:function(){0==--i&&a()}};n.each((function(){var n=_u(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(s),e._.interrupt.push(s),e._.end.push(u)),n.on=e})),0===i&&a()}))},[Symbol.iterator]:Ju[Symbol.iterator]};var Zu,Ku,Qu={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function tl(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function el(t){var e;if(Zu=Et(".detailed-settings"),(Ku=Zu.append("div").attr("class","settings-block")).append("h2").text("Back to settings").on("click",(function(){Zu.transition().duration(100).style("opacity",0).on("end",(function(){Et(this).html("").style("display","none"),Et(".template-settings").style("display","block").style("opacity",0).transition().duration(500).style("opacity",1)})),Zu.node()})),"string"==typeof t)e=Ku.append("div").html(t);else if("object"==typeof t&&(e=Ku.append(t.type),t.value&&(Ku.node().value=t.value),t.attributes))for(var n in t.attributes)e.attr(n,t.attributes[n]);return e.node().focus(),Et(".template-settings").style("display","none"),Zu.style("display","block").style("opacity",0).transition().duration(500).style("opacity",1),Zu.node()}At.prototype.interrupt=function(t){return this.each((function(){!function(t,e){var n,r,i,a=t.__transition,o=!0;if(a){for(i in e=null==e?null:e+"",a)(n=a[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete a[i]):o=!1;o&&delete t.__transition}}(this,t)}))},At.prototype.transition=function(t){var e,n;t instanceof Gu?(e=t._id,t=t._name):(e=Xu(),(n=Qu).time=su(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],u=s.length,l=0;l<u;++l)(o=s[l])&&gu(o,t,e,l,s,n||tl(o,e));return new Gu(r,this._parents,t,e)};var nl,rl,il,al,ol={},sl={},ul={"Flourish 1":{scheme:"flourish_default_1",colors:["#1D6996","#EDAD08","#73AF48","#94346E","#38A6A5","#E17C05","#5F4690","#0F8554","#6F4070","#CC503E","#994E95","#666666"]},"Flourish 2":{scheme:"flourish_default_2",colors:["#11A579","#CC503E","#3969AC","#F2B701","#7F3C8D","#80BA5A","#E68310","#CF1C90","#008695","#F97B72","#4B4B8F","#A5AA99"]},Rainbow:{colors:["#5F4690","#1D6996","#38A6A5","#0F8554","#73AF48","#EDAD08","#E17C05","#CC503E","#94346E","#6F4070","#994E95","#666666"]},Pastel:{colors:["#66C5CC","#F6CF71","#F89C74","#DCB0F2","#87C55F","#9EB9F3","#FE88B1","#C9DB74","#8BE0A4","#B497E7","#D3B484","#B3B3B3"]},Antique:{colors:["#855C75","#D9AF6B","#AF6458","#736F4C","#526A83","#625377","#68855C","#9C9C5E","#A06177","#8C785D","#467378","#7C7C7C"]},Accent:{scheme:"schemeAccent",colors:Fs},Dark:{scheme:"schemeDark2",colors:Ss},Paired:{scheme:"schemePaired",colors:Ms},Pale:{scheme:"schemePastel1",colors:Ns},"Farrow & Ball":{colors:["#EDD8C4","#C4A999","#F9C1C0","#B76A4C","#8F483C","#783027","#8A1D2E","#602A1F","#893838","#BD795A","#DC6130","#AD3B34","#ECE8BD","#F7E28A","#EBEB82","#FAD862","#F1CA61","#F5C03B","#F9E7D4","#F4E4AC","#EFD491","#DAC589","#D2B15E","#CD9344","#EFEFCC","#E8E7CA","#CAD5AD","#B9B495","#73806F","#636F65","#BDAB65","#889A73","#829C7A","#6C7855","#81B693","#BBBEA0","#99A286","#AAC0B3","#427E7F","#769194","#ECF3EC","#EBEBD4","#D0D9C9","#9EAF9F","#7A8E8D","#516365","#DBE5DC","#C4C9C5","#CBD7D7","#AABEBF","#66839A","#A0D2CD","#56AAC5","#535E7D","#2E3548","#48606E","#2C3437"]}},ll={};function cl(){var t,e={};for(t in ll)e[t]=ll[t];for(t in ul)e[t]=ul[t];return e}var dl="Edit color palette";function fl(t){t&&t.length?(ll={},t.forEach((function(t){var e=Object.keys(t)[0];ll[e]={colors:t[e]}}))):ll={},function(){for(var t in ol){ol[t].options(hl())}}()}function pl(){if(void 0!==nl)return nl;var t=document.createElement("input");return t.setAttribute("type","color"),t.setAttribute("value","!"),nl="color"==t.type&&"!"!==t.value}function hl(){var t=[],e=cl();for(var n in t.push([dl,""]),e)t.push([n,e[n].colors.join("|")]);return t}function ml(t,e){var n=t[0],r=t[1];if(!r){const t=Tt("em");return t.append("i").classed("fa fa-pencil",!0),t.node().append(dl),t.node()}Array.isArray(r)||(r=r.split("|"));const i=[];if(e&&n){const t=Tt("label").text(n);i.push(t.node())}return r.forEach((function(t,e){const n=Tt("span").attr("data-index",e).style("background-color",t);i.push(n.node())})),i}function vl(t,e){var n,r,i=cl(),a=t.parentNode.querySelector(".color-swatches");if(Array.isArray(e))r=e;else if("string"==typeof e){if(i[e])n=e;else for(var o in i)if(i[o].scheme==e){n=o;break}n&&(r=i[n].colors)}if(!r||!r.length)return t.parentNode.classList.remove("custom"),t.removeAttribute("data-value"),t.value="",void(a.innerHTML="");a.innerHTML="",a.append(...ml([null,r])),t.setAttribute("data-value",r.join("|"))}function gl(t){al=t.target,t.dataTransfer.setData("text/plain","x"),event.dataTransfer.effectAllowed="move",Et(al).classed("dragging",!0),Ct(".palette p:not(.dragging) input").style("pointer-events","none")}function yl(t){t.preventDefault();var e=Et(".palette").selectAll("[draggable='true']").style("border-color",null),n=Et(t.target);if("true"===n.attr("draggable")){var r="bottom";if(n.node()===e.nodes()[0]){var i=t.target.getBoundingClientRect(),a=i.top+i.height/2;t.clientY<a&&(r="top")}Et(t.target).style("border-"+r,"1px solid black")}}function _l(t){if(al){for(var e=t.target;e&&("P"!==e.tagName||!e.nextSibling);)e=e.parentNode;if(e){var n=e.nextSibling;if(e===Et(".palette").selectAll("[draggable='true']").style("border-color",null).nodes()[0]){var r=e.getBoundingClientRect(),i=r.top+r.height/2;t.clientY<i&&(n=e)}e.parentNode.insertBefore(al,n),al=!1,xl()}}}function bl(){Et(al).classed("dragging",!1),Ct(".palette *").style("border-bottom",null).style("border-top",null),Ct(".palette p input").style("pointer-events",null)}function wl(t){for(var e=t.target;e&&"BUTTON"!==e.tagName;)e=e.parentNode;e&&(e.classList.contains("fa-plus-square")?function(t){var e=t.target.parentNode,n=Al("#000000");e.insertAdjacentHTML("beforebegin",n),xl()}(t):e.classList.contains("fa-times")&&function(t){t.parentNode.childNodes.length>2?t.parentNode.removeChild(t):("INPUT"==t.firstChild.tagName?t.firstChild.value="#000000":t.firstChild.style.backgroundColor="#000000",t.firstChild.nextSibling.value="#000000");xl()}(e.parentNode))}function xl(){for(var t=il.getAttribute("data-autocomplete"),e=ol[t],n=[],r=rl.querySelectorAll(".palette input[type=text]"),i=0;i<r.length;i++)n.push(r[i].value);var a=e.options();sl[t]?a[0][1]=n.join("|"):a.unshift(["Custom",n.join("|")]),sl[t]=n,e.options(a),vl(il,n),Et(il).dispatch("change")}function Al(t){const e=Tt("p").attr("draggable",!0);return e.append("span").classed("swatch-handle",!0).text(".. .. .."),pl()?e.append("input").attr("type","color").attr("value",t):e.append("span").classed("swatch-color",!0).style("background-color",t),e.append("input").attr("type","text").attr("value",t),e.append("button").attr("type","button").classed("fa fa-times",!0),e.node().outerHTML}function El(t){var e=t.target,n=e.value,r=e.parentNode;if(!n)return r.parentNode.removeChild(r),void xl();var i=ms(n);if(!i)return console.warn("bad color",n),"color"==e.type?e.value=e.nextSibling.value:pl()?e.value=e.previousSibling.value:e.value=e.previousSibling.style.backgroundColor,void(je.point(e).text(n+" is not a valid color").draw()._getElement().style.zIndex=115);"color"==e.type?e.nextSibling.value=n:pl()?e.previousSibling.value=i.hex():e.previousSibling.style.backgroundColor=n,xl()}var Tl,Cl,kl,Dl={initialize:function(t,e){e.choices&&fl(e.choices),t.type="text",t.classList.add("colors");var n=document.createElement("span");n.setAttribute("class","color-swatches"),t.parentNode.insertBefore(n,t);var r=t.getAttribute("name")+"-dropdown";ol[r]=Bi(t,r,hl(),{custom_renderer:ml}),t.addEventListener("change",(function(e){t.value==dl?(e.stopImmediatePropagation(),t.value="",function(t){il=t;var e=(rl=el({type:"div",attributes:{class:"palette"}})).querySelector(".palette"),n=function(t,e){e||(e=t.parentNode.querySelector(".color-swatches"));for(var n=[],r=0;r<e.childNodes.length;r++)if(!e.childNodes[r].classList.contains("fa")){var i=e.childNodes[r].style.backgroundColor,a=ms(i);a?n.push(a.hex()):(console.warn("Bad color",i),n.push("#000000"))}return n}(t),r="";n.forEach((function(t){r+=Al(t)})),r+="<p><button class='fa fa-plus-square clickable'></button></p>",e.innerHTML=r,e.addEventListener("change",El),e.addEventListener("dragstart",gl),e.addEventListener("dragover",yl),e.addEventListener("drop",_l),e.addEventListener("dragend",bl),e.addEventListener("click",wl)}(t)):vl(t,(t.getAttribute("data-value")||"").split("|"))}))},update:vl,getValue:function(t){var e=t.getAttribute("data-value");return e?e.split("|"):null},replaceThemeColors:fl},Fl=void 0,Sl=/fa-(\S*)/g,Ml=/^data:image\/(svg|svg\+xml|png|jpg);base64,[A-Z-a-z0-9+/=]*$/;function Nl(t){var e=!Et(t.parentNode).classed("open");Ct(".template-settings .settings-block").classed("open",!1).attr("aria-expanded",!1),e&&Et(t.parentNode).classed("open",!0).attr("aria-expanded",!0)}function Ll(t){if(t){Fl={};for(var e=0,n=null,r=null,i=Tl&&Tl.user?Tl.user.template_settings_overrides:{},a=0;a<t.length;a++){var o=t[a];if("string"!=typeof o){if("object"!=typeof o||n||r||(e++,r=kl.append("div").attr("class","toplevel-settings-block")),"hidden"!==o.type){var s=n||r;if(o.new_section&&(s.append("div").classed("settings-divider",!0),"string"==typeof o.new_section&&s.append("h3").classed("settings-subhead",!0).text(o.new_section)),void 0!==o.show_if){if(o.show_condition)throw new Error("BUG: show_if present as well as show_condition");o.show_condition=[{type:"show",condition:o.show_if}],delete o.show_if}else if(void 0!==o.hide_if){if(o.show_condition)throw new Error("BUG: hide_if present as well as show_condition");o.show_condition=[{type:"hide",condition:o.hide_if}],delete o.hide_if}Fl[o.property]=o.type,Ol(s.append("div"),o,i)}}else r=null,(n=kl.append("div").attr("class","settings-block")).append("h2").attr("class","no-select").attr("tabindex","0").text(o).on("click",(function(){Nl(this)})).on("keyup",(function(t){13===t.keyCode&&Nl(this)})),n.classed("open",e<1),n.attr("aria-expanded",e<1),"State documentation"===o&&n.style("display","none"),e++}Ct(".upgrade-setting").on("click",(function(){!function(t,e,n,r,i){var a=[],o=[];i?(a.push(["Upgrade to a business account so you can:"]),o.push(["Add custom logos, colours and styles to keep projects on-brand","Remove Flourish logo","Manage your team with collaboration and approval features","And <a href='https://flourish.studio/pricing' target='_blank'>many other benefits</a>"])):(a.push(["Upgrade your account to:"]),o.push(["Keep your data and projects private","Download projects","Get priority support"]));var s=Math.floor(Math.random()*a.length),u=Math.floor(Math.random()*o.length),l="title"+s+"-list"+u,c="upgrade-click",d=[];i?d.push({text:"Email us",class:"convert",tag_name:"a",href:"mailto:sales@flourish.studio?subject=Business%20upgrade%20enquiry",keyCode:13,callback:function(){t.analytics("send","event",c,r,l),Jo.logHistory({category:"upgrade",action:"clicked",detail:r})}}):d.push({text:"Upgrade now",class:"convert",keyCode:13,callback:function(){t.analytics("send","event",c,r,l),Jo.logHistory({category:"upgrade",action:"clicked",detail:r}),setTimeout((function(){window.location.href="/choose-subscription"}),1e3)}}),d.push({text:"Maybe later",keyCode:27,class:"secondary",callback:function(){t.analytics("send","event","upgrade-close",r,l),Jo.logHistory({category:"upgrade",action:"closed",detail:r})}}),t.analytics("send","event","upgrade-open",r,l),Jo.logHistory({category:"upgrade",action:"viewed",detail:r}),Ui(e,n,{buttons:d,is_html:!0,upgrade:{message:a[s],list:o[u],is_business:i}})}(Tl,"This is a premium feature","Upgrade your plan to change this setting.","upgrade-settings",!0)})),Ye()}}function Ol(t,e,n){e.upgrade=e.property in n;var r=e.choices&&("buttons"==e.style||"boolean"==e.type);t.attr("class","settings-option option-type-"+e.type+(r?" settings-buttons":"")+(e.upgrade?" upgrade-setting":""));var i=t.append("label").attr("for","setting-"+e.property).classed("hidden",null==e.name).append("h3").text(e.name).classed("no-select",!0);e.upgrade?i.append("i").attr("class","popup fa fa-star setting-tooltip tooltip-upgrade").style("font-family","FontAwesome").style("background-color","#93366e").attr("data-popup-head","This is a premium feature").attr("data-popup-body",e.description?e.description.replace(/\[\[/g,"").replace(/\]\]/g,""):"").attr("data-popup-position","top"):e.description&&i.append("i").attr("class","popup fa fa-question setting-tooltip tooltip-help").style("font-family","FontAwesome").attr("data-popup-body",e.description.replace(/\[\[/g,"").replace(/\]\]/g,"")).attr("data-popup-position","top"),e.width&&t.classed("width-"+e.width.replace(/ /g,"-"),!0);var a="input";if("text"!=e.type&&"code"!=e.type||(a="textarea"),"code"==e.type){var o=!1;t.append("i").attr("class","popup fa fa-reply clickable wrap-control").attr("data-popup-body","Wrap/unwrap text").attr("data-popup-position","top").on("click",(function(){o=!o,Et(this.parentNode).select("textarea").attr("wrap",o?null:"off"),Et(this).classed("selected",o)}))}var s=t.append(a).attr("id","setting-"+e.property).attr("class","setting").attr("name",e.property).attr("disabled",!Tl.visualisation.can_edit||null),u=s.node();if("colors"==e.type)Dl.initialize(u,e);else if("font"==e.type)Fo.initialize(u,e,Tl.user&&null!=Tl.user.company_id);else if("number"==e.type)u.setAttribute("type","number"),null!=e.min&&u.setAttribute("min",e.min),null!=e.max&&u.setAttribute("max",e.max),e.step&&u.setAttribute("step",e.step);else if("url"==e.type)u.setAttribute("type","url"),Cl.addButton(u,e.upgrade);else if(r){s.remove(),s=t.append("div").attr("id","setting-"+e.property).attr("name",e.property).classed("buttons-container",!0).classed("large","large"==e.size),u=s.node();var l=e.choices.length,c=[3,4,5],d=function(){if(l<=2)return{column_count:l,rows:1};var t=c.map((function(t){return{column_count:t,orphans:l%t/t,rows:l/t}})).filter((function(t){return t.rows>=1})).sort((function(t,e){return t.rows>e.rows?1:t.rows<e.rows?-1:0})),e=t.filter((function(t){return 0===t.orphans}));return 1===e.length||e.length>1?e[0]:0===e.length?t.sort((function(t,e){return t.orphans>e.orphans?-1:t.orphans<e.orphans?1:0}))[0]:void 0}();e.choices.forEach((function(t,n){s.append("input").attr("type","radio").attr("name",e.property).attr("value",t[1]).attr("id",e.property+"_"+n).attr("class","setting").attr("disabled",!Tl.visualisation.can_edit||null).call(Ul(e)),Hl(t,s.append("label").attr("for",e.property+"_"+n).style("width",100/d.column_count+"%").style("border-radius",(function(){var t=d.column_count,e=Math.ceil(d.rows),r=t*e-l;return e<=1?0===n?"3px 0 0 3px":n===t-1?"0 3px 3px 0":null:e>1?0===n?"3px 0 0 0":n===t-1?"0 3px 0 0":n===l-(t-r)?"0 0 0 3px":n===l-1&&0===r?"0 0 3px 0":null:null})).node())}))}else"boolean"==e.type?(u.setAttribute("type","checkbox"),t.append("label").attr("class","slider").attr("for","setting-"+e.property)):u.setAttribute("type","text");if("code"==e.type&&(u.setAttribute("wrap","off"),s.on("keydown.tab",(function(t){var e=t;if(9===e.keyCode&&!(e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)){e.preventDefault();var n=this.selectionStart;this.value=this.value.substring(0,n)+"\t"+this.value.substring(this.selectionEnd),this.selectionEnd=n+1}}))),e.choices&&"string"==e.type&&"buttons"!=e.style&&Bi(u,e.property+"-dropdown",e.choices,{allow_other_option:e.choices_other,custom_renderer:Hl}),"color"==e.type){Et(u).classed("color",!0).style("display","none");var f=Et(u.parentNode).append("div").attr("class","color-picker"),p=f.append("div").attr("class","color-wrapper");e.optional&&f.append("button").attr("class","cancel-setting popup").html("<svg><use xlink:href='#cancel-setting'></use></svg>").attr("data-popup-body","If cleared, the color will be set automatically based on the theme or context").on("click",(function(){u.value="",s.dispatch("change"),Et(this.parentNode).classed("is-null",!0)})),p.append("input").attr("type","color").on("change",(function(){u.value=this.value,s.dispatch("change"),Et(this.parentNode.parentNode).classed("is-null",!1)})).on("focus",(function(){Et(this.parentNode.parentNode).classed("active",!0)})).on("blur",(function(){Et(this.parentNode.parentNode).classed("active",!1)}))}e.placeholder&&u.setAttribute("placeholder",e.placeholder),e.size&&u.classList.add("size-"+e.size),s.call(Ul(e))}function Ul(t){return function(e){var n=!1;e.on("change",(function(){var e=this;je.hide(),n=!0,Tl.preview_pane.getState(t.property,(function(r,i){return r?(console.error("Failed to get state property "+t.property,r),void(n=!1)):function(t,e){if("number"!==e.type)return!0;if(""===t.value)return!!e.optional||(je.point(t).text("A value is required").draw(),!1);var n=parseFloat(t.value);return e.hasOwnProperty("min")&&n<e.min?(je.point(t).text("Value cannot be less than "+e.min).draw(),t.value=e.min):e.hasOwnProperty("max")&&n>e.max&&(je.point(t).text("Value cannot be greater than "+e.max).draw(),t.value=e.max),!0}(e,t)?void function(t,e,n){r=e.property,i=100,a=Il,o=[t,e,n],clearTimeout(Rl[r]),Rl[r]=setTimeout((function(){a.apply(window,o),delete Rl[r]}),i);var r,i,a,o}(e,t,(function(r){if(!r)return n=!1,void("SELECT"==e.tagName&&Et(e).dispatch("blur"));var a="radio"==e.type?e.nextSibling:e;je.point(a).text("Not changed: "+r).draw();var o={};o[t.property]=i,Tl.preview_pane.setState(o,(function(r){if(r)return console.error("Failed to revert setting "+t.property+" to value: "+i),void(n=!1);Tl.preview_pane.update((function(r){if(r)return console.error("Failed to update after reverting setting "+t.property+" to value: "+i),void(n=!1);jl(e,i),n=!1}))}))})):(e.value=i,void(n=!1))}))})).on("keydown",(function(t){Tl.confirm.blank(),13==t.keyCode&&je.hide()})).on("blur",(function(){if(!n){var e=this;je.hide(),Tl.preview_pane.getState(t.property,(function(n,r){n?console.error("Failed to get state property "+t.property,n):jl(e,r)}))}}))}}var Rl={};function Bl(t,e,n){if(t.classList.contains("colors"))return Dl.getValue(t);if(t.classList.contains("font-menu")){var r=Fo.getValue(t);return e&&!r?n?null:"":r}if(t.classList.contains("buttons-container")){for(var i,a=t.querySelectorAll("input[type='radio']"),o=0;o<a.length;o++)if(a[o].checked){i=a[o];break}if(!i)return n?null:"";t=i}switch(t.getAttribute("type")){case"checkbox":return t.checked;case"number":return e&&!t.value.length?n?null:"":+t.value;case"radio":if(t.parentNode.parentNode.classList.contains("option-type-boolean"))return"true"==t.value;default:return e&&t.classList.contains("color")&&!t.value.length?n?null:"":t.hasAttribute("data-value")?t.getAttribute("data-value"):t.value}}function jl(t,e){if(t.classList.contains("colors"))Dl.update(t,e);else if(t.classList.contains("font-menu"))Fo.update(t,e);else if("checkbox"==t.getAttribute("type"))t.checked=e;else if(t.classList.contains("color"))t.value=e,Et(t.parentNode).select(".color-picker").classed("is-null",null===e),Et(t.parentNode).select(".color-wrapper input").node().value=e;else if(t.getAttribute("data-autocomplete")){for(var n=function(t){for(var e=0;e<Tl.settings.length;e++){var n=Tl.settings[e];if(n.property===t)return n}}(t.name),r=0;r<n.choices.length;r++){var i,a,o=n.choices[r];if("string"==typeof o?i=a=o:(i=o[1],a=o[0]),e==i)return t.value=a,void t.setAttribute("data-value",i)}t.value=e,t.setAttribute("data-value",e)}else if(t.className.indexOf("buttons-container")>-1){var s=t.querySelectorAll("input[type='radio']");for(r=0;r<s.length;r++)s[r].value===""+e&&(s[r].checked=!0)}else t.value=e}function Hl(t,e){var n=Et(e);if("string"!=typeof t){var r=t[2];r&&(r.match(Sl)?n.append("i").attr("class","fa "+r):r.match(Ml)&&n.append("img").attr("src",r));var i=t[0];i.match(Sl)?n.append("i").attr("class","fa "+i):i.match(Ml)?n.append("img").attr("src",i):n.node().append(i)}else n.text(t)}function Il(t,e,n){var r={},i=Bl(t,e.optional);if(r[e.property]=i,!("choices"in e)||"colors"===e.type||function(t,e){return!!t.choices_other||-1!==t.choices.map((function(t){return t instanceof Array?t[1]:t})).indexOf(e)}(e,i)){Tl.confirm.saving();var a=!1,o={};o[e.property]=Bl(t,e.optional,!0),Tl.preview_pane.setState(o,(function(t){if(t)return s(t);Tl.preview_pane.update((function(t){if(t)return s(t);Tl.visualisation.updateSettings(r,(function(t){if(t)return s(t);Tl.analytics("send","event","visualisation","change_setting",Tl.visualisation.id),Pl(),Tl.confirm.saved(),n&&n()}))}))}))}else n&&n("You can only choose values from the list");function s(r){a||(Tl.preview_pane.getState(e.property,(function(e,i){if(e)return console.error("Failed to get state",e),void Tl.confirm.error(e);jl(t,i),Pl(),Tl.confirm.blank(),n&&n(r)})),a=!0)}}function zl(t,e){return/^data\./.test(t)?function(t,e){var n=t.split(".");return Tl.visualisation.__sdk__?function(t,e){if(t.length>=4)return;for(var n=null,r=Tl.template_data_bindings,i=0;i<r.length;i++){var a=r[i];if("string"!=typeof a&&(a.dataset===t[1]&&a.key===t[2])){n=a;break}}if(!n)throw new Error("Bug: data binding not found - these should already have been checked");return"column"===n.type?!!n.column===e:!!n.columns.split("::")[1]===e}(n,e):function(t,e){if(t.length<4){return!!document.getElementById("data-binding-"+t[1]+"-"+t[2]).value===e}if("type"!==t[3])throw new Error("Fourth part of name must be “type”");var n=Tl.visualisation.template_id,r=Tl.visualisation.data_bindings[n][t[1]][t[2]];if(null==r)return!1;for(var i,a=Tl.visualisation.data_tables,o=r.data_table_id,s=r.columns||[r.column],u=0;u<a.length;u++)if(a[u].id===o){i=a[u].column_types;break}var l=!1;for(u=0;u<s.length;u++){var c=i[s[u]].type_id.split("$")[0];if(l=-1!==(Array.isArray(e)?e:[e]).indexOf(c))break}return l}(n,e)}(t,e):function(t,e){var n=document.getElementById("setting-"+t);if(!n)return console.error("Could not find input for setting",t),!1;var r=Bl(n);if(e instanceof Array)return-1!==e.indexOf(r);return r===e}(t,e)}function Pl(){Tl.settings.filter((function(t){return"object"==typeof t&&"show_condition"in t})).forEach((function(t){var e=t.show_condition.every((function(t){var e="show"===t.type,n=t.condition;if("boolean"==typeof n)return e===n;if("string"==typeof n)return e===zl(n,!0);for(var r in n)if(!zl(r,n[r]))return!1===e;return e})),n=document.getElementById("setting-"+t.property);if(n){for(var r=n;!r.classList.contains("settings-option");)r=r.parentNode;if(Et(r).classed("hidden",!e),t.new_section)for(var i=r.previousSibling;i&&(Et(i).classed("settings-divider")||Et(i).classed("settings-subhead"));)Et(i).classed("hidden",!e),i=i.previousSibling}else console.error("Could not find input",t.property)}));for(var t=document.querySelectorAll(".template-settings .settings-block"),e=0;e<t.length;e++){var n=t[e];n.classList.contains("hidden")?null!==n.querySelector(".settings-option:not(.hidden)")&&n.classList.remove("hidden"):null==n.querySelector(".settings-option:not(.hidden)")&&n.classList.add("hidden")}}function ql(t,e,n){return Tl=t,Cl={setup:lo,addButton:co,startUpload:po},(kl=Et(".side-panel .template-settings")).on("submit",(function(t){t.preventDefault()})),Dl.replaceThemeColors(e),Fo.replaceThemeFonts(n),Ll(Tl.settings),function(){function t(e,n){return!e||e.classList.contains("template-settings")?null:e.classList.contains(n)?e:t(e.parentNode,n)}function e(t){return t.replace(/ /g,"").replace(/-/g,"").toLowerCase().trim()}Et(".side-panel .template-settings-search").on("input",(function(n){var r=e(n.target.value),i=!r,a=Et(".side-panel .template-settings").selectAll(".settings-block:not(.hidden) > h2, .settings-option:not(.hidden) h3, .settings-subhead:not(.hidden)");Et(".side-panel .template-settings").selectAll(".settings-block:not(.hidden) > h2, .settings-option:not(.hidden), .settings-subhead:not(.hidden), .settings-divider:not(.hidden)").classed("search-filtered-out",!i),i||a.filter((function(){var t=e(this.innerText);return!!t&&t.indexOf(r)>-1})).each((function(){var e=t(this,"settings-block"),n=Et(this);if("H2"==this.tagName)e&&Et(e).selectAll("h2, .settings-option, .settings-subhead, .settings-divider").classed("search-filtered-out",!1);else if("H3"==this.tagName)if(e&&Et(e).select("h2").classed("search-filtered-out",!1),n.classed("settings-subhead")){n.classed("search-filtered-out",!1),this.previousSibling.classList.remove("search-filtered-out");for(var r=this.nextSibling;r&&r.classList.contains("settings-option");)r.classList.remove("search-filtered-out"),r=r.nextSibling}else{var i=t(this,"settings-option");if(i){i.classList.remove("search-filtered-out");for(var a=null,o=i.previousSibling;o&&null==a;)o.classList.contains("settings-subhead")?a=o:o=o.classList.contains("settings-divider")?null:o.previousSibling;a&&(a.classList.remove("search-filtered-out"),a.previousSibling.classList.remove("search-filtered-out"))}}}))}))}(),Et(".side-panel-scrollbox").on("scroll",(function(){je.hide()})),{update:function(t){kl.html(""),Et(".current-template").style("opacity","1"),Ll(Tl.settings=t)},populate:function(){Tl.preview_pane.getState((function(t,e){if(t)console.error("Failed to get state",t);else{var n=Ca(e);for(var r in n){var i=document.getElementById("setting-"+r);i&&jl(i,n[r])}Pl()}}))},getSettingsForCurrentTemplate:function(){return Fl},setReadOnly:function(){Ct(".setting").each((function(){Et(this).attr("disabled",!0)}))},unsetReadOnly:function(){Ct(".setting").each((function(){Et(this).attr("disabled",null)}))}}}var $l,Yl,Vl=!1,Wl=[];function Gl(){Et(".flourish-warn-list").classed("visible",!1),Vl=!1}function Xl(){return Et(".flourish-warn-btn").on("click",(function(){Vl?Gl():(Et(".flourish-warn-list").classed("visible",!0),Vl=!0)})),{clear:Zl,warn:Kl}}function Jl(){Et(".flourish-warn-container").classed("visible",Wl.length),Wl.length>100&&(Wl.length=100);var t=Et(".flourish-warn-list ul").selectAll("li").data(Wl),e=t.enter().append("li");e.append("i").attr("class","fa fa-warning"),e.append("p").attr("class","message"),e.append("p").attr("class","explanation");var n=t.merge(e);n.select(".message").text((function(t){return t.message||""})),n.select(".explanation").text((function(t){return t.explanation||""})),t.exit().remove()}function Zl(){Wl=[],Jl(),Gl()}function Kl(t){Wl.unshift(t),Jl()}function Ql(t){var e=$l.visualisation,n=e.getTemplate(),r=!1,i=!1,a=!1;function o(){var e=$l.template_settings.getSettingsForCurrentTemplate(),n=$l.visualisation.settingsForCurrentTemplate(),r={};for(var i in n)i in e&&(r[i]=n[i]);Yl.loadVisualisation($l,r,(function(){$l.template_settings.populate(),$l.data_bindings.updateRequiredBindingsOverlay(!1),so(),t&&t()})),Mt()}n.getSettings((function(t,e){t?console.error("Failed to get template settings: "+t):($l.template_settings.update(e),r=!0,i&&a&&o())})),n.getDataBindings((function(t,e){t?console.error("Failed to get template data bindings: "+t):($l.data_bindings.update(e),i=!0,r&&a&&o())})),e.refreshDataBindings((function(t){t?console.error("Failed to get template data bindings: "+t):(a=!0,i&&r&&o())}))}function tc(t){Yl.updateData($l.visualisation,t)}function ec(t){Yl.updateDataNotPreview($l.visualisation,t)}function nc(t){$l=t;var e=Xl();return{loadTemplate:Ql,updateData:tc,updateDataNotPreview:ec,sync:(Yl=ao("iframe#preview","editor",$l,e,{setSetting({name:t,value:e}){const n=function(t){return document.getElementById("setting-"+t)}(t);n?(jl(n,e),n.dispatchEvent(new Event("change"))):console.log(`Could not find setting ${t}`)}})).sync,setState:Yl.setState,getState:Yl.getState,hasData:Yl.hasData,setData:Yl.setData,getData:Yl.getData,draw:Yl.draw,update:Yl.update,getDefaultState:Yl.getDefaultState,snapshot:Yl.snapshot,setFixedHeight:Yl.setFixedHeight,resize:Yl.resize,getDrawCalled:Yl.getDrawCalled,setDrawCalled:Yl.setDrawCalled}}var rc={},ic={};function ac(t){return new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'})).join(",")+"}")}function oc(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 sc(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function uc(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":function(t){return t<0?"-"+sc(-t,6):t>9999?"+"+sc(t,6):sc(t,4)}(t.getUTCFullYear())+"-"+sc(t.getUTCMonth()+1,2)+"-"+sc(t.getUTCDate(),2)+(i?"T"+sc(e,2)+":"+sc(n,2)+":"+sc(r,2)+"."+sc(i,3)+"Z":r?"T"+sc(e,2)+":"+sc(n,2)+":"+sc(r,2)+"Z":n||e?"T"+sc(e,2)+":"+sc(n,2)+"Z":"")}var lc=function(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],a=t.length,o=0,s=0,u=a<=0,l=!1;function c(){if(u)return ic;if(l)return l=!1,rc;var e,r,i=o;if(34===t.charCodeAt(i)){for(;o++<a&&34!==t.charCodeAt(o)||34===t.charCodeAt(++o););return(e=o)>=a?u=!0:10===(r=t.charCodeAt(o++))?l=!0:13===r&&(l=!0,10===t.charCodeAt(o)&&++o),t.slice(i+1,e-1).replace(/""/g,'"')}for(;o<a;){if(10===(r=t.charCodeAt(e=o++)))l=!0;else if(13===r)l=!0,10===t.charCodeAt(o)&&++o;else if(r!==n)continue;return t.slice(i,e)}return u=!0,t.slice(i,a)}for(10===t.charCodeAt(a-1)&&--a,13===t.charCodeAt(a-1)&&--a;(r=c())!==ic;){for(var d=[];r!==rc&&r!==ic;)d.push(r),r=c();e&&null==(d=e(d,s++))||i.push(d)}return i}function i(e,n){return e.map((function(e){return n.map((function(t){return o(e[t])})).join(t)}))}function a(e){return e.map(o).join(t)}function o(t){return null==t?"":t instanceof Date?uc(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,a=r(t,(function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=ac(t);return function(r,i){return e(n(r),i,t)}}(t,e):ac(t)}));return a.columns=i||[],a},parseRows:r,format:function(e,n){return null==n&&(n=oc(e)),[n.map(o).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=oc(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(a).join("\n")},formatRow:a,formatValue:o}}(","),cc=lc.parseRows,dc=lc.formatRows;function fc(t,e,n){zo(this,"object"==typeof e?(n=e).id:e,void 0,n,{getVersionNumber:function(){return t.version_number},setVersionNumber:function(e){t.version_number=e}}),this.visualisation=t,this.api_prefix="/api/data_table"}function pc(t){return t.map((function(t){return null!=t&&"object"==typeof t&&"map"in t?pc(t):t}))}function hc(t){this.id=t}function mc(t,e,n){if(zo(this,t,e,n),this.api_prefix="/api/visualisation",this.data_tables){var r=this;this.data_tables=this.data_tables.map((function(t){return new fc(r,t)}))}}function vc(t,e,n){Vo({url:t.api_prefix+"/"+t.id+"/data_bindings",method:"POST",payload:function(){return{version_number:t.version_number,data_bindings:e}},callback:function(r,i){if(r)return n(r);t.version_number=i.version_number,t.data_bindings||(t.data_bindings={}),t.template_id in t.data_bindings||(t.data_bindings[t.template_id]={});var a=t.data_bindings[t.template_id];for(var o in e)for(var s in e[o]){var u=e[o][s];a[o]||(a[o]={}),null===u?delete a[o][s]:a[o][s]=u}n(void 0)}})}function gc(t,e,n){Vo({url:t.api_prefix+"/"+t.id+"/settings",payload:function(){return{version_number:t.version_number,settings:e}},callback:function(r,i){if(r)return n(r);t.version_number=i.version_number,t.settings||(t.settings={}),t.template_id in t.settings||(t.settings[t.template_id]={});var a=t.settings[t.template_id];for(var o in e){var s=e[o];a[o]=s}n(void 0)}})}function yc(t,e,n,r){Vo({url:t.api_prefix+"/"+t.id+"/publish",payload:function(){return{password:n,anyone_can_duplicate:r}},callback:function(n,r){if(n)return e(n);t.version_number=r.version_number,t.embed_url=r.embed_url,t.showcase_url=r.showcase_url,t.is_password_protected=r.is_password_protected,t.anyone_can_duplicate=r.anyone_can_duplicate,e(void 0,r)}})}function _c(t,e){for(var n in e)"object"!=typeof t[n]||null==t[n]||Array.isArray(t[n])||"object"!=typeof e[n]||null==e[n]||Array.isArray(e[n])?t[n]=e[n]:_c(t[n],e[n])}function bc(t,e,n,r){function i(){}this.visualisation=t,this.settings=e,this.template_data_bindings=n,this.public_url_prefix=r,this.is_read_only=!1,this.template_settings=ql(this),this.data_bindings=(Hi=this,Ii=Et(".data-bindings"),{update:function(t){t&&(Hi.template_data_bindings=t),Vi(Hi.visualisation,Hi.template_data_bindings)},modify:function(t,e=!1){Gi(t,(function(){Vi(Hi.visualisation,Hi.template_data_bindings),e&&Hi.preview_pane.updateData((t=>{if(t)return console.error("Failed to update preview pane: "+t)}))}))},requiredBindingsAreUnset:Zi,updateRequiredBindingsOverlay:Ki}),this.preview_pane=nc(this),this.responsive_menu=St(this),this.confirm={on:i,blank:i,saved:i,saving:i,error:i},this.analytics=i,this.tour={fireEvent:i},window.addEventListener("hashchange",(()=>{this.loadFromUrlHash()}))}fc.prototype.getColumnTypes=function(t){Vo({url:this.api_prefix+"/"+this.id,method:"GET",callback:function(e,n){if(e)return t(e);t(void 0,pc(n.column_types||[]))}},"load-data")},fc.prototype.csv=function(t){this.cached_data?t(void 0,pc(this.cached_data)):this.csvPromise().then((e=>t(null,e)),(e=>t(e)))},fc.prototype.csvPromise=async function(){if(this.cached_data)return pc(this.cached_data);const t=this;return new Promise(((e,n)=>{Vo({url:this.api_prefix+"/"+this.id+"/csv",response_type:"text/csv; charset=utf-8",method:"GET",callback(r,i){if(r)return n(r);t.cached_data=cc(i),e(pc(t.cached_data))}},"load-data")}))},fc.prototype.saveData=function(t,e){var n=this,r=Di(pc(t));Vo({url:this.api_prefix+"/"+this.id+"/csv",payload:function(){return{version_number:n.getVersionNumber(),data:dc(r)}},callback:function(t,i){if(t)return e(t);n.setVersionNumber(i.version_number),n.cached_data=r,e(void 0)}})},fc.prototype.updateFromUrl=function(t,e){var n=this;Vo({url:this.api_prefix+"/"+this.id+"/csv-url",payload:function(){return{live_csv_url:t,version_number:n.getVersionNumber()}},callback:function(r,i){if(r)return e(r);n.setVersionNumber(i.version_number),n.live_csv_url=t,t?n.updateFromLiveCsvUrl((function(t,r){if(t)return n.last_remote_data_error_message=t,e(t);var i,a=((i=Di(cc(r.csv))).forEach((function(t){for(var e=0;e<t.length;e++)t[e]&&"string"==typeof t[e]&&(t[e]=t[e].trim())})),i);n.cached_data=a,n.setVersionNumber(r.version_number),n.t_updated=r.t_updated,n.last_remote_data_error_message=null,e(void 0,a,r.new_column_types)})):(n.t_updated=i.t_updated,n.last_remote_data_error_message=null,e(void 0,null,null))}})},fc.prototype.updateFromLiveCsvUrl=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/update-from-live-csv-url",payload:function(){return{version_number:e.getVersionNumber()}},callback:function(n,r){if(n)return t(n);e.setVersionNumber(r.version_number),t(void 0,r)}})},fc.prototype.save=function(t,e){return Go(this,t,e)},fc.prototype.delete=function(t){return Xo(this,t)},hc.prototype.getSettings=function(t){if(this.settings)t(void 0,this.settings);else{var e=this;Vo({url:"/api/template/"+this.id+"/settings",method:"GET",callback:function(n,r){if(n)return t(n);e.settings=r.settings,t(void 0,e.settings)}})}},hc.prototype.getDataBindings=function(t){Vo({url:"/api/template/"+this.id+"/data_bindings",method:"GET",callback:t})},mc.prototype.save=function(t,e){this.is_listed||(t.is_listed=!0),Go(this,t,e)},mc.prototype.setTemplateId=function(t,e){Go(this,{template_id:t},e)},mc.prototype.getTemplate=function(){return this.template_id?(this._template&&this.template_id==this._template.id||(this._template=new hc(this.template_id)),this._template):null},mc.prototype.settingsForCurrentTemplate=function(){return this.settings&&this.template_id in this.settings?this.settings[this.template_id]:{}},mc.prototype.getState=function(t){this.template_id||t({});var e=this.settingsForCurrentTemplate();this.getTemplate().getSettings((function(n,r){if(n)throw n;for(var i={},a=0;a<r.length;a++){var o=r[a];o.property in e&&(i[o.property]=e[o.property])}t(ka(i))}))},mc.prototype.dataBindingsForCurrentTemplate=function(){return this.data_bindings&&this.template_id in this.data_bindings?this.data_bindings[this.template_id]:{}},mc.prototype.refreshDataBindings=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/data_bindings",method:"GET",callback:function(n,r){if(n)return t(n);e.data_bindings=r,t()}})},mc.prototype.resetToTheme=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/reset_to_theme",method:"POST",payload:function(){return{version_number:e.version_number}},callback:function(n,r){if(n)return t(n);e.version_number=r.version_number,t(void 0)}})},mc.prototype.updateDataBindings=function(t,e){var n=this;if(this.is_listed)return vc(n,t,e);this.save({is_listed:!0},(function(r){return r?e(r):vc(n,t,e)}))},mc.prototype.updateSettings=function(t,e){var n=this;if(this.is_listed)return gc(n,t,e);this.save({is_listed:!0},(function(r){return r?e(r):gc(n,t,e)}))},mc.prototype.refreshSettings=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/settings",method:"GET",callback:function(n,r){if(n)return t(n);e.settings=r,t()}})},mc.prototype.getThemeFontsAndColors=function(t){Vo({url:this.api_prefix+"/"+this.id+"/theme-fonts-and-colors",method:"GET",callback:function(e,n){if(e)return t(e);t(void 0,n.fonts,n.colors)}})},mc.prototype.getDataTables=function(t){Vo({url:this.api_prefix+"/"+this.id+"/data",method:"GET",callback:function(e,n){return e?t(e):t(void 0,n.data)}})},mc.prototype.dataTables=function(t){var e=this;e.data_tables?t(void 0,e.data_tables):(e.after_loading_data_tables||(e.after_loading_data_tables=[]),e.after_loading_data_tables.push(t),e.after_loading_data_tables.length>1||e.getDataTables((function(t,n){if(t){for(var r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](t);e.after_loading_data_tables=[]}else{e.data_tables=n.map((function(t){return new fc(e,t)}));for(r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](void 0,e.data_tables);e.after_loading_data_tables=[]}})))},mc.prototype.refreshDataTables=function(){this.data_tables=void 0,this.dataTablesHaveChanged()},mc.prototype.prepareData=function(t){var e=this;if(!e.data_bindings)throw new Error("No data bindings loaded");var n=e.template_id;e.dataTables((function(r,i){if(r)return t(r);if(e.template_id==n){for(var a={},o={},s=0,u=0;u<i.length;u++)!function(r){o[r.id]=r.column_types,r.csv((function(u,l){if(u)throw u;e.template_id==n&&(a[r.id]=l,++s==i.length&&e.getTemplate().getDataBindings((function(n,r){if(n)throw n;var i={};r.forEach((function(t){"string"!=typeof t&&(t.dataset in i||(i[t.dataset]={}),i[t.dataset][t.key]=t)}));var s={},u=e.dataBindingsForCurrentTemplate();for(var l in u)s[l]=Ci(u[l],a,o,i[l]);for(l in i)s[l]||(s[l]=[],s[l].column_names={},s[l].metadata={});t(void 0,s)})))}))}(i[u]);0==i.length&&t(void 0,{})}}))},mc.prototype.delete=function(t){Xo(this,t)},mc.prototype.getDataTableNames=function(){return void 0===this.data_table_names&&(this.data_table_names=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.id]=r.name}return e}(this.data_tables)),this.data_table_names},mc.prototype.getDataTableIds=function(){return void 0===this.data_table_ids&&(this.data_table_ids=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.name]=r.id}return e}(this.data_tables)),this.data_table_ids},mc.prototype.dataTablesHaveChanged=function(){this.data_table_names=this.data_table_ids=void 0},mc.prototype.duplicate=function(t){Vo({url:this.api_prefix+"/"+this.id+"/duplicate",callback:t})},mc.prototype.publish=function(t,e,n){var r=this;if(this.is_listed)return yc(r,t,e,n);this.save({is_listed:!0},(function(i){return i?t(i):yc(r,t,e,n)}))},mc.prototype.unpublish=function(t){var e=this;Vo({url:this.api_prefix+"/"+this.id+"/unpublish",callback:function(n,r){if(n)return t(n);e.version_number=r.version_number,e.embed_url=r.embed_url,e.showcase_url=r.showcase_url,t(void 0,r)}})},mc.prototype.published=function(){return!!this.showcase_url},mc.prototype.sendForReview=function(t,e,n){var r=this;Vo({url:"/api/reviews",payload:function(){return{project_id:r.id,project_type:"visualisation",reviewers:t,message:e}},callback:function(t,e){r.status=e,n(t,e)}})},mc.prototype.approve=function(t,e){var n=this;Vo({url:"/api/review/"+t+"/approve",callback:function(t,r){return n.status=r,e(t,r)}})},mc.prototype.decline=function(t,e,n){var r=this;Vo({url:"/api/review/"+t+"/decline",payload:function(){return{message:e}},callback:function(t,e){r.status=e,n(t,e)}})},mc.prototype.cancelReview=function(t,e){var n=this;Vo({url:"/api/review/"+t+"/cancel",callback:function(t,r){n.status=r,e(t,r)}})},mc.list=function(t){Vo({url:"/api/visualisations",method:"GET",callback:t})},mc.getById=function(t,e){Vo({url:"/api/visualisation/"+t,method:"GET",callback:function(n,r){if(n)return e(n);e(void 0,new mc(t,r.version_number,r))}})},mc.getPublishedJson=function(t,e,n){Vo({url:`${e}visualisation/${t}/visualisation.json`,method:"GET",callback(t,e){if(t)return n(t);n(void 0,e)}})},mc.createFromTemplate=function(t,e){Vo({url:"/api/template/"+t+"/visualisations",method:"PUT",callback:e})},mc.createFromVisualisation=function(t,e){Vo({url:"/api/visualisation/"+t+"/duplicate",callback:e})},mc.setAsStaffPick=function(t,e){Vo({url:"/api/visualisation/"+t+"/set_staff_pick",method:"POST",callback:e})},mc.unsetAsStaffPick=function(t,e){Vo({url:"/api/visualisation/"+t+"/unset_staff_pick",method:"POST",callback:e})},mc.setTag=function(t,e,n){Vo({url:"/api/visualisation/"+t+"/folder/"+encodeURIComponent(e),method:"PUT",callback:n})},mc.removeTag=function(t,e,n){Vo({url:"/api/visualisation/"+t+"/tag/"+encodeURIComponent(e),method:"DELETE",callback:n})},bc.prototype.loadFromUrlHash=async function(){if(!window.location.hash)return;const t=window.location.hash.slice(1),e=(n=mc.getPublishedJson,function(...t){return new Promise(((e,i)=>{n.call(r,...t,(function(t,n){if(t)return i(t);e(n)}))}))});var n,r;try{const n=await e(t,this.public_url_prefix);this.updateFromJson(n)}catch(t){console.error(t)}},bc.prototype.updateFromJson=function({state:t,bindings:e,data:n}){const r={};for(const[t,i]of Object.entries(e)){const e={},o={};for(const[t,n]of Object.entries(i))Array.isArray(n)?o[t]=n:e[t]=n;const s=a(n[t],e,o);r[t]=s}const i={};_c(i,this.preview_pane.getDefaultState()),_c(i,t),this.preview_pane.sync({state:i,data:r,overwrite_state:!0,update:!0},(()=>this.template_settings.populate()))};var wc={},xc={};function Ac(t){return new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'})).join(",")+"}")}function Ec(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 Tc(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function Cc(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":function(t){return t<0?"-"+Tc(-t,6):t>9999?"+"+Tc(t,6):Tc(t,4)}(t.getUTCFullYear())+"-"+Tc(t.getUTCMonth()+1,2)+"-"+Tc(t.getUTCDate(),2)+(i?"T"+Tc(e,2)+":"+Tc(n,2)+":"+Tc(r,2)+"."+Tc(i,3)+"Z":r?"T"+Tc(e,2)+":"+Tc(n,2)+":"+Tc(r,2)+"Z":n||e?"T"+Tc(e,2)+":"+Tc(n,2)+"Z":"")}var kc=function(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],a=t.length,o=0,s=0,u=a<=0,l=!1;function c(){if(u)return xc;if(l)return l=!1,wc;var e,r,i=o;if(34===t.charCodeAt(i)){for(;o++<a&&34!==t.charCodeAt(o)||34===t.charCodeAt(++o););return(e=o)>=a?u=!0:10===(r=t.charCodeAt(o++))?l=!0:13===r&&(l=!0,10===t.charCodeAt(o)&&++o),t.slice(i+1,e-1).replace(/""/g,'"')}for(;o<a;){if(10===(r=t.charCodeAt(e=o++)))l=!0;else if(13===r)l=!0,10===t.charCodeAt(o)&&++o;else if(r!==n)continue;return t.slice(i,e)}return u=!0,t.slice(i,a)}for(10===t.charCodeAt(a-1)&&--a,13===t.charCodeAt(a-1)&&--a;(r=c())!==xc;){for(var d=[];r!==wc&&r!==xc;)d.push(r),r=c();e&&null==(d=e(d,s++))||i.push(d)}return i}function i(e,n){return e.map((function(e){return n.map((function(t){return o(e[t])})).join(t)}))}function a(e){return e.map(o).join(t)}function o(t){return null==t?"":t instanceof Date?Cc(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,a=r(t,(function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=Ac(t);return function(r,i){return e(n(r),i,t)}}(t,e):Ac(t)}));return a.columns=i||[],a},parseRows:r,format:function(e,n){return null==n&&(n=Ec(e)),[n.map(o).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=Ec(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(a).join("\n")},formatRow:a,formatValue:o}}(",").parseRows,Dc="$";function Fc(){}function Sc(t,e){var n=new Fc;if(t instanceof Fc)t.each((function(t,e){n.set(e,t)}));else if(Array.isArray(t)){var r,i=-1,a=t.length;if(null==e)for(;++i<a;)n.set(i,t[i]);else for(;++i<a;)n.set(e(r=t[i],i,t),r)}else if(t)for(var o in t)n.set(o,t[o]);return n}function Mc(){}Fc.prototype=Sc.prototype={constructor:Fc,has:function(t){return Dc+t in this},get:function(t){return this[Dc+t]},set:function(t,e){return this[Dc+t]=e,this},remove:function(t){var e=Dc+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===Dc&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===Dc&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===Dc&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===Dc&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===Dc&&++t;return t},empty:function(){for(var t in this)if(t[0]===Dc)return!1;return!0},each:function(t){for(var e in this)e[0]===Dc&&t(this[e],e.slice(1),this)}};var Nc=Sc.prototype;Mc.prototype={constructor:Mc,has:Nc.has,add:function(t){return this[Dc+(t+="")]=t,this},remove:Nc.remove,clear:Nc.clear,values:Nc.keys,size:Nc.size,empty:Nc.empty,each:Nc.each};var Lc,Oc,Uc={value:function(){}};function Rc(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Bc(r)}function Bc(t){this._=t}function jc(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 Hc(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function Ic(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Uc,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function zc(t,e,n){var r;r="object"==typeof e?e.id:e,this.id=r,this.visualisation=t,this.api_prefix="/api/data_table"}function Pc(t){return t.map((function(t){return null!=t&&"object"==typeof t&&"map"in t?Pc(t):t}))}function qc(t){this.id=t}function $c(t,e,n){var r=this;r.id=1,r.template_id=1,r.api_prefix="/api/visualisation",r.can_edit=!0,r.__sdk__=!0,n.data_tables&&(this.data_tables=n.data_tables.map((function(t){return new zc(r,t)}))),n.data_bindings&&(this.data_bindings=n.data_bindings)}Bc.prototype=Rc.prototype={constructor:Bc,on:function(t,e){var n,r=this._,i=jc(t+"",r),a=-1,o=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<o;)if(n=(t=i[a]).type)r[n]=Ic(r[n],t.name,e);else if(null==e)for(n in r)r[n]=Ic(r[n],t.name,null);return this}for(;++a<o;)if((n=(t=i[a]).type)&&(n=Hc(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Bc(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}},zc.prototype.csv=function(t){if(this.cached_data)t(void 0,Pc(this.cached_data));else{var e=this;!function(t,e){var n,r,i,a,o=Rc("beforesend","progress","load","error"),s=Sc(),u=new XMLHttpRequest,l=null,c=null,d=0;function f(t){var e,r=u.status;if(!r&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(u)||r>=200&&r<300||304===r){if(i)try{e=i.call(n,u)}catch(t){return void o.call("error",n,t)}else e=u;o.call("load",n,e)}else o.call("error",n,t)}if("undefined"!=typeof XDomainRequest&&!("withCredentials"in u)&&/^(http(s)?:)?\/\//.test(t)&&(u=new XDomainRequest),"onload"in u?u.onload=u.onerror=u.ontimeout=f:u.onreadystatechange=function(t){u.readyState>3&&f(t)},u.onprogress=function(t){o.call("progress",n,t)},n={header:function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s.get(t):(null==e?s.remove(t):s.set(t,e+""),n)},mimeType:function(t){return arguments.length?(r=null==t?null:t+"",n):r},responseType:function(t){return arguments.length?(a=t,n):a},timeout:function(t){return arguments.length?(d=+t,n):d},user:function(t){return arguments.length<1?l:(l=null==t?null:t+"",n)},password:function(t){return arguments.length<1?c:(c=null==t?null:t+"",n)},response:function(t){return i=t,n},get:function(t,e){return n.send("GET",t,e)},post:function(t,e){return n.send("POST",t,e)},send:function(e,i,f){return u.open(e,t,!0,l,c),null==r||s.has("accept")||s.set("accept",r+",*/*"),u.setRequestHeader&&s.each((function(t,e){u.setRequestHeader(e,t)})),null!=r&&u.overrideMimeType&&u.overrideMimeType(r),null!=a&&(u.responseType=a),d>0&&(u.timeout=d),null==f&&"function"==typeof i&&(f=i,i=null),null!=f&&1===f.length&&(f=function(t){return function(e,n){t(null==e?n:null)}}(f)),null!=f&&n.on("error",f).on("load",(function(t){f(null,t)})),o.call("beforesend",n,u),u.send(null==i?null:i),n},abort:function(){return u.abort(),n},on:function(){var t=o.on.apply(o,arguments);return t===o?n:t}},null!=e){if("function"!=typeof e)throw new Error("invalid callback: "+e);return n.get(e)}}(this.api_prefix+"/"+this.id+"/csv",(function(n,r){e.cached_data=kc(r.response),t(void 0,Pc(e.cached_data))}))}},zc.prototype.saveData=function(t,e){e()},zc.prototype.save=function(t,e){e()},zc.prototype.delete=function(t){t()},qc.prototype.getSettings=function(t){t(void 0,window.Flourish.app.settings)},qc.prototype.getDataBindings=function(t){t(void 0,window.Flourish.app.template_data_bindings)},qc.prototype.refreshDataBindings=function(t){t(void 0)},$c.prototype.save=function(t,e){this.version_number++,e(void 0)},$c.prototype.getTemplate=function(){return this.template_id?(this._template&&this.template_id==this._template.id||(this._template=new qc(this.template_id)),this._template):null},$c.prototype.settingsForCurrentTemplate=function(){return this.settings&&this.template_id in this.settings?this.settings[this.template_id]:{}},$c.prototype.dataBindingsForCurrentTemplate=function(){return this.data_bindings&&this.template_id in this.data_bindings?this.data_bindings[this.template_id]:{}},$c.prototype.refreshDataBindings=function(t){t()},$c.prototype.updateDataBindings=function(t,e){var n=this;n.version_number++,n.data_bindings||(n.data_bindings={}),n.template_id in n.data_bindings||(n.data_bindings[n.template_id]={});var r=n.data_bindings[n.template_id];for(var i in t)for(var a in t[i]){var o=t[i][a];r[i][a]=o}e(void 0)},$c.prototype.updateSettings=function(t,e){var n=this;n.version_number++,n.settings||(n.settings={}),n.template_id in n.settings||(n.settings[n.template_id]={});var r=n.settings[n.template_id];for(var i in t){var a=t[i];r[i]=a}e(void 0)},$c.prototype.getDataTables=function(t){t(void 0,window.Flourish.app.data_tables)},$c.prototype.dataTables=function(t){var e=this;e.data_tables?t(void 0,e.data_tables):(e.after_loading_data_tables||(e.after_loading_data_tables=[]),e.after_loading_data_tables.push(t),e.after_loading_data_tables.length>1||e.getDataTables((function(t,n){if(t){for(var r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](t);e.after_loading_data_tables=[]}else{e.data_tables=n.map((function(t){return new zc(e,t)}));for(r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](void 0,e.data_tables);e.after_loading_data_tables=[]}})))},$c.prototype.refreshDataTables=function(){this.data_tables=void 0,this.dataTablesHaveChanged()},$c.prototype.prepareData=function(t){var e=this;if(!e.data_bindings)throw new Error("No data bindings loaded");var n=e.template_id;e.dataTables((function(r,i){if(r)return t(r);if(e.template_id==n){for(var a={},o={},s=0,u=0;u<i.length;u++)!function(r){r.csv((function(u,l){if(u)throw u;e.template_id==n&&(o[r.id]=ki(l),a[r.id]=l,++s==i.length&&e.getTemplate().getDataBindings((function(n,r){if(n)throw n;var i={};r.forEach((function(t){"string"!=typeof t&&(t.dataset in i||(i[t.dataset]={}),i[t.dataset][t.key]=t)}));var s={},u=e.dataBindingsForCurrentTemplate();for(var l in u)s[l]=Ci(u[l],a,o,i[l]);for(l in i)s[l]||(s[l]=[],s[l].column_names={},s[l].metadata={});t(void 0,s)})))}))}(i[u]);0==i.length&&t(void 0,{})}}))},$c.prototype.getDataTableNames=function(){return void 0===this.data_table_names&&(this.data_table_names=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.id]=r.name}return e}(this.data_tables)),this.data_table_names},$c.prototype.getDataTableIds=function(){return void 0===this.data_table_ids&&(this.data_table_ids=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.name]=r.id}return e}(this.data_tables)),this.data_table_ids},$c.prototype.dataTablesHaveChanged=function(){this.data_table_names=this.data_table_ids=void 0};var Yc=!1;function Vc(){Lc&&Lc.classList.remove("shown")}function Wc(){this.close(),Yc||(Lc&&setTimeout((function(){Lc.classList.add("shown")}),1e3),setTimeout(Gc,250))}function Gc(){Xc().addEventListener("open",(function(){window.location.reload()}))}function Xc(){var t=new window.WebSocket(Oc);return t.addEventListener("open",Vc),t.addEventListener("close",Wc),t}return t.Visualisation=$c,t.initSDK=function(t,e,n,r){return Ye(),window.Flourish=window.Flourish||{},window.Flourish.app=new bc(t,e,n,r),window.Flourish.app},t.talkToServer=function(){Lc=document.getElementById("error-server-down"),Oc=window.location.origin.replace(/^http(s?):\/\//,"ws$1://"),window.addEventListener("beforeunload",(function(){Yc=!0})),Xc()},Object.defineProperty(t,"__esModule",{value:!0}),t}({});
1
+ var Flourish=function(t){"use strict";function e(t){return parseInt(t).toString()===""+t&&t>=0}function n(t,e,n){return t.map((function(t){var r={};return Object.keys(e).forEach((function(n){r[n]=t[e[n]]})),Object.keys(n).forEach((function(e){var i=n[e];Array.isArray(i)||(i=[i]),r[e]=i.map((function(e){return t[e]}))})),r}))}function r(t,e,r){var i=n(t,e=e||{},r=r||{});return i.column_names={},Object.keys(e).forEach((function(t){i.column_names[t]=e[t]})),Object.keys(r).forEach((function(t){var e=r[t];i.column_names[t]=Array.isArray(e)?e:[e]})),i}function i(t,r,i){!function(t,n){var r;if(!Object.keys(t).every((function(n){return e(t[n])})))throw r="All column_bindings values should be non-negative integers",new TypeError(r);if(!Object.keys(n).every((function(t){var r=n[t];return Array.isArray(r)?r.every(e):e(r)})))throw r="All columns_bindings values should be non-negative integers or arrays thereof",new TypeError(r)}(r=r||{},i=i||{});var a=t[0],o=n(t.slice(1),r,i);return o.column_names={},Object.keys(r).forEach((function(t){o.column_names[t]=a[r[t]]})),Object.keys(i).forEach((function(t){var e=i[t];o.column_names[t]=(Array.isArray(e)?e:[e]).map((function(t){return a[t]}))})),o}function a(t,e,n){return(Array.isArray(t[0])?i:r)(t,e,n)}var o="http://www.w3.org/1999/xhtml",s={svg:"http://www.w3.org/2000/svg",xhtml:o,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function l(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),s.hasOwnProperty(e)?{space:s[e],local:t}:t}function u(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===o&&e.documentElement.namespaceURI===o?e.createElement(t):e.createElementNS(n,t)}}function c(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function d(t){var e=l(t);return(e.local?c:u)(e)}function f(){}function p(t){return null==t?f:function(){return this.querySelector(t)}}function h(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function m(){return[]}function g(t){return null==t?m:function(){return this.querySelectorAll(t)}}function v(t){return function(){return this.matches(t)}}function y(t){return function(e){return e.matches(t)}}var b=Array.prototype.find;function _(){return this.firstElementChild}var w=Array.prototype.filter;function x(){return this.children}function C(t){return new Array(t.length)}function A(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function E(t){return function(){return t}}function k(t,e,n,r,i,a){for(var o,s=0,l=e.length,u=a.length;s<u;++s)(o=e[s])?(o.__data__=a[s],r[s]=o):n[s]=new A(t,a[s]);for(;s<l;++s)(o=e[s])&&(i[s]=o)}function T(t,e,n,r,i,a,o){var s,l,u,c=new Map,d=e.length,f=a.length,p=new Array(d);for(s=0;s<d;++s)(l=e[s])&&(p[s]=u=o.call(l,l.__data__,s,e)+"",c.has(u)?i[s]=l:c.set(u,l));for(s=0;s<f;++s)u=o.call(t,a[s],s,a)+"",(l=c.get(u))?(r[s]=l,l.__data__=a[s],c.delete(u)):n[s]=new A(t,a[s]);for(s=0;s<d;++s)(l=e[s])&&c.get(p[s])===l&&(i[s]=l)}function L(t){return t.__data__}function D(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function F(t){return function(){this.removeAttribute(t)}}function S(t){return function(){this.removeAttributeNS(t.space,t.local)}}function M(t,e){return function(){this.setAttribute(t,e)}}function N(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function U(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function O(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 H(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function B(t){return function(){this.style.removeProperty(t)}}function R(t,e,n){return function(){this.style.setProperty(t,e,n)}}function j(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function I(t,e){return t.style.getPropertyValue(e)||H(t).getComputedStyle(t,null).getPropertyValue(e)}function z(t){return function(){delete this[t]}}function P(t,e){return function(){this[t]=e}}function $(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function q(t){return t.trim().split(/^|\s+/)}function V(t){return t.classList||new Y(t)}function Y(t){this._node=t,this._names=q(t.getAttribute("class")||"")}function W(t,e){for(var n=V(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function G(t,e){for(var n=V(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function Z(t){return function(){W(this,t)}}function X(t){return function(){G(this,t)}}function J(t,e){return function(){(e.apply(this,arguments)?W:G)(this,t)}}function K(){this.textContent=""}function Q(t){return function(){this.textContent=t}}function tt(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function et(){this.innerHTML=""}function nt(t){return function(){this.innerHTML=t}}function rt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function it(){this.nextSibling&&this.parentNode.appendChild(this)}function at(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ot(){return null}function st(){var t=this.parentNode;t&&t.removeChild(this)}function lt(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function ut(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function ct(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 dt(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,a=e.length;r<a;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function ft(t,e,n){return function(){var r,i=this.__on,a=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var o=0,s=i.length;o<s;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),void(r.value=e);this.addEventListener(t.type,a,n),r={type:t.type,name:t.name,value:e,listener:a,options:n},i?i.push(r):this.__on=[r]}}function pt(t,e,n){var r=H(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 ht(t,e){return function(){return pt(this,t,e)}}function mt(t,e){return function(){return pt(this,t,e.apply(this,arguments))}}A.prototype={constructor:A,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},Y.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var gt,vt,yt,bt,_t,wt=[null];function xt(t,e){this._groups=t,this._parents=e}function Ct(){return new xt([[document.documentElement]],wt)}function At(t){return"string"==typeof t?new xt([[document.querySelector(t)]],[document.documentElement]):new xt([[t]],wt)}function Et(t){return At(d(t).call(document.documentElement))}function kt(t){return"string"==typeof t?new xt([document.querySelectorAll(t)],[document.documentElement]):new xt([null==t?[]:h(t)],wt)}function Tt(){if(!yt)return null;var t=yt.nodes()[1].value;if("custom"===bt&&""!=t){var e=parseInt(t,10);return isNaN(e)?null:e}return null}function Lt(){_t&&_t.preview_pane&&_t.preview_pane.setFixedHeight&&_t.preview_pane.setFixedHeight(Tt())}function Dt(t,e=!1){bt=t,Lt(),"custom"===t?(At("#editor-custom-inputs").style("opacity",1),At(".preview-holder").style("width",yt.nodes()[0].value+"px").select("iframe").style("width",yt.nodes()[0].value+"px")):(At("#editor-custom-inputs").style("opacity",0),At(".preview-holder").attr("style",null).select("iframe").style("width",null)),e||At(".preview-holder").style("max-width","none"),kt("#preview-menu .preview-mode").classed("selected",(function(){return this.id=="editor-"+t})),At("#editor-rotate").classed("active",(function(){return"auto"!==t})),At(".row.editor").classed("mobile",(function(){return"mobile"==t})),At(".row.editor").classed("tablet",(function(){return"tablet"==t})),At(".preview-holder").on("webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd transitionend",St),gt=t}function Ft(t){return _t=t,yt=kt("#editor-custom-inputs input"),St(),kt("#preview-menu .preview-mode").on("click",(function(){Dt(this.getAttribute("data-target"))})),yt.on("change",(function(){Dt(this.getAttribute("data-target"))})),Dt("auto",!0),function(){var t,e,n=document.querySelector("#resize-handle"),r=document.querySelector(".preview-holder");function i(i){"editor-custom"!==i.target.parentElement.id&&(t=r.getBoundingClientRect().width,n.parentElement.parentElement.querySelector("#resize-overlay").classList.add("dragging"),n.parentElement.classList.add("dragging"),e=i.clientX,At(".preview-holder").style("transition","none"),Dt("custom"),document.addEventListener("mousemove",a),document.addEventListener("mouseup",o),i.preventDefault())}function a(n){var i=n.clientX-e,a=t+2*i;r.style.width=a+"px",r.querySelector("iframe").style.width=a-4+"px",St(),_t.preview_pane.resize()}function o(){t=r.getBoundingClientRect().width,At(".preview-holder").style("transition",null),n.parentElement.parentElement.querySelector("#resize-overlay").classList.remove("dragging"),n.parentElement.classList.remove("dragging"),St(),_t.preview_pane.resize(),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",o)}n.addEventListener("mousedown",i)}
2
+ /*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */(),window.innerWidth<=768&&(vt="auto"),window.addEventListener("resize",(function(){gt&&St(),window.innerWidth<=768?vt||(vt=gt,Dt("auto")):vt&&(Dt(vt),vt=null),_t.preview_pane.resize()})),{getHeightSetting:Tt}}function St(){var t=At(".preview-holder").node().getBoundingClientRect();yt.nodes()[0].value=Math.round(t.width),""!==yt.nodes()[1].value&&"custom"===bt&&(yt.nodes()[1].value=Math.round(t.height))}xt.prototype=Ct.prototype={constructor:xt,select:function(t){"function"!=typeof t&&(t=p(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o,s=e[i],l=s.length,u=r[i]=new Array(l),c=0;c<l;++c)(a=s[c])&&(o=t.call(a,a.__data__,c,s))&&("__data__"in a&&(o.__data__=a.__data__),u[c]=o);return new xt(r,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);return null==e?[]:h(e)}}(t):g(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o,s=e[a],l=s.length,u=0;u<l;++u)(o=s[u])&&(r.push(t.call(o,o.__data__,u,s)),i.push(o));return new xt(r,i)},selectChild:function(t){return this.select(null==t?_:function(t){return function(){return b.call(this.children,t)}}("function"==typeof t?t:y(t)))},selectChildren:function(t){return this.selectAll(null==t?x:function(t){return function(){return w.call(this.children,t)}}("function"==typeof t?t:y(t)))},filter:function(t){"function"!=typeof t&&(t=v(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,l=r[i]=[],u=0;u<s;++u)(a=o[u])&&t.call(a,a.__data__,u,o)&&l.push(a);return new xt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,L);var n=e?T:k,r=this._parents,i=this._groups;"function"!=typeof t&&(t=E(t));for(var a=i.length,o=new Array(a),s=new Array(a),l=new Array(a),u=0;u<a;++u){var c=r[u],d=i[u],f=d.length,p=h(t.call(c,c&&c.__data__,u,r)),m=p.length,g=s[u]=new Array(m),v=o[u]=new Array(m),y=l[u]=new Array(f);n(c,d,g,v,y,p,e);for(var b,_,w=0,x=0;w<m;++w)if(b=g[w]){for(w>=x&&(x=w+1);!(_=v[x])&&++x<m;);b._next=_||null}}return(o=new xt(o,r))._enter=s,o._exit=l,o},enter:function(){return new xt(this._enter||this._groups.map(C),this._parents)},exit:function(){return new xt(this._exit||this._groups.map(C),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,a=this.exit();return r="function"==typeof t?t(r):r.append(t+""),null!=e&&(i=e(i)),null==n?a.remove():n(a),r&&i?r.merge(i).order():i},merge:function(t){if(!(t instanceof xt))throw new Error("invalid merge");for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var l,u=e[s],c=n[s],d=u.length,f=o[s]=new Array(d),p=0;p<d;++p)(l=u[p]||c[p])&&(f[p]=l);for(;s<r;++s)o[s]=e[s];return new xt(o,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],a=i.length-1,o=i[a];--a>=0;)(r=i[a])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=D);for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o,s=n[a],l=s.length,u=i[a]=new Array(l),c=0;c<l;++c)(o=s[c])&&(u[c]=o);u.sort(e)}return new xt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,a=e[n],o=0,s=a.length;o<s;++o)(i=a[o])&&t.call(i,i.__data__,o,a);return this},attr:function(t,e){var n=l(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?S:F:"function"==typeof e?n.local?O:U:n.local?N:M)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?B:"function"==typeof e?j:R)(t,e,null==n?"":n)):I(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?z:"function"==typeof e?$:P)(t,e)):this.node()[t]},classed:function(t,e){var n=q(t+"");if(arguments.length<2){for(var r=V(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?J:e?Z:X)(n,e))},text:function(t){return arguments.length?this.each(null==t?K:("function"==typeof t?tt:Q)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?et:("function"==typeof t?rt:nt)(t)):this.node().innerHTML},raise:function(){return this.each(it)},lower:function(){return this.each(at)},append:function(t){var e="function"==typeof t?t:d(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:d(t),r=null==e?ot:"function"==typeof e?e:p(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(st)},clone:function(t){return this.select(t?ut:lt)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,a=ct(t+""),o=a.length;if(!(arguments.length<2)){for(s=e?ft:dt,r=0;r<o;++r)this.each(s(a[r],e,n));return this}var s=this.node().__on;if(s)for(var l,u=0,c=s.length;u<c;++u)for(r=0,l=s[u];r<o;++r)if((i=a[r]).type===l.type&&i.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?mt:ht)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],a=0,o=i.length;a<o;++a)(r=i[a])&&(yield r)}};var Mt=Object.hasOwnProperty,Nt=Object.setPrototypeOf,Ut=Object.isFrozen,Ot=Object.getPrototypeOf,Ht=Object.getOwnPropertyDescriptor,Bt=Object.freeze,Rt=Object.seal,jt=Object.create,It="undefined"!=typeof Reflect&&Reflect,zt=It.apply,Pt=It.construct;zt||(zt=function(t,e,n){return t.apply(e,n)}),Bt||(Bt=function(t){return t}),Rt||(Rt=function(t){return t}),Pt||(Pt=function(t,e){return new(Function.prototype.bind.apply(t,[null].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(e))))});var $t,qt=te(Array.prototype.forEach),Vt=te(Array.prototype.pop),Yt=te(Array.prototype.push),Wt=te(String.prototype.toLowerCase),Gt=te(String.prototype.match),Zt=te(String.prototype.replace),Xt=te(String.prototype.indexOf),Jt=te(String.prototype.trim),Kt=te(RegExp.prototype.test),Qt=($t=TypeError,function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return Pt($t,e)});function te(t){return function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return zt(t,e,r)}}function ee(t,e){Nt&&Nt(t,null);for(var n=e.length;n--;){var r=e[n];if("string"==typeof r){var i=Wt(r);i!==r&&(Ut(e)||(e[n]=i),r=i)}t[r]=!0}return t}function ne(t){var e=jt(null),n=void 0;for(n in t)zt(Mt,t,[n])&&(e[n]=t[n]);return e}function re(t,e){for(;null!==t;){var n=Ht(t,e);if(n){if(n.get)return te(n.get);if("function"==typeof n.value)return te(n.value)}t=Ot(t)}return function(t){return console.warn("fallback value for",t),null}}var ie=Bt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ae=Bt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),oe=Bt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),se=Bt(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),le=Bt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),ue=Bt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ce=Bt(["#text"]),de=Bt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),fe=Bt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),pe=Bt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),he=Bt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),me=Rt(/\{\{[\s\S]*|[\s\S]*\}\}/gm),ge=Rt(/<%[\s\S]*|[\s\S]*%>/gm),ve=Rt(/^data-[\-\w.\u00B7-\uFFFF]/),ye=Rt(/^aria-[\-\w]+$/),be=Rt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),_e=Rt(/^(?:\w+script|data):/i),we=Rt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),xe="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};function Ce(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}var Ae=function(){return"undefined"==typeof window?null:window},Ee=function(t,e){if("object"!==(void 0===t?"undefined":xe(t))||"function"!=typeof t.createPolicy)return null;var n=null,r="data-tt-policy-suffix";e.currentScript&&e.currentScript.hasAttribute(r)&&(n=e.currentScript.getAttribute(r));var i="dompurify"+(n?"#"+n:"");try{return t.createPolicy(i,{createHTML:function(t){return t}})}catch(t){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};var ke,Te,Le=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ae(),n=function(e){return t(e)};if(n.version="2.2.8",n.removed=[],!e||!e.document||9!==e.document.nodeType)return n.isSupported=!1,n;var r=e.document,i=e.document,a=e.DocumentFragment,o=e.HTMLTemplateElement,s=e.Node,l=e.Element,u=e.NodeFilter,c=e.NamedNodeMap,d=void 0===c?e.NamedNodeMap||e.MozNamedAttrMap:c,f=e.Text,p=e.Comment,h=e.DOMParser,m=e.trustedTypes,g=l.prototype,v=re(g,"cloneNode"),y=re(g,"nextSibling"),b=re(g,"childNodes"),_=re(g,"parentNode");if("function"==typeof o){var w=i.createElement("template");w.content&&w.content.ownerDocument&&(i=w.content.ownerDocument)}var x=Ee(m,r),C=x&&tt?x.createHTML(""):"",A=i,E=A.implementation,k=A.createNodeIterator,T=A.createDocumentFragment,L=r.importNode,D={};try{D=ne(i).documentMode?i.documentMode:{}}catch(t){}var F={};n.isSupported="function"==typeof _&&E&&void 0!==E.createHTMLDocument&&9!==D;var S=me,M=ge,N=ve,U=ye,O=_e,H=we,B=be,R=null,j=ee({},[].concat(Ce(ie),Ce(ae),Ce(oe),Ce(le),Ce(ce))),I=null,z=ee({},[].concat(Ce(de),Ce(fe),Ce(pe),Ce(he))),P=null,$=null,q=!0,V=!0,Y=!1,W=!1,G=!1,Z=!1,X=!1,J=!1,K=!1,Q=!0,tt=!1,et=!0,nt=!0,rt=!1,it={},at=ee({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ot=null,st=ee({},["audio","video","img","source","image","track"]),lt=null,ut=ee({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),ct="http://www.w3.org/1998/Math/MathML",dt="http://www.w3.org/2000/svg",ft="http://www.w3.org/1999/xhtml",pt=ft,ht=null,mt=i.createElement("form"),gt=function(t){ht&&ht===t||(t&&"object"===(void 0===t?"undefined":xe(t))||(t={}),t=ne(t),R="ALLOWED_TAGS"in t?ee({},t.ALLOWED_TAGS):j,I="ALLOWED_ATTR"in t?ee({},t.ALLOWED_ATTR):z,lt="ADD_URI_SAFE_ATTR"in t?ee(ne(ut),t.ADD_URI_SAFE_ATTR):ut,ot="ADD_DATA_URI_TAGS"in t?ee(ne(st),t.ADD_DATA_URI_TAGS):st,P="FORBID_TAGS"in t?ee({},t.FORBID_TAGS):{},$="FORBID_ATTR"in t?ee({},t.FORBID_ATTR):{},it="USE_PROFILES"in t&&t.USE_PROFILES,q=!1!==t.ALLOW_ARIA_ATTR,V=!1!==t.ALLOW_DATA_ATTR,Y=t.ALLOW_UNKNOWN_PROTOCOLS||!1,W=t.SAFE_FOR_TEMPLATES||!1,G=t.WHOLE_DOCUMENT||!1,J=t.RETURN_DOM||!1,K=t.RETURN_DOM_FRAGMENT||!1,Q=!1!==t.RETURN_DOM_IMPORT,tt=t.RETURN_TRUSTED_TYPE||!1,X=t.FORCE_BODY||!1,et=!1!==t.SANITIZE_DOM,nt=!1!==t.KEEP_CONTENT,rt=t.IN_PLACE||!1,B=t.ALLOWED_URI_REGEXP||B,pt=t.NAMESPACE||pt,W&&(V=!1),K&&(J=!0),it&&(R=ee({},[].concat(Ce(ce))),I=[],!0===it.html&&(ee(R,ie),ee(I,de)),!0===it.svg&&(ee(R,ae),ee(I,fe),ee(I,he)),!0===it.svgFilters&&(ee(R,oe),ee(I,fe),ee(I,he)),!0===it.mathMl&&(ee(R,le),ee(I,pe),ee(I,he))),t.ADD_TAGS&&(R===j&&(R=ne(R)),ee(R,t.ADD_TAGS)),t.ADD_ATTR&&(I===z&&(I=ne(I)),ee(I,t.ADD_ATTR)),t.ADD_URI_SAFE_ATTR&&ee(lt,t.ADD_URI_SAFE_ATTR),nt&&(R["#text"]=!0),G&&ee(R,["html","head","body"]),R.table&&(ee(R,["tbody"]),delete P.tbody),Bt&&Bt(t),ht=t)},vt=ee({},["mi","mo","mn","ms","mtext"]),yt=ee({},["foreignobject","desc","title","annotation-xml"]),bt=ee({},ae);ee(bt,oe),ee(bt,se);var _t=ee({},le);ee(_t,ue);var wt=function(t){var e=_(t);e&&e.tagName||(e={namespaceURI:ft,tagName:"template"});var n=Wt(t.tagName),r=Wt(e.tagName);if(t.namespaceURI===dt)return e.namespaceURI===ft?"svg"===n:e.namespaceURI===ct?"svg"===n&&("annotation-xml"===r||vt[r]):Boolean(bt[n]);if(t.namespaceURI===ct)return e.namespaceURI===ft?"math"===n:e.namespaceURI===dt?"math"===n&&yt[r]:Boolean(_t[n]);if(t.namespaceURI===ft){if(e.namespaceURI===dt&&!yt[r])return!1;if(e.namespaceURI===ct&&!vt[r])return!1;var i=ee({},["title","style","font","a","script"]);return!_t[n]&&(i[n]||!bt[n])}return!1},xt=function(t){Yt(n.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=C}catch(e){t.remove()}}},Ct=function(t,e){try{Yt(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){Yt(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t&&!I[t])if(J||K)try{xt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},At=function(t){var e=void 0,n=void 0;if(X)t="<remove></remove>"+t;else{var r=Gt(t,/^[\r\n\t ]+/);n=r&&r[0]}var a=x?x.createHTML(t):t;if(pt===ft)try{e=(new h).parseFromString(a,"text/html")}catch(t){}e&&e.documentElement||((e=E.createDocument(pt,"template",null)).documentElement.innerHTML=a);var o=e.body||e.documentElement;return t&&n&&o.insertBefore(i.createTextNode(n),o.childNodes[0]||null),G?e.documentElement:o},Et=function(t){return k.call(t.ownerDocument||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,(function(){return u.FILTER_ACCEPT}),!1)},kt=function(t){return!(t instanceof f||t instanceof p)&&!("string"==typeof t.nodeName&&"string"==typeof t.textContent&&"function"==typeof t.removeChild&&t.attributes instanceof d&&"function"==typeof t.removeAttribute&&"function"==typeof t.setAttribute&&"string"==typeof t.namespaceURI&&"function"==typeof t.insertBefore)},Tt=function(t){return"object"===(void 0===s?"undefined":xe(s))?t instanceof s:t&&"object"===(void 0===t?"undefined":xe(t))&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Lt=function(t,e,r){F[t]&&qt(F[t],(function(t){t.call(n,e,r,ht)}))},Dt=function(t){var e=void 0;if(Lt("beforeSanitizeElements",t,null),kt(t))return xt(t),!0;if(Gt(t.nodeName,/[\u0080-\uFFFF]/))return xt(t),!0;var r=Wt(t.nodeName);if(Lt("uponSanitizeElement",t,{tagName:r,allowedTags:R}),!Tt(t.firstElementChild)&&(!Tt(t.content)||!Tt(t.content.firstElementChild))&&Kt(/<[/\w]/g,t.innerHTML)&&Kt(/<[/\w]/g,t.textContent))return xt(t),!0;if(!R[r]||P[r]){if(nt&&!at[r]){var i=_(t)||t.parentNode,a=b(t)||t.childNodes;if(a&&i)for(var o=a.length-1;o>=0;--o)i.insertBefore(v(a[o],!0),y(t))}return xt(t),!0}return t instanceof l&&!wt(t)?(xt(t),!0):"noscript"!==r&&"noembed"!==r||!Kt(/<\/no(script|embed)/i,t.innerHTML)?(W&&3===t.nodeType&&(e=t.textContent,e=Zt(e,S," "),e=Zt(e,M," "),t.textContent!==e&&(Yt(n.removed,{element:t.cloneNode()}),t.textContent=e)),Lt("afterSanitizeElements",t,null),!1):(xt(t),!0)},Ft=function(t,e,n){if(et&&("id"===e||"name"===e)&&(n in i||n in mt))return!1;if(V&&Kt(N,e));else if(q&&Kt(U,e));else{if(!I[e]||$[e])return!1;if(lt[e]);else if(Kt(B,Zt(n,H,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==Xt(n,"data:")||!ot[t]){if(Y&&!Kt(O,Zt(n,H,"")));else if(n)return!1}else;}return!0},St=function(t){var e=void 0,r=void 0,i=void 0,a=void 0;Lt("beforeSanitizeAttributes",t,null);var o=t.attributes;if(o){var s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:I};for(a=o.length;a--;){var l=e=o[a],u=l.name,c=l.namespaceURI;if(r=Jt(e.value),i=Wt(u),s.attrName=i,s.attrValue=r,s.keepAttr=!0,s.forceKeepAttr=void 0,Lt("uponSanitizeAttribute",t,s),r=s.attrValue,!s.forceKeepAttr&&(Ct(u,t),s.keepAttr))if(Kt(/\/>/i,r))Ct(u,t);else{W&&(r=Zt(r,S," "),r=Zt(r,M," "));var d=t.nodeName.toLowerCase();if(Ft(d,i,r))try{c?t.setAttributeNS(c,u,r):t.setAttribute(u,r),Vt(n.removed)}catch(t){}}}Lt("afterSanitizeAttributes",t,null)}},Mt=function t(e){var n=void 0,r=Et(e);for(Lt("beforeSanitizeShadowDOM",e,null);n=r.nextNode();)Lt("uponSanitizeShadowNode",n,null),Dt(n)||(n.content instanceof a&&t(n.content),St(n));Lt("afterSanitizeShadowDOM",e,null)};return n.sanitize=function(t,i){var o=void 0,l=void 0,u=void 0,c=void 0,d=void 0;if(t||(t="\x3c!--\x3e"),"string"!=typeof t&&!Tt(t)){if("function"!=typeof t.toString)throw Qt("toString is not a function");if("string"!=typeof(t=t.toString()))throw Qt("dirty is not a string, aborting")}if(!n.isSupported){if("object"===xe(e.toStaticHTML)||"function"==typeof e.toStaticHTML){if("string"==typeof t)return e.toStaticHTML(t);if(Tt(t))return e.toStaticHTML(t.outerHTML)}return t}if(Z||gt(i),n.removed=[],"string"==typeof t&&(rt=!1),rt);else if(t instanceof s)1===(l=(o=At("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?o=l:o.appendChild(l);else{if(!J&&!W&&!G&&-1===t.indexOf("<"))return x&&tt?x.createHTML(t):t;if(!(o=At(t)))return J?null:C}o&&X&&xt(o.firstChild);for(var f=Et(rt?t:o);u=f.nextNode();)3===u.nodeType&&u===c||Dt(u)||(u.content instanceof a&&Mt(u.content),St(u),c=u);if(c=null,rt)return t;if(J){if(K)for(d=T.call(o.ownerDocument);o.firstChild;)d.appendChild(o.firstChild);else d=o;return Q&&(d=L.call(r,d,!0)),d}var p=G?o.outerHTML:o.innerHTML;return W&&(p=Zt(p,S," "),p=Zt(p,M," ")),x&&tt?x.createHTML(p):p},n.setConfig=function(t){gt(t),Z=!0},n.clearConfig=function(){ht=null,Z=!1},n.isValidAttribute=function(t,e,n){ht||gt({});var r=Wt(t),i=Wt(e);return Ft(r,i,n)},n.addHook=function(t,e){"function"==typeof e&&(F[t]=F[t]||[],Yt(F[t],e))},n.removeHook=function(t){F[t]&&Vt(F[t])},n.removeHooks=function(t){F[t]&&(F[t]=[])},n.removeAllHooks=function(){F={}},n}(),De=25,Fe=10,Se=10,Me={};function Ne(t,e,n,r,i,a,o){var s=n-t/2-Se,l=n+t/2+Se,u=t/2+Math.min(0,s-i.left)+Math.max(0,l-i.right);return{pos:[u,o],shape:u-Fe<5?[-u,-15*a,Math.max(Fe,5-u),-10*a]:u+Fe>t-5?[Math.min(-10,t-u-5),-10*a,Math.min(Fe,t-u),-15*a]:[-10,-10*a,Fe,-10*a]}}function Ue(t,e,n,r,i,a,o){var s=r-e/2-Se,l=r+e/2+Se,u=e/2+Math.min(0,s-i.top)+Math.max(0,l-i.bottom);return{pos:[o,u],shape:u-Fe<5?[-15*a,-u,-10*a,Math.max(Fe,5-u)]:u+Fe>e-5?[-10*a,Math.min(-10,e-u-5),-15*a,Math.min(Fe,e-u)]:[-10*a,-10,-10*a,Fe]}}function Oe(t,e,n,r,i,a){var o=Me[t](e,n,r,i,a),s=r-De-o.pos[0],l=i-De-o.pos[1];return{left:s,top:l,right:s+e+50,bottom:l+n+50}}function He(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 a=i.style;if(n)for(r in n)a[r]=n[r];return i}function Be(){return ke||((ke=document.createElement("div")).id="flourish-popup-constrainer",(Te=ke.style).overflow="hidden",Te.pointerEvents="none",Te.position="absolute",Te.left="0",Te.top="0",Te.margin="0",Te.padding="0",document.body.appendChild(ke),this._resizeConstrainer(),ke)}Me.bottom=function(t,e){return{shape:[-10,-10,Fe,-10],pos:[t/2,e+Se]}},Me.top=function(t,e){return{shape:[-10,Se,Fe,Se],pos:[t/2,-10]}},Me.left=function(t,e){return{shape:[Se,Fe,Se,-10],pos:[-10,e/2]}},Me.right=function(t,e){return{shape:[-10,Fe,-10,-10],pos:[t+Se,e/2]}},Me.topLeft=function(t,e){return{shape:[15,Se,Se,15],pos:[-10,-10]}},Me.bottomLeft=function(t,e){return{shape:[15,-10,Se,-15],pos:[-10,e+Se]}},Me.topRight=function(t,e){return{shape:[-15,Se,-10,15],pos:[t+Se,-10]}},Me.bottomRight=function(t,e){return{shape:[-15,-10,-10,-15],pos:[t+Se,e+Se]}},Me.bottomFlexible=function(t,e,n,r,i){return Ne(t,0,n,0,i,1,e+Se)},Me.topFlexible=function(t,e,n,r,i){return Ne(t,0,n,0,i,-1,-10)},Me.rightFlexible=function(t,e,n,r,i){return Ue(0,e,0,r,i,1,t+Se)},Me.leftFlexible=function(t,e,n,r,i){return Ue(0,e,0,r,i,-1,-10)};var Re,je=1,Ie={container:document.body,maxWidth:"70%",point:null,html:null,directions:["bottom","top","left","right","topLeft","bottomLeft","topRight","bottomRight","bottomFlexible","topFlexible","leftFlexible","rightFlexible"],fallbackFit:"horizontal"};function ze(){for(var t in this.unique_id=je++,this.is_visible=!0,Ie)this["_"+t]=Ie[t];this.handlers={click:[]}}function Pe(t){ze.prototype[t]=function(e){return void 0===e?this["_"+t]:(this["_"+t]=e,this)}}for(var $e in Ie)Pe($e);function qe(){return new ze}function Ve(){Re=qe().container(document.body),function(t){t.on("mouseover",Ye).on("mouseout",We)}(kt(".popup"))}function Ye(){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,a=this.getAttribute("data-popup-body")||null,o="",s=["top","topFlexible"];i&&(o+=Et("h1").html(Le.sanitize(i)).node().outerHTML),a&&(o+=Et("p").html(Le.sanitize(a)).node().outerHTML),t&&("left"===t?(s=["right","rightFlexible"],n=e.left,r=e.top+e.height/2):"right"===t?(s=["left","leftFlexible"],n=e.right,r=e.top+e.height/2):"top"===t?(s=["bottom","bottomFlexible"],n=e.left+e.width/2,r=e.top):"bottom"===t&&(s=["top","topFlexible"],n=e.left+e.width/2,r=e.top+e.height)),Re.point(n,r).html(o).directions(s).draw()}}function We(){Re.hide()}ze.prototype.point=function(t,e){if(void 0===t)return this._point;if(Array.isArray(t))this._point=[t[0],t[1]];else if(void 0!==e)this._point=[t,e];else if(t instanceof HTMLElement||t instanceof SVGElement){var n=t.getBoundingClientRect();this._point=[Math.floor(n.left+n.width/2),Math.floor(n.top+n.height/2)]}else console.error("Popup: could not understand argument");return this},ze.prototype.directions=function(t){return void 0===t?this._directions:("string"==typeof t&&(t=[t]),this._directions=t.slice(),this)},ze.prototype.text=function(t){return this._html=function(t){return t.replace(/[&<>]/g,(function(t){return{"&":"&amp;","<":"&lt;",">":"&gt;"}[t]}))}(t),this},ze.prototype.on=function(t,e){if(!(t in this.handlers))throw new Error("Popup.on: No such event: "+t);return this.handlers[t].push(e),this},ze.prototype.fire=function(t,e){if(!(t in this.handlers))throw new Error("Popup.fire: No such event: "+t);for(var n=this.handlers[t],r=0;r<n.length;r++)n[r].call(this,e);return this},ze.prototype._getElement=function(){var t=this,e="flourish-popup-"+t.unique_id,n=document.getElementById(e);if(!n){(n=document.createElement("div")).className="flourish-popup",n.id=e;var r=n.style;r.display="none",r.margin=r.padding=0,r.position="absolute",r.width="80px",r.height="40px",r.boxSizing="border-box",n.addEventListener("click",(function(e){t.fire("click",e)}),!1);var i=He("svg",{class:"flourish-popup-svg"},{position:"absolute",top:0,left:0,bottom:0,right:0}),a=He("filter",{id:"dropshadow-"+t.unique_id,height:"130%"});a.appendChild(He("feGaussianBlur",{in:"SourceAlpha",stdDeviation:5})),a.appendChild(He("feOffset",{dx:0,dy:2,result:"offsetblur"}));var o=He("feComponentTransfer");o.appendChild(He("feFuncA",{type:"linear",slope:.2})),a.appendChild(o);var s=He("feMerge");a.appendChild(s),s.appendChild(He("feMergeNode")),s.appendChild(He("feMergeNode",{in:"SourceGraphic"})),i.appendChild(a);var l=He("g",{filter:"url(#dropshadow-"+t.unique_id+")",fill:"white",stroke:"none"});l.appendChild(He("rect",{x:De,y:De,rx:5})),l.appendChild(He("path")),i.appendChild(l),n.appendChild(i);var u=document.createElement("div");u.className="flourish-popup-content",(r=u.style).position="absolute",r.top=r.left="25px",r.padding="10px",n.appendChild(u),t._getConstrainer().appendChild(n)}return t._resizeConstrainer(),n},ze.prototype._getConstrainer=Be,ze.prototype._resizeConstrainer=function(){ke||Be.call(this);var t=Te.display;Te.display="none",Te.width=document.documentElement.scrollWidth+"px",Te.height=document.documentElement.scrollHeight+"px",Te.display=t},ze.prototype.draw=function(){var t=this;if(t.is_visible=!0,t._point){var e=document.documentElement.getBoundingClientRect(),n=t._point[0],r=t._point[1],i=t._container.getBoundingClientRect();n<i.left?n=i.left:n>i.right&&(n=i.right),r<i.top?r=i.top:r>i.bottom&&(r=i.bottom);var a=n-e.left,o=r-e.top,s=t._getElement(),l=s.style,u=s.querySelector(".flourish-popup-svg"),c=u.querySelector("g"),d=c.querySelector("rect"),f=c.querySelector("path"),p=s.querySelector(".flourish-popup-content");l.display="block",p.style.maxWidth=function(e){return t._maxWidth.match(/^\d+(?:\.\d+)?%$/)?e.width*parseFloat(t._maxWidth)/100:t._maxWidth.match(/^\d+(?:\.\d+)?(?:px)?$/)?parseFloat(t._maxWidth):(null!=t._maxWidth&&console.error("Popup: Unknown value for maxWidth: "+t._maxWidth),e.width)}(i)+"px",t._inner_html!=t._html&&(p.innerHTML=t._inner_html=t._html);var h,m,g=p.getBoundingClientRect();do{h=Math.ceil(g.width),m=Math.ceil(g.height),l.width=h+50+"px",l.height=m+50+"px",g=p.getBoundingClientRect()}while(h!=Math.ceil(g.width)||m!=Math.ceil(g.height));d.setAttribute("width",h),d.setAttribute("height",m),u.setAttribute("width",h+50),u.setAttribute("height",m+50);for(var v,y,b=null,_=null,w=null,x=1/0,C=1/0,A=0;A<t._directions.length;A++){var E=t._directions[A],k=Oe(E,h,m,n,r,i),T=Math.max(0,Math.floor(i.left)-k.left-15)+Math.max(0,k.right-Math.ceil(i.right)-15),L=Math.max(0,Math.floor(i.top)-k.top-15)+Math.max(0,k.bottom-Math.ceil(i.bottom)-15);if(0==T&&0==L){b=E;break}(T<x||T==x&&L<v)&&(x=T,v=L,_=E),(L<C||L==C&&T<y)&&(C=L,y=T,w=E)}return b?E=b:"horizontal"==t._fallbackFit?E=_:"vertical"==t._fallbackFit?E=w:(console.warn("Popup: failed to point box of size ("+h+", "+m+") at ("+n+", "+r+") within ("+i.left+", "+i.top+", "+i.right+", "+i.bottom+")"),E=t._directions[0]),function(t,e,n,r,i,a,o,s,l,u){var c=Me[t](r,i,s,l,u);e.left=a-De-c.pos[0]+"px",e.top=o-De-c.pos[1]+"px",n.setAttribute("d","M0,0L"+c.shape.join(",")+"Z"),n.setAttribute("transform","translate("+(c.pos[0]+De)+","+(c.pos[1]+De)+")")}(E,l,f,h,m,a,o,n,r,i),t}console.error("Popup: cannot draw popup till point() has been specified")},ze.prototype.hide=function(){return this.is_visible?(this.is_visible=!1,this._getElement().style.display="none",this):this},qe.version="2.1.5";const Ge=Math.pow(2,31)-1,Ze=Math.pow(2,15);function Xe(t,e){if(t=t.toUpperCase(),!/^[A-Z]+$/.test(t)){if(!t){if(e)return-1;throw new Error("Non-optional data binding must specify column")}throw function(t){try{tn(t)}catch(t){return!1}return!0}(t)?new Error("You can only select one column"):new Error("Invalid column specification: "+t)}for(var n=0,r=0;r<t.length;r++)n=26*n+(t.charCodeAt(r)-64);return n-1>Ge&&console.warn("Column index out of range"),Math.min(n-1,Ge)}function Je(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 Ke(t){var e=t.match(/\s*(?:[-–—:]|\.\.)\s*/);if(!e)throw new Error("Failed to parse column range: "+t);var n=t.substr(0,e.index),r=t.substr(e.index+e[0].length),i=Xe(n),a=Xe(r),o=[],s=a>=i?1:-1,l=Math.abs(a-i)+1;l>Ze&&(console.warn("Truncating excessively long range"),l=Ze);for(var u=0;u<l;u++)o.push(i+u*s);return o}function Qe(t,e){return Je(t)+"-"+Je(e)}function tn(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(Xe(i)):Array.prototype.push.apply(e,Ke(i))}return e}function en(t){for(var e=function(t){if(!t.length)return[];for(var e=[],n=t[0],r=t[0],i=null,a=0;a<t.length-1;a++){var o=t[a+1]-t[a];null!==i||1!==Math.abs(o)?o!==i?(e.push([n,r]),n=r=t[a+1],i=null):r=t[a+1]:(r=t[a+1],i=o)}return e.push([n,r]),e}(t),n=[],r=0;r<e.length;r++){var i=e[r];i[0]==i[1]?n.push(Je(i[0])):n.push(Qe(i[0],i[1]))}return n.join(",")}function nn(t,e,n,r){var i=n?e[t.data_table_id]+"::":"";if("column"in t)return i+Je(t.column);if("columns"in t)return i+en(t.columns);if(r)return"";throw new Error("Data binding must have .column or .columns")}var rn=new Date,an=new Date;function on(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=function(e){return t(e=new Date(+e)),e},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,a){var o,s=[];if(n=i.ceil(n),a=null==a?1:Math.floor(a),!(n<r&&a>0))return s;do{s.push(o=new Date(+n)),e(n,a),t(n)}while(o<n&&n<r);return s},i.filter=function(n){return on((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 rn.setTime(+e),an.setTime(+r),t(rn),t(an),Math.floor(n(rn,an))},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}var sn=864e5,ln=6048e5,un=on((function(t){t.setHours(0,0,0,0)}),(function(t,e){t.setDate(t.getDate()+e)}),(function(t,e){return(e-t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/sn}),(function(t){return t.getDate()-1})),cn=un;function dn(t){return on((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-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/ln}))}un.range;var fn=dn(0),pn=dn(1),hn=dn(2),mn=dn(3),gn=dn(4),vn=dn(5),yn=dn(6);fn.range,pn.range,hn.range,mn.range,gn.range,vn.range,yn.range;var bn=on((function(t){t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,e){t.setFullYear(t.getFullYear()+e)}),(function(t,e){return e.getFullYear()-t.getFullYear()}),(function(t){return t.getFullYear()}));bn.every=function(t){return isFinite(t=Math.floor(t))&&t>0?on((function(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,n){e.setFullYear(e.getFullYear()+n*t)})):null};var _n=bn;bn.range;var wn=on((function(t){t.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCDate(t.getUTCDate()+e)}),(function(t,e){return(e-t)/sn}),(function(t){return t.getUTCDate()-1})),xn=wn;function Cn(t){return on((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)/ln}))}wn.range;var An=Cn(0),En=Cn(1),kn=Cn(2),Tn=Cn(3),Ln=Cn(4),Dn=Cn(5),Fn=Cn(6);An.range,En.range,kn.range,Tn.range,Ln.range,Dn.range,Fn.range;var Sn=on((function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCFullYear(t.getUTCFullYear()+e)}),(function(t,e){return e.getUTCFullYear()-t.getUTCFullYear()}),(function(t){return t.getUTCFullYear()}));Sn.every=function(t){return isFinite(t=Math.floor(t))&&t>0?on((function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n*t)})):null};var Mn=Sn;function Nn(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 Un(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 On(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}Sn.range;var Hn,Bn,Rn,jn={"-":"",_:" ",0:"0"},In=/^\s*\d+/,zn=/^%/,Pn=/[\\^$*+?|[\]().{}]/g;function $n(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function qn(t){return t.replace(Pn,"\\$&")}function Vn(t){return new RegExp("^(?:"+t.map(qn).join("|")+")","i")}function Yn(t){for(var e={},n=-1,r=t.length;++n<r;)e[t[n].toLowerCase()]=n;return e}function Wn(t,e,n){var r=In.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Gn(t,e,n){var r=In.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Zn(t,e,n){var r=In.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Xn(t,e,n){var r=In.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Jn(t,e,n){var r=In.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Kn(t,e,n){var r=In.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Qn(t,e,n){var r=In.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function tr(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 er(t,e,n){var r=In.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function nr(t,e,n){var r=In.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function rr(t,e,n){var r=In.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function ir(t,e,n){var r=In.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function ar(t,e,n){var r=In.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function or(t,e,n){var r=In.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function sr(t,e,n){var r=In.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function lr(t,e,n){var r=In.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function ur(t,e,n){var r=In.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function cr(t,e,n){var r=zn.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function dr(t,e,n){var r=In.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function fr(t,e,n){var r=In.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function pr(t,e){return $n(t.getDate(),e,2)}function hr(t,e){return $n(t.getHours(),e,2)}function mr(t,e){return $n(t.getHours()%12||12,e,2)}function gr(t,e){return $n(1+cn.count(_n(t),t),e,3)}function vr(t,e){return $n(t.getMilliseconds(),e,3)}function yr(t,e){return vr(t,e)+"000"}function br(t,e){return $n(t.getMonth()+1,e,2)}function _r(t,e){return $n(t.getMinutes(),e,2)}function wr(t,e){return $n(t.getSeconds(),e,2)}function xr(t){var e=t.getDay();return 0===e?7:e}function Cr(t,e){return $n(fn.count(_n(t)-1,t),e,2)}function Ar(t){var e=t.getDay();return e>=4||0===e?gn(t):gn.ceil(t)}function Er(t,e){return t=Ar(t),$n(gn.count(_n(t),t)+(4===_n(t).getDay()),e,2)}function kr(t){return t.getDay()}function Tr(t,e){return $n(pn.count(_n(t)-1,t),e,2)}function Lr(t,e){return $n(t.getFullYear()%100,e,2)}function Dr(t,e){return $n((t=Ar(t)).getFullYear()%100,e,2)}function Fr(t,e){return $n(t.getFullYear()%1e4,e,4)}function Sr(t,e){var n=t.getDay();return $n((t=n>=4||0===n?gn(t):gn.ceil(t)).getFullYear()%1e4,e,4)}function Mr(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+$n(e/60|0,"0",2)+$n(e%60,"0",2)}function Nr(t,e){return $n(t.getUTCDate(),e,2)}function Ur(t,e){return $n(t.getUTCHours(),e,2)}function Or(t,e){return $n(t.getUTCHours()%12||12,e,2)}function Hr(t,e){return $n(1+xn.count(Mn(t),t),e,3)}function Br(t,e){return $n(t.getUTCMilliseconds(),e,3)}function Rr(t,e){return Br(t,e)+"000"}function jr(t,e){return $n(t.getUTCMonth()+1,e,2)}function Ir(t,e){return $n(t.getUTCMinutes(),e,2)}function zr(t,e){return $n(t.getUTCSeconds(),e,2)}function Pr(t){var e=t.getUTCDay();return 0===e?7:e}function $r(t,e){return $n(An.count(Mn(t)-1,t),e,2)}function qr(t){var e=t.getUTCDay();return e>=4||0===e?Ln(t):Ln.ceil(t)}function Vr(t,e){return t=qr(t),$n(Ln.count(Mn(t),t)+(4===Mn(t).getUTCDay()),e,2)}function Yr(t){return t.getUTCDay()}function Wr(t,e){return $n(En.count(Mn(t)-1,t),e,2)}function Gr(t,e){return $n(t.getUTCFullYear()%100,e,2)}function Zr(t,e){return $n((t=qr(t)).getUTCFullYear()%100,e,2)}function Xr(t,e){return $n(t.getUTCFullYear()%1e4,e,4)}function Jr(t,e){var n=t.getUTCDay();return $n((t=n>=4||0===n?Ln(t):Ln.ceil(t)).getUTCFullYear()%1e4,e,4)}function Kr(){return"+0000"}function Qr(){return"%"}function ti(t){return+t}function ei(t){return Math.floor(+t/1e3)}function ni(t){throw new TypeError("Expected a value of type string but got a value of type "+typeof t)}function ri(t){return function(e){return"string"!=typeof e&&ni(e),(e=e.trim())?t(e):null}}Hn=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,s=t.months,l=t.shortMonths,u=Vn(i),c=Yn(i),d=Vn(a),f=Yn(a),p=Vn(o),h=Yn(o),m=Vn(s),g=Yn(s),v=Vn(l),y=Yn(l),b={a:function(t){return o[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:null,d:pr,e:pr,f:yr,g:Dr,G:Sr,H:hr,I:mr,j:gr,L:vr,m:br,M:_r,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:ti,s:ei,S:wr,u:xr,U:Cr,V:Er,w:kr,W:Tr,x:null,X:null,y:Lr,Y:Fr,Z:Mr,"%":Qr},_={a:function(t){return o[t.getUTCDay()]},A:function(t){return a[t.getUTCDay()]},b:function(t){return l[t.getUTCMonth()]},B:function(t){return s[t.getUTCMonth()]},c:null,d:Nr,e:Nr,f:Rr,g:Zr,G:Jr,H:Ur,I:Or,j:Hr,L:Br,m:jr,M:Ir,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:ti,s:ei,S:zr,u:Pr,U:$r,V:Vr,w:Yr,W:Wr,x:null,X:null,y:Gr,Y:Xr,Z:Kr,"%":Qr},w={a:function(t,e,n){var r=p.exec(e.slice(n));return r?(t.w=h[r[0].toLowerCase()],n+r[0].length):-1},A:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=f[r[0].toLowerCase()],n+r[0].length):-1},b:function(t,e,n){var r=v.exec(e.slice(n));return r?(t.m=y[r[0].toLowerCase()],n+r[0].length):-1},B:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=g[r[0].toLowerCase()],n+r[0].length):-1},c:function(t,n,r){return A(t,e,n,r)},d:rr,e:rr,f:ur,g:Qn,G:Kn,H:ar,I:ar,j:ir,L:lr,m:nr,M:or,p:function(t,e,n){var r=u.exec(e.slice(n));return r?(t.p=c[r[0].toLowerCase()],n+r[0].length):-1},q:er,Q:dr,s:fr,S:sr,u:Gn,U:Zn,V:Xn,w:Wn,W:Jn,x:function(t,e,r){return A(t,n,e,r)},X:function(t,e,n){return A(t,r,e,n)},y:Qn,Y:Kn,Z:tr,"%":cr};function x(t,e){return function(n){var r,i,a,o=[],s=-1,l=0,u=t.length;for(n instanceof Date||(n=new Date(+n));++s<u;)37===t.charCodeAt(s)&&(o.push(t.slice(l,s)),null!=(i=jn[r=t.charAt(++s)])?r=t.charAt(++s):i="e"===r?" ":"0",(a=e[r])&&(r=a(n,i)),o.push(r),l=s+1);return o.push(t.slice(l,s)),o.join("")}}function C(t,e){return function(n){var r,i,a=On(1900,void 0,1);if(A(a,t,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("s"in a)return new Date(1e3*a.s+("L"in a?a.L:0));if(e&&!("Z"in a)&&(a.Z=0),"p"in a&&(a.H=a.H%12+12*a.p),void 0===a.m&&(a.m="q"in a?a.q:0),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(i=(r=Un(On(a.y,0,1))).getUTCDay(),r=i>4||0===i?En.ceil(r):En(r),r=xn.offset(r,7*(a.V-1)),a.y=r.getUTCFullYear(),a.m=r.getUTCMonth(),a.d=r.getUTCDate()+(a.w+6)%7):(i=(r=Nn(On(a.y,0,1))).getDay(),r=i>4||0===i?pn.ceil(r):pn(r),r=cn.offset(r,7*(a.V-1)),a.y=r.getFullYear(),a.m=r.getMonth(),a.d=r.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),i="Z"in a?Un(On(a.y,0,1)).getUTCDay():Nn(On(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(i+5)%7:a.w+7*a.U-(i+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,Un(a)):Nn(a)}}function A(t,e,n,r){for(var i,a,o=0,s=e.length,l=n.length;o<s;){if(r>=l)return-1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(a=w[i in jn?e.charAt(o++):i])||(r=a(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return b.x=x(n,b),b.X=x(r,b),b.c=x(e,b),_.x=x(n,_),_.X=x(r,_),_.c=x(e,_),{format:function(t){var e=x(t+="",b);return e.toString=function(){return t},e},parse:function(t){var e=C(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=x(t+="",_);return e.toString=function(){return t},e},utcParse:function(t){var e=C(t+="",!0);return e.toString=function(){return t},e}}}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),Hn.format,Hn.parse,Bn=Hn.utcFormat,Rn=Hn.utcParse;var ii=new Date(1972,3,27,19,45,5),ai={"%b %d":[{regex:/^june\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(t){return new Date(null,5,t.split(/\s/)[1])}},{regex:/^july\s(3[01]|[12][0-9]|0?[1-9])$/i,toDate:function(t){return new Date(null,6,t.split(/\s/)[1])}},{regex:/^sept\s(30|[12][0-9]|0?[1-9])$/i,toDate:function(t){return new Date(null,8,t.split(/\s/)[1])}}],"%d %b":[{regex:/^(0?[1-9]|[1-9][0-9])\sjune$/i,toDate:function(t){return new Date(null,5,t.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\sjuly$/i,toDate:function(t){return new Date(null,6,t.split(/\s/)[0])}},{regex:/^(0?[1-9]|[1-9][0-9])\ssept$/i,toDate:function(t){return new Date(null,8,t.split(/\s/)[0])}}]};function oi(t){return function(e){var n=null;return t.forEach((function(t){e.match(t.regex)&&(n=t.toDate(e))})),n}}function si(t,e){var n,r=Rn(t),i=Bn(t);return n=ri("function"==typeof e?function(t){return e(t,null!==r(t))}:function(t){return null!==r(t)}),Object.freeze({test:n,parse:ri((function(e){return r(e)||(ai[t]?oi(ai[t])(e):null)})),format:function(t){return i(t)},type:"datetime",description:t,id:"datetime$"+t,example:i(ii)})}var li=Object.freeze([si("%Y-%m-%dT%H:%M:%S.%LZ"),si("%Y-%m-%d %H:%M:%S"),si("%Y-%m-%dT%H:%M:%S"),si("%Y-%m-%dT%H:%M:%SZ"),si("%d/%m/%Y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&n[2]>=1e3})),si("%d/%m/%Y %H:%M",(function(t,e){if(!e)return!1;var n=t.split(/[/ :]/).map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&n[2]>=1e3&&n[3]>=0&&n[3]<24&&n[4]>=0&&n[4]<60})),si("%d/%m/%y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&!isNaN(n[2])})),si("%m/%d/%Y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&n[2]>=1e3})),si("%m/%d/%Y %H:%M",(function(t,e){if(!e)return!1;var n=t.split(/[/ :]/).map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&n[2]>=1e3&&n[3]>=0&&n[3]<24&&n[4]>=0&&n[4]<60})),si("%m/%d/%y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&!isNaN(n[2])})),si("%Y/%m/%d",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>=1e3&&n[1]>0&&n[1]<=12&&n[2]>0&&n[2]<=31})),si("%d-%m-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&n[2]>=1e3})),si("%d-%m-%y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12&&!isNaN(n[2])})),si("%m-%d-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&n[2]>=1e3})),si("%m-%d-%y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>0&&n[1]<=31&&!isNaN(n[2])})),si("%Y-%m-%d",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>=1e3&&n[1]>0&&n[1]<=12&&n[2]>0&&n[2]<=31})),si("%Y-%m",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>=1e3&&n[1]>0&&n[1]<=12})),si("%d %b %Y",(function(t,e){if(!e)return!1;var n=t.split(" ").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),si("%d %B %Y",(function(t,e){if(!e)return!1;var n=t.split(" ").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),si("%d %b %y"),si("%-d %b ’%y"),si("%d %B %y"),si("%d-%b-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),si("%d-%B-%Y",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[2]>=1e3})),si("%d-%b-%y"),si("%d-%B-%y"),si("%m/%Y",(function(t,e){if(!e)return!1;var n=t.split("/").map(parseFloat);return n[0]>0&&n[0]<=12&&n[1]>=1e3})),si("%m/%y"),si("%b %Y",(function(t,e){return!!e&&t.split(" ").map(parseFloat)[1]>=1e3})),si("%B %Y",(function(t,e){return!!e&&t.split(" ").map(parseFloat)[1]>=1e3})),si("%b-%y"),si("%b %y"),si("%B %y"),si("%d %b",(function(t,e){return!!e||!!oi(ai["%d %b"])(t)})),si("%d %B"),si("%b %d",(function(t,e){return!!e||!!oi(ai["%b %d"])(t)})),si("%B %d"),si("%d-%m",(function(t,e){if(!e)return!1;var n=t.split("-").map(parseFloat);return n[0]>0&&n[0]<=31&&n[1]>0&&n[1]<=12})),si("%m-%d"),si("%d/%m"),si("%m/%d"),si("%b %d %Y"),si("%b %d %Y, %-I.%M%p"),si("%Y",(function(t,e){if(!e)return!1;var n=parseFloat(t);return n>1499&&n<2200})),si("%B"),si("%b"),si("%X"),si("%I:%M %p"),si("%-I.%M%p"),si("%H:%M"),si("%H:%M:%S"),si("%-I%p"),si("Q%q %Y",(function(t,e){return!!e&&6===t.replace(/\s/g,"").length})),si("%Y Q%q",(function(t,e){return!!e&&6===t.replace(/\s/g,"").length}))]);function ui(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}var ci,di=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function fi(t){if(!(e=di.exec(t)))throw new Error("invalid format: "+t);var e;return new pi({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function pi(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 hi(t,e){var n=ui(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}fi.prototype=pi.prototype,pi.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 mi={"%":function(t,e){return(100*t).toFixed(e)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},g:function(t,e){return t.toPrecision(e)},o:function(t){return Math.round(t).toString(8)},p:function(t,e){return hi(100*t,e)},r:hi,s:function(t,e){var n=ui(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(ci=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+ui(t,Math.max(0,e+a-1))[0]},X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}};function gi(t){return t}var vi=Array.prototype.map,yi=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function bi(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?gi:(e=vi.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,a=[],o=0,s=e[0],l=0;i>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?gi:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(vi.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",u=void 0===t.minus?"-":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function d(t){var e=(t=fi(t)).fill,n=t.align,d=t.sign,f=t.symbol,p=t.zero,h=t.width,m=t.comma,g=t.precision,v=t.trim,y=t.type;"n"===y?(m=!0,y="g"):mi[y]||(void 0===g&&(g=12),v=!0,y="g"),(p||"0"===e&&"="===n)&&(p=!0,e="0",n="=");var b="$"===f?i:"#"===f&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",_="$"===f?a:/[%p]/.test(y)?l:"",w=mi[y],x=/[defgprs%]/.test(y);function C(t){var i,a,l,f=b,C=_;if("c"===y)C=w(t)+C,t="";else{var A=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:w(Math.abs(t),g),v&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),A&&0==+t&&"+"!==d&&(A=!1),f=(A?"("===d?d:u:"-"===d||"("===d?"":d)+f,C=("s"===y?yi[8+ci/3]:"")+C+(A&&"("===d?")":""),x)for(i=-1,a=t.length;++i<a;)if(48>(l=t.charCodeAt(i))||l>57){C=(46===l?o+t.slice(i+1):t.slice(i))+C,t=t.slice(0,i);break}}m&&!p&&(t=r(t,1/0));var E=f.length+t.length+C.length,k=E<h?new Array(h-E+1).join(e):"";switch(m&&p&&(t=r(k+t,k.length?h-C.length:1/0),k=""),n){case"<":t=f+t+C+k;break;case"=":t=f+k+t+C;break;case"^":t=k.slice(0,E=k.length>>1)+f+t+C+k.slice(E);break;default:t=k+f+t+C}return s(t)}return g=void 0===g?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),C.toString=function(){return t+""},C}return{format:d,formatPrefix:function(t,e){var n,r=d(((t=fi(t)).type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor((n=e,((n=ui(Math.abs(n)))?n[1]:NaN)/3)))),a=Math.pow(10,-i),o=yi[8+i/3];return function(t){return r(a*t)+o}}}}var _i={test:ri((function(t){return/^(\+|-)?\d{1,3}(,\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:ri((function(t){return parseFloat(t.replace(/,/g,""))})),description:"Comma thousand separator, point decimal mark",thousand_separator:",",decimal_mark:".",id:"number$comma_point",example:"12,235.56"},wi={test:ri((function(t){return/^(\+|-)?\d{1,3}(\s\d{3})*(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:ri((function(t){return parseFloat(t.replace(/\s/g,""))})),description:"Space thousand separator, point decimal mark",thousand_separator:" ",decimal_mark:".",id:"number$space_point",example:"12 235.56"},xi={test:ri((function(t){return/^(\+|-)?\d+(\.\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:ri((function(t){return parseFloat(t)})),description:"No thousand separator, point decimal mark",thousand_separator:"",decimal_mark:".",id:"number$none_point",example:"12235.56"},Ci={test:ri((function(t){return/^(\+|-)?\d{1,3}(\.\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:ri((function(t){return parseFloat(t.replace(/\./g,"").replace(/,/,"."))})),description:"Point thousand separator, comma decimal mark",thousand_separator:".",decimal_mark:",",id:"number$point_comma",example:"12.235,56"},Ai={test:ri((function(t){return/^(\+|-)?\d{1,3}(\s\d{3})*(,\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:ri((function(t){return parseFloat(t.replace(/\s/g,"").replace(/,/,"."))})),description:"Space thousand separator, comma decimal mark",thousand_separator:" ",decimal_mark:",",id:"number$space_comma",example:"12 235,56"},Ei={test:ri((function(t){return/^(\+|-)?\d+(,\d+)?((e|E)(\+|-)?\d+)?$/.test(t.trim())})),parse:ri((function(t){return parseFloat(t.replace(/,/,"."))})),description:"No thousand separator, comma decimal mark",thousand_separator:"",decimal_mark:",",id:"number$none_comma",example:"12235,56"},ki=Object.freeze([_i,wi,Ci,Ai,xi,Ei]);ki.forEach((function(t){t.type="number",t.format=function(t){var e,n,r=bi({decimal:t.decimal_mark,thousands:t.thousand_separator,grouping:[3],currency:["",""]});return function(t,i){return null===t?"":(i||(i=",.2f"),i!==n&&(n=i,e=r.format(n)),e(t))}}(t),Object.freeze(t)}));var Ti,Li=Object.freeze({test:function(t){return"string"==typeof t||ni(t)},parse:function(t){return"string"==typeof t?t:ni(t)},format:function(t){if("string"==typeof t)return t},type:"string",description:"Arbitrary string",id:"string$arbitrary_string"}),Di=Object.freeze({datetime:li,number:ki}),Fi=Object.freeze(["datetime","number","string"]),Si=Object.freeze({n_max:250,n_failing_values:0,failure_fraction:.05,sort:!0}),Mi=Object.freeze(Object.keys(Si));function Ni(t,e){return t.index-e.index}function Ui(t,e){return e.n_success-t.n_success||Ni(t,e)}function Oi(t){return(""+t).trim()}function Hi(t){return void 0===t?function(t){return Oi(t)}:"function"==typeof t?function(e,n){return Oi(t(e,n))}:function(e){return Oi(e[""+t])}}function Bi(t){t?Array.isArray(t)||(t=[t]):t=Fi;var e=t.reduce((function(t,e){var n=Di[e];return n&&Array.prototype.push.apply(t,n),t}),[]),n=-1!==t.indexOf("string"),r=Mi.reduce((function(t,e){return t[e]=Si[e],t}),{}),i=function(t,i){i=Hi(i);var a=t.map(i).filter((function(t){return t}));if(!a.length)return n?[Li]:[];var o=Math.min(r.n_max,a.length),s=Math.floor(o*r.failure_fraction),l=r.n_failing_values,u=r.sort?Ui:Ni,c=e.slice().reduce((function(t,e,n){for(var r=c=0,i=[],u=!1,c=0;c<o;c++){var d=a[c];if(!e.test(d)&&(++r>s?u=!0:-1===i.indexOf(d)&&(i.push(d),i.length>l&&(u=!0)),u))break}return u||t.push({interp:e,n_success:o-r,index:n}),t}),[]).sort(u).map((function(t){return t.interp}));return n&&c.push(Li),c};return Mi.forEach((function(t){var e;i[(e=t,e.replace(/_(\w)/g,(function(t,e){return e.toUpperCase()})))]=function(e){return void 0===e?r[t]:(r[t]=e,i)}})),i}function Ri(t,e,n,r){var i=[],a=[],o=0,s=[],l={};function u(t,e){if(!l[t])return{};var n=l[t];return n[e]?n[e]:{}}for(var c in s.column_names={},s.metadata={},n){var d={},f=n[c];if(f){for(let t=0;t<f.length;t++){const e=f[t].type_id,n=f[t].output_format_id,r=n&&"auto"!==n?n:e;d[f[t].index]={type_id:e,output_format_id:r}}l[c]=d}}for(var p in t)if(null!==t[p]&&(void 0!==t[p].columns||void 0!==t[p].column)){var h=t[p];if(h.template_data_binding=r[p],h.key=p,h.data_table_id in e){var m=e[h.data_table_id];if(0!=m.length){if("columns"in h&&null!=h.columns){var g=m[0].length;h.columns=h.columns.filter((function(t){return t<g})),s.column_names[p]=h.columns.map((function(t){return m[0][t]})),s.metadata[p]=h.columns.map((function(t){const{type_id:e,output_format_id:n}=u(h.data_table_id,t);return e?{type:e.split("$")[0],type_id:e,output_format_id:n}:null}))}else{if(!("column"in h)||null==h.column)throw new Error("Data binding includes no column(s) specification: "+JSON.stringify(h));{s.column_names[p]=m[0][h.column];const{type_id:t,output_format_id:e}=u(h.data_table_id,h.column);t&&(s.metadata[p]={type:t.split("$")[0],type_id:t,output_format_id:e})}}-1==a.indexOf(h.data_table_id)&&(a.push(h.data_table_id),o=Math.max(o,m.length-1)),i.push(h)}else console.warn("Empty data table")}else{var v=[];for(var y in e)v.push(y);console.error("Data table id "+h.data_table_id+" not in "+JSON.stringify(v))}}function b(t,e,n){if(!t.template_data_binding.data_type)return n;var r=function(t,e){const{type_id:n}=u(t,e);if(n)return Bi.getInterpretation(n)}(t.data_table_id,e);r&&"number"==r.type&&(n=$i(n));var i=r?r.parse(n):n;return Number.isNaN(i)&&(i=null),i}for(var _=0;_<o;_++){for(var w={},x=0;x<i.length;x++){var C=e[(h=i[x]).data_table_id];_+1>=C.length||("columns"in h&&null!=h.columns?w[h.key]=h.columns.filter((function(t){return t<C[_+1].length})).map((function(t){return b(h,t,C[_+1][t])})):"column"in h&&null!=h.column&&(h.column>=C[_+1].length?w[h.key]=b(h,h.column,""):w[h.key]=b(h,h.column,C[_+1][h.column])))}s.push(w)}return s}function ji(t){return function(t){for(var e=t.length,n=e>0?t[0].length:0,r=[],i=0;i<n;i++){for(var a=[],o=0;o<e;o++)a.push(t[o][i]);r.push(a)}return r}(t).map((function(t,e){const n=function(t){const e=t.length;return e>100?t.slice(10,e-10):e>50?t.slice(5,e-5):e>30?t.slice(4,e-4):e>20?t.slice(3,e-3):e>10?t.slice(2,e-2):e>1?t.slice(1,e):t.slice(0,1)}(t);let r;r=n.length>2e3?function(t,e){if(t.length<=2*e)return t;const n=function(t){let e=t;return function(){e|=0,e=e+1831565813|0;var t=Math.imul(e^e>>>15,1|e);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}(t.length);for(;t.length>e;){const e=Math.floor(n()*t.length);t.splice(e,1)}return t}(n,1e3):n;const i=(a=r,o=a.filter((function(t){return t&&!zi.includes(t.trim())})).map($i),Pi(o))[0].id;var a,o;return{type_id:i,index:e,output_format_id:i}}))}function Ii(t){for(var e=t.length;e-- >1&&(!t[e]||!t[e].length||Array.isArray(t[e])&&-1==t[e].findIndex((function(t){return null!==t&&""!==t})));)t.splice(e,1);return t}Bi.DATETIME_IDS=Object.freeze(li.map((function(t){return t.id}))),Bi.NUMBER_IDS=Object.freeze(ki.map((function(t){return t.id}))),Bi.STRING_IDS=Object.freeze([Li.id]),Bi.getInterpretation=(Ti=li.concat(ki,Li).reduce((function(t,e){return t[e.id]=e,t}),{}),function(t){return Ti[t]}),Bi._createAccessorFunction=Hi,Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError("this is null or not defined");var e=Object(this),n=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var r=arguments[1],i=0;i<n;){var a=e[i];if(t.call(r,a,i,e))return i;i++}return-1},configurable:!0,writable:!0});var zi=["#DIV/0","#N/A","#NAME?","#NULL!","#NUM!","#REF!","#VALUE!","#ERROR!"],Pi=Bi().nMax(1/0).nFailingValues(8).failureFraction(.1);function $i(t){return(t=t||"").replace(/[€£$¥%º]/g,"")}let qi,Vi={};const Yi=t=>{const e=At(".dialog");if(t.which in Vi){var n=Vi[t.which];n.callback&&n.callback(qi.node().value),e.remove(),t.preventDefault()}};function Wi(t,e,{buttons:n=[{text:"Okay",keyCode:13}],is_html:r=!1,upgrade:i=null,is_loading:a=!1,width:o="420px"}={}){var s=At("body").append("div").attr("class","dialog").attr("tabindex",0).on("mousedown",(function(t){for(var e=t.target,n=!1;e&&"dialog"!=e.className;)"dialog"==(e=e.parentNode).className&&(n=!0);n||s.remove()})),l=s.append("div").attr("class","dialog-inner").style("width",o).on("click",(function(t){t.stopPropagation()})),u=l.append("div").attr("class","text"+(a?" loading":""));if("string"==typeof t?u.append("h1").text(t):t instanceof HTMLElement&&u.append("h1").append((()=>t)),"string"==typeof e)qi=r?u.append("div").classed("loading-spinner",a).html(e):u.append("p").text(e);else if(e instanceof HTMLElement)qi=u.append((()=>e));else if("object"==typeof e){if(qi=u.append(e.type),e.value&&(qi.node().value=e.value),e.attributes)for(var c in e.attributes)qi.attr(c,e.attributes[c]);qi.node().focus()}var d=l;null!=i&&"object"==typeof i&&function(t,e,n,r){r&&t.classed("business",!0);var i=t.append("div").attr("class","text");i.append("p").text(e),i.append("ul").selectAll("li").data(n).enter().append("li").html((function(t){return t})).append("i").attr("class","fa fa-check")}(d=d.append("div").attr("class","upgrade"),i.message,i.list,i.is_business);var f=d.append("div").attr("class","btns"+(a?" loading":""));return Vi={},n.forEach((function(t){var e=f.append(t.tag_name||"div").attr("class","btn").attr("data-testid","dialog-button").style("margin-right",a?"0":"0.75em").text(t.text).on("click",(function(){t.callback&&t.callback(qi.node().value,s),s.remove()}));t.class&&e.classed(t.class,!0),t.keyCode&&(Vi[t.keyCode]=t),t.href&&e.attr("href",t.href),t.target&&e.attr("target",t.target),t.fa_icon&&e.append("i").lower().attr("class","fa "+t.fa_icon)})),s.node().addEventListener("keydown",Yi),s.node().focus(),s}var Gi="Add new value: ";function Zi(t,e,n,{allow_other_option:r=!1,custom_renderer:i=null,match_anywhere:a=!1}={}){if(t.setAttribute("data-autocomplete",e),t.setAttribute("autocomplete","off"),!document.getElementById(e)){const n=Et("i").classed("fa fa-chevron-down clickable",!0),r=Et("div").classed("dropdown autocomplete",!0).attr("id",e);t.insertAdjacentHTML("afterend",n.node().outerHTML+r.node().outerHTML)}var o,s=At(document.getElementById(e));s.classed("click-to-open",!0);var l=s.append("div").attr("class","dropdown-list");function u(t){if(1===t.length)return"dropdown-category";var e="dropdown-item";return o&&t[0]===o&&(e+=" current"),e}function c(t){l.selectAll("div").remove(),l.selectAll("div").data(t).enter().append("div").attr("class",u).attr("data-value",(function(t){return"string"==typeof t?t||null:t[1]})).each((function(t){const e=At(this);if(!i){const n=Array.isArray(t)?t[0]:t;return void e.text(n)}let n=i(t,this);if(n){if(Array.isArray(n)||(n=[n]),n.find((t=>"string"!=typeof t&&!(t instanceof HTMLElement))))throw new Error("Autocomplete elements must be strings or HTMLElements");e.node().append(...n)}})),t.length||l.append("div").attr("class","dropdown-item disabled").text("No matches found")}function d(){s.classed("open",!1)}function f(t){var e=t.textContent;return 0===e.indexOf(Gi)&&(e=e.substr(Gi.length)),e}return s.on("mousedown",(function(e){var n=e.target;n.hasAttribute("data-value")?(t.value=f(n),t.setAttribute("data-value",n.getAttribute("data-value")),d(),At(t).dispatch("change")):e.preventDefault()})),At(t).on("keydown.autocomplete",(function(e){var n,r;9==e.keyCode||13==e.keyCode?(n=l.select(".selected")).empty()||(t.value=f(n.node()),t.setAttribute("data-value",n.attr("data-value")),d(),At(t).dispatch("change"),t.blur()):40==e.keyCode?((n=l.select(".selected")).empty()||(r=n.node().nextSibling),r||(r=l.select(".dropdown-item[data-value]").node()),l.selectAll(".selected").classed("selected",!1),At(r).classed("selected",!0)):38==e.keyCode&&((n=l.select(".selected")).empty()||(r=n.node().previousSibling),r||(r=l.select(".dropdown-item:last-child").node()),l.selectAll(".selected").classed("selected",!1),At(r).classed("selected",!0))})).on("input.autocomplete",(function(){var e,i,o=t.value,s=o.toLowerCase(),l=!1;if(At(t).attr("data-value",o),i=a?(t,e)=>t.includes(e):(t,e)=>0===t.indexOf(e),o){e=[];for(var u=0;u<n.length;u++){var d=("string"==typeof n[u]?n[u]:n[u][0]).toLowerCase();d==s&&(l=!0),i(d,s)&&e.push(n[u])}r&&!l&&e.unshift([Gi+o,o])}else e=n;c(e)})).on("focus.autocomplete",(function(){o=t.value,c(n),s.classed("open",!0)})).on("blur.autocomplete",d),{options:function(t){if(!arguments.length)return n;c(n=t)}}}var Xi={number:{text:"Number",symbol:"/images/data_type_number.svg"},datetime:{text:"Date/time",symbol:"/images/data_type_date.svg"},string:{text:"Text",symbol:"/images/data_type_string.svg"}};Bi.STRING_IDS[0];var Ji,Ki,Qi,ta=[{full:"#F4B1C5",light:"#FFDDE7"},{full:"#967EC6",light:"#D0C5E5"},{full:"#C67EBD",light:"#E5C5E1"},{full:"#7E91C6",light:"#C5CDE5"},{full:"#7EB0C6",light:"#C5DBE5"},{full:"#7EC69B",light:"#C5E5D2"},{full:"#B3C67E",light:"#DDE5C5"},{full:"#C69B7E",light:"#E5D2C5"}],ea={},na={},ra=0;function ia(t,e){ra=0;var n=!1;t.template_id&&t.dataTables((function(r,i){if(r)return console.error("Failed to get data tables: "+r);na={};var a=t.dataBindingsForCurrentTemplate(),o=t.getDataTableNames(),s=At(".sheet-tab.selected").size()>0?At(".sheet-tab.selected").datum().id:null;Ki.html("");var l=null;"string"!=typeof e[0]&&(e=["Data"].concat(e));for(var u,c=[],d=0;d<e.length;d++){const t=e[d],n=e[d-1],r=!(!n||"string"==typeof n||n.dataset===t.dataset),i=(t.columns||t.column||"").split("::")[0],s="string"==typeof t;if((s||r)&&(void 0!==u&&c.push(u),u={title:s?t:i,description:null,bindings:[],template_sheet:null,visualisation_sheet:null}),s){if(d<e.length-1){var f=e[d+1];"string"==typeof f&&(u.description=f,d+=1)}}else{if(null===u.template_sheet&&i)for(var p in o)if(o[p]===i){u.template_sheet=+p;break}if(null===u.visualisation_sheet){var h=a[t.dataset]&&a[t.dataset][t.key];h&&(u.visualisation_sheet=h.data_table_id)}u.bindings.push(t),d===e.length-1&&c.push(u)}}for(d=0;d<c.length;d++){var m=c[d],g=m.bindings,v=m.visualisation_sheet||m.template_sheet||i[0].id,y=(l=Ki.append("div").attr("class","data-block").attr("data-sheet",o[v]).style("display",v===s?null:"none")).append("h2").attr("class","no-select");y.append("i").attr("class","fa fa-table"),y.append("span").text(" "+m.title),m.description&&l.append("p").text(m.description);var b=l.append("div").attr("class","data-bindings-header");b.append("p").attr("class","data-bindings-title").text("Select columns to visualise");for(var _=0;_<g.length;_++){var w=g[_];w.data_type&&(n=!0);var x=a[w.dataset]&&a[w.dataset][w.key],C=x?x.data_table_id:v;na[w.dataset]||(na[w.dataset]={}),na[w.dataset][w.key]=C,C!==v&&C===s&&l.style("display",null),aa(l.append("div"),w,x,o,C!==s)}n&&b.append("p").attr("class","data-bindings-reset clickable").html("<i class='fa fa-magic'></i> Auto set columns").on("click",(function(){Wi("Automatically choose your columns","<i class='fa fa-magic'></i> Flourish will interpret your data to determine which columns to visualize",{is_html:!0,buttons:[{text:"Continue",keyCode:13,class:"primary",callback:function(){Ji.spreadsheet.inferDataBindings()}},{text:"Cancel",keyCode:27,class:"secondary"}]})}))}Ji.spreadsheet&&(Ji.spreadsheet.updateHighlights(),Ji.spreadsheet.updateTabs())}))}function aa(t,e,n,r,i){ta[ra]||(ra=0),t.attr("class","settings-option option-type-"+e.type).style("display",i?"none":null);var a=null==n?"":nn(n,r,!1,e.optional);ea[e.dataset]||(ea[e.dataset]={}),ea[e.dataset][e.key]=ra;var o="column"===e.type&&!e.optional,s=o&&!n;t.classed("empty-required-binding",s);var l=t.append("div").attr("class","data-binding-title").on("click",(function(){At(this).select("input").node().focus()}));l.append("h3").text(e.name).append("i").attr("class","fa fa-question setting-tooltip").style("display",e.description||e.data_type?null:"none"),"column"!=e.type||e.optional||l.select("h3").append("span").attr("class","required").text("Required"),l.append("input").attr("id","data-binding-"+e.dataset+"-"+e.key).attr("name",e.dataset+"-"+e.key).attr("disabled",!Ji.visualisation.can_edit||null).attr("autocomplete","off").attr("title",'Type in column IDs here, for example "A" or "A,B,D" or "A-D"').each((function(){this.value=a})).attr("data-value",a).attr("type","text").call(function(t){return function(e){e.on("change",(function(){Re.hide(),function(t,e){var n=t.parentElement.parentElement.parentElement.getAttribute("data-sheet"),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 a,o=t.getBoundingClientRect(),s=[o.left-5,o.top+.5*o.height];if(t.value||"column"!=i.type){try{a=function(t,e){var n={};if(!(t.type in t)){if(t.optional)return n;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 a=t[t.type].substr(r+2);if("column"==t.type)n.column=Xe(a,t.optional);else{if("columns"!=t.type)throw new Error("Unknown data binding type: "+t.type);n.columns=tn(a)}return n}(i,Ji.visualisation.getDataTableIds());var l=nn(a,Ji.visualisation.getDataTableNames(),!1,e.optional);t.value.toUpperCase()!==l&&(t.value=l)}catch(e){return console.error("Failed to parse data binding",e),Re.point(s).text(e.message).draw(),t.value=t.getAttribute("data-value"),void(Qi=!0)}if(At(t.parentElement.parentElement).classed("empty-required-binding",!1),!a.data_table_id)return t.value=t.getAttribute("data-value"),Re.point(s).text("No such data table").draw(),void(Qi=!0);if(e.data_type){const n=Ji.spreadsheet.getTypeAnnotatedColumns();if("column"===i.type){const r=n[a.column];if(!r)return Re.point(s).html(`<h1>Column '${t.value}' does not exist</h1><p>Choose a column from the data table</p>`).draw(),t.value=t.getAttribute("data-value"),void(Qi=!0);if(sa(e,r))return t.value=t.getAttribute("data-value"),Re.point(s).html(`\n\t\t\t\t\t\t<h1>This column selection does not accept ${la([r.type])} columns</h1>\n\t\t\t\t\t\t<p style="font-size:1em; margin-top:0.75em;">Choose a different column or check/change the column’s type in the header row with the following types:</p>\n\t\t\t\t\t\t<div style="font-size: 1em; margin-top: 0.75em;">${la(e.data_type)}</div>\n\t\t\t\t\t`).draw(),void(Qi=!0)}else{const r=n.filter((t=>a.columns.includes(t.index))).filter((t=>sa(e,t)));if(r.length){t.value=t.getAttribute("data-value");var u=r.map((t=>t.type)).reduce(((t,e)=>t.includes(e)?t:[...t,e]),[]),c=u.reduce(((t,e,n,r)=>1===r.length?la([e]):(n<r.length-1?t+=`${n>0?",":""} ${la([e])}`:t+=`or ${la([e])}`,t)),"");return Re.point(s).html(`\n\t\t\t\t\t\t<h1>This column selection does not accept ${c} columns</h1>\n\t\t\t\t\t\t<p style="font-size:1em; margin-top:0.75em;">Choose a different column or check/change the column’s type in the header row with the following types:</p>\n\t\t\t\t\t\t<div style="font-size: 1em; margin-top: 0.75em;">${la(e.data_type)}</div>\n\t\t\t\t\t`).draw(),void(Qi=!0)}}}}else if(a=null,!e.optional)return t.value=t.getAttribute("data-value"),Re.point(s).text("This column selection is required").draw(),void(Qi=!0);Ji.spreadsheet.updateTabs();var d={};d[e.dataset]={},d[e.dataset][e.key]=a,oa(d,(function(){t.setAttribute("data-value",t.value);var e=ua();e?(At(".publish-btn").classed("disabled",!0),At(".republish-btn").classed("disabled",!0),kt(".download-btn").classed("disabled",!0),At("body").classed("impossible",!0)):(At(".publish-btn").classed("disabled",!1),At(".republish-btn").classed("disabled",!1),kt(".download-btn").classed("disabled",!1),At("body").classed("impossible",!1),Ji.visualisation.getState((function(t){Ji.visualisation.prepareData((function(e,n){e?console.error("Failed to prepare data for template"):Ji.preview_pane.getDrawCalled()?Ji.preview_pane.sync({data:n,state:t,update:!0}):(Ji.preview_pane.sync({data:n,state:t,draw:!0}),Ji.preview_pane.setDrawCalled(!0))}))}))),Ji.spreadsheet&&Ji.spreadsheet.updateHighlights(),Ji.template_settings&&(e?Ji.template_settings.setReadOnly():Ji.template_settings.unsetReadOnly(),Ji.template_settings.populate()),Ji.theme_chooser.enableOrDisable()}))}(this,t)})).on("keydown",(function(){Ji.confirm.blank()})).on("focus",(function(){Qi||Re.hide(),Qi=!1,kt(".data-bindings .settings-option").classed("open",!1),At(this.parentElement.parentElement).classed("open",!0)}))}}(e)).style("background",ta[ra].light).style("border-color",ta[ra].full),s&&Ji.template_settings.setReadOnly(),o&&t.append("div").attr("class","data-binding-required").append("p").text("This column selection is required. The visualisation will not update while this field is empty.");var u,c=t.append("div").attr("class","data-binding-description");if(e.description&&c.append("p").text(e.description),e.data_type){var d=c.append("div").attr("class","data-binding-data-types");d.append("p").text("Accepted column types");for(var f=Array.isArray(e.data_type)?e.data_type:[e.data_type],p=0;p<f.length;p++)u="string"==typeof f[p]?f[p]:f[p].type,d.append("span").attr("class","type-symbol data-binding-type-symbol").attr("title",Xi[u].text+" column.").style("background-image","url("+Xi[u].symbol+")")}ra++}function oa(t,e){Ji.confirm.saving(),Ji.visualisation.updateDataBindings(t,(function(t){if(t)return Ji.confirm.error(t.message||t),console.error("Failed to save data binding:",t),void Ji.analytics("event","exception",{description:t.message||t,fatal:!0});Ji.analytics("event","visualisation",{change_data_binding:Ji.visualisation.id}),Ji.confirm.saved(),ca(),e&&e()}))}function sa(t,e){return!(Array.isArray(t.data_type)?t.data_type:[t.data_type]).some((t=>"string"==typeof t?t===e.type:t.type===e.type))}function la(t){return t.map((t=>`\n\t\t<span class="column-type">\n\t\t<span class="type-symbol" title="${Xi[t].text} column" style="background-image: url(${Xi[t].symbol});"></span>\n\t\t<h2>${Xi[t].text}</h2>\n\t\t</span>\n\t\t`)).join("")}function ua(){var t=Ji.visualisation.dataBindingsForCurrentTemplate(),e=Ji.template_data_bindings,n={};return e.forEach((function(t){"string"!=typeof t&&(n[t.dataset]||(n[t.dataset]={}),n[t.dataset][t.key]=t)})),e.some((function(e){if("string"!=typeof e&&"column"===e.type&&!n[e.dataset][e.key].optional)return!t[e.dataset]||null==t[e.dataset][e.key]}))}function ca(t=!0){if(ua())At("body").classed("impossible",!0),At(".empty-label").html("<i class='fa fa-exclamation-triangle'></i> Oops! It looks like one of the required column selections is empty."),At(".empty-details").html("Head over to the <span class='data-tab-icon'><i class='fa fa-table'></i> Data</span> tab to choose a suitable column.");else if(At("body").classed("impossible")){const e=Ji.visualisation?Ji.visualisation:Ji.story;e.status&&e.status.requested_by?Ji.confirm_published.awaitingReview(e.status,e.can_review,Ji.user):Ji.visualisation.embed_url&&t?Ji.confirm_published.edited():(Ji.confirm_published.unpublished(),At("body").classed("impossible",!1),At(".empty-label").text(""),At(".empty-details").text(""))}}var da,fa,pa,ha,ma,ga,va,ya,ba,_a=!1;function wa(t){if(_a&&window.top!==window.self){var e=window;"srcdoc"===e.location.pathname&&(e=e.parent);var n,r=(n={},window._Flourish_template_id&&(n.template_id=window._Flourish_template_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_template_id&&(n.template_id=window.Flourish.app.loaded_template_id),window._Flourish_visualisation_id&&(n.visualisation_id=window._Flourish_visualisation_id),window.Flourish&&window.Flourish.app&&window.Flourish.app.loaded_visualisation&&(n.visualisation_id=window.Flourish.app.loaded_visualisation.id),window.Flourish&&window.Flourish.app&&window.Flourish.app.story&&(n.story_id=window.Flourish.app.story.id,n.slide_count=window.Flourish.app.story.slides.length),window.Flourish&&window.Flourish.app&&window.Flourish.app.current_slide&&(n.slide_index=window.Flourish.app.current_slide.index+1),n),i={sender:"Flourish",method:"customerAnalytics"};for(var a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);for(var a in t)t.hasOwnProperty(a)&&(i[a]=t[a]);e.parent.postMessage(JSON.stringify(i),"*")}}function xa(t){if("function"!=typeof t)throw new Error("Analytics callback is not a function");window.Flourish._analytics_listeners.push(t)}function Ca(){_a=!0;[{event_name:"click",action_name:"click",use_capture:!0},{event_name:"keydown",action_name:"key_down",use_capture:!0},{event_name:"mouseenter",action_name:"mouse_enter",use_capture:!1},{event_name:"mouseleave",action_name:"mouse_leave",use_capture:!1}].forEach((function(t){document.body.addEventListener(t.event_name,(function(){wa({action:t.action_name})}),t.use_capture)}))}function Aa(){if(null==da){var t=function(){var t=window.location;"about:srcdoc"==t.href&&(t=window.parent.location);var e={};return function(t,n,r){for(;r=n.exec(t);)e[decodeURIComponent(r[1])]=decodeURIComponent(r[2])}(t.search.substring(1).replace(/\+/g,"%20"),/([^&=]+)=?([^&]*)/g),e}();da="referrer"in t?/^https:\/\/medium.com\//.test(t.referrer):!("auto"in t)}return da}function Ea(t){var e=t||window.innerWidth;return e>999?650:e>599?575:400}function ka(t){if(t&&window.top!==window.self){var e=window;"srcdoc"==e.location.pathname&&(e=e.parent);var n={sender:"Flourish",method:"scrolly"};if(t)for(var r in t)n[r]=t[r];e.parent.postMessage(JSON.stringify(n),"*")}}function Ta(t,e){if(window.top!==window.self){var n=window;if("srcdoc"==n.location.pathname&&(n=n.parent),fa)return t=parseInt(t,10),void n.parent.postMessage({sentinel:"amp",type:"embed-size",height:t},"*");var r={sender:"Flourish",context:"iframe.resize",method:"resize",height:t,src:n.location.toString()};if(e)for(var i in e)r[i]=e[i];n.parent.postMessage(JSON.stringify(r),"*")}}function La(){return(-1!==navigator.userAgent.indexOf("Safari")||-1!==navigator.userAgent.indexOf("iPhone"))&&-1==navigator.userAgent.indexOf("Chrome")}function Da(t){return"string"==typeof t||t instanceof String}function Fa(t){return"warn"!==t.method?(console.warn("BUG: validateWarnMessage called for method"+t.method),!1):!(null!=t.message&&!Da(t.message))&&!(null!=t.explanation&&!Da(t.explanation))}function Sa(t){return"resize"!==t.method?(console.warn("BUG: validateResizeMessage called for method"+t.method),!1):!!Da(t.src)&&(!!Da(t.context)&&!!("number"==typeof(e=t.height)?!isNaN(e)&&e>=0:Da(e)&&/\d/.test(e)&&/^[0-9]*(\.[0-9]*)?(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|vw|vh|vmin|vmax|%)?$/i.test(e)));var e}function Ma(t){throw new Error("Validation for setSetting is not implemented yet; see issue #4328")}function Na(t){return"scrolly"!==t.method?(console.warn("BUG: validateScrolly called for method"+t.method),!1):!!Array.isArray(t.slides)}function Ua(t){return"customerAnalytics"===t.method||(console.warn("BUG: validateCustomerAnalyticsMessage called for method"+t.method),!1)}function Oa(t){return"request-upload"!==t.method?(console.warn("BUG: validateResizeMessage called for method"+t.method),!1):!!Da(t.name)&&!(null!=t.accept&&!Da(t.accept))}function Ha(t,e){var n=function(t){for(var e={warn:Fa,resize:Sa,setSetting:Ma,customerAnalytics:Ua,"request-upload":Oa,scrolly:Na},n={},r=0;r<t.length;r++){var i=t[r];if(!e[i])throw new Error("No validator found for method "+i);n[i]=e[i]}return n}(e);window.addEventListener("message",(function(e){if(null!=e.source&&(e.origin===document.location.origin||e.origin.match(/\/\/localhost:\d+$|\/\/(?:public|app)\.flourish.devlocal$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$|\/\/flourish-user-templates\.com$/))){var r;try{r=JSON.parse(e.data)}catch(t){return void console.warn("Unexpected non-JSON message: "+JSON.stringify(e.data))}if("Flourish"===r.sender)if(r.method)if(Object.prototype.hasOwnProperty.call(n,r.method))if(n[r.method](r)){for(var i=document.querySelectorAll("iframe"),a=0;a<i.length;a++)if(i[a].contentWindow==e.source||i[a].contentWindow==e.source.parent)return void t(r,i[a]);console.warn("could not find frame",r)}else console.warn("Validation failed for the message",r);else console.warn("No validator implemented for message",r);else console.warn("The 'method' property was missing from message",r)}})),La()&&(window.addEventListener("resize",Ba),Ba())}function Ba(){for(var t=document.querySelectorAll(".flourish-embed"),e=0;e<t.length;e++){var n=t[e];if(!n.getAttribute("data-width")){var r=n.querySelector("iframe");if(r){var i=window.getComputedStyle(n),a=n.offsetWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight);r.style.width=a+"px"}}}}function Ra(t,e){var n=t.parentNode;if(n.classList.contains("fl-scrolly-wrapper"))console.warn("createScrolly is being called more than once per story. This should not happen.");else{n.classList.add("fl-scrolly-wrapper"),n.style.position="relative",n.style.paddingBottom="1px",n.style.transform="translate3d(0, 0, 0)",t.style.position="sticky";var r=n.getAttribute("data-height")||null;r||(r="80vh",t.style.height=r),t.style.top="calc(50vh - "+r+"/2)";var i=n.querySelector(".flourish-credit");i&&(i.style.position="sticky",i.style.top="calc(50vh + "+r+"/2)"),e.forEach((function(t,e){var r=document.createElement("div");r.setAttribute("data-slide",e),r.classList.add("fl-scrolly-caption"),r.style.position="relative",r.style.transform="translate3d(0,0,0)",r.style.textAlign="center",r.style.maxWidth="500px",r.style.height="auto",r.style.marginTop="0",r.style.marginBottom="100vh",r.style.marginLeft="auto",r.style.marginRight="auto";var i=document.createElement("div");i.innerHTML=t,i.style.display="inline-block",i.style.paddingTop="1.25em",i.style.paddingRight="1.25em",i.style.paddingBottom="1.25em",i.style.paddingLeft="1.25em",i.style.background="rgba(255,255,255,0.9)",i.style.boxShadow="0px 0px 10px rgba(0,0,0,0.2)",i.style.borderRadius="10px",i.style.textAlign="center",i.style.maxWidth="100%",i.style.margin="0 20px",i.style.overflowX="hidden",r.appendChild(i),n.appendChild(r)})),function(t){for(var e=new IntersectionObserver((function(e){e.forEach((function(e){if(e.isIntersecting){var n=t.querySelector("iframe");n&&(n.src=n.src.replace(/#slide-.*/,"")+"#slide-"+e.target.getAttribute("data-slide"))}}))}),{rootMargin:"0px 0px -0% 0px"}),n=t.querySelectorAll(".fl-scrolly-caption"),r=0;r<n.length;r++)e.observe(n[r]);t.querySelectorAll(".fl-scrolly-caption img").forEach((function(t){t.style.maxWidth="100%"}))}(n)}}function ja(t,e,n,r,i){var a=document.createElement("iframe");if(a.setAttribute("scrolling","no"),a.setAttribute("frameborder","0"),a.setAttribute("title","Interactive or visual content"),a.setAttribute("sandbox","allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"),e.appendChild(a),a.offsetParent||"fixed"===getComputedStyle(a).position)Ia(t,e,a,n,r,i);else{var o={embed_url:t,container:e,iframe:a,width:n,height:r,play_on_load:i};if(window._flourish_poll_items?window._flourish_poll_items.push(o):window._flourish_poll_items=[o],window._flourish_poll_items.length>1)return a;var s=setInterval((function(){window._flourish_poll_items=window._flourish_poll_items.filter((function(t){return!t.iframe.offsetParent||(Ia(t.embed_url,t.container,t.iframe,t.width,t.height,t.play_on_load),!1)})),window._flourish_poll_items.length||clearInterval(s)}),500)}return a}function Ia(t,e,n,r,i,a){var o;return r&&"number"==typeof r?(o=r,r+="px"):r&&r.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/)&&(o=parseFloat(r)),i&&"number"==typeof i&&(i+="px"),r?n.style.width=r:La()?n.style.width=e.offsetWidth+"px":n.style.width="100%",!!i||(t.match(/\?/)?t+="&auto=1":t+="?auto=1",i=Ea(o||n.offsetWidth)+"px"),i&&("%"===i.charAt(i.length-1)&&(i=parseFloat(i)/100*e.parentNode.offsetHeight+"px"),n.style.height=i),n.setAttribute("src",t+(a?"#play-on-load":"")),n}function za(t,e,n){for(var r in e||(e=[]),n||(n={}),t)e.push(r),"object"==typeof t[r]&&za(t[r],e,n),n[e.join(".")]=t[r],e.pop();return n}function Pa(t){var e={};for(var n in t){for(var r=e,i=n.indexOf("."),a=0;i>=0;i=n.indexOf(".",a=i+1)){var o=n.substring(a,i);o in r||(r[o]={}),r=r[o]}r[n.substring(a)]=t[n]}return e}function $a(t){if(null==t)return t;var e,n={};for(var r in t)Array.isArray(t[r])?n[r]=t[r].slice():(e=t[r],Array.isArray(e)||"object"!=typeof e||null==e?n[r]=t[r]:n[r]=$a(t[r]));return n}var qa,Va=null;function Ya(){return"MessageChannel"in window}var Wa=null;function Ga(){Wa&&pa.removeEventListener("load",Wa),Wa=null}function Za(t){Ga(),pa.addEventListener("load",t),Wa=t}function Xa(t,e,n){return vo(!1),ba=t?t.visualisation?t.visualisation:t.current_slide.visualisation:null,Va=null,ba&&ba.template_id?(Za(function(t,e,n){var r=t.visualisation?t.visualisation.template_id:t.current_slide.visualisation.template_id,i=t.current_slide?t.current_slide.id:null;return function(){Lt(),!ba||ba.template_id!=r||t.current_slide&&t.current_slide.id!==i||(Ga(),io((function(a,o){a?console.error("Failed to get default state"):!ba||ba.template_id!=r||t.current_slide&&t.current_slide.id!==i||ao((function(a,s){if(a)console.error("Failed to call hasData");else if(ba&&ba.template_id==r&&(!t.current_slide||t.current_slide.id===i)){var l=!1;t.visualisation&&(l=t.data_bindings.requiredBindingsAreUnset()),s?ba.refreshDataBindings((function(a){a?console.error("Failed to refresh data bindings"):!ba||ba.template_id!=r||t.current_slide&&t.current_slide.id!==i||ba.prepareData((function(a,s){a?console.error("Failed to prepare data for template"):!ba||ba.template_id!=r||t.current_slide&&t.current_slide.id!==i||mo({data:s,state:e,draw:!l},(function(t,e){Va=o,n(t,e)}))}))})):mo({state:e,draw:!l},(function(t,e){Va=o,n(t,e)}))}}))})))}}(t,e,n)),pa.src="/template/"+ba.template_id+"/embed/?auto=1&environment="+ha+"&is_read_only="+(t.is_read_only?"1":"0"),pa):(Ga(),pa.src="about:blank",pa)}function Ja(t){io((function(e,n){e?console.error("Failed to get default state"):(Va=n,t())}))}function Ka(t,e){var n=t.template_id;t.refreshDataBindings((function(r){r?console.error("Failed to fetch data bindings"):t.prepareData((function(t,r){if(ba&&ba.template_id==n)return t?(console.error("Failed to prepare data for template"),void e(t)):void e(void 0,r)}))}))}function Qa(t,e){Ka(t,(function(t,n){if(t)return e(t);mo({data:n,update:!0},e)}))}function to(t,e){Ka(t,(function(t,n){if(t)return e(t);mo({data:n,update:!1},e)}))}function eo(t,e,n){Ka(t,(function(t,r){if(t)return n(t);mo({data:r,state:e,overwrite_state:!0,update:!0},n)}))}function no(t,e,n){if(Ya()){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)},pa.contentWindow.postMessage({sender:"Flourish",method:t,argument:e},"*",[r.port2])}}function ro(t,e){no("setState",Pa(t),e)}function io(t,e){"function"!=typeof t?no("getState",t,e):no("getState",void 0,t)}function ao(t){no("hasData",void 0,t)}function oo(t,e){no("setData",t,e)}function so(t){no("getData",void 0,t)}function lo(t){no("draw",void 0,t),vo(!0)}function uo(t){va&&va.clear(),go()&&no("update",void 0,t)}function co(t,e){no("snapshot",t,e)}function fo(){return $a(Va)}function po(t,e){no("setFixedHeight",t,e)}function ho(t){if(pa.parentNode.offsetWidth){if(void 0!==t)qa=null!=t;else if(qa)return;var e=t||ga&&ga.responsive_menu&&ga.responsive_menu.getHeightSetting()||ma.getHeightForBreakpoint(pa.offsetWidth),n=typeof e;("number"===n||"string"===n&&!isNaN(e))&&(e+="px"),pa.style.height=e}}function mo(t,e){go()?delete t.draw:t.draw&&vo(!0),t.state&&(t.state=Pa(t.state)),va&&va.clear(),no("sync",t,(function(n,r){null!=n||"success"!==r?(t.draw&&vo(!1),function n(r){r?e&&e(r):function(t,e){return t.data?(oo(t.data,e),delete t.data,!1):t.state?(ro(t.state,e),delete t.state,!1):t.draw?(lo(e),delete t.draw,!1):!t.update||(uo(e),delete t.update,!1)}(t,n)&&e&&e(void 0)}(n)):e&&e(void 0)}))}function go(){return ya}function vo(t){ya=t}function yo(t,e,n,r,i){return pa=document.querySelector(t),ha=e,ga=n,va=r,i||(i={}),fa="#amp=1"==window.location.hash,ma={createEmbedIframe:ja,isFixedHeight:Aa,getHeightForBreakpoint:Ea,startEventListeners:Ha,notifyParentWindow:Ta,initScrolly:ka,createScrolly:Ra,isSafari:La,initCustomerAnalytics:Ca,addAnalyticsListener:xa,sendCustomerAnalyticsMessage:wa},pa.style.height=ma.getHeightForBreakpoint(pa.offsetWidth)+"px",ma.startEventListeners((function(t){"resize"==t.method?ho(t.height):"warn"==t.method?(va&&va.warn(t),console.warn("Warning from template:",t.message,t.explanation)):t.method in i&&i[t.method](t)}),["resize","warn","customerAnalytics","setSetting","request-upload"]),Ya()||function(t){if(t){var e=document.createElement("div");e.className="unsupported-notice",e.innerHTML="<h3>Please update your browser</h3><p>This page only works with newer versions of your browser.</p>",t.appendChild(e)}}(pa.parentNode),{loadVisualisation:Xa,updateData:Qa,updateDataAndState:eo,updateDataNotPreview:to,setState:ro,getState:io,getDefaultState:fo,hasData:ao,setData:oo,getData:so,draw:lo,update:uo,snapshot:co,setFixedHeight:po,resize:ho,sync:mo,getDrawCalled:go,setDrawCalled:vo,setFrameLoadListener:Za,updateDefaultState:Ja}}var bo=function(t=document.body){t.classList.add("loading")},_o=function(t=document.body){t.classList.remove("loading")};const wo=new Set([1,274,282,283,296,34675,40961,42240]);function xo(t){let e=0;function n(n){if(e>=t.byteLength)return null;void 0===n&&(n=1);const r=new DataView(t,e,n);return e+=n,r}const r=new Uint8Array(t.byteLength+2);let i=0;function a(t){r.set(new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)),i),i+=t.byteLength}const o=(new TextEncoder).encode("Exif\0\0");function*s(t){if(t<32)return;if(!function(t,e){if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t.getInt8(n)!==e.getInt8(n))return!1;return!0}(n(6),new DataView(o.buffer)))return void n(t-8);const e=[],r=n(t-8),i=r.getUint16(0);let a;if(18761===i)a=!0;else{if(19789!==i)return;a=!1}function s(t){return r.getUint16(t,a)}function l(t){return r.getUint32(t,a)}if(42!==s(2))return;let u=l(4);for(;0!=u;){const t=s(u);u+=2;for(let n=0;n<t;n++){const t=s(u),n=s(u+2),i=l(u+4),o=l(u+8);if(u+=12,!wo.has(t))continue;if(n<1||n>12)continue;let c;switch(n){case 1:case 2:case 6:case 7:c=1;break;case 3:case 8:c=2;break;case 4:case 9:case 11:c=4;break;case 5:case 10:case 12:c=8}const d=c*i;let f;if(d<=4)f=new DataView(new ArrayBuffer(4),0,4),f.setUint32(0,o,a);else{f=new DataView(new ArrayBuffer(d));for(let t=0;t<d;t++)f.setInt8(t,r.getInt8(o+t))}e.push({code:t,type:n,num_values:i,data:f})}u=l(u)}let c=10;for(const{data:t}of e)c+=12,t.byteLength>4&&(c+=t.byteLength);c+=4;const d=new Uint8Array(c),f=new DataView(d.buffer);d.set((new TextEncoder).encode("MM\0*\0\0\0\b"),0),f.setUint16(8,e.length);let p=10,h=10+12*e.length+4;for(const{code:t,type:n,num_values:r,data:i}of e){if(f.setUint16(p,t),f.setUint16(p+2,n),f.setUint32(p+4,r),i.byteLength<=4)for(let t=0;t<i.byteLength;t++)f.setInt8(p+8+t,i.getInt8(t));else{f.setUint32(p+8,h);for(let t=0;t<i.byteLength;t++)f.setInt8(h+t,i.getInt8(t));h+=i.byteLength}p+=12}const m=new Uint8Array(10),g=new DataView(m.buffer);g.setUint8(0,255),g.setUint8(1,225),g.setUint16(2,f.byteLength+8),m.set(o,4),yield m,yield f}const l=n(2);if(65496!==l.getUint16(0))throw new Error("Not a valid JPEG");for(a(l);;){const t=n(2),e=t.getUint16(0);if(65498===e){a(t);break}const r=n(2),i=r.getUint16(0);if(65505!==e)a(t),a(r),a(n(i-2));else for(const t of s(i))a(t)}const u=new Uint8Array([255,217]);let c,d=!1,f=!1;for(;null!=(c=n());){if(d&&217===c.getUint8(0)){f=!0,a(new DataView(new Uint8Array([217]).buffer));break}const t=new Uint8Array(c.buffer).indexOf(u);if(!(t<0)){a(c.slice(0,t+2)),f=!0;break}a(c),d=c.byteLength>0&&255===c.getUint8(c.byteLength-1)}return f||a(u),r}function Co(t){let e=0;function n(n){if(e+n>t.byteLength)return null;const r=new DataView(t,e,n);return e+=n,r}const r=new Uint8Array(t.byteLength);let i=0;function a(t){r.set(new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)),i),i+=t.byteLength}const o=n(8);if(80!==o.getUint8(1)||78!==o.getUint8(2)||71!==o.getUint8(3))throw new Error("Not a valid PNG");let s,l;for(a(o);null!=(s=n(4))&&null!=(l=n(4));){const t=s.getUint32(0),e=l.getUint8(0),r=l.getUint8(1);101===e||105===e&&84===r?(n(t),n(4)):(a(s),a(l),a(n(t)),a(n(4)))}return r}var Ao="/api/file/upload";function Eo(t){(t||document).querySelectorAll("input[type=url]").forEach((function(t){ko(t)}))}function ko(t,e){var n=t.ownerDocument.createElement("button");n.type="button",n.className="upload",n.setAttribute("title","Upload a file from your computer"),n.innerHTML="⬆︎",t.insertAdjacentElement("afterend",n),e||(n.onclick=To)}function To(){var t=this.previousSibling,e=t.getAttribute("accept");t.disabled=!0,t.classList.toggle("uploading",!0),Lo({accept:e,success:function(e){var n;t.disabled=!1,t.classList.toggle("uploading",!1),t.value=e,"createEvent"in document?(n=document.createEvent("Event")).initEvent("change",!0,!0):n=new Event("change",{bubbles:!0}),t.dispatchEvent(n)},failure:function(){t.disabled=!1,t.classList.toggle("uploading",!1)}})}function Lo(t){var e=document.getElementById("file-uploader");e||((e=document.createElement("input")).type="file",e.setAttribute("id","file-uploader"),e.style.display="none",document.body.appendChild(e)),t.accept?e.setAttribute("accept",t.accept):e.removeAttribute("accept"),e.onchange=async function(){bo(),await async function(t,e,n){const r=await async function(t){try{if("image/png"===t.type)return new File([Co(await t.arrayBuffer())],t.name,{type:t.type});if("image/jpeg"===t.type)return new File([xo(await t.arrayBuffer())],t.name,{type:t.type})}catch(t){console.error(t)}return t}(t[0]);!function(t,e){var n={filename:t.name,content_type:t.type,size:t.size};Do(Ao,n,(function(t,n){return t?e(t):e(null,JSON.parse(n.responseText))}))}(r,(function(t,i){if(t)return _o(),Wi("Upload error","There was a problem uploading your file: "+t),void console.error(t);var a=function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}({file:r},i.fields);Do(i.upload_url,a,(function(t,r){_o(),t?(Wi("Upload error","There was a problem uploading your file ("+r.status+")."),console.error(t),n&&n()):e(i.file_url)}))}))}(e.files,t.success,t.failure),e.parentNode.removeChild(e)},e.click()}function Do(t,e,n){var r=new XMLHttpRequest,i=new FormData;if("object"==typeof e){for(var a in e)e.hasOwnProperty(a)&&"file"!==a&&i.append(a,e[a]);e.hasOwnProperty("file")&&i.append("file",e.file)}window.Flourish.csrf_token&&i.append("csrf_token",window.Flourish.csrf_token),r.onload=function(){if(r.status>=200&&r.status<300)n(null,r);else try{var e=JSON.parse(r.responseText).error;n(e,r)}catch(e){n(new Error("POST "+t+" received status code: "+r.status),r)}},r.open("POST",t,!0),r.send(i)}var Fo="https://fonts.googleapis.com/css?family=",So=["Source Sans Pro","Roboto Condensed","Merriweather","Lora","Playfair Display","Coda","Lobster","Cabin Sketch"],Mo="Same as parent",No=[],Uo=[],Oo={};function Ho(t){return Fo+t.replace(/ /g,"+")+":400,700"}function Bo(t){var e=Uo.concat(No,So.map((function(t){return{name:t,url:Ho(t)}})));return t&&e.unshift({name:Mo}),e}function Ro(t){return Bo(!0).find((function(e){return e.name==t}))}var jo=!1;function Io(t){return t.substr(t.lastIndexOf("=")+1).replace(/\+/g," ")}function zo(t){var e=t.target,n=e.value;if(n&&(0==n.indexOf(Fo)&&(n=e.value=Io(n)),!Ro(n))){if(/^https?:\/\//.test(n)){jo||(Po(n),e.value="");var r=n;return n=e.value=Io(r),Uo.push({name:n,url:r}),void $o()}var i=Ho(n);try{var a=new XMLHttpRequest;if(a.open("HEAD",i,!1),a.send(),404==a.status)throw"Font not found";Uo.push({name:n,url:i}),$o()}catch(t){Po(n),e.value=""}}}function Po(t){Wi("Unrecognised font “"+t+"”","Fonts must be chosen from Google Fonts. Visit <a href='https://fonts.google.com'>fonts.google.com</a> to find more",{is_html:!0})}function $o(){var t,e,n=Object.keys(Oo);for(t=0;t<n.length;++t)(e=Oo[n[t]]).autocomplete.options(Bo(e.can_inherit).map((function(t){return t.name})))}var qo={initialize:function(t,e,n){var r=!!e.optional;jo=n,t.classList.add("font-menu"),Oo[e.property]={autocomplete:Zi(t,e.property+"-dropdown",Bo(r).map((function(t){return t.name})),{allow_other_option:!0}),can_inherit:r},t.addEventListener("change",zo)},update:function(t,e){var n=e?e.name:Mo;t.value=n,Ro(n)||(n!=Mo&&Uo.push({name:n,url:e.url}),$o())},getValue:function(t){if(/^https?:\/\//.test(t.value))return{name:Io(t.value),url:t.value};var e=t.value;if(e==Mo)return null;var n=Ro(e);return n||{name:e,url:Ho(e)}},replaceThemeFonts:function(t){No=(t||[]).map((function(t){return{name:t.name,url:t.url}})),$o()}},Vo="$";function Yo(){}function Wo(t,e){var n=new Yo;if(t instanceof Yo)t.each((function(t,e){n.set(e,t)}));else if(Array.isArray(t)){var r,i=-1,a=t.length;if(null==e)for(;++i<a;)n.set(i,t[i]);else for(;++i<a;)n.set(e(r=t[i],i,t),r)}else if(t)for(var o in t)n.set(o,t[o]);return n}function Go(){}Yo.prototype=Wo.prototype={constructor:Yo,has:function(t){return Vo+t in this},get:function(t){return this[Vo+t]},set:function(t,e){return this[Vo+t]=e,this},remove:function(t){var e=Vo+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===Vo&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===Vo&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===Vo&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===Vo&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===Vo&&++t;return t},empty:function(){for(var t in this)if(t[0]===Vo)return!1;return!0},each:function(t){for(var e in this)e[0]===Vo&&t(this[e],e.slice(1),this)}};var Zo=Wo.prototype;Go.prototype={constructor:Go,has:Zo.has,add:function(t){return this[Vo+(t+="")]=t,this},remove:Zo.remove,clear:Zo.clear,values:Zo.keys,size:Zo.size,empty:Zo.empty,each:Zo.each};var Xo={value:function(){}};function Jo(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Ko(r)}function Ko(t){this._=t}function Qo(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 ts(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function es(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Xo,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function ns(t,e,n,r,i){for(var a in t.getVersionNumber=function(){return t.version_number},t.setVersionNumber=function(e){t.version_number=e},t.id=e,t.version_number=n||0,r)t[a]=r[a];if(i)for(var a in i)t[a]=i[a]}Ko.prototype=Jo.prototype={constructor:Ko,on:function(t,e){var n,r=this._,i=Qo(t+"",r),a=-1,o=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<o;)if(n=(t=i[a]).type)r[n]=es(r[n],t.name,e);else if(null==e)for(n in r)r[n]=es(r[n],t.name,null);return this}for(;++a<o;)if((n=(t=i[a]).type)&&(n=ts(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Ko(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};var rs={};function is(t){t.running||(t.running=!0,as(t,(function(){t.running=!1})))}function as(t,e){t.request=function(t,e){var n="method"in t?t.method:"POST",r="request_type"in t?t.request_type:"application/json",i="response_type"in t?t.response_type:"application/json",a=t.url,o=t.payload,s=t.callback;!o&&os(n)&&(o=function(){return{}});if(o){if("function"!=typeof o)throw new Error("Internal error: processRequestThen: payload must be a function, not "+typeof o,o);"object"==typeof(o=o())&&os(n)&&(window.Flourish&&window.Flourish.csrf_token||console.trace("window.Flourish.csrf_token missing"),o.csrf_token=window.Flourish.csrf_token),"string"!=typeof o&&(o=JSON.stringify(o))}var l=function(t,e){var n,r,i,a,o=Jo("beforesend","progress","load","error"),s=Wo(),l=new XMLHttpRequest,u=null,c=null,d=0;function f(t){var e,r=l.status;if(!r&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(l)||r>=200&&r<300||304===r){if(i)try{e=i.call(n,l)}catch(t){return void o.call("error",n,t)}else e=l;o.call("load",n,e)}else o.call("error",n,t)}if("undefined"!=typeof XDomainRequest&&!("withCredentials"in l)&&/^(http(s)?:)?\/\//.test(t)&&(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=l.ontimeout=f:l.onreadystatechange=function(t){l.readyState>3&&f(t)},l.onprogress=function(t){o.call("progress",n,t)},n={header:function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s.get(t):(null==e?s.remove(t):s.set(t,e+""),n)},mimeType:function(t){return arguments.length?(r=null==t?null:t+"",n):r},responseType:function(t){return arguments.length?(a=t,n):a},timeout:function(t){return arguments.length?(d=+t,n):d},user:function(t){return arguments.length<1?u:(u=null==t?null:t+"",n)},password:function(t){return arguments.length<1?c:(c=null==t?null:t+"",n)},response:function(t){return i=t,n},get:function(t,e){return n.send("GET",t,e)},post:function(t,e){return n.send("POST",t,e)},send:function(e,i,f){return l.open(e,t,!0,u,c),null==r||s.has("accept")||s.set("accept",r+",*/*"),l.setRequestHeader&&s.each((function(t,e){l.setRequestHeader(e,t)})),null!=r&&l.overrideMimeType&&l.overrideMimeType(r),null!=a&&(l.responseType=a),d>0&&(l.timeout=d),null==f&&"function"==typeof i&&(f=i,i=null),null!=f&&1===f.length&&(f=function(t){return function(e,n){t(null==e?n:null)}}(f)),null!=f&&n.on("error",f).on("load",(function(t){f(null,t)})),o.call("beforesend",n,l),l.send(null==i?null:i),n},abort:function(){return l.abort(),n},on:function(){var t=o.on.apply(o,arguments);return t===o?n:t}},null!=e){if("function"!=typeof e)throw new Error("invalid callback: "+e);return n.get(e)}return n}(a);r&&"GET"!==n&&l.header("Content-Type",r);i&&l.mimeType(i);return l.on("error",(function(t){var n;try{n=JSON.parse(t.target.responseText),s(n.error)}catch(e){s("Internal error: "+t.target.responseText)}e()})),l.on("load",(function(t){var n=t.responseText;"application/json"===i&&(n=JSON.parse(n));try{s(void 0,n)}catch(t){console.error(t.stack)}e()})),l.send(n,o),l}(t.items.shift(),(function(){t.request=null,0==t.items.length?e():as(t,e)}))}function os(t){return["POST","PUT","DELETE"].includes(t)}function ss(t,e){void 0===e&&(e="default"),e in rs||(rs[e]={items:[],running:!1,name:e}),rs[e].items.push(t),is(rs[e])}function ls(t,e){for(var n in e)t[n]=e[n];return t}function us(t,e,n,r){"function"==typeof n&&(r=n,n=!1),n&&ls(t,e),ss({url:t.api_prefix+"/"+t.id,payload:function(){return{version_number:t.getVersionNumber(),fields:e}},callback:function(i,a){if(i)return r(i);n||ls(t,e),t.setVersionNumber(a.version_number),r(void 0)}})}function cs(t,e){t.delete_requested=!0,ss({url:t.api_prefix+"/"+t.id,method:"DELETE",payload:function(){return{version_number:t.getVersionNumber()}},callback:function(n,r){if(n)return e(n);t.setVersionNumber(r.version_number),t.is_deleted=!0,e(void 0,r)}})}var ds={addApiKey:function(t){ss({url:"/api/user/api_keys",method:"PUT",callback:t})},addTag:function(t,e){ss({url:"/api/user/tag/"+encodeURIComponent(t),method:"PUT",callback:e})},deleteApiKey:function(t,e){ss({url:"/api/user/api_keys/"+t,method:"DELETE",callback:e})},fetchFolders:function(t){ss({url:"/api/user/folders",method:"GET",callback:t})},fetchProjects:function(t,e,n,r,i,a,o,s){var l="";e&&(l+="&folder="+encodeURIComponent(e)),n&&(l+="&sort="+encodeURIComponent(n)),r&&(l+="&filter="+encodeURIComponent(r)),i&&(l+="&offset="+encodeURIComponent(i)),a&&(l+="&limit="+encodeURIComponent(a)),o&&(l+="&search="+encodeURIComponent(o)),s&&(l+="&is_recent=true"),ss({url:"/api/user/projects?"+l,method:"GET",callback:t})},generateSdkToken:function(t){ss({url:"/api/user/generate_sdk_token",method:"GET",callback:t})},revokeSdkToken:function(t,e){ss({url:"/api/user/sdk_token/"+encodeURIComponent(t),method:"DELETE",callback:e})},getApiKeys:function(t){ss({url:"/api/user/api_keys",method:"GET",callback:t})},getReviewCount:function(t){ss({url:"/api/reviews/count",method:"GET",callback:t})},isUsernameAvailable:function(t,e){ss({url:"/api/user/username?u="+encodeURIComponent(t),method:"GET",callback:e})},logHistory:function(t){ss({url:"/api/history",method:"POST",payload:function(){return t},callback:function(){}})},removeTag:function(t,e){ss({url:"/api/user/tag/"+encodeURIComponent(t),method:"DELETE",callback:e})},renameTag:function(t,e,n){ss({url:"/api/user/tag/"+encodeURIComponent(t)+"/"+encodeURIComponent(e),method:"PUT",callback:n})},setSamlProviderId:function(t,e,n){ss({url:"/api/user/"+encodeURIComponent(t)+"/change_saml_provider_id",method:"POST",payload:function(){return{saml_provider_id:e}},callback:n})},update:function(t,e){ss({url:"/api/user",method:"POST",payload:function(){return{fields:t}},callback:e})}};var fs={};function ps(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function hs(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function ms(){}var gs=.7,vs=1/gs,ys="\\s*([+-]?\\d+)\\s*",bs="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_s="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ws=/^#([0-9a-f]{3,8})$/,xs=new RegExp(`^rgb\\(${ys},${ys},${ys}\\)$`),Cs=new RegExp(`^rgb\\(${_s},${_s},${_s}\\)$`),As=new RegExp(`^rgba\\(${ys},${ys},${ys},${bs}\\)$`),Es=new RegExp(`^rgba\\(${_s},${_s},${_s},${bs}\\)$`),ks=new RegExp(`^hsl\\(${bs},${_s},${_s}\\)$`),Ts=new RegExp(`^hsla\\(${bs},${_s},${_s},${bs}\\)$`),Ls={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 Ds(){return this.rgb().formatHex()}function Fs(){return this.rgb().formatRgb()}function Ss(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ws.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Ms(e):3===n?new Hs(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?Ns(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?Ns(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=xs.exec(t))?new Hs(e[1],e[2],e[3],1):(e=Cs.exec(t))?new Hs(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=As.exec(t))?Ns(e[1],e[2],e[3],e[4]):(e=Es.exec(t))?Ns(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=ks.exec(t))?Ps(e[1],e[2]/100,e[3]/100,1):(e=Ts.exec(t))?Ps(e[1],e[2]/100,e[3]/100,e[4]):Ls.hasOwnProperty(t)?Ms(Ls[t]):"transparent"===t?new Hs(NaN,NaN,NaN,0):null}function Ms(t){return new Hs(t>>16&255,t>>8&255,255&t,1)}function Ns(t,e,n,r){return r<=0&&(t=e=n=NaN),new Hs(t,e,n,r)}function Us(t){return t instanceof ms||(t=Ss(t)),t?new Hs((t=t.rgb()).r,t.g,t.b,t.opacity):new Hs}function Os(t,e,n,r){return 1===arguments.length?Us(t):new Hs(t,e,n,null==r?1:r)}function Hs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Bs(){return`#${zs(this.r)}${zs(this.g)}${zs(this.b)}`}function Rs(){const t=js(this.opacity);return`${1===t?"rgb(":"rgba("}${Is(this.r)}, ${Is(this.g)}, ${Is(this.b)}${1===t?")":`, ${t})`}`}function js(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Is(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function zs(t){return((t=Is(t))<16?"0":"")+t.toString(16)}function Ps(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new qs(t,e,n,r)}function $s(t){if(t instanceof qs)return new qs(t.h,t.s,t.l,t.opacity);if(t instanceof ms||(t=Ss(t)),!t)return new qs;if(t instanceof qs)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,s=a-i,l=(a+i)/2;return s?(o=e===a?(n-r)/s+6*(n<r):n===a?(r-e)/s+2:(e-n)/s+4,s/=l<.5?a+i:2-a-i,o*=60):s=l>0&&l<1?0:o,new qs(o,s,l,t.opacity)}function qs(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Vs(t){return(t=(t||0)%360)<0?t+360:t}function Ys(t){return Math.max(0,Math.min(1,t||0))}function Ws(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 Gs(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(6*r,6*++r);return n}ps(ms,Ss,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Ds,formatHex:Ds,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return $s(this).formatHsl()},formatRgb:Fs,toString:Fs}),ps(Hs,Os,hs(ms,{brighter(t){return t=null==t?vs:Math.pow(vs,t),new Hs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?gs:Math.pow(gs,t),new Hs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Hs(Is(this.r),Is(this.g),Is(this.b),js(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Bs,formatHex:Bs,formatHex8:function(){return`#${zs(this.r)}${zs(this.g)}${zs(this.b)}${zs(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Rs,toString:Rs})),ps(qs,(function(t,e,n,r){return 1===arguments.length?$s(t):new qs(t,e,n,null==r?1:r)}),hs(ms,{brighter(t){return t=null==t?vs:Math.pow(vs,t),new qs(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?gs:Math.pow(gs,t),new qs(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Hs(Ws(t>=240?t-240:t+120,i,r),Ws(t,i,r),Ws(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new qs(Vs(this.h),Ys(this.s),Ys(this.l),js(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=js(this.opacity);return`${1===t?"hsl(":"hsla("}${Vs(this.h)}, ${100*Ys(this.s)}%, ${100*Ys(this.l)}%${1===t?")":`, ${t})`}`}}));var Zs=Gs("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"),Xs=Gs("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"),Js=Gs("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"),Ks=Gs("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"),Qs=t=>()=>t;function tl(t){return 1==(t=+t)?el:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):Qs(isNaN(e)?n:e)}}function el(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Qs(isNaN(t)?e:t)}var nl=function t(e){var n=tl(e);function r(t,e){var r=n((t=Os(t)).r,(e=Os(e)).r),i=n(t.g,e.g),a=n(t.b,e.b),o=el(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);function rl(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var il=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,al=new RegExp(il.source,"g");function ol(t,e){var n,r,i,a=il.lastIndex=al.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(n=il.exec(t))&&(r=al.exec(e));)(i=r.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,l.push({i:o,x:rl(n,r)})),a=al.lastIndex;return a<e.length&&(i=e.slice(a),s[o]?s[o]+=i:s[++o]=i),s.length<2?l[0]?function(t){return function(e){return t(e)+""}}(l[0].x):function(t){return function(){return t}}(e):(e=l.length,function(t){for(var n,r=0;r<e;++r)s[(n=l[r]).i]=n.x(t);return s.join("")})}var sl,ll=180/Math.PI,ul={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cl(t,e,n,r,i,a){var o,s,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,l/=s),t*r<e*n&&(t=-t,e=-e,l=-l,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(e,t)*ll,skewX:Math.atan(l)*ll,scaleX:o,scaleY:s}}function dl(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(a,o){var s=[],l=[];return a=t(a),o=t(o),function(t,r,i,a,o,s){if(t!==i||r!==a){var l=o.push("translate(",null,e,null,n);s.push({i:l-4,x:rl(t,i)},{i:l-2,x:rl(r,a)})}else(i||a)&&o.push("translate("+i+e+a+n)}(a.translateX,a.translateY,o.translateX,o.translateY,s,l),function(t,e,n,a){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(i(n)+"rotate(",null,r)-2,x:rl(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(a.rotate,o.rotate,s,l),function(t,e,n,a){t!==e?a.push({i:n.push(i(n)+"skewX(",null,r)-2,x:rl(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(a.skewX,o.skewX,s,l),function(t,e,n,r,a,o){if(t!==n||e!==r){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:rl(t,n)},{i:s-2,x:rl(e,r)})}else 1===n&&1===r||a.push(i(a)+"scale("+n+","+r+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,l),a=o=null,function(t){for(var e,n=-1,r=l.length;++n<r;)s[(e=l[n]).i]=e.x(t);return s.join("")}}}var fl,pl,hl=dl((function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?ul:cl(e.a,e.b,e.c,e.d,e.e,e.f)}),"px, ","px)","deg)"),ml=dl((function(t){return null==t?ul:(sl||(sl=document.createElementNS("http://www.w3.org/2000/svg","g")),sl.setAttribute("transform",t),(t=sl.transform.baseVal.consolidate())?cl((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):ul)}),", ",")",")"),gl=0,vl=0,yl=0,bl=0,_l=0,wl=0,xl="object"==typeof performance&&performance.now?performance:Date,Cl="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Al(){return _l||(Cl(El),_l=xl.now()+wl)}function El(){_l=0}function kl(){this._call=this._time=this._next=null}function Tl(t,e,n){var r=new kl;return r.restart(t,e,n),r}function Ll(){_l=(bl=xl.now())+wl,gl=vl=0;try{!function(){Al(),++gl;for(var t,e=fl;e;)(t=_l-e._time)>=0&&e._call.call(null,t),e=e._next;--gl}()}finally{gl=0,function(){var t,e,n=fl,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:fl=e);pl=t,Fl(r)}(),_l=0}}function Dl(){var t=xl.now(),e=t-bl;e>1e3&&(wl-=e,bl=t)}function Fl(t){gl||(vl&&(vl=clearTimeout(vl)),t-_l>24?(t<1/0&&(vl=setTimeout(Ll,t-xl.now()-wl)),yl&&(yl=clearInterval(yl))):(yl||(bl=xl.now(),yl=setInterval(Dl,1e3)),gl=1,Cl(Ll)))}function Sl(t,e,n){var r=new kl;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}kl.prototype=Tl.prototype={constructor:kl,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Al():+n)+(null==e?0:+e),this._next||pl===this||(pl?pl._next=this:fl=this,pl=this),this._call=t,this._time=n,Fl()},stop:function(){this._call&&(this._call=null,this._time=1/0,Fl())}};var Ml=Jo("start","end","cancel","interrupt"),Nl=[];function Ul(t,e,n,r,i,a){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function a(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(a){var u,c,d,f;if(1!==n.state)return l();for(u in i)if((f=i[u]).name===n.name){if(3===f.state)return Sl(o);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[u]):+u<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[u])}if(Sl((function(){3===n.state&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))})),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(d=n.tween.length),u=0,c=-1;u<d;++u)(f=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=f);r.length=c+1}}function s(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(l),n.state=5,1),a=-1,o=r.length;++a<o;)r[a].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=Tl(a,0,n.time)}(t,n,{name:e,index:r,group:i,on:Ml,tween:Nl,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Ol(t,e){var n=Bl(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function Hl(t,e){var n=Bl(t,e);if(n.state>3)throw new Error("too late; already running");return n}function Bl(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Rl(t,e){var n,r;return function(){var i=Hl(this,t),a=i.tween;if(a!==n)for(var o=0,s=(r=n=a).length;o<s;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r}}function jl(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var a=Hl(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:e,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===e){i[l]=s;break}l===u&&i.push(s)}a.tween=i}}function Il(t,e,n){var r=t._id;return t.each((function(){var t=Hl(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)})),function(t){return Bl(t,r).value[e]}}function zl(t,e){var n;return("number"==typeof e?rl:e instanceof Ss?nl:(n=Ss(e))?(e=n,nl):ol)(t,e)}function Pl(t){return function(){this.removeAttribute(t)}}function $l(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ql(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=e(r=o,n)}}function Vl(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=e(r=o,n)}}function Yl(t,e,n){var r,i,a;return function(){var o,s,l=n(this);if(null!=l)return(o=this.getAttribute(t))===(s=l+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,l));this.removeAttribute(t)}}function Wl(t,e,n){var r,i,a;return function(){var o,s,l=n(this);if(null!=l)return(o=this.getAttributeNS(t.space,t.local))===(s=l+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,l));this.removeAttributeNS(t.space,t.local)}}function Gl(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function Zl(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function Xl(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Zl(t,i)),n}return i._value=e,i}function Jl(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&Gl(t,i)),n}return i._value=e,i}function Kl(t,e){return function(){Ol(this,t).delay=+e.apply(this,arguments)}}function Ql(t,e){return e=+e,function(){Ol(this,t).delay=e}}function tu(t,e){return function(){Hl(this,t).duration=+e.apply(this,arguments)}}function eu(t,e){return e=+e,function(){Hl(this,t).duration=e}}function nu(t,e){if("function"!=typeof e)throw new Error;return function(){Hl(this,t).ease=e}}function ru(t,e,n){var r,i,a=function(t){return(t+"").trim().split(/^|\s+/).every((function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?Ol:Hl;return function(){var o=a(this,t),s=o.on;s!==r&&(i=(r=s).copy()).on(e,n),o.on=i}}var iu=Ct.prototype.constructor;function au(t){return function(){this.style.removeProperty(t)}}function ou(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function su(t,e,n){var r,i;function a(){var a=e.apply(this,arguments);return a!==i&&(r=(i=a)&&ou(t,a,n)),r}return a._value=e,a}function lu(t){return function(e){this.textContent=t.call(this,e)}}function uu(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&lu(r)),e}return r._value=t,r}var cu=0;function du(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function fu(){return++cu}var pu=Ct.prototype;du.prototype={constructor:du,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=p(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s,l,u=r[o],c=u.length,d=a[o]=new Array(c),f=0;f<c;++f)(s=u[f])&&(l=t.call(s,s.__data__,f,u))&&("__data__"in s&&(l.__data__=s.__data__),d[f]=l,Ul(d[f],e,n,f,d,Bl(s,n)));return new du(a,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=g(t));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var l,u=r[s],c=u.length,d=0;d<c;++d)if(l=u[d]){for(var f,p=t.call(l,l.__data__,d,u),h=Bl(l,n),m=0,v=p.length;m<v;++m)(f=p[m])&&Ul(f,e,n,m,p,h);a.push(p),o.push(l)}return new du(a,o,e,n)},selectChild:pu.selectChild,selectChildren:pu.selectChildren,filter:function(t){"function"!=typeof t&&(t=v(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,l=r[i]=[],u=0;u<s;++u)(a=o[u])&&t.call(a,a.__data__,u,o)&&l.push(a);return new du(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var l,u=e[s],c=n[s],d=u.length,f=o[s]=new Array(d),p=0;p<d;++p)(l=u[p]||c[p])&&(f[p]=l);for(;s<r;++s)o[s]=e[s];return new du(o,this._parents,this._name,this._id)},selection:function(){return new iu(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=fu(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],l=s.length,u=0;u<l;++u)if(o=s[u]){var c=Bl(o,e);Ul(o,t,n,u,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new du(r,this._parents,t,n)},call:pu.call,nodes:pu.nodes,node:pu.node,size:pu.size,empty:pu.empty,each:pu.each,on:function(t,e){var n=this._id;return arguments.length<2?Bl(this.node(),n).on.on(t):this.each(ru(n,t,e))},attr:function(t,e){var n=l(t),r="transform"===n?ml:zl;return this.attrTween(t,"function"==typeof e?(n.local?Wl:Yl)(n,r,Il(this,"attr."+t,e)):null==e?(n.local?$l:Pl)(n):(n.local?Vl:ql)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=l(t);return this.tween(n,(r.local?Xl:Jl)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?hl:zl;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var a=I(this,t),o=(this.style.removeProperty(t),I(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}(t,r)).on("end.style."+t,au(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,a;return function(){var o=I(this,t),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(t),l=s=I(this,t)),o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s))}}(t,r,Il(this,"style."+t,e))).each(function(t,e){var n,r,i,a,o="style."+e,s="end."+o;return function(){var l=Hl(this,t),u=l.on,c=null==l.value[o]?a||(a=au(e)):void 0;u===n&&i===c||(r=(n=u).copy()).on(s,i=c),l.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,a=n+"";return function(){var o=I(this,t);return o===a?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,su(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Il(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,uu(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=Bl(this.node(),n).tween,a=0,o=i.length;a<o;++a)if((r=i[a]).name===t)return r.value;return null}return this.each((null==e?Rl:jl)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Kl:Ql)(e,t)):Bl(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?tu:eu)(e,t)):Bl(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(nu(e,t)):Bl(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;Hl(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise((function(a,o){var s={value:o},l={value:function(){0==--i&&a()}};n.each((function(){var n=Hl(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(s),e._.interrupt.push(s),e._.end.push(l)),n.on=e})),0===i&&a()}))},[Symbol.iterator]:pu[Symbol.iterator]};var hu,mu,gu={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function vu(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function yu(t){var e;if(hu=At(".detailed-settings"),(mu=hu.append("div").attr("class","settings-block")).append("h2").text("Back to settings").on("click",(function(){hu.transition().duration(100).style("opacity",0).on("end",(function(){At(this).html("").style("display","none"),At(".template-settings").style("display","block").style("opacity",0).transition().duration(200).style("opacity",1),At(".template-settings-search").style("display",null).style("opacity",0).transition().duration(200).style("opacity",1)})),hu.node()})),"string"==typeof t)e=mu.append("div").html(t);else if("object"==typeof t&&(e=mu.append(t.type),t.value&&(mu.node().value=t.value),t.attributes))for(var n in t.attributes)e.attr(n,t.attributes[n]);return e.node().focus(),At(".template-settings-search").style("display","none"),At(".template-settings").style("display","none"),hu.style("display","block").style("opacity",0).transition().duration(200).style("opacity",1),hu.node()}Ct.prototype.interrupt=function(t){return this.each((function(){!function(t,e){var n,r,i,a=t.__transition,o=!0;if(a){for(i in e=null==e?null:e+"",a)(n=a[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete a[i]):o=!1;o&&delete t.__transition}}(this,t)}))},Ct.prototype.transition=function(t){var e,n;t instanceof du?(e=t._id,t=t._name):(e=fu(),(n=gu).time=Al(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],l=s.length,u=0;u<l;++u)(o=s[u])&&Ul(o,t,e,u,s,n||vu(o,e));return new du(r,this._parents,t,e)};var bu,_u,wu,xu,Cu={},Au={},Eu={Flourish:{colors:["#4328e7","#9654e5","#ff6283","#ff8800","#ffc502","#007d8e","#1aa7ee","#29dae4","#88e99a","#019c00","#c11f1f","#730000"]},"Flourish Alternate":{colors:["#4328e7","#9654e5","#ff6283","#ff8800","#ffc502","#88e99a","#29dae4","#1aa7ee","#019c00","#007d8e","#c11f1f","#730000"]},"Flourish High Fire":{colors:["#730000","#c11f1f","#9654e5","#ff6283","#ff8800","#ffc502"]},"Flourish Low Fire":{colors:["#4328e7","#007d8e","#019c00","#1aa7ee","#29dae4","#88e99a"]},"Flourish Uranium":{colors:["#c11f1f","#ff8800","#ffc502"]},"Flourish Erbium":{colors:["#730000","#9654e5","#ff6283"]},"Flourish Barium":{colors:["#4328e7","#1aa7ee","#29dae4"]},"Flourish Chromium":{colors:["#007d8e","#019c00","#88e99a"]},"Flourish Pale":{colors:["#e667b1","#a193f3","#eb8484","#4bedf3","#d6a4e9","#48ffa7","#ffb1c1","#8cd3f7","#f6c992","#94ecf1","#ffe281","#c4f4cd"]},"Flourish Deep":{colors:["#430b2b","#1d0e7a","#611010","#04393b","#5a1c72","#004826","#b10025","#09557b","#0f7277","#816300","#1d9c34"]},"Flourish Mono":{colors:["#000000","#6a6a6a","#959595","#dddddd"]},"Flourish Legacy":{scheme:"flourish_default_1",colors:["#1D6996","#EDAD08","#73AF48","#94346E","#38A6A5","#E17C05","#5F4690","#0F8554","#6F4070","#CC503E","#994E95","#666666"]},"Flourish Legacy Alternate":{scheme:"flourish_default_2",colors:["#11A579","#CC503E","#3969AC","#F2B701","#7F3C8D","#80BA5A","#E68310","#CF1C90","#008695","#F97B72","#4B4B8F","#A5AA99"]},Rainbow:{colors:["#5F4690","#1D6996","#38A6A5","#0F8554","#73AF48","#EDAD08","#E17C05","#CC503E","#94346E","#6F4070","#994E95","#666666"]},Pastel:{colors:["#66C5CC","#F6CF71","#F89C74","#DCB0F2","#87C55F","#9EB9F3","#FE88B1","#C9DB74","#8BE0A4","#B497E7","#D3B484","#B3B3B3"]},Antique:{colors:["#855C75","#D9AF6B","#AF6458","#736F4C","#526A83","#625377","#68855C","#9C9C5E","#A06177","#8C785D","#467378","#7C7C7C"]},Accent:{scheme:"schemeAccent",colors:Zs},Dark:{scheme:"schemeDark2",colors:Xs},Paired:{scheme:"schemePaired",colors:Js},Pale:{scheme:"schemePastel1",colors:Ks},"Farrow & Ball":{colors:["#EDD8C4","#C4A999","#F9C1C0","#B76A4C","#8F483C","#783027","#8A1D2E","#602A1F","#893838","#BD795A","#DC6130","#AD3B34","#ECE8BD","#F7E28A","#EBEB82","#FAD862","#F1CA61","#F5C03B","#F9E7D4","#F4E4AC","#EFD491","#DAC589","#D2B15E","#CD9344","#EFEFCC","#E8E7CA","#CAD5AD","#B9B495","#73806F","#636F65","#BDAB65","#889A73","#829C7A","#6C7855","#81B693","#BBBEA0","#99A286","#AAC0B3","#427E7F","#769194","#ECF3EC","#EBEBD4","#D0D9C9","#9EAF9F","#7A8E8D","#516365","#DBE5DC","#C4C9C5","#CBD7D7","#AABEBF","#66839A","#A0D2CD","#56AAC5","#535E7D","#2E3548","#48606E","#2C3437"]}},ku={};function Tu(){var t,e={};for(t in ku)e[t]=ku[t];for(t in Eu)e[t]=Eu[t];return e}var Lu="Edit color palette";function Du(t){t&&t.length?(ku={},t.forEach((function(t){var e=Object.keys(t)[0];ku[e]={colors:t[e]}}))):ku={},function(){for(var t in Cu){Cu[t].options(Su())}}()}function Fu(){if(void 0!==bu)return bu;var t=document.createElement("input");return t.setAttribute("type","color"),t.setAttribute("value","!"),bu="color"==t.type&&"!"!==t.value}function Su(){var t=[],e=Tu();for(var n in t.push([Lu,""]),e)t.push([n,e[n].colors.join("|")]);return t}function Mu(t,e){var n=t[0],r=t[1];if(!r){const t=Et("em");return t.append("i").classed("fa fa-pencil",!0),t.node().append(Lu),t.node()}Array.isArray(r)||(r=r.split("|"));const i=[];if(e&&n){const t=Et("label").text(n);i.push(t.node())}return r.forEach((function(t,e){const n=Et("span").attr("data-index",e).style("background-color",t);i.push(n.node())})),i}function Nu(t,e){var n,r,i=Tu(),a=t.parentNode.querySelector(".color-swatches");if(Array.isArray(e))r=e;else if("string"==typeof e){if(i[e])n=e;else for(var o in i)if(i[o].scheme==e){n=o;break}n&&(r=i[n].colors)}if(!r||!r.length)return t.parentNode.classList.remove("custom"),t.removeAttribute("data-value"),t.value="",void(a.innerHTML="");a.innerHTML="",a.append(...Mu([null,r])),t.setAttribute("data-value",r.join("|"))}function Uu(t){xu=t.target,t.dataTransfer.setData("text/plain","x"),event.dataTransfer.effectAllowed="move",At(xu).classed("dragging",!0),kt(".palette p:not(.dragging) input").style("pointer-events","none")}function Ou(t){t.preventDefault();var e=At(".palette").selectAll("[draggable='true']").style("border-color",null),n=At(t.target);if("true"===n.attr("draggable")){var r="bottom";if(n.node()===e.nodes()[0]){var i=t.target.getBoundingClientRect(),a=i.top+i.height/2;t.clientY<a&&(r="top")}At(t.target).style("border-"+r,"1px solid black")}}function Hu(t){if(xu){for(var e=t.target;e&&("P"!==e.tagName||!e.nextSibling);)e=e.parentNode;if(e){var n=e.nextSibling;if(e===At(".palette").selectAll("[draggable='true']").style("border-color",null).nodes()[0]){var r=e.getBoundingClientRect(),i=r.top+r.height/2;t.clientY<i&&(n=e)}e.parentNode.insertBefore(xu,n),xu=!1,ju()}}}function Bu(){At(xu).classed("dragging",!1),kt(".palette *").style("border-bottom",null).style("border-top",null),kt(".palette p input").style("pointer-events",null)}function Ru(t){for(var e=t.target;e&&"BUTTON"!==e.tagName;)e=e.parentNode;e&&(e.classList.contains("fa-plus-square")?function(t){var e=t.target.parentNode,n=Iu("#000000");e.insertAdjacentHTML("beforebegin",n),ju()}(t):e.classList.contains("fa-times")&&function(t){t.parentNode.childNodes.length>2?t.parentNode.removeChild(t):("INPUT"==t.firstChild.tagName?t.firstChild.value="#000000":t.firstChild.style.backgroundColor="#000000",t.firstChild.nextSibling.value="#000000");ju()}(e.parentNode))}function ju(){for(var t=wu.getAttribute("data-autocomplete"),e=Cu[t],n=[],r=_u.querySelectorAll(".palette input[type=text]"),i=0;i<r.length;i++)n.push(r[i].value);var a=e.options();Au[t]?a[0][1]=n.join("|"):a.unshift(["Custom",n.join("|")]),Au[t]=n,e.options(a),Nu(wu,n),At(wu).dispatch("change")}function Iu(t){const e=Et("p").attr("draggable",!0);return e.append("span").classed("swatch-handle",!0).text(".. .. .."),Fu()?e.append("input").attr("type","color").attr("value",t):e.append("span").classed("swatch-color",!0).style("background-color",t),e.append("input").attr("type","text").attr("value",t),e.append("button").attr("type","button").classed("fa fa-times",!0),e.node().outerHTML}function zu(t){var e=t.target,n=e.value,r=e.parentNode;if(!n)return r.parentNode.removeChild(r),void ju();var i=Ss(n);if(!i)return console.warn("bad color",n),"color"==e.type?e.value=e.nextSibling.value:Fu()?e.value=e.previousSibling.value:e.value=e.previousSibling.style.backgroundColor,void(Re.point(e).text(n+" is not a valid color").draw()._getElement().style.zIndex=115);"color"==e.type?e.nextSibling.value=n:Fu()?e.previousSibling.value=i.hex():e.previousSibling.style.backgroundColor=n,ju()}var Pu,$u,qu={initialize:function(t,e){e.choices&&Du(e.choices),t.type="text",t.classList.add("colors");var n=document.createElement("span");n.setAttribute("class","color-swatches"),t.parentNode.insertBefore(n,t);var r=t.getAttribute("name")+"-dropdown";Cu[r]=Zi(t,r,Su(),{custom_renderer:Mu}),t.addEventListener("change",(function(e){t.value==Lu?(e.stopImmediatePropagation(),t.value="",function(t){wu=t;var e=(_u=yu({type:"div",attributes:{class:"palette"}})).querySelector(".palette"),n=function(t,e){e||(e=t.parentNode.querySelector(".color-swatches"));for(var n=[],r=0;r<e.childNodes.length;r++)if(!e.childNodes[r].classList.contains("fa")){var i=e.childNodes[r].style.backgroundColor,a=Ss(i);a?n.push(a.hex()):(console.warn("Bad color",i),n.push("#000000"))}return n}(t),r="";n.forEach((function(t){r+=Iu(t)})),r+="<p><button class='fa fa-plus-square clickable'></button></p>",e.innerHTML=r,e.addEventListener("change",zu),e.addEventListener("dragstart",Uu),e.addEventListener("dragover",Ou),e.addEventListener("drop",Hu),e.addEventListener("dragend",Bu),e.addEventListener("click",Ru)}(t)):Nu(t,(t.getAttribute("data-value")||"").split("|"))}))},update:Nu,getValue:function(t){var e=t.getAttribute("data-value");return e?e.split("|"):null},replaceThemeColors:Du},Vu={};const Yu={style:!0,url:!0,flourish_embed:!0};var Wu={h1:{path:"M0.00100708 0.524002V9H1.91201V5.464H4.83701V9H6.76101V0.524002H4.83701V3.787H1.91201V0.524002H0.00100708ZM8.91 7.453V9H14.162V7.453H12.615V0.744995H11.211C10.9163 0.918329 10.613 1.06566 10.301 1.187C9.989 1.30833 9.60767 1.41233 9.157 1.499V2.682H10.704V7.453H8.91Z",width:14,height:9},h2:{path:"M0.00100708 0.524002V9H1.91201V5.464H4.83701V9H6.76101V0.524002H4.83701V3.787H1.91201V0.524002H0.00100708ZM8.24078 7.908V9H14.0518V7.388H12.3878C12.1884 7.388 11.9588 7.401 11.6988 7.427C11.4474 7.44434 11.2178 7.466 11.0098 7.492C11.3478 7.14534 11.6728 6.79434 11.9848 6.439C12.3054 6.07501 12.5871 5.71534 12.8298 5.36C13.0811 4.996 13.2804 4.63634 13.4278 4.281C13.5751 3.917 13.6488 3.56167 13.6488 3.215C13.6488 2.81634 13.5838 2.45667 13.4538 2.136C13.3238 1.81534 13.1374 1.54234 12.8948 1.317C12.6521 1.083 12.3618 0.905338 12.0238 0.784004C11.6944 0.654004 11.3261 0.589005 10.9188 0.589005C10.3294 0.589005 9.82245 0.701671 9.39778 0.927004C8.97311 1.14367 8.55711 1.46867 8.14978 1.902L9.18978 2.929C9.39778 2.70367 9.61878 2.50867 9.85278 2.344C10.0868 2.17067 10.3554 2.084 10.6588 2.084C11.0228 2.084 11.3088 2.19234 11.5168 2.409C11.7248 2.617 11.8288 2.92467 11.8288 3.332C11.8288 3.62667 11.7378 3.93867 11.5558 4.268C11.3824 4.58867 11.1354 4.93967 10.8148 5.321C10.5028 5.69367 10.1258 6.09667 9.68378 6.53C9.25045 6.95467 8.76945 7.414 8.24078 7.908Z",width:15,height:9},bold:{path:"M0.00100708 9V0.524002H2.90001C3.34201 0.524002 3.74934 0.558669 4.12201 0.628002C4.50334 0.688669 4.83267 0.801335 5.11001 0.966002C5.39601 1.13067 5.61701 1.34734 5.77301 1.616C5.93767 1.88467 6.02001 2.22267 6.02001 2.63C6.02001 2.82067 5.99401 3.01134 5.94201 3.202C5.89001 3.39267 5.81634 3.57034 5.72101 3.735C5.62567 3.89967 5.50867 4.047 5.37001 4.177C5.24001 4.307 5.08834 4.40234 4.91501 4.463V4.515C5.13167 4.567 5.33101 4.64934 5.51301 4.762C5.69501 4.866 5.85534 5.00034 5.99401 5.165C6.13267 5.32967 6.24101 5.52467 6.31901 5.75C6.39701 5.96667 6.43601 6.218 6.43601 6.504C6.43601 6.93734 6.34934 7.31 6.17601 7.622C6.01134 7.934 5.77734 8.194 5.47401 8.402C5.17934 8.60134 4.83267 8.753 4.43401 8.857C4.03534 8.95234 3.60634 9 3.14701 9H0.00100708ZM1.91201 3.917H2.80901C3.27701 3.917 3.61501 3.826 3.82301 3.644C4.03967 3.462 4.14801 3.21934 4.14801 2.916C4.14801 2.58667 4.03967 2.35267 3.82301 2.214C3.60634 2.07534 3.27267 2.006 2.82201 2.006H1.91201V3.917ZM1.91201 7.518H2.99101C4.03967 7.518 4.56401 7.13667 4.56401 6.374C4.56401 6.00134 4.43401 5.737 4.17401 5.581C3.91401 5.41634 3.51967 5.334 2.99101 5.334H1.91201V7.518Z",width:7,height:9},italic:{path:"M7 1.44444H5.06656L3.6687 8.05556H5.5V9H0.5V8.05556H2.6547L4.05256 1.44444H2V0.5H7V1.44444Z",width:7,height:9},line_break:{description:"Add line break",path:"M14 0V6H3.83L6.41 3.41L5 2L0 7L5 12L6.41 10.59L3.83 8H16V0H14Z",width:16,height:12},url:{description:"Add URL",path:"M8.03571429,6.69642857 C8.03571429,6.5476183 7.98363147,6.42113147 7.87946429,6.31696429 L6.71875,5.15625 C6.61458281,5.05208281 6.48809598,5 6.33928571,5 C6.18303493,5 6.0491077,5.05952321 5.9375,5.17857143 L6.16350446,5.40178571 L6.16350446,5.40178571 L6.21434766,5.4637896 C6.22447497,5.4770171 6.23542901,5.49169139 6.24720982,5.5078125 C6.28255226,5.55617584 6.30673357,5.6036084 6.31975446,5.65011161 C6.33277536,5.69661482 6.33928571,5.74776758 6.33928571,5.80357143 C6.33928571,5.9523817 6.2872029,6.07886853 6.18303571,6.18303571 C6.07886853,6.2872029 5.9523817,6.33928571 5.80357143,6.33928571 C5.74776758,6.33928571 5.69661482,6.33277536 5.65011161,6.31975446 C5.6036084,6.30673357 5.55617584,6.28255226 5.5078125,6.24720982 L5.42844742,6.18644594 L5.42844742,6.18644594 L5.37357392,6.13653276 L5.37357392,6.13653276 L5.17857143,5.9375 L5.17857143,5.9375 C5.05580296,6.05282796 4.99441964,6.18861529 4.99441964,6.34486607 C4.99441964,6.49367634 5.04650246,6.62016317 5.15066964,6.72433036 L6.30022321,7.87946429 C6.40067015,7.97991122 6.52715698,8.03013393 6.6796875,8.03013393 C6.82849777,8.03013393 6.9549846,7.98177132 7.05915179,7.88504464 L7.87946429,7.0703125 C7.98363147,6.96614531 8.03571429,6.84151858 8.03571429,6.69642857 Z M4.11272321,2.76227679 C4.11272321,2.61346652 4.0606404,2.48697969 3.95647321,2.3828125 L2.80691964,1.22767857 C2.70275246,1.12351138 2.57626562,1.07142857 2.42745536,1.07142857 C2.28236535,1.07142857 2.15587852,1.12165128 2.04799107,1.22209821 L1.22767857,2.03683036 C1.12351138,2.14099754 1.07142857,2.26562427 1.07142857,2.41071429 C1.07142857,2.55952455 1.12351138,2.68601138 1.22767857,2.79017857 L2.38839286,3.95089286 C2.48883979,4.05133979 2.61532662,4.1015625 2.76785714,4.1015625 C2.92410792,4.1015625 3.05803516,4.04389939 3.16964286,3.92857143 L2.94363839,3.70535714 L2.94363839,3.70535714 L2.85993304,3.59933036 L2.85993304,3.59933036 C2.8245906,3.55096702 2.80040929,3.50353446 2.78738839,3.45703125 C2.77436749,3.41052804 2.76785714,3.35937528 2.76785714,3.30357143 C2.76785714,3.15476116 2.81993996,3.02827433 2.92410714,2.92410714 C3.02827433,2.81993996 3.15476116,2.76785714 3.30357143,2.76785714 C3.35937528,2.76785714 3.41052804,2.77436749 3.45703125,2.78738839 C3.50353446,2.80040929 3.55096702,2.8245906 3.59933036,2.85993304 L3.70535714,2.94363839 L3.70535714,2.94363839 L3.92857143,3.16964286 L3.92857143,3.16964286 C4.0513399,3.0543149 4.11272321,2.91852757 4.11272321,2.76227679 Z M8.63839286,5.55803571 C8.95089442,5.87053728 9.10714286,6.24999777 9.10714286,6.69642857 C9.10714286,7.14285938 8.94903432,7.52045977 8.6328125,7.82924107 L7.8125,8.64397321 C7.50371869,8.95275452 7.1261183,9.10714286 6.6796875,9.10714286 C6.22953644,9.10714286 5.85007595,8.94903432 5.54129464,8.6328125 L4.39174107,7.47767857 C4.08295977,7.16889727 3.92857143,6.79129688 3.92857143,6.34486607 C3.92857143,5.8872745 4.09226027,5.4985135 4.41964286,5.17857143 L3.92857143,4.6875 C3.60862935,5.01488259 3.22172846,5.17857143 2.76785714,5.17857143 C2.32142634,5.17857143 1.94196585,5.02232299 1.62946429,4.70982143 L0.46875,3.54910714 C0.156248437,3.23660558 -8.52651283e-14,2.85714509 -8.52651283e-14,2.41071429 C-8.52651283e-14,1.96428348 0.158108538,1.58668309 0.474330357,1.27790179 L1.29464286,0.463169643 C1.60342416,0.154388337 1.98102455,1.42108547e-14 2.42745536,1.42108547e-14 C2.87760642,1.42108547e-14 3.25706691,0.158108538 3.56584821,0.474330357 L4.71540179,1.62946429 C5.02418309,1.93824559 5.17857143,2.31584598 5.17857143,2.76227679 C5.17857143,3.21986836 5.01488259,3.60862935 4.6875,3.92857143 L5.17857143,4.41964286 C5.4985135,4.09226027 5.8854144,3.92857143 6.33928571,3.92857143 C6.78571652,3.92857143 7.16517701,4.08481987 7.47767857,4.39732143 L8.63839286,5.55803571 Z",width:9.5,height:9.5},flourish_embed:{description:"Add Flourish embed",path:"M7.57358 5.28931L10.1281 6.04854L10.0432 6.517L7.37515 6.22624L9.44904 7.9224L9.20119 8.29833L6.86556 7.0207L8.11097 9.37696L7.7504 9.62552L6.06604 7.5604L6.34206 10.2078L5.89578 10.2926L5.11055 7.73772L4.36044 10.2926L3.89331 10.2078L4.16934 7.5604L2.50622 9.62552L2.12402 9.37696L3.38372 7.0207L1.04113 8.29833L0.793673 7.9224L2.88146 6.22624L0.213045 6.517L0.128113 6.04854L2.6479 5.28931L0.128113 4.53667L0.213045 4.06859L2.88146 4.35974L0.793673 2.66319L1.04113 2.28687L3.38372 3.56451L2.12402 1.20824L2.50622 0.960069L4.16934 3.02519L3.89331 0.377778L4.36044 0.292603L5.11055 2.84787L5.89578 0.292603L6.34206 0.377778L6.06604 3.02519L7.7504 0.960069L8.11097 1.20824L6.86556 3.56451L9.20119 2.28687L9.44904 2.66319L7.37515 4.35974L10.0432 4.06859L10.1281 4.53667L7.57358 5.28931Z",width:10,height:10}};function Gu(t,e){Vu=e||Yu;var n=At($u=yu({type:"div",attributes:{class:"text-editor-container settings-option"}})).select(".text-editor-container").html("");for(var r in n.append("div").attr("class","text-settings"),n.append("textarea").text(t.value).attr("class","text-input").on("blur",(function(){t.value=this.value,At(t).dispatch("change")})),Vu)Vu[r]&&Zu(r);(Vu.bindings||Vu.bindings_custom)&&(n.append("div").attr("class","text-bindings"),Xu()),Ve()}function Zu(t){if("bindings"!=t&&"bindings_custom"!=t){var e=At($u).select(".text-settings").append("div").attr("class","editor-section");if("style"==t){["h1","h2","bold","italic","line_break"].forEach((function(t){var n=Wu[t].description?Wu[t].description:"Add "+t+" text";e.append("div").attr("class","editor-button popup").attr("data-action",t).attr("data-popup-body",n).attr("data-popup-position","top").on("click",Ju).append("svg").attr("height",Wu[t].height).attr("width",Wu[t].width).attr("viewBox","0 0 "+Wu[t].width+" "+Wu[t].height).append("path").attr("fill","#333333").attr("d",Wu[t].path)}))}else{var n=Wu[t].description?Wu[t].description:"Add "+t;e.append("div").attr("class","editor-button popup").attr("data-action",t).attr("data-popup-body",n).attr("data-popup-position","top").on("click",Ju).append("svg").attr("height",Wu[t].height).attr("width",Wu[t].width).attr("viewBox","0 0 "+Wu[t].width+" "+Wu[t].height).append("path").attr("fill","#333333").attr("d",Wu[t].path)}}}function Xu(){if(Vu.bindings||Vu.bindings_custom){var t;if(Array.isArray(Vu.bindings))t={},Vu.bindings.forEach((function(e){var n=e.split("."),r=n[0],i=n.length>1?n[1]:null;i&&(t[r]||(t[r]=[]),t[r].push(i))}));else if(!0===Vu.bindings)t=null;else if(!Array.isArray(Vu.bindings_custom))return;var e=Pu.visualisation.data_bindings[Pu.visualisation.template_id],n={},r=[];Pu.visualisation.data_tables.forEach((function(t){n[t.id]=t.cached_data[0]}));var i=null!==t;for(var a in e)if(!i||t[a]){var o=e[a];for(var s in o)if(!i||t[a].includes(s)){var l=o[s];if(null!=l.column){var u=n[l.data_table_id][l.column];u&&!r.includes(u)&&r.push(u)}else l.columns&&l.columns.forEach((function(t){var e=n[l.data_table_id][t];e&&!r.includes(e)&&r.push(e)}))}}Vu.bindings_custom&&Array.isArray(Vu.bindings_custom)&&Vu.bindings_custom.forEach((function(t){t[0]&&t[1]&&r.push({name:t[0],binding:t[1],type:"dynamic"})})),At(".text-bindings").html("").style("display",r.length?null:"none").append("p").text("Click to add values from your data"),At(".text-bindings").selectAll("button.binding").data(r).enter().append("button").attr("data-action","binding").attr("data-binding",(function(t){return"object"==typeof t?t.binding:t})).attr("data-type",(function(t){return"object"==typeof t?t.type:null})).on("click",Ju).text((function(t){return"object"==typeof t?t.name:t}))}}function Ju(){var t,e=At(".text-editor-container .text-input"),n=e.node().value,r=e.node().selectionStart,i=e.node().selectionEnd,a=i-r,o=n.substr(r,a),s=At(this).attr("data-action"),l="flourish_embed"==s?prompt("Specify the ID of published Flourish project (eg. story/123 or visualisation/124)","visualisation/"):"";if("bold"==s)t=Ku(o,"<b>","</b>");else if("italic"==s)t=Ku(o,"<i>","</i>");else if("h1"==s)t=Ku(o,"<h1>","</h1>");else if("h2"==s)t=Ku(o,"<h2>","</h2>");else if("line_break"==s)t=Ku(o,"<br>","");else if("url"==s)t=Ku(o,'<a href ="">',"</a>",10);else if("flourish_embed"==s)t=Ku(l,'<iframe src="https://flo.uri.sh/','/embed" frameborder="0" scrolling="no" style="width:100%;height:400px;"></iframe>');else if("binding"==s){var u=At(this).attr("data-binding");t=Ku(u,"{{","}}",u.length+4)}e.node().setRangeText(t.text,r,i),e.node().focus(),e.node().selectionStart=r+t.cursor,e.node().selectionEnd=r+t.cursor}function Ku(t,e,n,r){return e=e||"",n=n||"",t=t||"",{cursor:r||e.length+t.length,text:e+t+n}}var Qu,tc,ec,nc={initialize:function(t,e,n){Pu=t,At(e.parentElement).append("div").attr("class","text-editor-btn").attr("tabindex","0").on("click",(function(){Gu(e,n.editor)})).on("keydown",(function(t){13==t.keyCode&&Gu(e,n.editor)})).append("i").attr("class","fa fa-paint-brush")},updateDataBindings:Xu},rc=void 0,ic=/fa-(\S*)/g,ac=/^data:image\/(svg|svg\+xml|png|jpg);base64,[A-Z-a-z0-9+/=]*$/,oc=/^gradient:/g;function sc(t){var e=!At(t.parentNode).classed("open");kt(".template-settings .settings-block").classed("open",!1).attr("aria-expanded",!1),e&&At(t.parentNode).classed("open",!0).attr("aria-expanded",!0)}function lc(t){if(t){rc={};for(var e=0,n=null,r=null,i=Qu&&Qu.user?Qu.user.template_settings_overrides:{},a=0;a<t.length;a++){var o=t[a];if("string"!=typeof o){if("object"!=typeof o||n||r||(e++,r=ec.append("div").attr("class","toplevel-settings-block")),"hidden"!==o.type){var s=n||r;if(o.new_section&&(s.append("div").classed("settings-divider",!0),"string"==typeof o.new_section&&s.append("h3").classed("settings-subhead",!0).text(o.new_section)),void 0!==o.show_if){if(o.show_condition)throw new Error("BUG: show_if present as well as show_condition");o.show_condition=[{type:"show",condition:o.show_if}],delete o.show_if}else if(void 0!==o.hide_if){if(o.show_condition)throw new Error("BUG: hide_if present as well as show_condition");o.show_condition=[{type:"hide",condition:o.hide_if}],delete o.hide_if}rc[o.property]=o.type,uc(s.append("div"),o,i)}}else r=null,(n=ec.append("div").attr("class","settings-block")).append("h2").attr("class","no-select").attr("tabindex","0").text(o).on("click",(function(){sc(this)})).on("keyup",(function(t){13===t.keyCode&&sc(this)})),n.classed("open",e<1),n.attr("aria-expanded",e<1),"State documentation"===o&&n.style("display","none"),e++}kt(".upgrade-setting").on("click",(function(){!function(t,e,n,r){var i=[],a=[];i.push(["Upgrade to a premium account to get:"]),a.push(["<strong>Branding control:</strong> Add custom logos, colors, and styles to keep your projects consistent with your brand identity","<strong>Logo removal:</strong> Embed your projects without the Flourish logo appended","<strong>Team management:</strong> Seamlessly manage your team with our collaboration and approval features"]);var o=Math.floor(Math.random()*i.length),s=Math.floor(Math.random()*a.length),l="title"+o+"-list"+s,u=[{text:"Upgrade now",class:"convert",tag_name:"a",href:"https://flourish.studio/pricing",target:"_blank",keyCode:13,callback:function(){t.analytics("event","upgrade-click",{upgrade_id:l}),ds.logHistory({category:"upgrade",action:"clicked",detail:r})}},{text:"Maybe later",keyCode:27,class:"secondary",callback:function(){t.analytics("event","upgrade-close",{upgrade_id:l}),ds.logHistory({category:"upgrade",action:"closed",detail:r})}}];t.analytics("event","upgrade-open",{upgrade_id:l}),ds.logHistory({category:"upgrade",action:"viewed",detail:r}),Wi(e,n,{buttons:u,is_html:!0,upgrade:{message:i[o],list:a[s],is_business:!0}})}(Qu,"This is a premium feature","Upgrade your plan to change this setting.","upgrade-settings")})),Ve()}}function uc(t,e,n){e.upgrade=e.property in n;var r="html"==e.type,i=e.choices&&("buttons"==e.style||"boolean"==e.type);t.attr("class","settings-option option-type-"+e.type+(i?" settings-buttons":"")+(r?" text-editor":"")+(e.upgrade?" upgrade-setting":""));var a=t.append("label").attr("for","setting-"+e.property).classed("hidden",null==e.name).append("h3").text(e.name).classed("no-select",!0);e.upgrade?a.append("i").attr("class","popup fa fa-star setting-tooltip tooltip-upgrade").style("font-family","FontAwesome").style("background-color","#93366e").attr("data-popup-head","This is a premium feature").attr("data-popup-body",e.description?e.description.replace(/\[\[/g,"").replace(/\]\]/g,""):"").attr("data-popup-position","top"):e.description&&a.append("i").attr("class","popup fa fa-question setting-tooltip tooltip-help").style("font-family","FontAwesome").attr("data-popup-body",e.description.replace(/\[\[/g,"").replace(/\]\]/g,"")).attr("data-popup-position","top"),e.width&&t.classed("width-"+e.width.replace(/ /g,"-"),!0);var o="input";if(["text","code","html"].includes(e.type)&&(o="textarea"),"code"==e.type){var s=!1;t.append("i").attr("class","popup fa fa-reply clickable wrap-control").attr("data-popup-body","Wrap/unwrap text").attr("data-popup-position","top").on("click",(function(){s=!s,At(this.parentNode).select("textarea").attr("wrap",s?null:"off"),At(this).classed("selected",s)}))}var l=t.append(o).attr("id","setting-"+e.property).attr("class","setting").attr("name",e.property).attr("disabled",!Qu.visualisation.can_edit||null),u=l.node();if("colors"==e.type)qu.initialize(u,e);else if("font"==e.type)qo.initialize(u,e,Qu.user&&null!=Qu.user.company_id);else if("number"==e.type)u.setAttribute("type","number"),null!=e.min&&u.setAttribute("min",e.min),null!=e.max&&u.setAttribute("max",e.max),e.step&&u.setAttribute("step",e.step);else if("url"==e.type)u.setAttribute("type","url"),tc.addButton(u,e.upgrade);else if(i){l.remove(),l=t.append("div").attr("id","setting-"+e.property).attr("name",e.property).classed("buttons-container",!0).classed("large","large"==e.size),u=l.node();var c=e.choices.length,d=[3,4,5],f=function(){if(c<=2)return{column_count:c,rows:1};var t=d.map((function(t){return{column_count:t,orphans:c%t/t,rows:c/t}})).filter((function(t){return t.rows>=1})).sort((function(t,e){return t.rows>e.rows?1:t.rows<e.rows?-1:0})),e=t.filter((function(t){return 0===t.orphans}));return 1===e.length||e.length>1?e[0]:0===e.length?t.sort((function(t,e){return t.orphans>e.orphans?-1:t.orphans<e.orphans?1:0}))[0]:void 0}();e.choices.forEach((function(t,n){l.append("input").attr("type","radio").attr("name",e.property).attr("value",t[1]).attr("id",e.property+"_"+n).attr("class","setting").attr("disabled",!Qu.visualisation.can_edit||null).call(cc(e)),pc(t,l.append("label").attr("for",e.property+"_"+n).style("width",100/f.column_count+"%").style("border-radius",(function(){var t=f.column_count,e=Math.ceil(f.rows),r=t*e-c;return e<=1?0===n?"3px 0 0 3px":n===t-1?"0 3px 3px 0":null:e>1?0===n?"3px 0 0 0":n===t-1?"0 3px 0 0":n===c-(t-r)?"0 0 0 3px":n===c-1&&0===r?"0 0 3px 0":null:null})).node())}))}else"boolean"==e.type?(u.setAttribute("type","checkbox"),t.classed("slider-container",!0),t.append("label").attr("class","slider").attr("for","setting-"+e.property)):u.setAttribute("type","text");if("code"==e.type&&(u.setAttribute("wrap","off"),l.on("keydown.tab",(function(t){var e=t;if(9===e.keyCode&&!(e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)){e.preventDefault();var n=this.selectionStart;this.value=this.value.substring(0,n)+"\t"+this.value.substring(this.selectionEnd),this.selectionEnd=n+1}}))),r&&(t.append("div").attr("class","text-editor-setting").node().appendChild(u),nc.initialize(Qu,u,e)),e.choices&&"string"==e.type&&"buttons"!=e.style&&Zi(u,e.property+"-dropdown",e.choices,{allow_other_option:e.choices_other,custom_renderer:pc}),"color"==e.type){At(u).classed("color",!0).style("display","none");var p=At(u.parentNode).append("div").attr("class","color-picker"),h=p.append("div").attr("class","color-wrapper");e.optional&&p.append("div").attr("class","cancel-setting popup").attr("tabindex","0").html("<svg><use xlink:href='#cancel-setting'></use></svg>").attr("data-popup-body","If cleared, the color will be set automatically based on the theme or context").on("click keydown",(function(t){t.keyCode&&13!==t.keyCode||(u.value="",l.dispatch("change"),At(this.parentNode).classed("is-null",!0))})),h.append("input").attr("type","color").on("change",(function(){u.value=this.value,l.dispatch("change"),At(this.parentNode.parentNode).classed("is-null",!1)})).on("focus",(function(){At(this.parentNode.parentNode).classed("active",!0)})).on("blur",(function(){At(this.parentNode.parentNode).classed("active",!1)}))}e.placeholder&&u.setAttribute("placeholder",e.placeholder),e.size&&u.classList.add("size-"+e.size),l.call(cc(e))}function cc(t){return function(e){var n=!1;e.on("change",(function(){var e=this;Re.hide(),n=!0,Qu.preview_pane.getState(t.property,(function(r,i){return r?(console.error("Failed to get state property "+t.property,r),void(n=!1)):function(t,e){if("number"!==e.type)return!0;if(""===t.value)return!!e.optional||(Re.point(t).text("A value is required").draw(),!1);var n=parseFloat(t.value);return e.hasOwnProperty("min")&&n<e.min?(Re.point(t).text("Value cannot be less than "+e.min).draw(),t.value=e.min):e.hasOwnProperty("max")&&n>e.max&&(Re.point(t).text("Value cannot be greater than "+e.max).draw(),t.value=e.max),!0}(e,t)?void function(t,e,n){r=e.property,i=100,a=hc,o=[t,e,n],clearTimeout(fs[r]),fs[r]=setTimeout((function(){a.apply(window,o),delete fs[r]}),i);var r,i,a,o}(e,t,(function(r){if(!r)return n=!1,void("SELECT"==e.tagName&&At(e).dispatch("blur"));var a="radio"==e.type?e.nextSibling:e;Re.point(a).text("Not changed: "+r).draw();var o={};o[t.property]=i,Qu.preview_pane.setState(o,(function(r){if(r)return console.error("Failed to revert setting "+t.property+" to value: "+i),void(n=!1);Qu.preview_pane.update((function(r){if(r)return console.error("Failed to update after reverting setting "+t.property+" to value: "+i),void(n=!1);fc(e,i),n=!1}))}))})):(e.value=i,void(n=!1))}))})).on("keydown",(function(t){Qu.confirm.blank(),13==t.keyCode&&Re.hide()})).on("blur",(function(){if(!n){var e=this;Re.hide(),Qu.preview_pane.getState(t.property,(function(n,r){n?console.error("Failed to get state property "+t.property,n):fc(e,r)}))}}))}}function dc(t,e,n){if(t.classList.contains("colors"))return qu.getValue(t);if(t.classList.contains("font-menu")){var r=qo.getValue(t);return e&&!r?n?null:"":r}if(t.classList.contains("buttons-container")){for(var i,a=t.querySelectorAll("input[type='radio']"),o=0;o<a.length;o++)if(a[o].checked){i=a[o];break}if(!i)return n?null:"";t=i}switch(t.getAttribute("type")){case"checkbox":return t.checked;case"number":return e&&!t.value.length?n?null:"":+t.value;case"radio":if(t.parentNode.parentNode.classList.contains("option-type-boolean"))return"true"==t.value;default:return e&&t.classList.contains("color")&&!t.value.length?n?null:"":t.hasAttribute("data-value")?t.getAttribute("data-value"):t.value}}function fc(t,e){if(t.classList.contains("colors"))qu.update(t,e);else if(t.classList.contains("font-menu"))qo.update(t,e);else if("checkbox"==t.getAttribute("type"))t.checked=e;else if(t.classList.contains("color"))t.value=e,At(t.parentNode).select(".color-picker").classed("is-null",null===e),At(t.parentNode).select(".color-wrapper input").node().value=e;else if(t.getAttribute("data-autocomplete")){for(var n=function(t){for(var e=0;e<Qu.settings.length;e++){var n=Qu.settings[e];if(n.property===t)return n}}(t.name),r=0;r<n.choices.length;r++){var i,a,o=n.choices[r];if("string"==typeof o?i=a=o:(i=o[1],a=o[0]),e==i)return t.value=a,void t.setAttribute("data-value",i)}t.value=e,t.setAttribute("data-value",e)}else if(t.className.indexOf("buttons-container")>-1){var s=t.querySelectorAll("input[type='radio']");for(r=0;r<s.length;r++)s[r].value===""+e&&(s[r].checked=!0)}else t.value=e}function pc(t,e){var n=At(e);if("string"!=typeof t){var r=t[2];if(r)if(r.match(ic))n.append("i").attr("class","fa "+r);else if(r.match(ac))n.append("img").attr("src",r);else if(r.match(oc)){var i=r.replace("gradient:","");n.append("div").attr("class","gradient-swatch").style("width","15px").style("height","15px").style("margin-right","5px").style("border-radius","15px").style("background","linear-gradient(to right, "+i+")")}var a=t[0];a.match(ic)?n.append("i").attr("class","fa "+a):a.match(ac)?n.append("img").attr("src",a):n.node().append(a)}else n.text(t)}function hc(t,e,n){var r={},i=dc(t,e.optional);if(r[e.property]=i,!("choices"in e)||"colors"===e.type||function(t,e){return!!t.choices_other||-1!==t.choices.map((function(t){return t instanceof Array?t[1]:t})).indexOf(e)}(e,i)){Qu.confirm.saving();var a=!1,o={};o[e.property]=dc(t,e.optional,!0),Qu.preview_pane.setState(o,(function(t){if(t)return s(t);Qu.preview_pane.update((function(t){if(t)return s(t);Qu.visualisation.updateSettings(r,(function(t){if(t)return s(t);Qu.analytics("event","visualisation",{change_setting:Qu.visualisation.id}),gc(),Qu.confirm.saved(),n&&n()}))}))}))}else n&&n("You can only choose values from the list");function s(r){a||(Qu.preview_pane.getState(e.property,(function(e,i){if(e)return console.error("Failed to get state",e),void Qu.confirm.error(e);fc(t,i),gc(),Qu.confirm.blank(),n&&n(r)})),a=!0)}}function mc(t,e){return/^data\./.test(t)?function(t,e){var n=t.split(".");return Qu.visualisation.__sdk__?function(t,e){if(t.length>=4)return;for(var n=null,r=Qu.template_data_bindings,i=0;i<r.length;i++){var a=r[i];if("string"!=typeof a&&(a.dataset===t[1]&&a.key===t[2])){n=a;break}}if(!n)throw new Error("Bug: data binding not found - these should already have been checked");return"column"===n.type?!!n.column===e:!!n.columns.split("::")[1]===e}(n,e):function(t,e){if(t.length<4){return!!document.getElementById("data-binding-"+t[1]+"-"+t[2]).value===e}if("type"!==t[3])throw new Error("Fourth part of name must be “type”");var n=Qu.visualisation.template_id,r=Qu.visualisation.data_bindings[n][t[1]][t[2]];if(null==r)return!1;for(var i,a=Qu.visualisation.data_tables,o=r.data_table_id,s=r.columns||[r.column],l=0;l<a.length;l++)if(a[l].id===o){i=a[l].column_types;break}var u=!1;for(l=0;l<s.length;l++){var c=i[s[l]].type_id.split("$")[0];if(u=-1!==(Array.isArray(e)?e:[e]).indexOf(c))break}return u}(n,e)}(t,e):function(t,e){var n=document.getElementById("setting-"+t);if(!n)return console.error("Could not find input for setting",t),!1;var r=dc(n);if(e instanceof Array)return-1!==e.indexOf(r);return r===e}(t,e)}function gc(){Qu.settings.filter((function(t){return"object"==typeof t&&"show_condition"in t})).forEach((function(t){var e=t.show_condition.every((function(t){var e="show"===t.type,n=t.condition;if("boolean"==typeof n)return e===n;if("string"==typeof n)return e===mc(n,!0);for(var r in n)if(!mc(r,n[r]))return!1===e;return e})),n=document.getElementById("setting-"+t.property);if(n){for(var r=n;!r.classList.contains("settings-option");)r=r.parentNode;if(At(r).classed("hidden",!e),t.new_section)for(var i=r.previousSibling;i&&(At(i).classed("settings-divider")||At(i).classed("settings-subhead"));)At(i).classed("hidden",!e),i=i.previousSibling}else console.error("Could not find input",t.property)}));for(var t=document.querySelectorAll(".template-settings .settings-block, .template-settings .toplevel-settings-block"),e=0;e<t.length;e++){var n=t[e];n.classList.contains("hidden")?null!==n.querySelector(".settings-option:not(.hidden)")&&n.classList.remove("hidden"):null==n.querySelector(".settings-option:not(.hidden)")&&n.classList.add("hidden")}}function vc(t,e,n){return Qu=t,tc={setup:Eo,addButton:ko,startUpload:Lo},(ec=At(".side-panel .template-settings")).on("submit",(function(t){t.preventDefault()})),qu.replaceThemeColors(e),qo.replaceThemeFonts(n),lc(Qu.settings),function(){function t(e,n){return!e||e.classList.contains("template-settings")?null:e.classList.contains(n)?e:t(e.parentNode,n)}function e(t){return t.replace(/ /g,"").replace(/-/g,"").toLowerCase().trim()}At(".side-panel .template-settings-search").on("input",(function(n){var r=e(n.target.value),i=!r,a=At(".side-panel .template-settings").selectAll(".settings-block:not(.hidden) > h2, .settings-option:not(.hidden) h3, .settings-subhead:not(.hidden)");At(".side-panel .template-settings").selectAll(".settings-block:not(.hidden) > h2, .settings-option:not(.hidden), .settings-subhead:not(.hidden), .settings-divider:not(.hidden)").classed("search-filtered-out",!i),i||a.filter((function(){var t=e(this.innerText);return!!t&&t.indexOf(r)>-1})).each((function(){var e=t(this,"settings-block"),n=At(this);if("H2"==this.tagName)e&&At(e).selectAll("h2, .settings-option, .settings-subhead, .settings-divider").classed("search-filtered-out",!1);else if("H3"==this.tagName)if(e&&At(e).select("h2").classed("search-filtered-out",!1),n.classed("settings-subhead")){n.classed("search-filtered-out",!1),this.previousSibling.classList.remove("search-filtered-out");for(var r=this.nextSibling;r&&r.classList.contains("settings-option");)r.classList.remove("search-filtered-out"),r=r.nextSibling}else{var i=t(this,"settings-option");if(i){i.classList.remove("search-filtered-out");for(var a=null,o=i.previousSibling;o&&null==a;)o.classList.contains("settings-subhead")?a=o:o=o.classList.contains("settings-divider")?null:o.previousSibling;a&&(a.classList.remove("search-filtered-out"),a.previousSibling.classList.remove("search-filtered-out"))}}}))}))}(),At(".side-panel-scrollbox").on("scroll",(function(){Re.hide()})),{update:function(t){ec.html(""),At(".current-template").style("opacity","1"),lc(Qu.settings=t)},populate:function(){Qu.preview_pane.getState((function(t,e){if(t)console.error("Failed to get state",t);else{var n=za(e);for(var r in n){var i=document.getElementById("setting-"+r);i&&fc(i,n[r])}nc.updateDataBindings(),gc()}}))},getSettingsForCurrentTemplate:function(){return rc},setReadOnly:function(){kt(".setting").each((function(){At(this).attr("disabled",!0)}))},unsetReadOnly:function(){kt(".setting").each((function(){At(this).attr("disabled",null)}))}}}var yc,bc,_c=!1,wc=[];function xc(){At(".flourish-warn-list").classed("visible",!1),_c=!1}function Cc(){return At(".flourish-warn-btn").on("click",(function(){_c?xc():(At(".flourish-warn-list").classed("visible",!0),_c=!0)})),{clear:Ec,warn:kc}}function Ac(){At(".flourish-warn-container").classed("visible",wc.length),wc.length>100&&(wc.length=100);var t=At(".flourish-warn-list ul").selectAll("li").data(wc),e=t.enter().append("li");e.append("i").attr("class","fa fa-warning"),e.append("p").attr("class","message"),e.append("p").attr("class","explanation");var n=t.merge(e);n.select(".message").text((function(t){return t.message||""})),n.select(".explanation").text((function(t){return t.explanation||""})),t.exit().remove()}function Ec(){wc=[],Ac(),xc()}function kc(t){wc.unshift(t),Ac()}function Tc(t){var e=yc.visualisation,n=e.getTemplate(),r=!1,i=!1,a=!1;function o(){var e=yc.template_settings.getSettingsForCurrentTemplate(),n=yc.visualisation.settingsForCurrentTemplate(),r={};for(var i in n)i in e&&(r[i]=n[i]);bc.loadVisualisation(yc,r,(function(){yc.template_settings.populate(),yc.data_bindings.updateRequiredBindingsOverlay(!1),_o(),t&&t()})),St()}n.getSettings((function(t,e){t?console.error("Failed to get template settings: "+t):(yc.template_settings.update(e),r=!0,i&&a&&o())})),n.getDataBindings((function(t,e){t?console.error("Failed to get template data bindings: "+t):(yc.data_bindings.update(e),i=!0,r&&a&&o())})),e.refreshDataBindings((function(t){t?console.error("Failed to get template data bindings: "+t):(a=!0,i&&r&&o())}))}function Lc(t){bc.updateData(yc.visualisation,t)}function Dc(t){bc.updateDataNotPreview(yc.visualisation,t)}function Fc(t){yc=t;var e=Cc();return{loadTemplate:Tc,updateData:Lc,updateDataNotPreview:Dc,sync:(bc=yo("iframe#preview","editor",yc,e,{setSetting({name:t,value:e}){const n=function(t){return document.getElementById("setting-"+t)}(t);n?(fc(n,e),n.dispatchEvent(new Event("change"))):console.log(`Could not find setting ${t}`)}})).sync,setState:bc.setState,getState:bc.getState,hasData:bc.hasData,setData:bc.setData,getData:bc.getData,draw:bc.draw,update:bc.update,getDefaultState:bc.getDefaultState,snapshot:bc.snapshot,setFixedHeight:bc.setFixedHeight,resize:bc.resize,getDrawCalled:bc.getDrawCalled,setDrawCalled:bc.setDrawCalled}}var Sc={},Mc={};function Nc(t){return new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'})).join(",")+"}")}function Uc(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 Oc(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function Hc(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":function(t){return t<0?"-"+Oc(-t,6):t>9999?"+"+Oc(t,6):Oc(t,4)}(t.getUTCFullYear())+"-"+Oc(t.getUTCMonth()+1,2)+"-"+Oc(t.getUTCDate(),2)+(i?"T"+Oc(e,2)+":"+Oc(n,2)+":"+Oc(r,2)+"."+Oc(i,3)+"Z":r?"T"+Oc(e,2)+":"+Oc(n,2)+":"+Oc(r,2)+"Z":n||e?"T"+Oc(e,2)+":"+Oc(n,2)+"Z":"")}var Bc=function(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],a=t.length,o=0,s=0,l=a<=0,u=!1;function c(){if(l)return Mc;if(u)return u=!1,Sc;var e,r,i=o;if(34===t.charCodeAt(i)){for(;o++<a&&34!==t.charCodeAt(o)||34===t.charCodeAt(++o););return(e=o)>=a?l=!0:10===(r=t.charCodeAt(o++))?u=!0:13===r&&(u=!0,10===t.charCodeAt(o)&&++o),t.slice(i+1,e-1).replace(/""/g,'"')}for(;o<a;){if(10===(r=t.charCodeAt(e=o++)))u=!0;else if(13===r)u=!0,10===t.charCodeAt(o)&&++o;else if(r!==n)continue;return t.slice(i,e)}return l=!0,t.slice(i,a)}for(10===t.charCodeAt(a-1)&&--a,13===t.charCodeAt(a-1)&&--a;(r=c())!==Mc;){for(var d=[];r!==Sc&&r!==Mc;)d.push(r),r=c();e&&null==(d=e(d,s++))||i.push(d)}return i}function i(e,n){return e.map((function(e){return n.map((function(t){return o(e[t])})).join(t)}))}function a(e){return e.map(o).join(t)}function o(t){return null==t?"":t instanceof Date?Hc(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,a=r(t,(function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=Nc(t);return function(r,i){return e(n(r),i,t)}}(t,e):Nc(t)}));return a.columns=i||[],a},parseRows:r,format:function(e,n){return null==n&&(n=Uc(e)),[n.map(o).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=Uc(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(a).join("\n")},formatRow:a,formatValue:o}}(","),Rc=Bc.parseRows,jc=Bc.formatRows;function Ic(t,e,n){ns(this,"object"==typeof e?(n=e).id:e,void 0,n,{getVersionNumber:function(){return t.version_number},setVersionNumber:function(e){t.version_number=e}}),this.visualisation=t,this.api_prefix="/api/data_table"}function zc(t){return t.map((function(t){return null!=t&&"object"==typeof t&&"map"in t?zc(t):t}))}function Pc(t){this.id=t}function $c(t,e,n){if(ns(this,t,e,n),this.api_prefix="/api/visualisation",this.data_tables){var r=this;this.data_tables=this.data_tables.map((function(t){return new Ic(r,t)}))}}function qc(t,e,n){ss({url:t.api_prefix+"/"+t.id+"/data_bindings",method:"POST",payload:function(){return{version_number:t.version_number,data_bindings:e}},callback:function(r,i){if(r)return n(r);t.version_number=i.version_number,t.data_bindings||(t.data_bindings={}),t.template_id in t.data_bindings||(t.data_bindings[t.template_id]={});var a=t.data_bindings[t.template_id];for(var o in e)for(var s in e[o]){var l=e[o][s];a[o]||(a[o]={}),null===l?delete a[o][s]:a[o][s]=l}n(void 0)}})}function Vc(t,e,n){ss({url:t.api_prefix+"/"+t.id+"/settings",payload:function(){return{version_number:t.version_number,settings:e}},callback:function(r,i){if(r)return n(r);t.version_number=i.version_number,t.settings||(t.settings={}),t.template_id in t.settings||(t.settings[t.template_id]={});var a=t.settings[t.template_id];for(var o in e){var s=e[o];a[o]=s}n(void 0)}})}function Yc(t,e,n,r){ss({url:t.api_prefix+"/"+t.id+"/publish",payload:function(){return{password:n,anyone_can_duplicate:r}},callback:function(n,r){if(n)return e(n);t.version_number=r.version_number,t.embed_url=r.embed_url,t.showcase_url=r.showcase_url,t.is_password_protected=r.is_password_protected,t.anyone_can_duplicate=r.anyone_can_duplicate,e(void 0,r)}})}function Wc(t,e){for(var n in e)"object"!=typeof t[n]||null==t[n]||Array.isArray(t[n])||"object"!=typeof e[n]||null==e[n]||Array.isArray(e[n])?t[n]=e[n]:Wc(t[n],e[n])}function Gc(t,e,n,r){function i(){}this.visualisation=t,this.settings=e,this.template_data_bindings=n,this.public_url_prefix=r,this.is_read_only=!1,this.template_settings=vc(this),this.data_bindings=(Ji=this,Ki=At(".data-bindings"),{update:function(t){t&&(Ji.template_data_bindings=t),ia(Ji.visualisation,Ji.template_data_bindings)},modify:function(t,e=!1){oa(t,(function(){ia(Ji.visualisation,Ji.template_data_bindings),e&&Ji.preview_pane.updateData((t=>{if(t)return console.error("Failed to update preview pane: "+t)}))}))},requiredBindingsAreUnset:ua,updateRequiredBindingsOverlay:ca}),this.preview_pane=Fc(this),this.responsive_menu=Ft(this),this.confirm={on:i,blank:i,saved:i,saving:i,error:i},this.analytics=i,this.tour={fireEvent:i},window.addEventListener("hashchange",(()=>{this.loadFromUrlHash()}))}Ic.prototype.getColumnTypes=function(t){ss({url:this.api_prefix+"/"+this.id,method:"GET",callback:function(e,n){if(e)return t(e);t(void 0,zc(n.column_types||[]))}},"load-data")},Ic.prototype.csv=function(t){this.cached_data?t(void 0,zc(this.cached_data)):this.csvPromise().then((e=>t(null,e)),(e=>t(e)))},Ic.prototype.csvPromise=async function(){if(this.cached_data)return zc(this.cached_data);const t=this;return new Promise(((e,n)=>{ss({url:this.api_prefix+"/"+this.id+"/csv",response_type:"text/csv; charset=utf-8",method:"GET",callback(r,i){if(r)return n(r);t.cached_data=Rc(i),e(zc(t.cached_data))}},"load-data")}))},Ic.prototype.saveData=function(t,e){var n=this,r=Ii(zc(t));ss({url:this.api_prefix+"/"+this.id+"/csv",payload:function(){return{version_number:n.getVersionNumber(),data:jc(r)}},callback:function(t,i){if(t)return e(t);n.setVersionNumber(i.version_number),n.cached_data=r,e(void 0)}})},Ic.prototype.updateFromUrl=function(t,e){var n=this;ss({url:this.api_prefix+"/"+this.id+"/csv-url",payload:function(){return{live_csv_url:t,version_number:n.getVersionNumber()}},callback:function(r,i){if(r)return e(r);n.setVersionNumber(i.version_number),n.live_csv_url=t,t?n.updateFromLiveCsvUrl((function(t,r){if(t)return n.last_remote_data_error_message=t,e(t);var i,a=((i=Ii(Rc(r.csv))).forEach((function(t){for(var e=0;e<t.length;e++)t[e]&&"string"==typeof t[e]&&(t[e]=t[e].trim())})),i);n.cached_data=a,n.setVersionNumber(r.version_number),n.t_updated=r.t_updated,n.last_remote_data_error_message=null,e(void 0,a,r.new_column_types)})):(n.t_updated=i.t_updated,n.last_remote_data_error_message=null,e(void 0,null,null))}})},Ic.prototype.updateFromLiveCsvUrl=function(t){var e=this;ss({url:this.api_prefix+"/"+this.id+"/update-from-live-csv-url",payload:function(){return{version_number:e.getVersionNumber()}},callback:function(n,r){if(n)return t(n);e.setVersionNumber(r.version_number),t(void 0,r)}})},Ic.prototype.save=function(t,e){return us(this,t,e)},Ic.prototype.delete=function(t){return cs(this,t)},Pc.prototype.getSettings=function(t){if(this.settings)t(void 0,this.settings);else{var e=this;ss({url:"/api/template/"+this.id+"/settings",method:"GET",callback:function(n,r){if(n)return t(n);e.settings=r.settings,t(void 0,e.settings)}})}},Pc.prototype.getDataBindings=function(t){ss({url:"/api/template/"+this.id+"/data_bindings",method:"GET",callback:t})},$c.prototype.save=function(t,e){this.is_listed||(t.is_listed=!0),us(this,t,e)},$c.prototype.setTemplateId=function(t,e){us(this,{template_id:t},e)},$c.prototype.getTemplate=function(){return this.template_id?(this._template&&this.template_id==this._template.id||(this._template=new Pc(this.template_id)),this._template):null},$c.prototype.settingsForCurrentTemplate=function(){return this.settings&&this.template_id in this.settings?this.settings[this.template_id]:{}},$c.prototype.getState=function(t){this.template_id||t({});var e=this.settingsForCurrentTemplate();this.getTemplate().getSettings((function(n,r){if(n)throw n;for(var i={},a=0;a<r.length;a++){var o=r[a];o.property in e&&(i[o.property]=e[o.property])}t(Pa(i))}))},$c.prototype.dataBindingsForCurrentTemplate=function(){return this.data_bindings&&this.template_id in this.data_bindings?this.data_bindings[this.template_id]:{}},$c.prototype.refreshDataBindings=function(t){var e=this;ss({url:this.api_prefix+"/"+this.id+"/data_bindings",method:"GET",callback:function(n,r){if(n)return t(n);e.data_bindings=r,t()}})},$c.prototype.resetToTheme=function(t){var e=this;ss({url:this.api_prefix+"/"+this.id+"/reset_to_theme",method:"POST",payload:function(){return{version_number:e.version_number}},callback:function(n,r){if(n)return t(n);e.version_number=r.version_number,t(void 0)}})},$c.prototype.updateDataBindings=function(t,e){var n=this;if(this.is_listed)return qc(n,t,e);this.save({is_listed:!0},(function(r){return r?e(r):qc(n,t,e)}))},$c.prototype.updateSettings=function(t,e){var n=this;if(this.is_listed)return Vc(n,t,e);this.save({is_listed:!0},(function(r){return r?e(r):Vc(n,t,e)}))},$c.prototype.refreshSettings=function(t){var e=this;ss({url:this.api_prefix+"/"+this.id+"/settings",method:"GET",callback:function(n,r){if(n)return t(n);e.settings=r,t()}})},$c.prototype.getThemeFontsAndColors=function(t){ss({url:this.api_prefix+"/"+this.id+"/theme-fonts-and-colors",method:"GET",callback:function(e,n){if(e)return t(e);t(void 0,n.fonts,n.colors)}})},$c.prototype.getDataTables=function(t){ss({url:this.api_prefix+"/"+this.id+"/data",method:"GET",callback:function(e,n){return e?t(e):t(void 0,n.data)}})},$c.prototype.dataTables=function(t){var e=this;e.data_tables?t(void 0,e.data_tables):(e.after_loading_data_tables||(e.after_loading_data_tables=[]),e.after_loading_data_tables.push(t),e.after_loading_data_tables.length>1||e.getDataTables((function(t,n){if(t){for(var r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](t);e.after_loading_data_tables=[]}else{e.data_tables=n.map((function(t){return new Ic(e,t)}));for(r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](void 0,e.data_tables);e.after_loading_data_tables=[]}})))},$c.prototype.refreshDataTables=function(){this.data_tables=void 0,this.dataTablesHaveChanged()},$c.prototype.prepareData=function(t){var e=this;if(!e.data_bindings)throw new Error("No data bindings loaded");var n=e.template_id;e.dataTables((function(r,i){if(r)return t(r);if(e.template_id==n){for(var a={},o={},s=0,l=0;l<i.length;l++)!function(r){o[r.id]=r.column_types,r.csv((function(l,u){if(l)throw l;e.template_id==n&&(a[r.id]=u,++s==i.length&&e.getTemplate().getDataBindings((function(n,r){if(n)throw n;var i={};r.forEach((function(t){"string"!=typeof t&&(t.dataset in i||(i[t.dataset]={}),i[t.dataset][t.key]=t)}));var s={},l=e.dataBindingsForCurrentTemplate();for(var u in l)s[u]=Ri(l[u],a,o,i[u]);for(u in i)s[u]||(s[u]=[],s[u].column_names={},s[u].metadata={});t(void 0,s)})))}))}(i[l]);0==i.length&&t(void 0,{})}}))},$c.prototype.delete=function(t){cs(this,t)},$c.prototype.getDataTableNames=function(){return void 0===this.data_table_names&&(this.data_table_names=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.id]=r.name}return e}(this.data_tables)),this.data_table_names},$c.prototype.getDataTableIds=function(){return void 0===this.data_table_ids&&(this.data_table_ids=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.name]=r.id}return e}(this.data_tables)),this.data_table_ids},$c.prototype.dataTablesHaveChanged=function(){this.data_table_names=this.data_table_ids=void 0},$c.prototype.duplicate=function(t){ss({url:this.api_prefix+"/"+this.id+"/duplicate",callback:t})},$c.prototype.deleteCanvaEmbed=function(t){ss({url:this.api_prefix+"/"+this.id+"/delete_canva_embed",callback:t})},$c.prototype.publish=function(t,e,n){var r=this;if(this.is_listed)return Yc(r,t,e,n);this.save({is_listed:!0},(function(i){return i?t(i):Yc(r,t,e,n)}))},$c.prototype.unpublish=function(t){var e=this;ss({url:this.api_prefix+"/"+this.id+"/unpublish",callback:function(n,r){if(n)return t(n);e.version_number=r.version_number,e.embed_url=r.embed_url,e.showcase_url=r.showcase_url,t(void 0,r)}})},$c.prototype.published=function(){return!!this.showcase_url},$c.prototype.sendForReview=function(t,e,n){var r=this;ss({url:"/api/reviews",payload:function(){return{project_id:r.id,project_type:"visualisation",reviewers:t,message:e}},callback:function(t,e){r.status=e,n(t,e)}})},$c.prototype.approve=function(t,e){var n=this;ss({url:"/api/review/"+t+"/approve",callback:function(t,r){return n.status=r,e(t,r)}})},$c.prototype.decline=function(t,e,n){var r=this;ss({url:"/api/review/"+t+"/decline",payload:function(){return{message:e}},callback:function(t,e){r.status=e,n(t,e)}})},$c.prototype.cancelReview=function(t,e){var n=this;ss({url:"/api/review/"+t+"/cancel",callback:function(t,r){n.status=r,e(t,r)}})},$c.list=function(t){ss({url:"/api/visualisations",method:"GET",callback:t})},$c.getById=function(t,e){ss({url:"/api/visualisation/"+t,method:"GET",callback:function(n,r){if(n)return e(n);e(void 0,new $c(t,r.version_number,r))}})},$c.getPublishedJson=function(t,e,n){ss({url:`${e}visualisation/${t}/visualisation.json`,method:"GET",callback(t,e){if(t)return n(t);n(void 0,e)}})},$c.createFromTemplate=function(t,e){ss({url:"/api/template/"+t+"/visualisations",method:"PUT",callback:e})},$c.createFromVisualisation=function(t,e){ss({url:"/api/visualisation/"+t+"/duplicate",callback:e})},$c.setAsStaffPick=function(t,e){ss({url:"/api/visualisation/"+t+"/set_staff_pick",method:"POST",callback:e})},$c.unsetAsStaffPick=function(t,e){ss({url:"/api/visualisation/"+t+"/unset_staff_pick",method:"POST",callback:e})},$c.setTag=function(t,e,n){ss({url:"/api/visualisation/"+t+"/folder/"+encodeURIComponent(e),method:"PUT",callback:n})},$c.removeTag=function(t,e,n){ss({url:"/api/visualisation/"+t+"/tag/"+encodeURIComponent(e),method:"DELETE",callback:n})},Gc.prototype.loadFromUrlHash=async function(){if(!window.location.hash)return;const t=window.location.hash.slice(1),e=(n=$c.getPublishedJson,function(...t){return new Promise(((e,i)=>{n.call(r,...t,(function(t,n){if(t)return i(t);e(n)}))}))});var n,r;try{const n=await e(t,this.public_url_prefix);this.updateFromJson(n)}catch(t){console.error(t)}},Gc.prototype.updateFromJson=function({state:t,bindings:e,data:n}){const r={};for(const[t,i]of Object.entries(e)){const e={},o={};for(const[t,n]of Object.entries(i))Array.isArray(n)?o[t]=n:e[t]=n;const s=a(n[t],e,o);r[t]=s}const i={};Wc(i,this.preview_pane.getDefaultState()),Wc(i,t),this.preview_pane.sync({state:i,data:r,overwrite_state:!0,update:!0},(()=>this.template_settings.populate()))};var Zc={},Xc={};function Jc(t){return new Function("d","return {"+t.map((function(t,e){return JSON.stringify(t)+": d["+e+'] || ""'})).join(",")+"}")}function Kc(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 Qc(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n}function td(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":function(t){return t<0?"-"+Qc(-t,6):t>9999?"+"+Qc(t,6):Qc(t,4)}(t.getUTCFullYear())+"-"+Qc(t.getUTCMonth()+1,2)+"-"+Qc(t.getUTCDate(),2)+(i?"T"+Qc(e,2)+":"+Qc(n,2)+":"+Qc(r,2)+"."+Qc(i,3)+"Z":r?"T"+Qc(e,2)+":"+Qc(n,2)+":"+Qc(r,2)+"Z":n||e?"T"+Qc(e,2)+":"+Qc(n,2)+"Z":"")}var ed=function(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function r(t,e){var r,i=[],a=t.length,o=0,s=0,l=a<=0,u=!1;function c(){if(l)return Xc;if(u)return u=!1,Zc;var e,r,i=o;if(34===t.charCodeAt(i)){for(;o++<a&&34!==t.charCodeAt(o)||34===t.charCodeAt(++o););return(e=o)>=a?l=!0:10===(r=t.charCodeAt(o++))?u=!0:13===r&&(u=!0,10===t.charCodeAt(o)&&++o),t.slice(i+1,e-1).replace(/""/g,'"')}for(;o<a;){if(10===(r=t.charCodeAt(e=o++)))u=!0;else if(13===r)u=!0,10===t.charCodeAt(o)&&++o;else if(r!==n)continue;return t.slice(i,e)}return l=!0,t.slice(i,a)}for(10===t.charCodeAt(a-1)&&--a,13===t.charCodeAt(a-1)&&--a;(r=c())!==Xc;){for(var d=[];r!==Zc&&r!==Xc;)d.push(r),r=c();e&&null==(d=e(d,s++))||i.push(d)}return i}function i(e,n){return e.map((function(e){return n.map((function(t){return o(e[t])})).join(t)}))}function a(e){return e.map(o).join(t)}function o(t){return null==t?"":t instanceof Date?td(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t}return{parse:function(t,e){var n,i,a=r(t,(function(t,r){if(n)return n(t,r-1);i=t,n=e?function(t,e){var n=Jc(t);return function(r,i){return e(n(r),i,t)}}(t,e):Jc(t)}));return a.columns=i||[],a},parseRows:r,format:function(e,n){return null==n&&(n=Kc(e)),[n.map(o).join(t)].concat(i(e,n)).join("\n")},formatBody:function(t,e){return null==e&&(e=Kc(t)),i(t,e).join("\n")},formatRows:function(t){return t.map(a).join("\n")},formatRow:a,formatValue:o}}(","),nd=ed.parseRows,rd="$";function id(){}function ad(t,e){var n=new id;if(t instanceof id)t.each((function(t,e){n.set(e,t)}));else if(Array.isArray(t)){var r,i=-1,a=t.length;if(null==e)for(;++i<a;)n.set(i,t[i]);else for(;++i<a;)n.set(e(r=t[i],i,t),r)}else if(t)for(var o in t)n.set(o,t[o]);return n}function od(){}id.prototype=ad.prototype={constructor:id,has:function(t){return rd+t in this},get:function(t){return this[rd+t]},set:function(t,e){return this[rd+t]=e,this},remove:function(t){var e=rd+t;return e in this&&delete this[e]},clear:function(){for(var t in this)t[0]===rd&&delete this[t]},keys:function(){var t=[];for(var e in this)e[0]===rd&&t.push(e.slice(1));return t},values:function(){var t=[];for(var e in this)e[0]===rd&&t.push(this[e]);return t},entries:function(){var t=[];for(var e in this)e[0]===rd&&t.push({key:e.slice(1),value:this[e]});return t},size:function(){var t=0;for(var e in this)e[0]===rd&&++t;return t},empty:function(){for(var t in this)if(t[0]===rd)return!1;return!0},each:function(t){for(var e in this)e[0]===rd&&t(this[e],e.slice(1),this)}};var sd=ad.prototype;od.prototype={constructor:od,has:sd.has,add:function(t){return this[rd+(t+="")]=t,this},remove:sd.remove,clear:sd.clear,values:sd.keys,size:sd.size,empty:sd.empty,each:sd.each};var ld,ud,cd={value:function(){}};function dd(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new fd(r)}function fd(t){this._=t}function pd(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 hd(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function md(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=cd,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function gd(t,e,n){var r;r="object"==typeof e?e.id:e,this.id=r,this.visualisation=t,this.api_prefix="/api/data_table"}function vd(t){return t.map((function(t){return null!=t&&"object"==typeof t&&"map"in t?vd(t):t}))}function yd(t){this.id=t}function bd(t,e,n){var r=this;r.id=1,r.template_id=1,r.api_prefix="/api/visualisation",r.can_edit=!0,r.__sdk__=!0,n.data_tables&&(this.data_tables=n.data_tables.map((function(t){return new gd(r,t)}))),n.data_bindings&&(this.data_bindings=n.data_bindings)}fd.prototype=dd.prototype={constructor:fd,on:function(t,e){var n,r=this._,i=pd(t+"",r),a=-1,o=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<o;)if(n=(t=i[a]).type)r[n]=md(r[n],t.name,e);else if(null==e)for(n in r)r[n]=md(r[n],t.name,null);return this}for(;++a<o;)if((n=(t=i[a]).type)&&(n=hd(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new fd(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}},gd.prototype.csv=function(t){if(this.cached_data)t(void 0,vd(this.cached_data));else{var e=this;!function(t,e){var n,r,i,a,o=dd("beforesend","progress","load","error"),s=ad(),l=new XMLHttpRequest,u=null,c=null,d=0;function f(t){var e,r=l.status;if(!r&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(l)||r>=200&&r<300||304===r){if(i)try{e=i.call(n,l)}catch(t){return void o.call("error",n,t)}else e=l;o.call("load",n,e)}else o.call("error",n,t)}if("undefined"!=typeof XDomainRequest&&!("withCredentials"in l)&&/^(http(s)?:)?\/\//.test(t)&&(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=l.ontimeout=f:l.onreadystatechange=function(t){l.readyState>3&&f(t)},l.onprogress=function(t){o.call("progress",n,t)},n={header:function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s.get(t):(null==e?s.remove(t):s.set(t,e+""),n)},mimeType:function(t){return arguments.length?(r=null==t?null:t+"",n):r},responseType:function(t){return arguments.length?(a=t,n):a},timeout:function(t){return arguments.length?(d=+t,n):d},user:function(t){return arguments.length<1?u:(u=null==t?null:t+"",n)},password:function(t){return arguments.length<1?c:(c=null==t?null:t+"",n)},response:function(t){return i=t,n},get:function(t,e){return n.send("GET",t,e)},post:function(t,e){return n.send("POST",t,e)},send:function(e,i,f){return l.open(e,t,!0,u,c),null==r||s.has("accept")||s.set("accept",r+",*/*"),l.setRequestHeader&&s.each((function(t,e){l.setRequestHeader(e,t)})),null!=r&&l.overrideMimeType&&l.overrideMimeType(r),null!=a&&(l.responseType=a),d>0&&(l.timeout=d),null==f&&"function"==typeof i&&(f=i,i=null),null!=f&&1===f.length&&(f=function(t){return function(e,n){t(null==e?n:null)}}(f)),null!=f&&n.on("error",f).on("load",(function(t){f(null,t)})),o.call("beforesend",n,l),l.send(null==i?null:i),n},abort:function(){return l.abort(),n},on:function(){var t=o.on.apply(o,arguments);return t===o?n:t}},null!=e){if("function"!=typeof e)throw new Error("invalid callback: "+e);return n.get(e)}}(this.api_prefix+"/"+this.id+"/csv",(function(n,r){e.cached_data=nd(r.response),t(void 0,vd(e.cached_data))}))}},gd.prototype.saveData=function(t,e){e()},gd.prototype.save=function(t,e){e()},gd.prototype.delete=function(t){t()},yd.prototype.getSettings=function(t){t(void 0,window.Flourish.app.settings)},yd.prototype.getDataBindings=function(t){t(void 0,window.Flourish.app.template_data_bindings)},yd.prototype.refreshDataBindings=function(t){t(void 0)},bd.prototype.save=function(t,e){this.version_number++,e(void 0)},bd.prototype.getTemplate=function(){return this.template_id?(this._template&&this.template_id==this._template.id||(this._template=new yd(this.template_id)),this._template):null},bd.prototype.settingsForCurrentTemplate=function(){return this.settings&&this.template_id in this.settings?this.settings[this.template_id]:{}},bd.prototype.dataBindingsForCurrentTemplate=function(){return this.data_bindings&&this.template_id in this.data_bindings?this.data_bindings[this.template_id]:{}},bd.prototype.refreshDataBindings=function(t){t()},bd.prototype.updateDataBindings=function(t,e){var n=this;n.version_number++,n.data_bindings||(n.data_bindings={}),n.template_id in n.data_bindings||(n.data_bindings[n.template_id]={});var r=n.data_bindings[n.template_id];for(var i in t)for(var a in t[i]){var o=t[i][a];r[i][a]=o}e(void 0)},bd.prototype.updateSettings=function(t,e){var n=this;n.version_number++,n.settings||(n.settings={}),n.template_id in n.settings||(n.settings[n.template_id]={});var r=n.settings[n.template_id];for(var i in t){var a=t[i];r[i]=a}e(void 0)},bd.prototype.getDataTables=function(t){t(void 0,window.Flourish.app.data_tables)},bd.prototype.dataTables=function(t){var e=this;e.data_tables?t(void 0,e.data_tables):(e.after_loading_data_tables||(e.after_loading_data_tables=[]),e.after_loading_data_tables.push(t),e.after_loading_data_tables.length>1||e.getDataTables((function(t,n){if(t){for(var r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](t);e.after_loading_data_tables=[]}else{e.data_tables=n.map((function(t){return new gd(e,t)}));for(r=0;r<e.after_loading_data_tables.length;r++)e.after_loading_data_tables[r](void 0,e.data_tables);e.after_loading_data_tables=[]}})))},bd.prototype.refreshDataTables=function(){this.data_tables=void 0,this.dataTablesHaveChanged()},bd.prototype.prepareData=function(t){var e=this;if(!e.data_bindings)throw new Error("No data bindings loaded");var n=e.template_id;e.dataTables((function(r,i){if(r)return t(r);if(e.template_id==n){for(var a={},o={},s=0,l=0;l<i.length;l++)!function(r){r.csv((function(l,u){if(l)throw l;e.template_id==n&&(o[r.id]=ji(u),a[r.id]=u,++s==i.length&&e.getTemplate().getDataBindings((function(n,r){if(n)throw n;var i={};r.forEach((function(t){"string"!=typeof t&&(t.dataset in i||(i[t.dataset]={}),i[t.dataset][t.key]=t)}));var s={},l=e.dataBindingsForCurrentTemplate();for(var u in l)s[u]=Ri(l[u],a,o,i[u]);for(u in i)s[u]||(s[u]=[],s[u].column_names={},s[u].metadata={});t(void 0,s)})))}))}(i[l]);0==i.length&&t(void 0,{})}}))},bd.prototype.getDataTableNames=function(){return void 0===this.data_table_names&&(this.data_table_names=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.id]=r.name}return e}(this.data_tables)),this.data_table_names},bd.prototype.getDataTableIds=function(){return void 0===this.data_table_ids&&(this.data_table_ids=function(t){for(var e={},n=0;n<t.length;n++){var r=t[n];e[r.name]=r.id}return e}(this.data_tables)),this.data_table_ids},bd.prototype.dataTablesHaveChanged=function(){this.data_table_names=this.data_table_ids=void 0};var _d=!1;function wd(){ld&&ld.classList.remove("shown")}function xd(){this.close(),_d||(ld&&setTimeout((function(){ld.classList.add("shown")}),1e3),setTimeout(Cd,250))}function Cd(){Ad().addEventListener("open",(function(){window.location.reload()}))}function Ad(){var t=new window.WebSocket(ud);return t.addEventListener("open",wd),t.addEventListener("close",xd),t}return t.Visualisation=bd,t.initSDK=function(t,e,n,r){return Ve(),window.Flourish=window.Flourish||{},window.Flourish.app=new Gc(t,e,n,r),window.Flourish.app},t.talkToServer=function(){ld=document.getElementById("error-server-down"),ud=window.location.origin.replace(/^http(s?):\/\//,"ws$1://"),window.addEventListener("beforeunload",(function(){_d=!0})),Ad()},Object.defineProperty(t,"__esModule",{value:!0}),t}({});
3
3
  //# sourceMappingURL=script.js.map