!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.g9=t():e.g9=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(4)},function(e,t){"use strict";function n(e,n){function r(e){t.draggingCount=s+=1,e.stopPropagation(),e.preventDefault(),e=e.touches?e.touches[0]:e;var r=n(e);i=e.clientX,o=e.clientY;var a=function(e){e.preventDefault(),e=e.touches?e.touches[0]:e,r(e.clientX-i,e.clientY-o)},u=function c(e){e.preventDefault(),t.draggingCount=s-=1,document.removeEventListener("mousemove",a),document.removeEventListener("touchmove",a),document.removeEventListener("touchend",c),document.removeEventListener("touchcancel",c),document.removeEventListener("mouseup",c)};document.addEventListener("touchmove",a),document.addEventListener("mousemove",a),document.addEventListener("touchend",u),document.addEventListener("touchcancel",u),document.addEventListener("mouseup",u)}var i,o;e.addEventListener("touchstart",r),e.addEventListener("mousedown",r)}function r(e,n,r){function i(e){t.draggingCount=s+=1,e.preventDefault(),e=e.touches?e.touches[0]:e,o=e.clientX,a=e.clientY;var r=n(e),i=c(r,2);u=i[0],f=i[1],u=u||0,f=f||0,document.addEventListener("touchmove",l),document.addEventListener("mousemove",l),document.addEventListener("touchend",d),document.addEventListener("touchcancel",d),document.addEventListener("mouseup",d)}var o,a,u,f,l=function(e){e=e.touches?e.touches[0]:e,r(u+e.clientX-o,f+e.clientY-a)},d=function h(e){t.draggingCount=s-=1,document.removeEventListener("mousemove",l),document.removeEventListener("touchmove",l),document.removeEventListener("touchend",h),document.removeEventListener("touchcancel",h),document.removeEventListener("mouseup",h)};e.addEventListener("touchstart",i),e.addEventListener("mousedown",i)}function i(e,t){e&&Object.keys(e).forEach(function(n){return t(e[n],n)})}function o(e,t){var n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];i(t,function(t,r){e.setAttributeNS(n,r,t)})}function a(e){var t={};return Object.keys(e).forEach(function(n){return t[n]=e[n]}),t}function u(e,t,n){for(;Math.abs(t-n)>.001;){var r=(t+n)/2;e(r)?t=r:n=r}return(t+n)/2}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(c){i=!0,o=c}finally{try{!r&&u["return"]&&u["return"]()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.addDragHandler=n,t.makeDraggable=r,t.forIn=i,t.setAttributes=o,t.shallowClone=a,t.findPhaseChange=u;var s=t.draggingCount=0},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),o=r(i),a=n(9),u=r(a),c=n(8),s=r(c),f=n(10),l=r(f),d=n(11),h=r(d),v=n(7),g=r(v),m={point:u["default"],circle:o["default"],line:s["default"],rect:l["default"],text:h["default"],image:g["default"]};t["default"]=m},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function i(e){return function(t){function n(){return"auto"+g+h++}function r(e){return function(){if(v[v.length-1]++,null===i||(i+"|").startsWith(v.join("|"))){v.push(0);var t=h;h=0,g=v.join("|");var n=e.apply(this,arguments);v.pop(),h=t,g=v.join("|")}return n}}var i=arguments.length<=1||void 0===arguments[1]?null:arguments[1],u=arguments[2],f=u.width,l=u.height,d={},h=0,v=[0],g=v.join("|"),m={pure:r,width:f,height:l};return(0,s.forIn)(c["default"],function(e,t){m[t]=function(){var r=[].slice.call(arguments),i={},u=r[r.length-1];if("object"===("undefined"==typeof u?"undefined":a(u))){i=o({},u);var c=r.length-1}else var c=r.length;for(var s=0;c>s;s++)i[e.argNames[s]]=r[s];i.type=t,i.id=n(),i.stack=v.join("|"),d[i.id]=i}}),e(t,m),d}}Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t0}}}var o=Object.assign||function(e){for(var t=1;tn;n++){t[n]=Array(e);for(var r=0;e>r;r++)t[n][r]=+(n==r)}return t}function i(e){return e.map(function(e){return-e})}function o(e,t){return"number"!=typeof e[0]?e.map(function(e){return o(e,t)}):e.reduce(function(e,n,r){return e+n*t[r]},0)}function a(e,t){return"number"!=typeof e[0]?e.map(function(e,n){return a(e,t[n])}):e.map(function(e,n){return e-t[n]})}function u(e,t){return"number"!=typeof e[0]?e.map(function(e,n){return u(e,t[n])}):e.map(function(e,n){return e+t[n]})}function c(e,t){return e.map(function(e){return e.map(function(e){return e/t})})}function s(e,t){return"number"!=typeof e[0]?e.map(function(e){return s(e,t)}):e.map(function(e){return e*t})}function f(e,t){return e.map(function(e,n){return s(t,e)})}function l(e,t){var n=t.length,r=e(t);if(isNaN(r))throw new Error("The gradient at ["+t.join(" ")+"] is NaN!");for(var i=Math.max,o=Math.abs,a=Math.min,u=t.slice(0),c=Array(n),s=0;n>s;s++)for(var f=i(1e-6*r,1e-8),l=0;;l++){if(20==l)throw new Error("Gradient failed at index "+s+" of ["+t.join(" ")+"]");u[s]=t[s]+f;var d=e(u);u[s]=t[s]-f;var h=e(u);if(u[s]=t[s],!isNaN(d)&&!isNaN(h)){c[s]=(d-h)/(2*f);var v=t[s]-f,g=t[s],m=t[s]+f,p=(d-r)/f,y=(r-h)/f,w=a(i(o(p-c[s]),o(y-c[s]),o(p-y)),f),b=i(o(c[s]),o(d),o(r),o(h),o(v),o(g),o(m),1e-8);if(.001>w/b)break}f/=16}return c}function d(e,t,d){var h=arguments.length<=3||void 0===arguments[3]?1e-8:arguments[3],v=arguments.length<=4||void 0===arguments[4]?1e3:arguments[4];h=Math.max(h,2e-16);var g=function(t){return l(e,t)};t=t.slice(0);var m=g(t),p=e(t);if(isNaN(p))throw new Error("minimize: f(x0) is a NaN!");for(var y=t.length,w=r(y),b=0;v>b;b++){if(!m.every(isFinite)){var _="Gradient has Infinity or NaN";break}var E=i(o(w,m));if(!E.every(isFinite)){var _="Search direction has Infinity or NaN";break}var x=n(E);if(h>x){var _="Newton step smaller than tol";break}for(var k,j=1,N=o(m,E),O=t;v>b&&j*x>=h;b++){k=s(E,j),O=u(t,k);var C=e(O);if(!(C-p>=.1*j*N||isNaN(C)))break;j*=.5}if(h>j*x&&d){var _="Line search step size smaller than tol";break}if(b===v){var _="maxit reached during line search";break}var L=g(O),M=a(L,m),P=o(M,k),z=o(w,M);w=a(u(w,s(f(k,k),(P+o(M,z))/(P*P))),c(u(f(z,k),f(k,z)),P)),t=O,p=C,m=L}return{solution:t,f:p,gradient:m,invHessian:w,iterations:b,message:_}}Object.defineProperty(t,"__esModule",{value:!0}),t.gradient=l,t["default"]=d},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nt&&(e.x+=t,e.width=-t),0>n&&(e.y+=n,e.height=-n),(0,o.setAttributes)(this.el,e),(0,o.setAttributes)(this.el,{href:e.href},"http://www.w3.org/1999/xlink")}}]),e}();a.argNames=["href","x","y","width","height","affects"],t["default"]=a},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;nt&&(e.x+=t,e.width=-t),0>n&&(e.y+=n,e.height=-n),(0,o.setAttributes)(this.el,e)}}]),e}();a.argNames=["x","y","width","height","affects"],t["default"]=a},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n