You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
122 KiB
JavaScript

exports.canvas=function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){var n,s;
/*!
* svg.js - A lightweight library for manipulating and animating SVG.
* @version 2.7.1
* https://svgdotjs.github.io/
*
* @copyright Wout Fierens <wout@mick-wout.com>
* @license MIT
*
* BUILT: Fri Nov 30 2018 10:01:55 GMT+0100 (GMT+01:00)
*/s="undefined"!=typeof window?window:this,void 0===(n=function(){return function(t,e){var i=(void 0!==this?this:t).SVG=function(t){if(i.supported)return t=new i.Doc(t),i.parser.draw||i.prepare(),t};if(i.ns="http://www.w3.org/2000/svg",i.xmlns="http://www.w3.org/2000/xmlns/",i.xlink="http://www.w3.org/1999/xlink",i.svgjs="http://svgjs.com/svgjs",i.supported=!!e.createElementNS&&!!e.createElementNS(i.ns,"svg").createSVGRect,!i.supported)return!1;i.did=1e3,i.eid=function(t){return"Svgjs"+c(t)+i.did++},i.create=function(t){var i=e.createElementNS(this.ns,t);return i.setAttribute("id",this.eid(t)),i},i.extend=function(){var t,e,n,s;for(t=[].slice.call(arguments),e=t.pop(),s=t.length-1;s>=0;s--)if(t[s])for(n in e)t[s].prototype[n]=e[n];i.Set&&i.Set.inherit&&i.Set.inherit()},i.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,i.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&i.extend(e,t.extend),t.construct&&i.extend(t.parent||i.Container,t.construct),e},i.adopt=function(e){return e?e.instance?e.instance:((n="svg"==e.nodeName?e.parentNode instanceof t.SVGElement?new i.Nested:new i.Doc:"linearGradient"==e.nodeName?new i.Gradient("linear"):"radialGradient"==e.nodeName?new i.Gradient("radial"):i[c(e.nodeName)]?new(i[c(e.nodeName)]):new i.Element(e)).type=e.nodeName,n.node=e,e.instance=n,n instanceof i.Doc&&n.namespace().defs(),n.setData(JSON.parse(e.getAttribute("svgjs:data"))||{}),n):null;var n},i.prepare=function(){var t=e.getElementsByTagName("body")[0],n=(t?new i.Doc(t):i.adopt(e.documentElement).nested()).size(2,0);i.parser={body:t||e.documentElement,draw:n.style("opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden").attr("focusable","false").node,poly:n.polyline().node,path:n.path().node,native:i.create("svg")}},i.parser={native:i.create("svg")},e.addEventListener("DOMContentLoaded",function(){i.parser.draw||i.prepare()},!1),i.regex={numberAndUnit:/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,hex:/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,rgb:/rgb\((\d+),(\d+),(\d+)\)/,reference:/#([a-z0-9\-_]+)/i,transforms:/\)\s*,?\s*/,whitespace:/\s/g,isHex:/^#[a-f0-9]{3,6}$/i,isRgb:/^rgb\(/,isCss:/[^:]+:[^;]+;?/,isBlank:/^(\s+)?$/,isNumber:/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,isPercent:/^-?[\d\.]+%$/,isImage:/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,delimiter:/[\s,]+/,hyphen:/([^e])\-/gi,pathLetters:/[MLHVCSQTAZ]/gi,isPathLetter:/[MLHVCSQTAZ]/i,numbersWithDots:/((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi,dots:/\./g},i.utils={map:function(t,e){var i,n=t.length,s=[];for(i=0;i<n;i++)s.push(e(t[i]));return s},filter:function(t,e){var i,n=t.length,s=[];for(i=0;i<n;i++)e(t[i])&&s.push(t[i]);return s},radians:function(t){return t%360*Math.PI/180},degrees:function(t){return 180*t/Math.PI%360},filterSVGElements:function(e){return this.filter(e,function(e){return e instanceof t.SVGElement})}},i.defaults={attrs:{"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","font-size":16,"font-family":"Helvetica, Arial, sans-serif","text-anchor":"start"}},i.Color=function(t){var e,n;this.r=0,this.g=0,this.b=0,t&&("string"==typeof t?i.regex.isRgb.test(t)?(e=i.regex.rgb.exec(t.replace(i.regex.whitespace,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):i.regex.isHex.test(t)&&(e=i.regex.hex.exec(4==(n=t).length?["#",n.substring(1,2),n.substring(1,2),n.substring(2,3),n.substring(2,3),n.substring(3,4),n.substring(3,4)].join(""):n),this.r=parseInt(e[1],16),this.g=parseInt(e[2],16),this.b=parseInt(e[3],16)):"object"==typeof t&&(this.r=t.r,this.g=t.g,this.b=t.b))},i.extend(i.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+u(this.r)+u(this.g)+u(this.b)},toRgb:function(){return"rgb("+[this.r,this.g,this.b].join()+")"},brightness:function(){return this.r/255*.3+this.g/255*.59+this.b/255*.11},morph:function(t){return this.destination=new i.Color(t),this},at:function(t){return this.destination?(t=t<0?0:t>1?1:t,new i.Color({r:~~(this.r+(this.destination.r-this.r)*t),g:~~(this.g+(this.destination.g-this.g)*t),b:~~(this.b+(this.destination.b-this.b)*t)})):this}}),i.Color.test=function(t){return t+="",i.regex.isHex.test(t)||i.regex.isRgb.test(t)},i.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},i.Color.isColor=function(t){return i.Color.isRgb(t)||i.Color.test(t)},i.Array=function(t,e){0==(t=(t||[]).valueOf()).length&&e&&(t=e.valueOf()),this.value=this.parse(t)},i.extend(i.Array,{morph:function(t){if(this.destination=this.parse(t),this.value.length!=this.destination.length){for(var e=this.value[this.value.length-1],i=this.destination[this.destination.length-1];this.value.length>this.destination.length;)this.destination.push(i);for(;this.value.length<this.destination.length;)this.value.push(e)}return this},settle:function(){for(var t=0,e=this.value.length,i=[];t<e;t++)-1==i.indexOf(this.value[t])&&i.push(this.value[t]);return this.value=i},at:function(t){if(!this.destination)return this;for(var e=0,n=this.value.length,s=[];e<n;e++)s.push(this.value[e]+(this.destination[e]-this.value[e])*t);return new i.Array(s)},toString:function(){return this.value.join(" ")},valueOf:function(){return this.value},parse:function(t){return t=t.valueOf(),Array.isArray(t)?t:this.split(t)},split:function(t){return t.trim().split(i.regex.delimiter).map(parseFloat)},reverse:function(){return this.value.reverse(),this},clone:function(){var t=new this.constructor;return t.value=function t(e){for(var i=e.slice(0),n=i.length;n--;)Array.isArray(i[n])&&(i[n]=t(i[n]));return i}(this.value),t}}),i.PointArray=function(t,e){i.Array.call(this,t,e||[[0,0]])},i.PointArray.prototype=new i.Array,i.PointArray.prototype.constructor=i.PointArray,i.extend(i.PointArray,{toString:function(){for(var t=0,e=this.value.length,i=[];t<e;t++)i.push(this.value[t].join(","));return i.join(" ")},toLine:function(){return{x1:this.value[0][0],y1:this.value[0][1],x2:this.value[1][0],y2:this.value[1][1]}},at:function(t){if(!this.destination)return this;for(var e=0,n=this.value.length,s=[];e<n;e++)s.push([this.value[e][0]+(this.destination[e][0]-this.value[e][0])*t,this.value[e][1]+(this.destination[e][1]-this.value[e][1])*t]);return new i.PointArray(s)},parse:function(t){var e=[];if(t=t.valueOf(),Array.isArray(t)){if(Array.isArray(t[0]))return t.map(function(t){return t.slice()});if(null!=t[0].x)return t.map(function(t){return[t.x,t.y]})}else t=t.trim().split(i.regex.delimiter).map(parseFloat);t.length%2!=0&&t.pop();for(var n=0,s=t.length;n<s;n+=2)e.push([t[n],t[n+1]]);return e},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n=this.value.length-1;n>=0;n--)this.value[n]=[this.value[n][0]+t,this.value[n][1]+e];return this},size:function(t,e){var i,n=this.bbox();for(i=this.value.length-1;i>=0;i--)n.width&&(this.value[i][0]=(this.value[i][0]-n.x)*t/n.width+n.x),n.height&&(this.value[i][1]=(this.value[i][1]-n.y)*e/n.height+n.y);return this},bbox:function(){return i.parser.poly.setAttribute("points",this.toString()),i.parser.poly.getBBox()}});for(var n={M:function(t,e,i){return e.x=i.x=t[0],e.y=i.y=t[1],["M",e.x,e.y]},L:function(t,e){return e.x=t[0],e.y=t[1],["L",t[0],t[1]]},H:function(t,e){return e.x=t[0],["H",t[0]]},V:function(t,e){return e.y=t[0],["V",t[0]]},C:function(t,e){return e.x=t[4],e.y=t[5],["C",t[0],t[1],t[2],t[3],t[4],t[5]]},S:function(t,e){return e.x=t[2],e.y=t[3],["S",t[0],t[1],t[2],t[3]]},Q:function(t,e){return e.x=t[2],e.y=t[3],["Q",t[0],t[1],t[2],t[3]]},T:function(t,e){return e.x=t[0],e.y=t[1],["T",t[0],t[1]]},Z:function(t,e,i){return e.x=i.x,e.y=i.y,["Z"]},A:function(t,e){return e.x=t[5],e.y=t[6],["A",t[0],t[1],t[2],t[3],t[4],t[5],t[6]]}},s="mlhvqtcsaz".split(""),r=0,a=s.length;r<a;++r)n[s[r]]=function(t){return function(e,i,s){if("H"==t)e[0]=e[0]+i.x;else if("V"==t)e[0]=e[0]+i.y;else if("A"==t)e[5]=e[5]+i.x,e[6]=e[6]+i.y;else for(var r=0,a=e.length;r<a;++r)e[r]=e[r]+(r%2?i.y:i.x);return n[t](e,i,s)}}(s[r].toUpperCase());i.PathArray=function(t,e){i.Array.call(this,t,e||[["M",0,0]])},i.PathArray.prototype=new i.Array,i.PathArray.prototype.constructor=i.PathArray,i.extend(i.PathArray,{toString:function(){return function(t){for(var e=0,i=t.length,n="";e<i;e++)n+=t[e][0],null!=t[e][1]&&(n+=t[e][1],null!=t[e][2]&&(n+=" ",n+=t[e][2],null!=t[e][3]&&(n+=" ",n+=t[e][3],n+=" ",n+=t[e][4],null!=t[e][5]&&(n+=" ",n+=t[e][5],n+=" ",n+=t[e][6],null!=t[e][7]&&(n+=" ",n+=t[e][7])))));return n+" "}(this.value)},move:function(t,e){var i=this.bbox();if(t-=i.x,e-=i.y,!isNaN(t)&&!isNaN(e))for(var n,s=this.value.length-1;s>=0;s--)"M"==(n=this.value[s][0])||"L"==n||"T"==n?(this.value[s][1]+=t,this.value[s][2]+=e):"H"==n?this.value[s][1]+=t:"V"==n?this.value[s][1]+=e:"C"==n||"S"==n||"Q"==n?(this.value[s][1]+=t,this.value[s][2]+=e,this.value[s][3]+=t,this.value[s][4]+=e,"C"==n&&(this.value[s][5]+=t,this.value[s][6]+=e)):"A"==n&&(this.value[s][6]+=t,this.value[s][7]+=e);return this},size:function(t,e){var i,n,s=this.bbox();for(i=this.value.length-1;i>=0;i--)"M"==(n=this.value[i][0])||"L"==n||"T"==n?(this.value[i][1]=(this.value[i][1]-s.x)*t/s.width+s.x,this.value[i][2]=(this.value[i][2]-s.y)*e/s.height+s.y):"H"==n?this.value[i][1]=(this.value[i][1]-s.x)*t/s.width+s.x:"V"==n?this.value[i][1]=(this.value[i][1]-s.y)*e/s.height+s.y:"C"==n||"S"==n||"Q"==n?(this.value[i][1]=(this.value[i][1]-s.x)*t/s.width+s.x,this.value[i][2]=(this.value[i][2]-s.y)*e/s.height+s.y,this.value[i][3]=(this.value[i][3]-s.x)*t/s.width+s.x,this.value[i][4]=(this.value[i][4]-s.y)*e/s.height+s.y,"C"==n&&(this.value[i][5]=(this.value[i][5]-s.x)*t/s.width+s.x,this.value[i][6]=(this.value[i][6]-s.y)*e/s.height+s.y)):"A"==n&&(this.value[i][1]=this.value[i][1]*t/s.width,this.value[i][2]=this.value[i][2]*e/s.height,this.value[i][6]=(this.value[i][6]-s.x)*t/s.width+s.x,this.value[i][7]=(this.value[i][7]-s.y)*e/s.height+s.y);return this},equalCommands:function(t){var e,n,s;for(t=new i.PathArray(t),s=this.value.length===t.value.length,e=0,n=this.value.length;s&&e<n;e++)s=this.value[e][0]===t.value[e][0];return s},morph:function(t){return t=new i.PathArray(t),this.equalCommands(t)?this.destination=t:this.destination=null,this},at:function(t){if(!this.destination)return this;var e,n,s,r,a=this.value,o=this.destination.value,h=[],l=new i.PathArray;for(e=0,n=a.length;e<n;e++){for(h[e]=[a[e][0]],s=1,r=a[e].length;s<r;s++)h[e][s]=a[e][s]+(o[e][s]-a[e][s])*t;"A"===h[e][0]&&(h[e][4]=+(0!=h[e][4]),h[e][5]=+(0!=h[e][5]))}return l.value=h,l},parse:function(t){if(t instanceof i.PathArray)return t.valueOf();var e,s={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};t="string"==typeof t?t.replace(i.regex.numbersWithDots,h).replace(i.regex.pathLetters," $& ").replace(i.regex.hyphen,"$1 -").trim().split(i.regex.delimiter):t.reduce(function(t,e){return[].concat.call(t,e)},[]);var r=[],a=new i.Point,o=new i.Point,l=0,c=t.length;do{i.regex.isPathLetter.test(t[l])?(e=t[l],++l):"M"==e?e="L":"m"==e&&(e="l"),r.push(n[e].call(null,t.slice(l,l+=s[e.toUpperCase()]).map(parseFloat),a,o))}while(c>l);return r},bbox:function(){return i.parser.path.setAttribute("d",this.toString()),i.parser.path.getBBox()}}),i.Number=i.invent({create:function(t,e){this.value=0,this.unit=e||"","number"==typeof t?this.value=isNaN(t)?0:isFinite(t)?t:t<0?-34e37:34e37:"string"==typeof t?(e=t.match(i.regex.numberAndUnit))&&(this.value=parseFloat(e[1]),"%"==e[5]?this.value/=100:"s"==e[5]&&(this.value*=1e3),this.unit=e[5]):t instanceof i.Number&&(this.value=t.valueOf(),this.unit=t.unit)},extend:{toString:function(){return("%"==this.unit?~~(1e8*this.value)/1e6:"s"==this.unit?this.value/1e3:this.value)+this.unit},toJSON:function(){return this.toString()},valueOf:function(){return this.value},plus:function(t){return t=new i.Number(t),new i.Number(this+t,this.unit||t.unit)},minus:function(t){return t=new i.Number(t),new i.Number(this-t,this.unit||t.unit)},times:function(t){return t=new i.Number(t),new i.Number(this*t,this.unit||t.unit)},divide:function(t){return t=new i.Number(t),new i.Number(this/t,this.unit||t.unit)},to:function(t){var e=new i.Number(this);return"string"==typeof t&&(e.unit=t),e},morph:function(t){return this.destination=new i.Number(t),t.relative&&(this.destination.value+=this.value),this},at:function(t){return this.destination?new i.Number(this.destination).minus(this).times(t).plus(this):this}}}),i.Element=i.invent({create:function(t){this._stroke=i.defaults.attrs.stroke,this._event=null,this._events={},this.dom={},(this.node=t)&&(this.type=t.nodeName,this.node.instance=this,this._events=t._events||{},this._stroke=t.getAttribute("stroke")||this._stroke)},extend:{x:function(t){return this.attr("x",t)},y:function(t){return this.attr("y",t)},cx:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)},cy:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},width:function(t){return this.attr("width",t)},height:function(t){return this.attr("height",t)},size:function(t,e){var n=d(this,t,e);return this.width(new i.Number(n.width)).height(new i.Number(n.height))},clone:function(t){this.writeDataToDom();var e=v(this.node.cloneNode(!0));return t?t.add(e):this.after(e),e},remove:function(){return this.parent()&&this.parent().removeElement(this),this},replace:function(t){return this.after(t).remove(),t},addTo:function(t){return t.put(this)},putIn:function(t){return t.add(this)},id:function(t){return this.attr("id",t)},inside:function(t,e){var i=this.bbox();return t>i.x&&e>i.y&&t<i.x+i.width&&e<i.y+i.height},show:function(){return this.style("display","")},hide:function(){return this.style("display","none")},visible:function(){return"none"!=this.style("display")},toString:function(){return this.attr("id")},classes:function(){var t=this.attr("class");return null==t?[]:t.trim().split(i.regex.delimiter)},hasClass:function(t){return-1!=this.classes().indexOf(t)},addClass:function(t){if(!this.hasClass(t)){var e=this.classes();e.push(t),this.attr("class",e.join(" "))}return this},removeClass:function(t){return this.hasClass(t)&&this.attr("class",this.classes().filter(function(e){return e!=t}).join(" ")),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)},reference:function(t){return i.get(this.attr(t))},parent:function(e){var n=this;if(!n.node.parentNode)return null;if(n=i.adopt(n.node.parentNode),!e)return n;for(;n&&n.node instanceof t.SVGElement;){if("string"==typeof e?n.matches(e):n instanceof e)return n;if(!n.node.parentNode||"#document"==n.node.parentNode.nodeName||"#document-fragment"==n.node.parentNode.nodeName)return null;n=i.adopt(n.node.parentNode)}},doc:function(){return this instanceof i.Doc?this:this.parent(i.Doc)},parents:function(t){var e=[],i=this;do{if(!(i=i.parent(t))||!i.node)break;e.push(i)}while(i.parent);return e},matches:function(t){return function(t,e){return(t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector).call(t,e)}(this.node,t)},native:function(){return this.node},svg:function(t){var n=e.createElement("svg");if(!(t&&this instanceof i.Parent))return n.appendChild(t=e.createElement("svg")),this.writeDataToDom(),t.appendChild(this.node.cloneNode(!0)),n.innerHTML.replace(/^<svg>/,"").replace(/<\/svg>$/,"");n.innerHTML="<svg>"+t.replace(/\n/,"").replace(/<([\w:-]+)([^<]+?)\/>/g,"<$1$2></$1>")+"</svg>";for(var s=0,r=n.firstChild.childNodes.length;s<r;s++)this.node.appendChild(n.firstChild.firstChild);return this},writeDataToDom:function(){if(this.each||this.lines){var t=this.each?this:this.lines();t.each(function(){this.writeDataToDom()})}return this.node.removeAttribute("svgjs:data"),Object.keys(this.dom).length&&this.node.setAttribute("svgjs:data",JSON.stringify(this.dom)),this},setData:function(t){return this.dom=t,this},is:function(t){return function(t,e){return t instanceof e}(this,t)}}}),i.easing={"-":function(t){return t},"<>":function(t){return-Math.cos(t*Math.PI)/2+.5},">":function(t){return Math.sin(t*Math.PI/2)},"<":function(t){return 1-Math.cos(t*Math.PI/2)}},i.morph=function(t){return function(e,n){return new i.MorphObj(e,n).at(t)}},i.Situation=i.invent({create:function(t){this.init=!1,this.reversed=!1,this.reversing=!1,this.duration=new i.Number(t.duration).valueOf(),this.delay=new i.Number(t.delay).valueOf(),this.start=+new Date+this.delay,this.finish=this.start+this.duration,this.ease=t.ease,this.loop=0,this.loops=!1,this.animations={},this.attrs={},this.styles={},this.transforms=[],this.once={}}}),i.FX=i.invent({create:function(t){this._target=t,this.situations=[],this.active=!1,this.situation=null,this.paused=!1,this.lastPos=0,this.pos=0,this.absPos=0,this._speed=1},extend:{animate:function(t,e,n){"object"==typeof t&&(e=t.ease,n=t.delay,t=t.duration);var s=new i.Situation({duration:t||1e3,delay:n||0,ease:i.easing[e||"-"]||e});return this.queue(s),this},delay:function(t){var e=new i.Situation({duration:t,delay:0,ease:i.easing["-"]});return this.queue(e)},target:function(t){return t&&t instanceof i.Element?(this._target=t,this):this._target},timeToAbsPos:function(t){return(t-this.situation.start)/(this.situation.duration/this._speed)},absPosToTime:function(t){return this.situation.duration/this._speed*t+this.situation.start},startAnimFrame:function(){this.stopAnimFrame(),this.animationFrame=t.requestAnimationFrame(function(){this.step()}.bind(this))},stopAnimFrame:function(){t.cancelAnimationFrame(this.animationFrame)},start:function(){return!this.active&&this.situation&&(this.active=!0,this.startCurrent()),this},startCurrent:function(){return this.situation.start=+new Date+this.situation.delay/this._speed,this.situation.finish=this.situation.start+this.situation.duration/this._speed,this.initAnimations().step()},queue:function(t){return("function"==typeof t||t instanceof i.Situation)&&this.situations.push(t),this.situation||(this.situation=this.situations.shift()),this},dequeue:function(){return this.stop(),this.situation=this.situations.shift(),this.situation&&(this.situation instanceof i.Situation?this.start():this.situation.call(this)),this},initAnimations:function(){var t,e,n,s=this.situation;if(s.init)return this;for(t in s.animations)for(n=this.target()[t](),Array.isArray(n)||(n=[n]),Array.isArray(s.animations[t])||(s.animations[t]=[s.animations[t]]),e=n.length;e--;)s.animations[t][e]instanceof i.Number&&(n[e]=new i.Number(n[e])),s.animations[t][e]=n[e].morph(s.animations[t][e]);for(t in s.attrs)s.attrs[t]=new i.MorphObj(this.target().attr(t),s.attrs[t]);for(t in s.styles)s.styles[t]=new i.MorphObj(this.target().style(t),s.styles[t]);return s.initialTransformation=this.target().matrixify(),s.init=!0,this},clearQueue:function(){return this.situations=[],this},clearCurrent:function(){return this.situation=null,this},stop:function(t,e){var i=this.active;return this.active=!1,e&&this.clearQueue(),t&&this.situation&&(!i&&this.startCurrent(),this.atEnd()),this.stopAnimFrame(),this.clearCurrent()},reset:function(){if(this.situation){var t=this.situation;this.stop(),this.situation=t,this.atStart()}return this},finish:function(){for(this.stop(!0,!1);this.dequeue().situation&&this.stop(!0,!1););return this.clearQueue().clearCurrent(),this},atStart:function(){return this.at(0,!0)},atEnd:function(){return!0===this.situation.loops&&(this.situation.loops=this.situation.loop+1),"number"==typeof this.situation.loops?this.at(this.situation.loops,!0):this.at(1,!0)},at:function(t,e){var i=this.situation.duration/this._speed;return this.absPos=t,e||(this.situation.reversed&&(this.absPos=1-this.absPos),this.absPos+=this.situation.loop),this.situation.start=+new Date-this.absPos*i,this.situation.finish=this.situation.start+i,this.step(!0)},speed:function(t){return 0===t?this.pause():t?(this._speed=t,this.at(this.absPos,!0)):this._speed},loop:function(t,e){var i=this.last();return i.loops=null==t||t,i.loop=0,e&&(i.reversing=!0),this},pause:function(){return this.paused=!0,this.stopAnimFrame(),this},play:function(){return this.paused?(this.paused=!1,this.at(this.absPos,!0)):this},reverse:function(t){var e=this.last();return e.reversed=void 0===t?!e.reversed:t,this},progress:function(t){return t?this.situation.ease(this.pos):this.pos},after:function(t){var e=this.last();return this.target().on("finished.fx",function i(n){n.detail.situation==e&&(t.call(this,e),this.off("finished.fx",i))}),this._callStart()},during:function(t){var e=this.last(),n=function(n){n.detail.situation==e&&t.call(this,n.detail.pos,i.morph(n.detail.pos),n.detail.eased,e)};return this.target().off("during.fx",n).on("during.fx",n),this.after(function(){this.off("during.fx",n)}),this._callStart()},afterAll:function(t){var e=function e(i){t.call(this),this.off("allfinished.fx",e)};return this.target().off("allfinished.fx",e).on("allfinished.fx",e),this._callStart()},duringAll:function(t){var e=function(e){t.call(this,e.detail.pos,i.morph(e.detail.pos),e.detail.eased,e.detail.situation)};return this.target().off("during.fx",e).on("during.fx",e),this.afterAll(function(){this.off("during.fx",e)}),this._callStart()},last:function(){return this.situations.length?this.situations[this.situations.length-1]:this.situation},add:function(t,e,i){return this.last()[i||"animations"][t]=e,this._callStart()},step:function(t){var e,i,n;t||(this.absPos=this.timeToAbsPos(+new Date)),!1!==this.situation.loops?(e=Math.max(this.absPos,0),i=Math.floor(e),!0===this.situation.loops||i<this.situation.loops?(this.pos=e-i,n=this.situation.loop,this.situation.loop=i):(this.absPos=this.situation.loops,this.pos=1,n=this.situation.loop-1,this.situation.loop=this.situation.loops),this.situation.reversing&&(this.situation.reversed=this.situation.reversed!=Boolean((this.situation.loop-n)%2))):(this.absPos=Math.min(this.absPos,1),this.pos=this.absPos),this.pos<0&&(this.pos=0),this.situation.reversed&&(this.pos=1-this.pos);var s=this.situation.ease(this.pos);for(var r in this.situation.once)r>this.lastPos&&r<=s&&(this.situation.once[r].call(this.target(),this.pos,s),delete this.situation.once[r]);return this.active&&this.target().fire("during",{pos:this.pos,eased:s,fx:this,situation:this.situation}),this.situation?(this.eachAt(),1==this.pos&&!this.situation.reversed||this.situation.reversed&&0==this.pos?(this.stopAnimFrame(),this.target().fire("finished",{fx:this,situation:this.situation}),this.situations.length||(this.target().fire("allfinished"),this.situations.length||(this.target().off(".fx"),this.active=!1)),this.active?this.dequeue():this.clearCurrent()):!this.paused&&this.active&&this.startAnimFrame(),this.lastPos=s,this):this},eachAt:function(){var t,e,n,s=this,r=this.target(),a=this.situation;for(t in a.animations)n=[].concat(a.animations[t]).map(function(t){return"string"!=typeof t&&t.at?t.at(a.ease(s.pos),s.pos):t}),r[t].apply(r,n);for(t in a.attrs)n=[t].concat(a.attrs[t]).map(function(t){return"string"!=typeof t&&t.at?t.at(a.ease(s.pos),s.pos):t}),r.attr.apply(r,n);for(t in a.styles)n=[t].concat(a.styles[t]).map(function(t){return"string"!=typeof t&&t.at?t.at(a.ease(s.pos),s.pos):t}),r.style.apply(r,n);if(a.transforms.length){for(n=a.initialTransformation,t=0,e=a.transforms.length;t<e;t++){var o=a.transforms[t];o instanceof i.Matrix?n=o.relative?n.multiply((new i.Matrix).morph(o).at(a.ease(this.pos))):n.morph(o).at(a.ease(this.pos)):(o.relative||o.undo(n.extract()),n=n.multiply(o.at(a.ease(this.pos))))}r.matrix(n)}return this},once:function(t,e,i){var n=this.last();return i||(t=n.ease(t)),n.once[t]=e,this},_callStart:function(){return setTimeout(function(){this.start()}.bind(this),0),this}},parent:i.Element,construct:{animate:function(t,e,n){return(this.fx||(this.fx=new i.FX(this))).animate(t,e,n)},delay:function(t){return(this.fx||(this.fx=new i.FX(this))).delay(t)},stop:function(t,e){return this.fx&&this.fx.stop(t,e),this},finish:function(){return this.fx&&this.fx.finish(),this},pause:function(){return this.fx&&this.fx.pause(),this},play:function(){return this.fx&&this.fx.play(),this},speed:function(t){if(this.fx){if(null==t)return this.fx.speed();this.fx.speed(t)}return this}}}),i.MorphObj=i.invent({create:function(t,e){return i.Color.isColor(e)?new i.Color(t).morph(e):i.regex.delimiter.test(t)?i.regex.pathLetters.test(t)?new i.PathArray(t).morph(e):new i.Array(t).morph(e):i.regex.numberAndUnit.test(e)?new i.Number(t).morph(e):(this.value=t,void(this.destination=e))},extend:{at:function(t,e){return e<1?this.value:this.destination},valueOf:function(){return this.value}}}),i.extend(i.FX,{attr:function(t,e,i){if("object"==typeof t)for(var n in t)this.attr(n,t[n]);else this.add(t,e,"attrs");return this},style:function(t,e){if("object"==typeof t)for(var i in t)this.style(i,t[i]);else this.add(t,e,"styles");return this},x:function(t,e){if(this.target()instanceof i.G)return this.transform({x:t},e),this;var n=new i.Number(t);return n.relative=e,this.add("x",n)},y:function(t,e){if(this.target()instanceof i.G)return this.transform({y:t},e),this;var n=new i.Number(t);return n.relative=e,this.add("y",n)},cx:function(t){return this.add("cx",new i.Number(t))},cy:function(t){return this.add("cy",new i.Number(t))},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},size:function(t,e){var n;return this.target()instanceof i.Text?this.attr("font-size",t):(t&&e||(n=this.target().bbox()),t||(t=n.width/n.height*e),e||(e=n.height/n.width*t),this.add("width",new i.Number(t)).add("height",new i.Number(e))),this},width:function(t){return this.add("width",new i.Number(t))},height:function(t){return this.add("height",new i.Number(t))},plot:function(t,e,i,n){return 4==arguments.length?this.plot([t,e,i,n]):this.add("plot",new(this.target().morphArray)(t))},leading:function(t){return this.target().leading?this.add("leading",new i.Number(t)):this},viewbox:function(t,e,n,s){return this.target()instanceof i.Container&&this.add("viewbox",new i.ViewBox(t,e,n,s)),this},update:function(t){if(this.target()instanceof i.Stop){if("number"==typeof t||t instanceof i.Number)return this.update({offset:arguments[0],color:arguments[1],opacity:arguments[2]});null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",t.offset)}return this}}),i.Box=i.invent({create:function(t,e,n,s){if(!("object"!=typeof t||t instanceof i.Element))return i.Box.call(this,null!=t.left?t.left:t.x,null!=t.top?t.top:t.y,t.width,t.height);4==arguments.length&&(this.x=t,this.y=e,this.width=n,this.height=s),y(this)},extend:{merge:function(t){var e=new this.constructor;return e.x=Math.min(this.x,t.x),e.y=Math.min(this.y,t.y),e.width=Math.max(this.x+this.width,t.x+t.width)-e.x,e.height=Math.max(this.y+this.height,t.y+t.height)-e.y,y(e)},transform:function(t){var e,n=1/0,s=-1/0,r=1/0,a=-1/0,o=[new i.Point(this.x,this.y),new i.Point(this.x2,this.y),new i.Point(this.x,this.y2),new i.Point(this.x2,this.y2)];return o.forEach(function(e){e=e.transform(t),n=Math.min(n,e.x),s=Math.max(s,e.x),r=Math.min(r,e.y),a=Math.max(a,e.y)}),(e=new this.constructor).x=n,e.width=s-n,e.y=r,e.height=a-r,y(e),e}}}),i.BBox=i.invent({create:function(t){if(i.Box.apply(this,[].slice.call(arguments)),t instanceof i.Element){var n;try{if(e.documentElement.contains){if(!e.documentElement.contains(t.node))throw new Exception("Element not in the dom")}else{for(var s=t.node;s.parentNode;)s=s.parentNode;if(s!=e)throw new Exception("Element not in the dom")}n=t.node.getBBox()}catch(e){if(t instanceof i.Shape){var r=t.clone(i.parser.draw.instance).show();n=r.node.getBBox(),r.remove()}else n={x:t.node.clientLeft,y:t.node.clientTop,width:t.node.clientWidth,height:t.node.clientHeight}}i.Box.call(this,n)}},inherit:i.Box,parent:i.Element,construct:{bbox:function(){return new i.BBox(this)}}}),i.BBox.prototype.constructor=i.BBox,i.extend(i.Element,{tbox:function(){return console.warn("Use of TBox is deprecated and mapped to RBox. Use .rbox() instead."),this.rbox(this.doc())}}),i.RBox=i.invent({create:function(t){i.Box.apply(this,[].slice.call(arguments)),t instanceof i.Element&&i.Box.call(this,t.node.getBoundingClientRect())},inherit:i.Box,parent:i.Element,extend:{addOffset:function(){return this.x+=t.pageXOffset,this.y+=t.pageYOffset,this}},construct:{rbox:function(t){return t?new i.RBox(this).transform(t.screenCTM().inverse()):new i.RBox(this).addOffset()}}}),i.RBox.prototype.constructor=i.RBox,i.Matrix=i.invent({create:function(t){var e,n=p([1,0,0,1,0,0]);for(t=t instanceof i.Element?t.matrixify():"string"==typeof t?p(t.split(i.regex.delimiter).map(parseFloat)):6==arguments.length?p([].slice.call(arguments)):Array.isArray(t)?p(t):"object"==typeof t?t:n,e=x.length-1;e>=0;--e)this[x[e]]=null!=t[x[e]]?t[x[e]]:n[x[e]]},extend:{extract:function(){var t=f(this,0,1),e=f(this,1,0),n=180/Math.PI*Math.atan2(t.y,t.x)-90;return{x:this.e,y:this.f,transformedX:(this.e*Math.cos(n*Math.PI/180)+this.f*Math.sin(n*Math.PI/180))/Math.sqrt(this.a*this.a+this.b*this.b),transformedY:(this.f*Math.cos(n*Math.PI/180)+this.e*Math.sin(-n*Math.PI/180))/Math.sqrt(this.c*this.c+this.d*this.d),skewX:-n,skewY:180/Math.PI*Math.atan2(e.y,e.x),scaleX:Math.sqrt(this.a*this.a+this.b*this.b),scaleY:Math.sqrt(this.c*this.c+this.d*this.d),rotation:n,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f,matrix:new i.Matrix(this)}},clone:function(){return new i.Matrix(this)},morph:function(t){return this.destination=new i.Matrix(t),this},at:function(t){if(!this.destination)return this;var e=new i.Matrix({a:this.a+(this.destination.a-this.a)*t,b:this.b+(this.destination.b-this.b)*t,c:this.c+(this.destination.c-this.c)*t,d:this.d+(this.destination.d-this.d)*t,e:this.e+(this.destination.e-this.e)*t,f:this.f+(this.destination.f-this.f)*t});return e},multiply:function(t){return new i.Matrix(this.native().multiply(function(t){return t instanceof i.Matrix||(t=new i.Matrix(t)),t}(t).native()))},inverse:function(){return new i.Matrix(this.native().inverse())},translate:function(t,e){return new i.Matrix(this.native().translate(t||0,e||0))},scale:function(t,e,n,s){return 1==arguments.length?e=t:3==arguments.length&&(s=n,n=e,e=t),this.around(n,s,new i.Matrix(t,0,0,e,0,0))},rotate:function(t,e,n){return t=i.utils.radians(t),this.around(e,n,new i.Matrix(Math.cos(t),Math.sin(t),-Math.sin(t),Math.cos(t),0,0))},flip:function(t,e){return"x"==t?this.scale(-1,1,e,0):"y"==t?this.scale(1,-1,0,e):this.scale(-1,-1,t,null!=e?e:t)},skew:function(t,e,n,s){return 1==arguments.length?e=t:3==arguments.length&&(s=n,n=e,e=t),t=i.utils.radians(t),e=i.utils.radians(e),this.around(n,s,new i.Matrix(1,Math.tan(e),Math.tan(t),1,0,0))},skewX:function(t,e,i){return this.skew(t,0,e,i)},skewY:function(t,e,i){return this.skew(0,t,e,i)},around:function(t,e,n){return this.multiply(new i.Matrix(1,0,0,1,t||0,e||0)).multiply(n).multiply(new i.Matrix(1,0,0,1,-t||0,-e||0))},native:function(){for(var t=i.parser.native.createSVGMatrix(),e=x.length-1;e>=0;e--)t[x[e]]=this[x[e]];return t},toString:function(){return"matrix("+g(this.a)+","+g(this.b)+","+g(this.c)+","+g(this.d)+","+g(this.e)+","+g(this.f)+")"}},parent:i.Element,construct:{ctm:function(){return new i.Matrix(this.node.getCTM())},screenCTM:function(){if(this instanceof i.Nested){var t=this.rect(1,1),e=t.node.getScreenCTM();return t.remove(),new i.Matrix(e)}return new i.Matrix(this.node.getScreenCTM())}}}),i.Point=i.invent({create:function(t,e){var i;i=Array.isArray(t)?{x:t[0],y:t[1]}:"object"==typeof t?{x:t.x,y:t.y}:null!=t?{x:t,y:null!=e?e:t}:{x:0,y:0},this.x=i.x,this.y=i.y},extend:{clone:function(){return new i.Point(this)},morph:function(t,e){return this.destination=new i.Point(t,e),this},at:function(t){if(!this.destination)return this;var e=new i.Point({x:this.x+(this.destination.x-this.x)*t,y:this.y+(this.destination.y-this.y)*t});return e},native:function(){var t=i.parser.native.createSVGPoint();return t.x=this.x,t.y=this.y,t},transform:function(t){return new i.Point(this.native().matrixTransform(t.native()))}}}),i.extend(i.Element,{point:function(t,e){return new i.Point(t,e).transform(this.screenCTM().inverse())}}),i.extend(i.Element,{attr:function(t,e,n){if(null==t){for(t={},e=this.node.attributes,n=e.length-1;n>=0;n--)t[e[n].nodeName]=i.regex.isNumber.test(e[n].nodeValue)?parseFloat(e[n].nodeValue):e[n].nodeValue;return t}if("object"==typeof t)for(e in t)this.attr(e,t[e]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return null==(e=this.node.getAttribute(t))?i.defaults.attrs[t]:i.regex.isNumber.test(e)?parseFloat(e):e;"stroke-width"==t?this.attr("stroke",parseFloat(e)>0?this._stroke:null):"stroke"==t&&(this._stroke=e),"fill"!=t&&"stroke"!=t||(i.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof i.Image&&(e=this.doc().defs().pattern(0,0,function(){this.add(e)}))),"number"==typeof e?e=new i.Number(e):i.Color.isColor(e)?e=new i.Color(e):Array.isArray(e)&&(e=new i.Array(e)),"leading"==t?this.leading&&this.leading(e):"string"==typeof n?this.node.setAttributeNS(n,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!=t&&"x"!=t||this.rebuild(t,e)}return this}}),i.extend(i.Element,{transform:function(t,e){var n,s;if("object"!=typeof t)return n=new i.Matrix(this).extract(),"string"==typeof t?n[t]:n;if(n=new i.Matrix(this),e=!!e||!!t.relative,null!=t.a)n=e?n.multiply(new i.Matrix(t)):new i.Matrix(t);else if(null!=t.rotation)m(t,this),n=e?n.rotate(t.rotation,t.cx,t.cy):n.rotate(t.rotation-n.extract().rotation,t.cx,t.cy);else if(null!=t.scale||null!=t.scaleX||null!=t.scaleY){if(m(t,this),t.scaleX=null!=t.scale?t.scale:null!=t.scaleX?t.scaleX:1,t.scaleY=null!=t.scale?t.scale:null!=t.scaleY?t.scaleY:1,!e){var r=n.extract();t.scaleX=1*t.scaleX/r.scaleX,t.scaleY=1*t.scaleY/r.scaleY}n=n.scale(t.scaleX,t.scaleY,t.cx,t.cy)}else if(null!=t.skew||null!=t.skewX||null!=t.skewY){if(m(t,this),t.skewX=null!=t.skew?t.skew:null!=t.skewX?t.skewX:0,t.skewY=null!=t.skew?t.skew:null!=t.skewY?t.skewY:0,!e){var r=n.extract();n=n.multiply((new i.Matrix).skew(r.skewX,r.skewY,t.cx,t.cy).inverse())}n=n.skew(t.skewX,t.skewY,t.cx,t.cy)}else t.flip?("x"==t.flip||"y"==t.flip?t.offset=null==t.offset?this.bbox()["c"+t.flip]:t.offset:null==t.offset?(s=this.bbox(),t.flip=s.cx,t.offset=s.cy):t.flip=t.offset,n=(new i.Matrix).flip(t.flip,t.offset)):null==t.x&&null==t.y||(e?n=n.translate(t.x,t.y):(null!=t.x&&(n.e=t.x),null!=t.y&&(n.f=t.y)));return this.attr("transform",n)}}),i.extend(i.FX,{transform:function(t,e){var n,s,r=this.target();return"object"!=typeof t?(n=new i.Matrix(r).extract(),"string"==typeof t?n[t]:n):(e=!!e||!!t.relative,null!=t.a?n=new i.Matrix(t):null!=t.rotation?(m(t,r),n=new i.Rotate(t.rotation,t.cx,t.cy)):null!=t.scale||null!=t.scaleX||null!=t.scaleY?(m(t,r),t.scaleX=null!=t.scale?t.scale:null!=t.scaleX?t.scaleX:1,t.scaleY=null!=t.scale?t.scale:null!=t.scaleY?t.scaleY:1,n=new i.Scale(t.scaleX,t.scaleY,t.cx,t.cy)):null!=t.skewX||null!=t.skewY?(m(t,r),t.skewX=null!=t.skewX?t.skewX:0,t.skewY=null!=t.skewY?t.skewY:0,n=new i.Skew(t.skewX,t.skewY,t.cx,t.cy)):t.flip?("x"==t.flip||"y"==t.flip?t.offset=null==t.offset?r.bbox()["c"+t.flip]:t.offset:null==t.offset?(s=r.bbox(),t.flip=s.cx,t.offset=s.cy):t.flip=t.offset,n=(new i.Matrix).flip(t.flip,t.offset)):null==t.x&&null==t.y||(n=new i.Translate(t.x,t.y)),n?(n.relative=e,this.last().transforms.push(n),this._callStart()):this)}}),i.extend(i.Element,{untransform:function(){return this.attr("transform",null)},matrixify:function(){var t=(this.attr("transform")||"").split(i.regex.transforms).slice(0,-1).map(function(t){var e=t.trim().split("(");return[e[0],e[1].split(i.regex.delimiter).map(function(t){return parseFloat(t)})]}).reduce(function(t,e){return"matrix"==e[0]?t.multiply(p(e[1])):t[e[0]].apply(t,e[1])},new i.Matrix);return t},toParent:function(t){if(this==t)return this;var e=this.screenCTM(),i=t.screenCTM().inverse();return this.addTo(t).untransform().transform(i.multiply(e)),this},toDoc:function(){return this.toParent(this.doc())}}),i.Transformation=i.invent({create:function(t,e){if(arguments.length>1&&"boolean"!=typeof e)return this.constructor.call(this,[].slice.call(arguments));if(Array.isArray(t))for(var i=0,n=this.arguments.length;i<n;++i)this[this.arguments[i]]=t[i];else if("object"==typeof t)for(var i=0,n=this.arguments.length;i<n;++i)this[this.arguments[i]]=t[this.arguments[i]];this.inversed=!1,!0===e&&(this.inversed=!0)},extend:{arguments:[],method:"",at:function(t){for(var e=[],n=0,s=this.arguments.length;n<s;++n)e.push(this[this.arguments[n]]);var r=this._undo||new i.Matrix;return r=(new i.Matrix).morph(i.Matrix.prototype[this.method].apply(r,e)).at(t),this.inversed?r.inverse():r},undo:function(t){for(var e=0,n=this.arguments.length;e<n;++e)t[this.arguments[e]]=void 0===this[this.arguments[e]]?0:t[this.arguments[e]];return t.cx=this.cx,t.cy=this.cy,this._undo=new(i[c(this.method)])(t,!0).at(1),this}}}),i.Translate=i.invent({parent:i.Matrix,inherit:i.Transformation,create:function(t,e){this.constructor.apply(this,[].slice.call(arguments))},extend:{arguments:["transformedX","transformedY"],method:"translate"}}),i.Rotate=i.invent({parent:i.Matrix,inherit:i.Transformation,create:function(t,e){this.constructor.apply(this,[].slice.call(arguments))},extend:{arguments:["rotation","cx","cy"],method:"rotate",at:function(t){var e=(new i.Matrix).rotate((new i.Number).morph(this.rotation-(this._undo?this._undo.rotation:0)).at(t),this.cx,this.cy);return this.inversed?e.inverse():e},undo:function(t){return this._undo=t,this}}}),i.Scale=i.invent({parent:i.Matrix,inherit:i.Transformation,create:function(t,e){this.constructor.apply(this,[].slice.call(arguments))},extend:{arguments:["scaleX","scaleY","cx","cy"],method:"scale"}}),i.Skew=i.invent({parent:i.Matrix,inherit:i.Transformation,create:function(t,e){this.constructor.apply(this,[].slice.call(arguments))},extend:{arguments:["skewX","skewY","cx","cy"],method:"skew"}}),i.extend(i.Element,{style:function(t,e){if(0==arguments.length)return this.node.style.cssText||"";if(arguments.length<2)if("object"==typeof t)for(e in t)this.style(e,t[e]);else{if(!i.regex.isCss.test(t))return this.node.style[l(t)];for(t=t.split(/\s*;\s*/).filter(function(t){return!!t}).map(function(t){return t.split(/\s*:\s*/)});e=t.pop();)this.style(e[0],e[1])}else this.node.style[l(t)]=null===e||i.regex.isBlank.test(e)?"":e;return this}}),i.Parent=i.invent({create:function(t){this.constructor.call(this,t)},inherit:i.Element,extend:{children:function(){return i.utils.map(i.utils.filterSVGElements(this.node.childNodes),function(t){return i.adopt(t)})},add:function(t,e){return null==e?this.node.appendChild(t.node):t.node!=this.node.childNodes[e]&&this.node.insertBefore(t.node,this.node.childNodes[e]),this},put:function(t,e){return this.add(t,e),t},has:function(t){return this.index(t)>=0},index:function(t){return[].slice.call(this.node.childNodes).indexOf(t.node)},get:function(t){return i.adopt(this.node.childNodes[t])},first:function(){return this.get(0)},last:function(){return this.get(this.node.childNodes.length-1)},each:function(t,e){var n,s,r=this.children();for(n=0,s=r.length;n<s;n++)r[n]instanceof i.Element&&t.apply(r[n],[n,r]),e&&r[n]instanceof i.Container&&r[n].each(t,e);return this},removeElement:function(t){return this.node.removeChild(t.node),this},clear:function(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return delete this._defs,this},defs:function(){return this.doc().defs()}}}),i.extend(i.Parent,{ungroup:function(t,e){return 0===e||this instanceof i.Defs||this.node==i.parser.draw?this:(t=t||(this instanceof i.Doc?this:this.parent(i.Parent)),e=e||1/0,this.each(function(){return this instanceof i.Defs?this:this instanceof i.Parent?this.ungroup(t,e-1):this.toParent(t)}),this.node.firstChild||this.remove(),this)},flatten:function(t,e){return this.ungroup(t,e)}}),i.Container=i.invent({create:function(t){this.constructor.call(this,t)},inherit:i.Parent}),i.ViewBox=i.invent({create:function(t){var e,n,s,r,a,o,h,l=[0,0,0,0],c=1,u=1,d=/[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/gi;if(t instanceof i.Element){for(o=t,h=t,a=(t.attr("viewBox")||"").match(d),t.bbox,s=new i.Number(t.width()),r=new i.Number(t.height());"%"==s.unit;)c*=s.value,s=new i.Number(o instanceof i.Doc?o.parent().offsetWidth:o.parent().width()),o=o.parent();for(;"%"==r.unit;)u*=r.value,r=new i.Number(h instanceof i.Doc?h.parent().offsetHeight:h.parent().height()),h=h.parent();this.x=0,this.y=0,this.width=s*c,this.height=r*u,this.zoom=1,a&&(e=parseFloat(a[0]),n=parseFloat(a[1]),s=parseFloat(a[2]),r=parseFloat(a[3]),this.zoom=this.width/this.height>s/r?this.height/r:this.width/s,this.x=e,this.y=n,this.width=s,this.height=r)}else t="string"==typeof t?t.match(d).map(function(t){return parseFloat(t)}):Array.isArray(t)?t:"object"==typeof t?[t.x,t.y,t.width,t.height]:4==arguments.length?[].slice.call(arguments):l,this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]},extend:{toString:function(){return this.x+" "+this.y+" "+this.width+" "+this.height},morph:function(t,e,n,s){return this.destination=new i.ViewBox(t,e,n,s),this},at:function(t){return this.destination?new i.ViewBox([this.x+(this.destination.x-this.x)*t,this.y+(this.destination.y-this.y)*t,this.width+(this.destination.width-this.width)*t,this.height+(this.destination.height-this.height)*t]):this}},parent:i.Container,construct:{viewbox:function(t,e,n,s){return 0==arguments.length?new i.ViewBox(this):this.attr("viewBox",new i.ViewBox(t,e,n,s))}}}),["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach(function(t){i.Element.prototype[t]=function(e){return null==e?i.off(this,t):i.on(this,t,e),this}}),i.listenerId=0,i.on=function(t,e,n,s,r){var a=n.bind(s||t),o=t instanceof i.Element?t.node:t;o.instance=o.instance||{_events:{}};var h=o.instance._events;n._svgjsListenerId||(n._svgjsListenerId=++i.listenerId),e.split(i.regex.delimiter).forEach(function(t){var e=t.split(".")[0],i=t.split(".")[1]||"*";h[e]=h[e]||{},h[e][i]=h[e][i]||{},h[e][i][n._svgjsListenerId]=a,o.addEventListener(e,a,r||!1)})},i.off=function(t,e,n,s){var r=t instanceof i.Element?t.node:t;if(r.instance&&("function"!=typeof n||(n=n._svgjsListenerId))){var a=r.instance._events;(e||"").split(i.regex.delimiter).forEach(function(t){var e,o,h=t&&t.split(".")[0],l=t&&t.split(".")[1];if(n)a[h]&&a[h][l||"*"]&&(r.removeEventListener(h,a[h][l||"*"][n],s||!1),delete a[h][l||"*"][n]);else if(h&&l){if(a[h]&&a[h][l]){for(o in a[h][l])i.off(r,[h,l].join("."),o);delete a[h][l]}}else if(l)for(t in a)for(e in a[t])l===e&&i.off(r,[t,l].join("."));else if(h){if(a[h]){for(e in a[h])i.off(r,[h,e].join("."));delete a[h]}}else{for(t in a)i.off(r,t);r.instance._events={}}})}},i.extend(i.Element,{on:function(t,e,n,s){return i.on(this,t,e,n,s),this},off:function(t,e){return i.off(this.node,t,e),this},fire:function(e,n){return e instanceof t.Event?this.node.dispatchEvent(e):this.node.dispatchEvent(e=new i.CustomEvent(e,{detail:n,cancelable:!0})),this._event=e,this},event:function(){return this._event}}),i.Defs=i.invent({create:"defs",inherit:i.Container}),i.G=i.invent({create:"g",inherit:i.Container,extend:{x:function(t){return null==t?this.transform("x"):this.transform({x:t-this.x()},!0)},y:function(t){return null==t?this.transform("y"):this.transform({y:t-this.y()},!0)},cx:function(t){return null==t?this.gbox().cx:this.x(t-this.gbox().width/2)},cy:function(t){return null==t?this.gbox().cy:this.y(t-this.gbox().height/2)},gbox:function(){var t=this.bbox(),e=this.transform();return t.x+=e.x,t.x2+=e.x,t.cx+=e.x,t.y+=e.y,t.y2+=e.y,t.cy+=e.y,t}},construct:{group:function(){return this.put(new i.G)}}}),i.Doc=i.invent({create:function(t){t&&("svg"==(t="string"==typeof t?e.getElementById(t):t).nodeName?this.constructor.call(this,t):(this.constructor.call(this,i.create("svg")),t.appendChild(this.node),this.size("100%","100%")),this.namespace().defs())},inherit:i.Container,extend:{namespace:function(){return this.attr({xmlns:i.ns,version:"1.1"}).attr("xmlns:xlink",i.xlink,i.xmlns).attr("xmlns:svgjs",i.svgjs,i.xmlns)},defs:function(){var t;return this._defs||((t=this.node.getElementsByTagName("defs")[0])?this._defs=i.adopt(t):this._defs=new i.Defs,this.node.appendChild(this._defs.node)),this._defs},parent:function(){return this.node.parentNode&&"#document"!=this.node.parentNode.nodeName&&"#document-fragment"!=this.node.parentNode.nodeName?this.node.parentNode:null},spof:function(){var t=this.node.getScreenCTM();return t&&this.style("left",-t.e%1+"px").style("top",-t.f%1+"px"),this},remove:function(){return this.parent()&&this.parent().removeChild(this.node),this},clear:function(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return delete this._defs,i.parser.draw.parentNode||this.node.appendChild(i.parser.draw),this},clone:function(t){this.writeDataToDom();var e=this.node,i=v(e.cloneNode(!0));return t?(t.node||t).appendChild(i.node):e.parentNode.insertBefore(i.node,e.nextSibling),i}}}),i.extend(i.Element,{siblings:function(){return this.parent().children()},position:function(){return this.parent().index(this)},next:function(){return this.siblings()[this.position()+1]},previous:function(){return this.siblings()[this.position()-1]},forward:function(){var t=this.position()+1,e=this.parent();return e.removeElement(this).add(this,t),e instanceof i.Doc&&e.node.appendChild(e.defs().node),this},backward:function(){var t=this.position();return t>0&&this.parent().removeElement(this).add(this,t-1),this},front:function(){var t=this.parent();return t.node.appendChild(this.node),t instanceof i.Doc&&t.node.appendChild(t.defs().node),this},back:function(){return this.position()>0&&this.parent().removeElement(this).add(this,0),this},before:function(t){t.remove();var e=this.position();return this.parent().add(t,e),this},after:function(t){t.remove();var e=this.position();return this.parent().add(t,e+1),this}}),i.Mask=i.invent({create:function(){this.constructor.call(this,i.create("mask")),this.targets=[]},inherit:i.Container,extend:{remove:function(){for(var t=this.targets.length-1;t>=0;t--)this.targets[t]&&this.targets[t].unmask();return this.targets=[],i.Element.prototype.remove.call(this),this}},construct:{mask:function(){return this.defs().put(new i.Mask)}}}),i.extend(i.Element,{maskWith:function(t){return this.masker=t instanceof i.Mask?t:this.parent().mask().add(t),this.masker.targets.push(this),this.attr("mask",'url("#'+this.masker.attr("id")+'")')},unmask:function(){return delete this.masker,this.attr("mask",null)}}),i.ClipPath=i.invent({create:function(){this.constructor.call(this,i.create("clipPath")),this.targets=[]},inherit:i.Container,extend:{remove:function(){for(var t=this.targets.length-1;t>=0;t--)this.targets[t]&&this.targets[t].unclip();return this.targets=[],this.parent().removeElement(this),this}},construct:{clip:function(){return this.defs().put(new i.ClipPath)}}}),i.extend(i.Element,{clipWith:function(t){return this.clipper=t instanceof i.ClipPath?t:this.parent().clip().add(t),this.clipper.targets.push(this),this.attr("clip-path",'url("#'+this.clipper.attr("id")+'")')},unclip:function(){return delete this.clipper,this.attr("clip-path",null)}}),i.Gradient=i.invent({create:function(t){this.constructor.call(this,i.create(t+"Gradient")),this.type=t},inherit:i.Container,extend:{at:function(t,e,n){return this.put(new i.Stop).update(t,e,n)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},fill:function(){return"url(#"+this.id()+")"},toString:function(){return this.fill()},attr:function(t,e,n){return"transform"==t&&(t="gradientTransform"),i.Container.prototype.attr.call(this,t,e,n)}},construct:{gradient:function(t,e){return this.defs().gradient(t,e)}}}),i.extend(i.Gradient,i.FX,{from:function(t,e){return"radial"==(this._target||this).type?this.attr({fx:new i.Number(t),fy:new i.Number(e)}):this.attr({x1:new i.Number(t),y1:new i.Number(e)})},to:function(t,e){return"radial"==(this._target||this).type?this.attr({cx:new i.Number(t),cy:new i.Number(e)}):this.attr({x2:new i.Number(t),y2:new i.Number(e)})}}),i.extend(i.Defs,{gradient:function(t,e){return this.put(new i.Gradient(t)).update(e)}}),i.Stop=i.invent({create:"stop",inherit:i.Element,extend:{update:function(t){return("number"==typeof t||t instanceof i.Number)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new i.Number(t.offset)),this}}}),i.Pattern=i.invent({create:"pattern",inherit:i.Container,extend:{fill:function(){return"url(#"+this.id()+")"},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},toString:function(){return this.fill()},attr:function(t,e,n){return"transform"==t&&(t="patternTransform"),i.Container.prototype.attr.call(this,t,e,n)}},construct:{pattern:function(t,e,i){return this.defs().pattern(t,e,i)}}}),i.extend(i.Defs,{pattern:function(t,e,n){return this.put(new i.Pattern).update(n).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}),i.Shape=i.invent({create:function(t){this.constructor.call(this,t)},inherit:i.Element}),i.Bare=i.invent({create:function(t,e){if(this.constructor.call(this,i.create(t)),e)for(var n in e.prototype)"function"==typeof e.prototype[n]&&(this[n]=e.prototype[n])},inherit:i.Element,extend:{words:function(t){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this.node.appendChild(e.createTextNode(t)),this}}}),i.extend(i.Parent,{element:function(t,e){return this.put(new i.Bare(t,e))}}),i.Symbol=i.invent({create:"symbol",inherit:i.Container,construct:{symbol:function(){return this.put(new i.Symbol)}}}),i.Use=i.invent({create:"use",inherit:i.Shape,extend:{element:function(t,e){return this.attr("href",(e||"")+"#"+t,i.xlink)}},construct:{use:function(t,e){return this.put(new i.Use).element(t,e)}}}),i.Rect=i.invent({create:"rect",inherit:i.Shape,construct:{rect:function(t,e){return this.put(new i.Rect).size(t,e)}}}),i.Circle=i.invent({create:"circle",inherit:i.Shape,construct:{circle:function(t){return this.put(new i.Circle).rx(new i.Number(t).divide(2)).move(0,0)}}}),i.extend(i.Circle,i.FX,{rx:function(t){return this.attr("r",t)},ry:function(t){return this.rx(t)}}),i.Ellipse=i.invent({create:"ellipse",inherit:i.Shape,construct:{ellipse:function(t,e){return this.put(new i.Ellipse).size(t,e).move(0,0)}}}),i.extend(i.Ellipse,i.Rect,i.FX,{rx:function(t){return this.attr("rx",t)},ry:function(t){return this.attr("ry",t)}}),i.extend(i.Circle,i.Ellipse,{x:function(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())},y:function(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())},cx:function(t){return null==t?this.attr("cx"):this.attr("cx",t)},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",t)},width:function(t){return null==t?2*this.rx():this.rx(new i.Number(t).divide(2))},height:function(t){return null==t?2*this.ry():this.ry(new i.Number(t).divide(2))},size:function(t,e){var n=d(this,t,e);return this.rx(new i.Number(n.width).divide(2)).ry(new i.Number(n.height).divide(2))}}),i.Line=i.invent({create:"line",inherit:i.Shape,extend:{array:function(){return new i.PointArray([[this.attr("x1"),this.attr("y1")],[this.attr("x2"),this.attr("y2")]])},plot:function(t,e,n,s){return null==t?this.array():(t=void 0!==e?{x1:t,y1:e,x2:n,y2:s}:new i.PointArray(t).toLine(),this.attr(t))},move:function(t,e){return this.attr(this.array().move(t,e).toLine())},size:function(t,e){var i=d(this,t,e);return this.attr(this.array().size(i.width,i.height).toLine())}},construct:{line:function(t,e,n,s){return i.Line.prototype.plot.apply(this.put(new i.Line),null!=t?[t,e,n,s]:[0,0,0,0])}}}),i.Polyline=i.invent({create:"polyline",inherit:i.Shape,construct:{polyline:function(t){return this.put(new i.Polyline).plot(t||new i.PointArray)}}}),i.Polygon=i.invent({create:"polygon",inherit:i.Shape,construct:{polygon:function(t){return this.put(new i.Polygon).plot(t||new i.PointArray)}}}),i.extend(i.Polyline,i.Polygon,{array:function(){return this._array||(this._array=new i.PointArray(this.attr("points")))},plot:function(t){return null==t?this.array():this.clear().attr("points","string"==typeof t?t:this._array=new i.PointArray(t))},clear:function(){return delete this._array,this},move:function(t,e){return this.attr("points",this.array().move(t,e))},size:function(t,e){var i=d(this,t,e);return this.attr("points",this.array().size(i.width,i.height))}}),i.extend(i.Line,i.Polyline,i.Polygon,{morphArray:i.PointArray,x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},width:function(t){var e=this.bbox();return null==t?e.width:this.size(t,e.height)},height:function(t){var e=this.bbox();return null==t?e.height:this.size(e.width,t)}}),i.Path=i.invent({create:"path",inherit:i.Shape,extend:{morphArray:i.PathArray,array:function(){return this._array||(this._array=new i.PathArray(this.attr("d")))},plot:function(t){return null==t?this.array():this.clear().attr("d","string"==typeof t?t:this._array=new i.PathArray(t))},clear:function(){return delete this._array,this},move:function(t,e){return this.attr("d",this.array().move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},size:function(t,e){var i=d(this,t,e);return this.attr("d",this.array().size(i.width,i.height))},width:function(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)},height:function(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}},construct:{path:function(t){return this.put(new i.Path).plot(t||new i.PathArray)}}}),i.Image=i.invent({create:"image",inherit:i.Shape,extend:{load:function(e){if(!e)return this;var n=this,s=new t.Image;return i.on(s,"load",function(){i.off(s);var t=n.parent(i.Pattern);null!==t&&(0==n.width()&&0==n.height()&&n.size(s.width,s.height),t&&0==t.width()&&0==t.height()&&t.size(n.width(),n.height()),"function"==typeof n._loaded&&n._loaded.call(n,{width:s.width,height:s.height,ratio:s.width/s.height,url:e}))}),i.on(s,"error",function(t){i.off(s),"function"==typeof n._error&&n._error.call(n,t)}),this.attr("href",s.src=this.src=e,i.xlink)},loaded:function(t){return this._loaded=t,this},error:function(t){return this._error=t,this}},construct:{image:function(t,e,n){return this.put(new i.Image).load(t).size(e||0,n||e||0)}}}),i.Text=i.invent({create:function(){this.constructor.call(this,i.create("text")),this.dom.leading=new i.Number(1.3),this._rebuild=!0,this._build=!1,this.attr("font-family",i.defaults.attrs["font-family"])},inherit:i.Shape,extend:{x:function(t){return null==t?this.attr("x"):this.attr("x",t)},y:function(t){var e=this.attr("y"),i="number"==typeof e?e-this.bbox().y:0;return null==t?"number"==typeof e?e-i:e:this.attr("y","number"==typeof t.valueOf()?t+i:t)},cx:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)},cy:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)},text:function(t){if(void 0===t){for(var t="",e=this.node.childNodes,n=0,s=e.length;n<s;++n)0!=n&&3!=e[n].nodeType&&1==i.adopt(e[n]).dom.newLined&&(t+="\n"),t+=e[n].textContent;return t}if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else{t=t.split("\n");for(var n=0,r=t.length;n<r;n++)this.tspan(t[n]).newLine()}return this.build(!1).rebuild()},size:function(t){return this.attr("font-size",t).rebuild()},leading:function(t){return null==t?this.dom.leading:(this.dom.leading=new i.Number(t),this.rebuild())},lines:function(){var t=(this.textPath&&this.textPath()||this).node,e=i.utils.map(i.utils.filterSVGElements(t.childNodes),function(t){return i.adopt(t)});return new i.Set(e)},rebuild:function(t){if("boolean"==typeof t&&(this._rebuild=t),this._rebuild){var e=this,n=0,s=this.dom.leading*new i.Number(this.attr("font-size"));this.lines().each(function(){this.dom.newLined&&(e.textPath()||this.attr("x",e.attr("x")),"\n"==this.text()?n+=s:(this.attr("dy",s+n),n=0))}),this.fire("rebuild")}return this},build:function(t){return this._build=!!t,this},setData:function(t){return this.dom=t,this.dom.leading=new i.Number(t.leading||1.3),this}},construct:{text:function(t){return this.put(new i.Text).text(t)},plain:function(t){return this.put(new i.Text).plain(t)}}}),i.Tspan=i.invent({create:"tspan",inherit:i.Shape,extend:{text:function(t){return null==t?this.node.textContent+(this.dom.newLined?"\n":""):("function"==typeof t?t.call(this,this):this.plain(t),this)},dx:function(t){return this.attr("dx",t)},dy:function(t){return this.attr("dy",t)},newLine:function(){var t=this.parent(i.Text);return this.dom.newLined=!0,this.dy(t.dom.leading*t.attr("font-size")).attr("x",t.x())}}}),i.extend(i.Text,i.Tspan,{plain:function(t){return!1===this._build&&this.clear(),this.node.appendChild(e.createTextNode(t)),this},tspan:function(t){var e=(this.textPath&&this.textPath()||this).node,n=new i.Tspan;return!1===this._build&&this.clear(),e.appendChild(n.node),n.text(t)},clear:function(){for(var t=(this.textPath&&this.textPath()||this).node;t.hasChildNodes();)t.removeChild(t.lastChild);return this},length:function(){return this.node.getComputedTextLength()}}),i.TextPath=i.invent({create:"textPath",inherit:i.Parent,parent:i.Text,construct:{morphArray:i.PathArray,path:function(t){for(var e=new i.TextPath,n=this.doc().defs().path(t);this.node.hasChildNodes();)e.node.appendChild(this.node.firstChild);return this.node.appendChild(e.node),e.attr("href","#"+n,i.xlink),this},array:function(){var t=this.track();return t?t.array():null},plot:function(t){var e=this.track(),i=null;return e&&(i=e.plot(t)),null==t?i:this},track:function(){var t=this.textPath();if(t)return t.reference("href")},textPath:function(){if(this.node.firstChild&&"textPath"==this.node.firstChild.nodeName)return i.adopt(this.node.firstChild)}}}),i.Nested=i.invent({create:function(){this.constructor.call(this,i.create("svg")),this.style("overflow","visible")},inherit:i.Container,construct:{nested:function(){return this.put(new i.Nested)}}}),i.A=i.invent({create:"a",inherit:i.Container,extend:{to:function(t){return this.attr("href",t,i.xlink)},show:function(t){return this.attr("show",t,i.xlink)},target:function(t){return this.attr("target",t)}},construct:{link:function(t){return this.put(new i.A).to(t)}}}),i.extend(i.Element,{linkTo:function(t){var e=new i.A;return"function"==typeof t?t.call(e,e):e.to(t),this.parent().put(e).put(this)}}),i.Marker=i.invent({create:"marker",inherit:i.Container,extend:{width:function(t){return this.attr("markerWidth",t)},height:function(t){return this.attr("markerHeight",t)},ref:function(t,e){return this.attr("refX",t).attr("refY",e)},update:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this},toString:function(){return"url(#"+this.id()+")"}},construct:{marker:function(t,e,i){return this.defs().marker(t,e,i)}}}),i.extend(i.Defs,{marker:function(t,e,n){return this.put(new i.Marker).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(n)}}),i.extend(i.Line,i.Polyline,i.Polygon,i.Path,{marker:function(t,e,n,s){var r=["marker"];return"all"!=t&&r.push(t),r=r.join("-"),t=arguments[1]instanceof i.Marker?arguments[1]:this.doc().marker(e,n,s),this.attr(r,t)}});var o={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"==e?t:t+"-"+e}};function h(t,e,n,s){return n+s.replace(i.regex.dots," .")}function l(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function c(t){return t.charAt(0).toUpperCase()+t.slice(1)}function u(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function d(t,e,i){if(null==e||null==i){var n=t.bbox();null==e?e=n.width/n.height*i:null==i&&(i=n.height/n.width*e)}return{width:e,height:i}}function f(t,e,i){return{x:e*t.a+i*t.c+0,y:e*t.b+i*t.d+0}}function p(t){return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}function m(t,e){t.cx=null==t.cx?e.bbox().cx:t.cx,t.cy=null==t.cy?e.bbox().cy:t.cy}function v(e){for(var n=e.childNodes.length-1;n>=0;n--)e.childNodes[n]instanceof t.SVGElement&&v(e.childNodes[n]);return i.adopt(e).id(i.eid(e.nodeName))}function y(t){return null==t.x&&(t.x=0,t.y=0,t.width=0,t.height=0),t.w=t.width,t.h=t.height,t.x2=t.x+t.width,t.y2=t.y+t.height,t.cx=t.x+t.width/2,t.cy=t.y+t.height/2,t}function g(t){return Math.abs(t)>1e-37?t:0}["fill","stroke"].forEach(function(t){var e,n={};n[t]=function(n){if(void 0===n)return this;if("string"==typeof n||i.Color.isRgb(n)||n&&"function"==typeof n.fill)this.attr(t,n);else for(e=o[t].length-1;e>=0;e--)null!=n[o[t][e]]&&this.attr(o.prefix(t,o[t][e]),n[o[t][e]]);return this},i.extend(i.Element,i.FX,n)}),i.extend(i.Element,i.FX,{rotate:function(t,e,i){return this.transform({rotation:t,cx:e,cy:i})},skew:function(t,e,i,n){return 1==arguments.length||3==arguments.length?this.transform({skew:t,cx:e,cy:i}):this.transform({skewX:t,skewY:e,cx:i,cy:n})},scale:function(t,e,i,n){return 1==arguments.length||3==arguments.length?this.transform({scale:t,cx:e,cy:i}):this.transform({scaleX:t,scaleY:e,cx:i,cy:n})},translate:function(t,e){return this.transform({x:t,y:e})},flip:function(t,e){return e="number"==typeof t?t:e,this.transform({flip:t||"both",offset:e})},matrix:function(t){return this.attr("transform",new i.Matrix(6==arguments.length?[].slice.call(arguments):t))},opacity:function(t){return this.attr("opacity",t)},dx:function(t){return this.x(new i.Number(t).plus(this instanceof i.FX?0:this.x()),!0)},dy:function(t){return this.y(new i.Number(t).plus(this instanceof i.FX?0:this.y()),!0)},dmove:function(t,e){return this.dx(t).dy(e)}}),i.extend(i.Rect,i.Ellipse,i.Circle,i.Gradient,i.FX,{radius:function(t,e){var n=(this._target||this).type;return"radial"==n||"circle"==n?this.attr("r",new i.Number(t)):this.rx(t).ry(null==e?t:e)}}),i.extend(i.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),i.extend(i.Parent,i.Text,i.Tspan,i.FX,{font:function(t,e){if("object"==typeof t)for(e in t)this.font(e,t[e]);return"leading"==t?this.leading(e):"anchor"==t?this.attr("text-anchor",e):"size"==t||"family"==t||"weight"==t||"stretch"==t||"variant"==t||"style"==t?this.attr("font-"+t,e):this.attr(t,e)}}),i.Set=i.invent({create:function(t){t instanceof i.Set?this.members=t.members.slice():Array.isArray(t)?this.members=t:this.clear()},extend:{add:function(){var t,e,i=[].slice.call(arguments);for(t=0,e=i.length;t<e;t++)this.members.push(i[t]);return this},remove:function(t){var e=this.index(t);return e>-1&&this.members.splice(e,1),this},each:function(t){for(var e=0,i=this.members.length;e<i;e++)t.apply(this.members[e],[e,this.members]);return this},clear:function(){return this.members=[],this},length:function(){return this.members.length},has:function(t){return this.index(t)>=0},index:function(t){return this.members.indexOf(t)},get:function(t){return this.members[t]},first:function(){return this.get(0)},last:function(){return this.get(this.members.length-1)},valueOf:function(){return this.members},bbox:function(){if(0==this.members.length)return new i.RBox;var t=this.members[0].rbox(this.members[0].doc());return this.each(function(){t=t.merge(this.rbox(this.doc()))}),t}},construct:{set:function(t){return new i.Set(t)}}}),i.FX.Set=i.invent({create:function(t){this.set=t}}),i.Set.inherit=function(){var t=[];for(var e in i.Shape.prototype)"function"==typeof i.Shape.prototype[e]&&"function"!=typeof i.Set.prototype[e]&&t.push(e);for(var e in t.forEach(function(t){i.Set.prototype[t]=function(){for(var e=0,n=this.members.length;e<n;e++)this.members[e]&&"function"==typeof this.members[e][t]&&this.members[e][t].apply(this.members[e],arguments);return"animate"==t?this.fx||(this.fx=new i.FX.Set(this)):this}}),t=[],i.FX.prototype)"function"==typeof i.FX.prototype[e]&&"function"!=typeof i.FX.Set.prototype[e]&&t.push(e);t.forEach(function(t){i.FX.Set.prototype[t]=function(){for(var e=0,i=this.set.members.length;e<i;e++)this.set.members[e].fx[t].apply(this.set.members[e].fx,arguments);return this}})},i.extend(i.Element,{data:function(t,e,i){if("object"==typeof t)for(e in t)this.data(e,t[e]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+t))}catch(e){return this.attr("data-"+t)}else this.attr("data-"+t,null===e?null:!0===i||"string"==typeof e||"number"==typeof e?e:JSON.stringify(e));return this}}),i.extend(i.Element,{remember:function(t,e){if("object"==typeof arguments[0])for(var e in t)this.remember(e,t[e]);else{if(1==arguments.length)return this.memory()[t];this.memory()[t]=e}return this},forget:function(){if(0==arguments.length)this._memory={};else for(var t=arguments.length-1;t>=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory||(this._memory={})}}),i.get=function(t){var n=e.getElementById(function(t){var e=(t||"").toString().match(i.regex.reference);if(e)return e[1]}(t)||t);return i.adopt(n)},i.select=function(t,n){return new i.Set(i.utils.map((n||e).querySelectorAll(t),function(t){return i.adopt(t)}))},i.extend(i.Parent,{select:function(t){return i.select(t,this.node)}});var x="abcdef".split("");if("function"!=typeof t.CustomEvent){var w=function(t,i){i=i||{bubbles:!1,cancelable:!1,detail:void 0};var n=e.createEvent("CustomEvent");return n.initCustomEvent(t,i.bubbles,i.cancelable,i.detail),n};w.prototype=t.Event.prototype,i.CustomEvent=w}else i.CustomEvent=t.CustomEvent;return function(e){for(var i=0,n=["moz","webkit"],s=0;s<n.length&&!t.requestAnimationFrame;++s)e.requestAnimationFrame=e[n[s]+"RequestAnimationFrame"],e.cancelAnimationFrame=e[n[s]+"CancelAnimationFrame"]||e[n[s]+"CancelRequestAnimationFrame"];e.requestAnimationFrame=e.requestAnimationFrame||function(t){var n=(new Date).getTime(),s=Math.max(0,16-(n-i)),r=e.setTimeout(function(){t(n+s)},s);return i=n+s,r},e.cancelAnimationFrame=e.cancelAnimationFrame||e.clearTimeout}(t),i}(s,s.document)}.call(e,i,e,t))||(t.exports=n)},function(t,e){(function(){function t(t){t.remember("_draggable",this),this.el=t}t.prototype.init=function(t,e){var i=this;this.constraint=t,this.value=e,this.el.on("mousedown.drag",function(t){i.start(t)}),this.el.on("touchstart.drag",function(t){i.start(t)})},t.prototype.transformPoint=function(t,e){var i=(t=t||window.event).changedTouches&&t.changedTouches[0]||t;return this.p.x=i.clientX-(e||0),this.p.y=i.clientY,this.p.matrixTransform(this.m)},t.prototype.getBBox=function(){var t=this.el.bbox();return this.el instanceof SVG.Nested&&(t=this.el.rbox()),(this.el instanceof SVG.G||this.el instanceof SVG.Use||this.el instanceof SVG.Nested)&&(t.x=this.el.x(),t.y=this.el.y()),t},t.prototype.start=function(t){if("click"!=t.type&&"mousedown"!=t.type&&"mousemove"!=t.type||1==(t.which||t.buttons)){var e=this;if(this.el.fire("beforedrag",{event:t,handler:this}),!this.el.event().defaultPrevented){t.preventDefault(),t.stopPropagation(),this.parent=this.parent||this.el.parent(SVG.Nested)||this.el.parent(SVG.Doc),this.p=this.parent.node.createSVGPoint(),this.m=this.el.node.getScreenCTM().inverse();var i,n=this.getBBox();if(this.el instanceof SVG.Text)switch(i=this.el.node.getComputedTextLength(),this.el.attr("text-anchor")){case"middle":i/=2;break;case"start":i=0}this.startPoints={point:this.transformPoint(t,i),box:n,transform:this.el.transform()},SVG.on(window,"mousemove.drag",function(t){e.drag(t)}),SVG.on(window,"touchmove.drag",function(t){e.drag(t)}),SVG.on(window,"mouseup.drag",function(t){e.end(t)}),SVG.on(window,"touchend.drag",function(t){e.end(t)}),this.el.fire("dragstart",{event:t,p:this.startPoints.point,m:this.m,handler:this})}}},t.prototype.drag=function(t){var e=this.getBBox(),i=this.transformPoint(t),n=this.startPoints.box.x+i.x-this.startPoints.point.x,s=this.startPoints.box.y+i.y-this.startPoints.point.y,r=this.constraint,a=i.x-this.startPoints.point.x,o=i.y-this.startPoints.point.y;if(this.el.fire("dragmove",{event:t,p:i,m:this.m,handler:this}),this.el.event().defaultPrevented)return i;if("function"==typeof r){var h=r.call(this.el,n,s,this.m);"boolean"==typeof h&&(h={x:h,y:h}),!0===h.x?this.el.x(n):!1!==h.x&&this.el.x(h.x),!0===h.y?this.el.y(s):!1!==h.y&&this.el.y(h.y)}else"object"==typeof r&&(null!=r.minX&&n<r.minX?a=(n=r.minX)-this.startPoints.box.x:null!=r.maxX&&n>r.maxX-e.width&&(a=(n=r.maxX-e.width)-this.startPoints.box.x),null!=r.minY&&s<r.minY?o=(s=r.minY)-this.startPoints.box.y:null!=r.maxY&&s>r.maxY-e.height&&(o=(s=r.maxY-e.height)-this.startPoints.box.y),null!=r.snapToGrid&&(n-=n%r.snapToGrid,s-=s%r.snapToGrid,a-=a%r.snapToGrid,o-=o%r.snapToGrid),this.el instanceof SVG.G?this.el.matrix(this.startPoints.transform).transform({x:a,y:o},!0):this.el.move(n,s));return i},t.prototype.end=function(t){var e=this.drag(t);this.el.fire("dragend",{event:t,p:e,m:this.m,handler:this}),SVG.off(window,"mousemove.drag"),SVG.off(window,"touchmove.drag"),SVG.off(window,"mouseup.drag"),SVG.off(window,"touchend.drag")},SVG.extend(SVG.Element,{draggable:function(e,i){"function"!=typeof e&&"object"!=typeof e||(i=e,e=!0);var n=this.remember("_draggable")||new t(this);return(e=void 0===e||e)?n.init(i||{},e):(this.off("mousedown.drag"),this.off("touchstart.drag")),this}})}).call(this)},function(t,e){!function(){"use strict";(function(){function t(t){t.remember("_resizeHandler",this),this.el=t,this.parameters={},this.lastUpdateCall=null,this.p=t.doc().node.createSVGPoint()}t.prototype.transformPoint=function(t,e,i){return this.p.x=t-(this.offset.x-window.pageXOffset),this.p.y=e-(this.offset.y-window.pageYOffset),this.p.matrixTransform(i||this.m)},t.prototype._extractPosition=function(t){return{x:null!=t.clientX?t.clientX:t.touches[0].clientX,y:null!=t.clientY?t.clientY:t.touches[0].clientY}},t.prototype.init=function(t){var e=this;if(this.stop(),"stop"!==t){for(var i in this.options={},this.el.resize.defaults)this.options[i]=this.el.resize.defaults[i],void 0!==t[i]&&(this.options[i]=t[i]);this.el.on("lt.resize",function(t){e.resize(t||window.event)}),this.el.on("rt.resize",function(t){e.resize(t||window.event)}),this.el.on("rb.resize",function(t){e.resize(t||window.event)}),this.el.on("lb.resize",function(t){e.resize(t||window.event)}),this.el.on("t.resize",function(t){e.resize(t||window.event)}),this.el.on("r.resize",function(t){e.resize(t||window.event)}),this.el.on("b.resize",function(t){e.resize(t||window.event)}),this.el.on("l.resize",function(t){e.resize(t||window.event)}),this.el.on("rot.resize",function(t){e.resize(t||window.event)}),this.el.on("point.resize",function(t){e.resize(t||window.event)}),this.update()}},t.prototype.stop=function(){return this.el.off("lt.resize"),this.el.off("rt.resize"),this.el.off("rb.resize"),this.el.off("lb.resize"),this.el.off("t.resize"),this.el.off("r.resize"),this.el.off("b.resize"),this.el.off("l.resize"),this.el.off("rot.resize"),this.el.off("point.resize"),this},t.prototype.resize=function(t){var e=this;this.m=this.el.node.getScreenCTM().inverse(),this.offset={x:window.pageXOffset,y:window.pageYOffset};var i=this._extractPosition(t.detail.event);if(this.parameters={type:this.el.type,p:this.transformPoint(i.x,i.y),x:t.detail.x,y:t.detail.y,box:this.el.bbox(),rotation:this.el.transform().rotation},"text"===this.el.type&&(this.parameters.fontSize=this.el.attr()["font-size"]),void 0!==t.detail.i){var n=this.el.array().valueOf();this.parameters.i=t.detail.i,this.parameters.pointCoords=[n[t.detail.i][0],n[t.detail.i][1]]}switch(t.type){case"lt":this.calc=function(t,e){var i=this.snapToGrid(t,e);if(this.parameters.box.width-i[0]>0&&this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-i[0]);i=this.checkAspectRatio(i),this.el.move(this.parameters.box.x+i[0],this.parameters.box.y+i[1]).size(this.parameters.box.width-i[0],this.parameters.box.height-i[1])}};break;case"rt":this.calc=function(t,e){var i=this.snapToGrid(t,e,2);if(this.parameters.box.width+i[0]>0&&this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+i[0]);i=this.checkAspectRatio(i,!0),this.el.move(this.parameters.box.x,this.parameters.box.y+i[1]).size(this.parameters.box.width+i[0],this.parameters.box.height-i[1])}};break;case"rb":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.width+i[0]>0&&this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+i[0]);i=this.checkAspectRatio(i),this.el.move(this.parameters.box.x,this.parameters.box.y).size(this.parameters.box.width+i[0],this.parameters.box.height+i[1])}};break;case"lb":this.calc=function(t,e){var i=this.snapToGrid(t,e,1);if(this.parameters.box.width-i[0]>0&&this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-i[0]);i=this.checkAspectRatio(i,!0),this.el.move(this.parameters.box.x+i[0],this.parameters.box.y).size(this.parameters.box.width-i[0],this.parameters.box.height+i[1])}};break;case"t":this.calc=function(t,e){var i=this.snapToGrid(t,e,2);if(this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y+i[1]).height(this.parameters.box.height-i[1])}};break;case"r":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.width+i[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).width(this.parameters.box.width+i[0])}};break;case"b":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).height(this.parameters.box.height+i[1])}};break;case"l":this.calc=function(t,e){var i=this.snapToGrid(t,e,1);if(this.parameters.box.width-i[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x+i[0],this.parameters.box.y).width(this.parameters.box.width-i[0])}};break;case"rot":this.calc=function(t,e){var i=t+this.parameters.p.x,n=e+this.parameters.p.y,s=Math.atan2(this.parameters.p.y-this.parameters.box.y-this.parameters.box.height/2,this.parameters.p.x-this.parameters.box.x-this.parameters.box.width/2),r=Math.atan2(n-this.parameters.box.y-this.parameters.box.height/2,i-this.parameters.box.x-this.parameters.box.width/2),a=this.parameters.rotation+180*(r-s)/Math.PI+this.options.snapToAngle/2;this.el.center(this.parameters.box.cx,this.parameters.box.cy).rotate(a-a%this.options.snapToAngle,this.parameters.box.cx,this.parameters.box.cy)};break;case"point":this.calc=function(t,e){var i=this.snapToGrid(t,e,this.parameters.pointCoords[0],this.parameters.pointCoords[1]),n=this.el.array().valueOf();n[this.parameters.i][0]=this.parameters.pointCoords[0]+i[0],n[this.parameters.i][1]=this.parameters.pointCoords[1]+i[1],this.el.plot(n)}}this.el.fire("resizestart",{dx:this.parameters.x,dy:this.parameters.y,event:t}),SVG.on(window,"touchmove.resize",function(t){e.update(t||window.event)}),SVG.on(window,"touchend.resize",function(){e.done()}),SVG.on(window,"mousemove.resize",function(t){e.update(t||window.event)}),SVG.on(window,"mouseup.resize",function(){e.done()})},t.prototype.update=function(t){if(t){var e=this._extractPosition(t),i=this.transformPoint(e.x,e.y),n=i.x-this.parameters.p.x,s=i.y-this.parameters.p.y;this.lastUpdateCall=[n,s],this.calc(n,s),this.el.fire("resizing",{dx:n,dy:s,event:t})}else this.lastUpdateCall&&this.calc(this.lastUpdateCall[0],this.lastUpdateCall[1])},t.prototype.done=function(){this.lastUpdateCall=null,SVG.off(window,"mousemove.resize"),SVG.off(window,"mouseup.resize"),SVG.off(window,"touchmove.resize"),SVG.off(window,"touchend.resize"),this.el.fire("resizedone")},t.prototype.snapToGrid=function(t,e,i,n){var s;return void 0!==n?s=[(i+t)%this.options.snapToGrid,(n+e)%this.options.snapToGrid]:(i=null==i?3:i,s=[(this.parameters.box.x+t+(1&i?0:this.parameters.box.width))%this.options.snapToGrid,(this.parameters.box.y+e+(2&i?0:this.parameters.box.height))%this.options.snapToGrid]),t<0&&(s[0]-=this.options.snapToGrid),e<0&&(s[1]-=this.options.snapToGrid),t-=Math.abs(s[0])<this.options.snapToGrid/2?s[0]:s[0]-(t<0?-this.options.snapToGrid:this.options.snapToGrid),e-=Math.abs(s[1])<this.options.snapToGrid/2?s[1]:s[1]-(e<0?-this.options.snapToGrid:this.options.snapToGrid),this.constraintToBox(t,e,i,n)},t.prototype.constraintToBox=function(t,e,i,n){var s,r,a=this.options.constraint||{};return void 0!==n?(s=i,r=n):(s=this.parameters.box.x+(1&i?0:this.parameters.box.width),r=this.parameters.box.y+(2&i?0:this.parameters.box.height)),void 0!==a.minX&&s+t<a.minX&&(t=a.minX-s),void 0!==a.maxX&&s+t>a.maxX&&(t=a.maxX-s),void 0!==a.minY&&r+e<a.minY&&(e=a.minY-r),void 0!==a.maxY&&r+e>a.maxY&&(e=a.maxY-r),[t,e]},t.prototype.checkAspectRatio=function(t,e){if(!this.options.saveAspectRatio)return t;var i=t.slice(),n=this.parameters.box.width/this.parameters.box.height,s=this.parameters.box.width+t[0],r=this.parameters.box.height-t[1],a=s/r;return a<n?(i[1]=s/n-this.parameters.box.height,e&&(i[1]=-i[1])):a>n&&(i[0]=this.parameters.box.width-r*n,e&&(i[0]=-i[0])),i},SVG.extend(SVG.Element,{resize:function(e){return(this.remember("_resizeHandler")||new t(this)).init(e||{}),this}}),SVG.Element.prototype.resize.defaults={snapToAngle:.1,snapToGrid:1,constraint:{},saveAspectRatio:!1}}).call(this)}()},function(t,e){!function(){"use strict";function t(t){this.el=t,t.remember("_selectHandler",this),this.pointSelection={isSelected:!1},this.rectSelection={isSelected:!1},this.pointsList={lt:[0,0],rt:["width",0],rb:["width","height"],lb:[0,"height"],t:["width",0],r:["width","height"],b:["width","height"],l:[0,"height"]},this.pointCoord=function(t,e,i){var n="string"!=typeof t?t:e[t];return i?n/2:n},this.pointCoords=function(t,e){var i=this.pointsList[t];return{x:this.pointCoord(i[0],e,"t"===t||"b"===t),y:this.pointCoord(i[1],e,"r"===t||"l"===t)}}}t.prototype.init=function(t,e){var i=this.el.bbox();this.options={};var n=this.el.selectize.defaults.points;for(var s in this.el.selectize.defaults)this.options[s]=this.el.selectize.defaults[s],void 0!==e[s]&&(this.options[s]=e[s]);var r=["points","pointsExclude"];for(var s in r){var a=this.options[r[s]];"string"==typeof a?a=a.length>0?a.split(/\s*,\s*/i):[]:"boolean"==typeof a&&"points"===r[s]&&(a=a?n:[]),this.options[r[s]]=a}this.options.points=[n,this.options.points].reduce(function(t,e){return t.filter(function(t){return e.indexOf(t)>-1})}),this.options.points=[this.options.points,this.options.pointsExclude].reduce(function(t,e){return t.filter(function(t){return e.indexOf(t)<0})}),this.parent=this.el.parent(),this.nested=this.nested||this.parent.group(),this.nested.matrix(new SVG.Matrix(this.el).translate(i.x,i.y)),this.options.deepSelect&&-1!==["line","polyline","polygon"].indexOf(this.el.type)?this.selectPoints(t):this.selectRect(t),this.observe(),this.cleanup()},t.prototype.selectPoints=function(t){return this.pointSelection.isSelected=t,this.pointSelection.set?this:(this.pointSelection.set=this.parent.set(),this.drawPoints(),this)},t.prototype.getPointArray=function(){var t=this.el.bbox();return this.el.array().valueOf().map(function(e){return[e[0]-t.x,e[1]-t.y]})},t.prototype.drawPoints=function(){for(var t=this,e=this.getPointArray(),i=0,n=e.length;i<n;++i){var s=function(e){return function(i){(i=i||window.event).preventDefault?i.preventDefault():i.returnValue=!1,i.stopPropagation();var n=i.pageX||i.touches[0].pageX,s=i.pageY||i.touches[0].pageY;t.el.fire("point",{x:n,y:s,i:e,event:i})}}(i),r=this.drawPoint(e[i][0],e[i][1]).addClass(this.options.classPoints).addClass(this.options.classPoints+"_point").on("touchstart",s).on("mousedown",s);this.pointSelection.set.add(r)}},t.prototype.drawPoint=function(t,e){var i=this.options.pointType;switch(i){case"circle":return this.drawCircle(t,e);case"rect":return this.drawRect(t,e);default:if("function"==typeof i)return i.call(this,t,e);throw new Error("Unknown "+i+" point type!")}},t.prototype.drawCircle=function(t,e){return this.nested.circle(this.options.pointSize).center(t,e)},t.prototype.drawRect=function(t,e){return this.nested.rect(this.options.pointSize,this.options.pointSize).center(t,e)},t.prototype.updatePointSelection=function(){var t=this.getPointArray();this.pointSelection.set.each(function(e){this.cx()===t[e][0]&&this.cy()===t[e][1]||this.center(t[e][0],t[e][1])})},t.prototype.updateRectSelection=function(){var t=this,e=this.el.bbox();if(this.rectSelection.set.get(0).attr({width:e.width,height:e.height}),this.options.points.length&&this.options.points.map(function(i,n){var s=t.pointCoords(i,e);t.rectSelection.set.get(n+1).center(s.x,s.y)}),this.options.rotationPoint){var i=this.rectSelection.set.length();this.rectSelection.set.get(i-1).center(e.width/2,20)}},t.prototype.selectRect=function(t){var e=this,i=this.el.bbox();function n(t){return function(i){(i=i||window.event).preventDefault?i.preventDefault():i.returnValue=!1,i.stopPropagation();var n=i.pageX||i.touches[0].pageX,s=i.pageY||i.touches[0].pageY;e.el.fire(t,{x:n,y:s,event:i})}}if(this.rectSelection.isSelected=t,this.rectSelection.set=this.rectSelection.set||this.parent.set(),this.rectSelection.set.get(0)||this.rectSelection.set.add(this.nested.rect(i.width,i.height).addClass(this.options.classRect)),this.options.points.length&&this.rectSelection.set.length()<2){this.options.points.map(function(t,s){var r=e.pointCoords(t,i),a=e.drawPoint(r.x,r.y).attr("class",e.options.classPoints+"_"+t).on("mousedown",n(t)).on("touchstart",n(t));e.rectSelection.set.add(a)}),this.rectSelection.set.each(function(){this.addClass(e.options.classPoints)})}if(this.options.rotationPoint&&(this.options.points&&!this.rectSelection.set.get(9)||!this.options.points&&!this.rectSelection.set.get(1))){var s=function(t){(t=t||window.event).preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation();var i=t.pageX||t.touches[0].pageX,n=t.pageY||t.touches[0].pageY;e.el.fire("rot",{x:i,y:n,event:t})},r=this.drawPoint(i.width/2,20).attr("class",this.options.classPoints+"_rot").on("touchstart",s).on("mousedown",s);this.rectSelection.set.add(r)}},t.prototype.handler=function(){var t=this.el.bbox();this.nested.matrix(new SVG.Matrix(this.el).translate(t.x,t.y)),this.rectSelection.isSelected&&this.updateRectSelection(),this.pointSelection.isSelected&&this.updatePointSelection()},t.prototype.observe=function(){var t=this;if(MutationObserver)if(this.rectSelection.isSelected||this.pointSelection.isSelected)this.observerInst=this.observerInst||new MutationObserver(function(){t.handler()}),this.observerInst.observe(this.el.node,{attributes:!0});else try{this.observerInst.disconnect(),delete this.observerInst}catch(t){}else this.el.off("DOMAttrModified.select"),(this.rectSelection.isSelected||this.pointSelection.isSelected)&&this.el.on("DOMAttrModified.select",function(){t.handler()})},t.prototype.cleanup=function(){!this.rectSelection.isSelected&&this.rectSelection.set&&(this.rectSelection.set.each(function(){this.remove()}),this.rectSelection.set.clear(),delete this.rectSelection.set),!this.pointSelection.isSelected&&this.pointSelection.set&&(this.pointSelection.set.each(function(){this.remove()}),this.pointSelection.set.clear(),delete this.pointSelection.set),this.pointSelection.isSelected||this.rectSelection.isSelected||(this.nested.remove(),delete this.nested)},SVG.extend(SVG.Element,{selectize:function(e,i){return"object"==typeof e&&(i=e,e=!0),(this.remember("_selectHandler")||new t(this)).init(void 0===e||e,i||{}),this}}),SVG.Element.prototype.selectize.defaults={points:["lt","rt","rb","lb","t","r","b","l"],pointsExclude:[],classRect:"svg_select_boundingRect",classPoints:"svg_select_points",pointSize:7,rotationPoint:!0,deepSelect:!1,pointType:"circle"}}()},function(t,e){(function(){function t(t,e,i){this.el=t,t.remember("_paintHandler",this);var n=this,s=this.getPlugin();for(var r in this.parent=t.parent(SVG.Nested)||t.parent(SVG.Doc),this.p=this.parent.node.createSVGPoint(),this.m=null,this.startPoint=null,this.lastUpdateCall=null,this.options={},this.el.draw.defaults)this.options[r]=this.el.draw.defaults[r],void 0!==i[r]&&(this.options[r]=i[r]);for(var r in s.point&&(s.pointPlugin=s.point,delete s.point),s)this[r]=s[r];e||this.parent.on("click.draw",function(t){n.start(t)})}t.prototype.transformPoint=function(t,e){return this.p.x=t-(this.offset.x-window.pageXOffset),this.p.y=e-(this.offset.y-window.pageYOffset),this.p.matrixTransform(this.m)},t.prototype.start=function(t){var e=this;this.m=this.el.node.getScreenCTM().inverse(),this.offset={x:window.pageXOffset,y:window.pageYOffset},this.options.snapToGrid*=Math.sqrt(this.m.a*this.m.a+this.m.b*this.m.b),this.startPoint=this.snapToGrid(this.transformPoint(t.clientX,t.clientY)),this.init&&this.init(t),this.el.fire("drawstart",{event:t,p:this.p,m:this.m}),SVG.on(window,"mousemove.draw",function(t){e.update(t)}),this.start=this.point},t.prototype.point=function(t){return this.point!=this.start?this.start(t):this.pointPlugin?this.pointPlugin(t):void this.stop(t)},t.prototype.stop=function(t){t&&this.update(t),this.clean&&this.clean(),SVG.off(window,"mousemove.draw"),this.parent.off("click.draw"),this.el.forget("_paintHandler"),this.el.draw=function(){},this.el.fire("drawstop")},t.prototype.update=function(t){!t&&this.lastUpdateCall&&(t=this.lastUpdateCall),this.lastUpdateCall=t,this.calc(t),this.el.fire("drawupdate",{event:t,p:this.p,m:this.m})},t.prototype.done=function(){this.calc(),this.stop(),this.el.fire("drawdone")},t.prototype.cancel=function(){this.stop(),this.el.remove(),this.el.fire("drawcancel")},t.prototype.snapToGrid=function(t){var e=null;if(t.length)return e=[t[0]%this.options.snapToGrid,t[1]%this.options.snapToGrid],t[0]-=e[0]<this.options.snapToGrid/2?e[0]:e[0]-this.options.snapToGrid,t[1]-=e[1]<this.options.snapToGrid/2?e[1]:e[1]-this.options.snapToGrid,t;for(var i in t)e=t[i]%this.options.snapToGrid,t[i]-=(e<this.options.snapToGrid/2?e:e-this.options.snapToGrid)+(e<0?this.options.snapToGrid:0);return t},t.prototype.param=function(t,e){this.options[t]=null===e?this.el.draw.defaults[t]:e,this.update()},t.prototype.getPlugin=function(){return this.el.draw.plugins[this.el.type]},SVG.extend(SVG.Element,{draw:function(e,i,n){e instanceof Event||"string"==typeof e||(i=e,e=null);var s=this.remember("_paintHandler")||new t(this,e,i||{});return e instanceof Event&&s.start(e),s[e]&&s[e](i,n),this}}),SVG.Element.prototype.draw.defaults={snapToGrid:1},SVG.Element.prototype.draw.extend=function(t,e){var i={};for(var n in"string"==typeof t?i[t]=e:i=t,i){var s=n.trim().split(/\s+/);for(var r in s)SVG.Element.prototype.draw.plugins[s[r]]=i[n]}},SVG.Element.prototype.draw.plugins={},SVG.Element.prototype.draw.extend("rect image",{init:function(t){var e=this.startPoint;this.el.attr({x:e.x,y:e.y,height:0,width:0})},calc:function(t){var e={x:this.startPoint.x,y:this.startPoint.y},i=this.transformPoint(t.clientX,t.clientY);e.width=i.x-e.x,e.height=i.y-e.y,this.snapToGrid(e),e.width<0&&(e.x=e.x+e.width,e.width=-e.width),e.height<0&&(e.y=e.y+e.height,e.height=-e.height),this.el.attr(e)}}),SVG.Element.prototype.draw.extend("line polyline polygon",{init:function(t){this.set=new SVG.Set;var e=this.startPoint,i=[[e.x,e.y],[e.x,e.y]];this.el.plot(i),this.drawCircles()},calc:function(t){var e=this.el.array().valueOf();if(e.pop(),t){var i=this.transformPoint(t.clientX,t.clientY);e.push(this.snapToGrid([i.x,i.y]))}this.el.plot(e)},point:function(t){if(this.el.type.indexOf("poly")>-1){var e=this.transformPoint(t.clientX,t.clientY),i=this.el.array().valueOf();return i.push(this.snapToGrid([e.x,e.y])),this.el.plot(i),this.drawCircles(),void this.el.fire("drawpoint",{event:t,p:{x:e.x,y:e.y},m:this.m})}this.stop(t)},clean:function(){this.set.each(function(){this.remove()}),this.set.clear(),delete this.set},drawCircles:function(){var t=this.el.array().valueOf();this.set.each(function(){this.remove()}),this.set.clear();for(var e=0;e<t.length;++e){this.p.x=t[e][0],this.p.y=t[e][1];var i=this.p.matrixTransform(this.parent.node.getScreenCTM().inverse().multiply(this.el.node.getScreenCTM()));this.set.add(this.parent.circle(5).stroke({width:1}).fill("#ccc").center(i.x,i.y))}}}),SVG.Element.prototype.draw.extend("circle",{init:function(t){var e=this.startPoint;this.el.attr({cx:e.x,cy:e.y,r:1})},calc:function(t){var e=this.transformPoint(t.clientX,t.clientY),i={cx:this.startPoint.x,cy:this.startPoint.y,r:Math.sqrt((e.x-this.startPoint.x)*(e.x-this.startPoint.x)+(e.y-this.startPoint.y)*(e.y-this.startPoint.y))};this.snapToGrid(i),this.el.attr(i)}}),SVG.Element.prototype.draw.extend("ellipse",{init:function(t){var e=this.startPoint;this.el.attr({cx:e.x,cy:e.y,rx:1,ry:1})},calc:function(t){var e=this.transformPoint(t.clientX,t.clientY),i={cx:this.startPoint.x,cy:this.startPoint.y,rx:Math.abs(e.x-this.startPoint.x),ry:Math.abs(e.y-this.startPoint.y)};this.snapToGrid(i),this.el.attr(i)}})}).call(this)},function(t,e,i){"use strict";function n(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}i.r(e);var s,r,a,o=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.listeners=[]}var e,i,s;return e=t,(i=[{key:"subscribe",value:function(t){this.listeners.push(t)}},{key:"unsubscribe",value:function(t){for(var e=0;e<this.listeners.length;e++)this.listeners[e]===t&&this.listeners.splice(e,1)}},{key:"unsubscribeAll",value:function(){this.listeners=[]}},{key:"notify",value:function(t){var e=!0,i=!1,n=void 0;try{for(var s,r=this.listeners[Symbol.iterator]();!(e=(s=r.next()).done);e=!0){s.value.notify(this,t)}}catch(t){i=!0,n=t}finally{try{e||null==r.return||r.return()}finally{if(i)throw n}}}}])&&n(e.prototype,i),s&&n(e,s),t}();function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function l(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function c(t,e){return!e||"object"!==h(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function d(t,e){return(d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}!function(t){t[t.MIN=.1]="MIN",t[t.MAX=10]="MAX"}(s||(s={})),function(t){t[t.ANTICLOCKWISE90=0]="ANTICLOCKWISE90",t[t.CLOCKWISE90=1]="CLOCKWISE90"}(r||(r={})),function(t){t.IMAGE="image",t.OBJECTS="objects",t.ZOOM="zoom",t.FIT="fit",t.MOVE="move",t.GRID="grid",t.FOCUS="focus",t.ACTIVATE="activate",t.DRAW="draw"}(a||(a={}));var f=function(t){function e(t){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(i=c(this,u(e).call(this))).data={activeElement:{clientID:null,attributeID:null},angle:0,canvasSize:{height:0,width:0},drawData:{enabled:!1,shapeType:null,numberOfPoints:null,initialState:null},image:"",imageOffset:0,imageSize:{height:0,width:0},focusData:{clientID:0,padding:0},gridSize:{height:100,width:100},left:0,objects:[],ObjectStateClass:t,rememberAngle:!1,scale:1,top:0},i}var i,n,h;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&d(t,e)}(e,o),i=e,(n=[{key:"zoom",value:function(t,e,i){var n=this.data.scale,r=i>0?6*n/5:5*n/6;this.data.scale=Math.min(Math.max(r,s.MIN),s.MAX);var o=this.data.angle,h=Math.sin(o*Math.PI/180)+Math.cos(o*Math.PI/180);o/90%2?(this.data.top+=h*((t-this.data.imageSize.width/2)*(n/this.data.scale-1))*this.data.scale,this.data.left-=h*((e-this.data.imageSize.height/2)*(n/this.data.scale-1))*this.data.scale):(this.data.left+=h*((t-this.data.imageSize.width/2)*(n/this.data.scale-1))*this.data.scale,this.data.top+=h*((e-this.data.imageSize.height/2)*(n/this.data.scale-1))*this.data.scale),this.notify(a.ZOOM)}},{key:"move",value:function(t,e){this.data.top+=t,this.data.left+=e,this.notify(a.MOVE)}},{key:"setup",value:function(t,e){var i=this;t.data(function(){i.data.image="",i.notify(a.IMAGE)}).then(function(n){i.data.imageSize={height:t.height,width:t.width},i.data.rememberAngle||(i.data.angle=0),i.data.image=n,i.notify(a.IMAGE),i.data.objects=e,i.notify(a.OBJECTS)}).catch(function(t){throw t})}},{key:"activate",value:function(t,e){this.data.activeElement={clientID:t,attributeID:e},this.notify(a.ACTIVATE)}},{key:"rotate",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t===r.CLOCKWISE90?this.data.angle+=90:this.data.angle-=90,this.data.angle%=360,this.data.rememberAngle=e,this.fit()}},{key:"focus",value:function(t,e){this.data.focusData={clientID:t,padding:e},this.notify(a.FOCUS)}},{key:"fit",value:function(){var t=this.data.angle;this.data.scale=t/90%2?Math.min(this.data.canvasSize.width/this.data.imageSize.height,this.data.canvasSize.height/this.data.imageSize.width):Math.min(this.data.canvasSize.width/this.data.imageSize.width,this.data.canvasSize.height/this.data.imageSize.height),this.data.scale=Math.min(Math.max(this.data.scale,s.MIN),s.MAX),this.data.top=this.data.canvasSize.height/2-this.data.imageSize.height/2,this.data.left=this.data.canvasSize.width/2-this.data.imageSize.width/2,this.notify(a.FIT)}},{key:"grid",value:function(t,e){this.data.gridSize={height:e,width:t},this.notify(a.GRID)}},{key:"draw",value:function(t){if(t.enabled){if(this.data.drawData.enabled)throw new Error("Drawing has been already started");if(!t.shapeType)throw new Error("A shape type is not specified");if(void 0!==t.numberOfPoints){if("polygon"===t.shapeType&&t.numberOfPoints<3)throw new Error("A polygon consists of at least 3 points");if("polyline"===t.shapeType&&t.numberOfPoints<2)throw new Error("A polyline consists of at least 2 points")}}this.data.drawData=Object.assign({},t),this.notify(a.DRAW)}},{key:"split",value:function(t){return t}},{key:"group",value:function(t){return t}},{key:"merge",value:function(t){return t}},{key:"cancel",value:function(){console.log("hello")}},{key:"geometry",get:function(){return{angle:this.data.angle,canvas:Object.assign({},this.data.canvasSize),image:Object.assign({},this.data.imageSize),grid:Object.assign({},this.data.gridSize),left:this.data.left,offset:this.data.imageOffset,scale:this.data.scale,top:this.data.top}},set:function(t){this.data.angle=t.angle,this.data.canvasSize=Object.assign({},t.canvas),this.data.imageSize=Object.assign({},t.image),this.data.gridSize=Object.assign({},t.grid),this.data.left=t.left,this.data.top=t.top,this.data.imageOffset=t.offset,this.data.scale=t.scale,this.data.imageOffset=Math.floor(Math.max(this.data.canvasSize.height/s.MIN,this.data.canvasSize.width/s.MIN))}},{key:"image",get:function(){return this.data.image}},{key:"objects",get:function(){return this.data.objects}},{key:"gridSize",get:function(){return Object.assign({},this.data.gridSize)}},{key:"focusData",get:function(){return Object.assign({},this.data.focusData)}},{key:"activeElement",get:function(){return Object.assign({},this.data.activeElement)}},{key:"objectStateClass",get:function(){return this.data.ObjectStateClass}},{key:"drawData",get:function(){return Object.assign({},this.data.drawData)}}])&&l(i.prototype,n),h&&l(i,h),e}();function p(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var m=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.model=e}var e,i,n;return e=t,(i=[{key:"zoom",value:function(t,e,i){this.model.zoom(t,e,i)}},{key:"fit",value:function(){this.model.fit()}},{key:"enableDrag",value:function(t,e){this.lastDragPosition={x:t,y:e},this.isDragging=!0}},{key:"drag",value:function(t,e){if(this.isDragging){var i=e-this.lastDragPosition.y,n=t-this.lastDragPosition.x;this.lastDragPosition={x:t,y:e},this.model.move(i,n)}}},{key:"disableDrag",value:function(){this.isDragging=!1}},{key:"draw",value:function(t){this.model.draw(t)}},{key:"geometry",get:function(){return this.model.geometry},set:function(t){this.model.geometry=t}},{key:"objects",get:function(){return this.model.objects}},{key:"focusData",get:function(){return this.model.focusData}},{key:"activeElement",get:function(){return this.model.activeElement}},{key:"objectStateClass",get:function(){return this.model.objectStateClass}},{key:"drawData",get:function(){return this.model.drawData}}])&&p(e.prototype,i),n&&p(e,n),t}(),v=i(0),y=(i(1),i(2),i(3),{BASE_STROKE_WIDTH:2,BASE_POINT_SIZE:8,TEXT_MARGIN:10,AREA_THRESHOLD:9,SIZE_THRESHOLD:3});i(4);function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=[],n=!0,s=!1,r=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done)&&(i.push(a.value),!e||i.length!==e);n=!0);}catch(t){s=!0,r=t}finally{try{n||null==o.return||o.return()}finally{if(s)throw r}}return i}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var x=v.Element.prototype.draw;v.Element.prototype.draw=function(){for(var t=this.remember("_paintHandler"),e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return t?x.call.apply(x,[this].concat(i)):(x.call.apply(x,[this].concat(i)),(t=this.remember("_paintHandler")).set=new v.Set),this};for(var w=0,b=Object.keys(x);w<b.length;w++){var S=b[w];v.Element.prototype.draw[S]=x[S]}function E(){this.set.length()&&(this.set.members.splice(-1,1)[0].remove(),this.el.array().value.splice(-2,1),this.el.plot(this.el.array()),this.el.fire("undopoint"))}function P(){this.m=this.el.node.getScreenCTM().inverse(),this.offset={x:window.pageXOffset,y:window.pageYOffset}}function T(){var t=this.el.array().valueOf();this.set.each(function(){this.remove()}),this.set.clear();for(var e=0;e<t.length-1;++e){var i=g(t[e],1);this.p.x=i[0];var n=g(t[e],2);this.p.y=n[1];var s=this.p.matrixTransform(this.parent.node.getScreenCTM().inverse().multiply(this.el.node.getScreenCTM()));this.set.add(this.parent.circle(5).stroke({width:1}).fill("#ccc").center(s.x,s.y))}}v.Element.prototype.draw.extend("polyline",Object.assign({},v.Element.prototype.draw.plugins.polyline,{undo:E})),v.Element.prototype.draw.extend("polygon",Object.assign({},v.Element.prototype.draw.plugins.polygon,{undo:E})),v.Element.prototype.draw.extend("rect",Object.assign({},v.Element.prototype.draw.plugins.rect,{transform:P})),v.Element.prototype.draw.extend("polyline",Object.assign({},v.Element.prototype.draw.plugins.polyline,{transform:P})),v.Element.prototype.draw.extend("polygon",Object.assign({},v.Element.prototype.draw.plugins.polygon,{transform:P})),v.Element.prototype.draw.extend("line",Object.assign({},v.Element.prototype.draw.plugins.line,{drawCircles:T})),v.Element.prototype.draw.extend("polyline",Object.assign({},v.Element.prototype.draw.plugins.polyline,{drawCircles:T})),v.Element.prototype.draw.extend("polygon",Object.assign({},v.Element.prototype.draw.plugins.polygon,{drawCircles:T}));var k=v.Element.prototype.draggable;v.Element.prototype.draggable=function(){for(var t=this.remember("_draggable"),e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return t?k.call.apply(k,[this].concat(i)):(k.call.apply(k,[this].concat(i)),(t=this.remember("_draggable")).drag=function(e){this.m=this.el.node.getScreenCTM().inverse(),t.constructor.prototype.drag.call(this,e)}),this};for(var A=0,C=Object.keys(k);A<C.length;A++){var _=C[A];v.Element.prototype.draggable[_]=k[_]}var M=v.Element.prototype.resize;v.Element.prototype.resize=function(){for(var t=this.remember("_resizeHandler"),e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return t?M.call.apply(M,[this].concat(i)):(M.call.apply(M,[this].concat(i)),(t=this.remember("_resizeHandler")).update=function(e){this.m=this.el.node.getScreenCTM().inverse(),t.constructor.prototype.update.call(this,e)}),this};for(var D=0,N=Object.keys(M);D<N.length;D++){var O=N[D];v.Element.prototype.resize[O]=M[O]}function I(t,e){for(var i=[],n=t.getScreenCTM(),s=t.createSVGPoint(),r=0;r<e.length-1;r+=2)s.x=e[r],s.y=e[r+1],s=s.matrixTransform(n),i.push(s.x,s.y);return i}function z(t,e){for(var i=[],n=t.getScreenCTM().inverse(),s=t.createSVGPoint(),r=0;r<e.length;r+=2)s.x=e[r],s.y=e[r+1],s=s.matrixTransform(n),i.push(s.x,s.y);return i}function G(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=[],n=!0,s=!1,r=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done)&&(i.push(a.value),!e||i.length!==e);n=!0);}catch(t){s=!0,r=t}finally{try{n||null==o.return||o.return()}finally{if(s)throw r}}return i}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function j(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function X(t,e,i){return e&&j(t.prototype,e),i&&j(t,i),t}var B,V=function(){function t(e,i,n){var s=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.onDrawDone=e,this.canvas=i,this.background=n,this.drawData=null,this.geometry=null,this.crosshair=null,this.drawInstance=null,this.canvas.node.addEventListener("mousemove",function(t){if(s.crosshair){var e=G(z(s.canvas.node,[t.clientX,t.clientY]),2),i=e[0],n=e[1];s.crosshair.x.attr({y1:n,y2:n}),s.crosshair.y.attr({x1:i,x2:i})}})}return X(t,[{key:"addCrosshair",value:function(){this.crosshair={x:this.canvas.line(0,0,this.canvas.node.clientWidth,0).attr({"stroke-width":y.BASE_STROKE_WIDTH/(2*this.geometry.scale),zOrder:Number.MAX_SAFE_INTEGER}).addClass("cvat_canvas_crosshair"),y:this.canvas.line(0,0,0,this.canvas.node.clientHeight).attr({"stroke-width":y.BASE_STROKE_WIDTH/(2*this.geometry.scale),zOrder:Number.MAX_SAFE_INTEGER}).addClass("cvat_canvas_crosshair")}}},{key:"removeCrosshair",value:function(){this.crosshair.x.remove(),this.crosshair.y.remove(),this.crosshair=null}},{key:"initDrawing",value:function(){this.drawData.crosshair&&this.addCrosshair()}},{key:"closeDrawing",value:function(){this.crosshair&&this.removeCrosshair(),this.drawInstance&&("rectangle"===this.drawData.shapeType?this.drawInstance.draw("cancel"):this.drawInstance.draw("done"),this.drawInstance&&(this.drawInstance.remove(),this.drawInstance=null))}},{key:"drawBox",value:function(){var t=this;this.drawInstance=this.canvas.rect(),this.drawInstance.draw({snapToGrid:.1}).addClass("cvat_canvas_shape_drawing").attr({"stroke-width":y.BASE_STROKE_WIDTH/this.geometry.scale}).on("drawstop",function(e){var i=t.geometry.image.width,n=t.geometry.image.height,s=e.target.getBBox(),r=G(I(t.canvas.node,[s.x,s.y,s.x+s.width,s.y+s.height]),4),a=r[0],o=r[1],h=r[2],l=r[3],c=G(z(t.background,[a,o,h,l]),4);a=c[0],o=c[1],h=c[2],l=c[3],a=Math.min(Math.max(a,0),i),h=Math.min(Math.max(h,0),i),o=Math.min(Math.max(o,0),n),(h-a)*((l=Math.min(Math.max(l,0),n))-o)>=y.AREA_THRESHOLD?t.onDrawDone({points:[a,o,h,l]}):t.onDrawDone(null)})}},{key:"drawPolyshape",value:function(){var t=this,e=this.drawData.numberOfPoints,i=function(){--e||this.drawInstance.draw("done")}.bind(this);this.drawData.numberOfPoints&&(this.drawInstance.on("drawstart",i),this.drawInstance.on("drawpoint",i),this.drawInstance.on("undopoint",function(){e++}));var n=function(t){3===t.which&&(t.stopPropagation(),t.preventDefault(),this.drawInstance.draw("undo"))}.bind(this);this.canvas.node.addEventListener("mousedown",n);var s={x:null,y:null},r=function(t){if(t.shiftKey&&["polygon","polyline"].includes(this.drawData.shapeType))if(null===s.x||null===s.y)this.drawInstance.draw("point",t);else{Math.sqrt(Math.pow(t.clientX-s.x,2)+Math.pow(t.clientY-s.y,2))>15&&this.drawInstance.draw("point",t)}}.bind(this);this.canvas.node.addEventListener("mousemove",r);var a=this;this.drawInstance.on("drawstart drawpoint",function(t){a.transform(a.geometry),s.x=t.detail.event.clientX,s.y=t.detail.event.clientY}),this.drawInstance.on("drawstop",function(){a.canvas.node.removeEventListener("mousedown",n),a.canvas.node.removeEventListener("mousemove",r)}),this.drawInstance.on("drawdone",function(e){var i=I(t.canvas.node,e.target.getAttribute("points").split(/[,\s]/g).map(function(t){return+t}));i=z(t.background,i);for(var n={xtl:Number.MAX_SAFE_INTEGER,ytl:Number.MAX_SAFE_INTEGER,xbr:Number.MAX_SAFE_INTEGER,ybr:Number.MAX_SAFE_INTEGER},s=t.geometry.image.width,r=t.geometry.image.height,a=0;a<i.length-1;a+=2)i[a]=Math.min(Math.max(i[a],0),s),i[a+1]=Math.min(Math.max(i[a+1],0),r),n.xtl=Math.min(n.xtl,i[a]),n.ytl=Math.min(n.ytl,i[a+1]),n.xbr=Math.max(n.xbr,i[a]),n.ybr=Math.max(n.ybr,i[a+1]);"polygon"===t.drawData.shapeType&&(n.xbr-n.xtl)*(n.ybr-n.ytl)>=y.AREA_THRESHOLD?t.onDrawDone({points:i}):"polyline"===t.drawData.shapeType&&(n.xbr-n.xtl>=y.SIZE_THRESHOLD||n.ybr-n.ytl>=y.SIZE_THRESHOLD)?t.onDrawDone({points:i}):"points"===t.drawData.shapeType?t.onDrawDone({points:i}):t.onDrawDone(null)})}},{key:"drawPolygon",value:function(){this.drawInstance=this.canvas.polygon().draw({snapToGrid:.1}).addClass("cvat_canvas_shape_drawing").style({"stroke-width":y.BASE_STROKE_WIDTH/this.geometry.scale}),this.drawPolyshape()}},{key:"drawPolyline",value:function(){this.drawInstance=this.canvas.polyline().draw({snapToGrid:.1}).addClass("cvat_canvas_shape_drawing").style({"stroke-width":y.BASE_STROKE_WIDTH/this.geometry.scale,"fill-opacity":0}),this.drawPolyshape()}},{key:"drawPoints",value:function(){this.drawInstance=this.canvas.polygon().draw({snapToGrid:.1}).addClass("cvat_canvas_shape_drawing").style({"stroke-width":0,opacity:0}),this.drawPolyshape()}},{key:"startDraw",value:function(){"rectangle"===this.drawData.shapeType?this.drawBox():"polygon"===this.drawData.shapeType?this.drawPolygon():"polyline"===this.drawData.shapeType?this.drawPolyline():"points"===this.drawData.shapeType&&this.drawPoints()}}]),X(t,[{key:"transform",value:function(t){if(this.geometry=t,this.crosshair&&(this.crosshair.x.attr({"stroke-width":y.BASE_STROKE_WIDTH/(2*t.scale)}),this.crosshair.y.attr({"stroke-width":y.BASE_STROKE_WIDTH/(2*t.scale)})),this.drawInstance){this.drawInstance.draw("transform"),this.drawInstance.style({"stroke-width":y.BASE_STROKE_WIDTH/t.scale});var e=this.drawInstance.remember("_paintHandler"),i=!0,n=!1,s=void 0;try{for(var r,a=e.set.members[Symbol.iterator]();!(i=(r=a.next()).done);i=!0){var o=r.value;o.style("stroke-width","".concat(y.BASE_STROKE_WIDTH/(3*t.scale))),o.attr("r","".concat(y.BASE_POINT_SIZE/(2*t.scale)))}}catch(t){n=!0,s=t}finally{try{i||null==a.return||a.return()}finally{if(n)throw s}}}}},{key:"draw",value:function(t,e){this.geometry=e,t.enabled?(this.drawData=t,this.initDrawing(),this.startDraw()):(this.closeDrawing(),this.drawData=t)}}]),t}();function R(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=[],n=!0,s=!1,r=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done)&&(i.push(a.value),!e||i.length!==e);n=!0);}catch(t){s=!0,r=t}finally{try{n||null==o.return||o.return()}finally{if(s)throw r}}return i}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function L(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Y(t,e,i){return e&&L(t.prototype,e),i&&L(t,i),t}function F(t,e){var i=Math.round(parseInt(t.slice(1,3),16)*(1-e/100)),n=Math.round(parseInt(t.slice(3,5),16)*(1-e/100)),s=Math.round(parseInt(t.slice(5,7),16)*(1-e/100)),r=Math.max(0,i).toString(16),a=Math.max(0,n).toString(16),o=Math.max(0,s).toString(16);return"#".concat(1===r.length?"0".concat(r):r)+"".concat(1===a.length?"0".concat(a):a)+"".concat(1===o.length?"0".concat(o):o)}!function(t){t.IDLE="idle",t.DRAG="drag",t.RESIZE="resize",t.DRAW="draw"}(B||(B={}));var H=function(){function t(e,i){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.controller=i,this.svgShapes={},this.svgTexts={},this.activeElement=null,this.mode=B.IDLE,this.loadingAnimation=window.document.createElementNS("http://www.w3.org/2000/svg","svg"),this.text=window.document.createElementNS("http://www.w3.org/2000/svg","svg"),this.adoptedText=v.adopt(this.text),this.background=window.document.createElementNS("http://www.w3.org/2000/svg","svg"),this.grid=window.document.createElementNS("http://www.w3.org/2000/svg","svg"),this.gridPath=window.document.createElementNS("http://www.w3.org/2000/svg","path"),this.gridPattern=window.document.createElementNS("http://www.w3.org/2000/svg","pattern"),this.content=window.document.createElementNS("http://www.w3.org/2000/svg","svg"),this.adoptedContent=v.adopt(this.content),this.drawHandler=new V(this.onDrawDone.bind(this),this.adoptedContent,this.background),this.canvas=window.document.createElement("div");var s=window.document.createElementNS("http://www.w3.org/2000/svg","circle"),r=window.document.createElementNS("http://www.w3.org/2000/svg","defs"),a=window.document.createElementNS("http://www.w3.org/2000/svg","rect");this.loadingAnimation.setAttribute("id","cvat_canvas_loading_animation"),s.setAttribute("id","cvat_canvas_loading_circle"),s.setAttribute("r","30"),s.setAttribute("cx","50%"),s.setAttribute("cy","50%"),this.grid.setAttribute("id","cvat_canvas_grid"),this.grid.setAttribute("version","2"),this.gridPath.setAttribute("d","M 1000 0 L 0 0 0 1000"),this.gridPath.setAttribute("fill","none"),this.gridPath.setAttribute("stroke-width","1.5"),this.gridPattern.setAttribute("id","cvat_canvas_grid_pattern"),this.gridPattern.setAttribute("width","100"),this.gridPattern.setAttribute("height","100"),this.gridPattern.setAttribute("patternUnits","userSpaceOnUse"),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("fill","url(#cvat_canvas_grid_pattern)"),this.text.setAttribute("id","cvat_canvas_text_content"),this.background.setAttribute("id","cvat_canvas_background"),this.content.setAttribute("id","cvat_canvas_content"),this.canvas.setAttribute("id","cvat_canvas_wrapper"),this.loadingAnimation.appendChild(s),this.grid.appendChild(r),this.grid.appendChild(a),r.appendChild(this.gridPattern),this.gridPattern.appendChild(this.gridPath),this.canvas.appendChild(this.loadingAnimation),this.canvas.appendChild(this.text),this.canvas.appendChild(this.background),this.canvas.appendChild(this.grid),this.canvas.appendChild(this.content);var o=this;this.canvas.addEventListener("animationstart",function t(e){if("loadingAnimation"===e.animationName){var i=n.controller.geometry;i.canvas={height:o.canvas.clientHeight,width:o.canvas.clientWidth},n.controller.geometry=i,o.canvas.removeEventListener("animationstart",t)}}),this.content.addEventListener("dblclick",function(){o.controller.fit()}),this.content.addEventListener("mousedown",function(t){(1===t.which&&n.mode===B.IDLE||2===t.which)&&o.controller.enableDrag(t.clientX,t.clientY)}),this.content.addEventListener("mousemove",function(t){o.controller.drag(t.clientX,t.clientY)}),window.document.addEventListener("mouseup",function(t){1!==t.which&&2!==t.which||o.controller.disableDrag()}),this.content.addEventListener("wheel",function(t){var e=z(o.background,[t.clientX,t.clientY]);o.controller.zoom(e[0],e[1],t.deltaY>0?-1:1),t.preventDefault()}),this.content.addEventListener("mousemove",function(t){if(n.mode===B.IDLE){var e=R(z(n.background,[t.clientX,t.clientY]),2),i=e[0],s=e[1],r=new CustomEvent("canvas.moved",{bubbles:!1,cancelable:!0,detail:{x:i,y:s,objects:n.controller.objects}});n.canvas.dispatchEvent(r)}}),this.content.oncontextmenu=function(){return!1},e.subscribe(this)}return Y(t,[{key:"onDrawDone",value:function(t){if(t){var e=new CustomEvent("canvas.drawn",{bubbles:!1,cancelable:!0,detail:{state:new this.controller.objectStateClass(t)}});this.canvas.dispatchEvent(e)}else{var i=new CustomEvent("canvas.canceled",{bubbles:!1,cancelable:!0});this.canvas.dispatchEvent(i)}this.controller.draw({enabled:!1})}}]),Y(t,[{key:"notify",value:function(t,e){function i(t){for(var e=0,i=[this.background,this.grid,this.loadingAnimation,this.content];e<i.length;e++){i[e].style.transform="scale(".concat(t.scale,") rotate(").concat(t.angle,"deg)")}this.gridPath.setAttribute("stroke-width","".concat(y.BASE_STROKE_WIDTH/(2*t.scale),"px"));var n=!0,s=!1,r=void 0;try{for(var a,o=window.document.getElementsByClassName("svg_select_points")[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var h=a.value;h.setAttribute("stroke-width","".concat(y.BASE_STROKE_WIDTH/(3*t.scale))),h.setAttribute("r","".concat(y.BASE_POINT_SIZE/(2*t.scale)))}}catch(t){s=!0,r=t}finally{try{n||null==o.return||o.return()}finally{if(s)throw r}}var l=!0,c=!1,u=void 0;try{for(var d,f=window.document.getElementsByClassName("cvat_canvas_selected_point")[Symbol.iterator]();!(l=(d=f.next()).done);l=!0){var p=d.value;p.setAttribute("stroke-width","".concat(2*+p.getAttribute("stroke-width")))}}catch(t){c=!0,u=t}finally{try{l||null==f.return||f.return()}finally{if(c)throw u}}for(var m in this.svgShapes)if(Object.prototype.hasOwnProperty.call(this.svgShapes,m)){var v=this.svgShapes[m];v.attr("stroke-width")&&v.attr({"stroke-width":y.BASE_STROKE_WIDTH/t.scale})}for(var g in this.svgShapes)Object.prototype.hasOwnProperty.call(this.svgShapes,g)&&Object.prototype.hasOwnProperty.call(this.svgTexts,g)&&this.updateTextPosition(this.svgTexts[g],this.svgShapes[g]);this.drawHandler.transform(t)}function n(t){for(var e=0,i=[this.background,this.grid,this.loadingAnimation];e<i.length;e++){var n=i[e];n.style.top="".concat(t.top,"px"),n.style.left="".concat(t.left,"px")}for(var s=0,r=[this.content,this.text];s<r.length;s++){var a=r[s];a.style.top="".concat(t.top-t.offset,"px"),a.style.left="".concat(t.left-t.offset,"px")}this.drawHandler.transform(t)}var r=this.controller.geometry;if(e===a.IMAGE)t.image.length?(this.loadingAnimation.classList.add("cvat_canvas_hidden"),this.background.style.backgroundImage='url("'.concat(t.image,'")'),n.call(this,r),function(t){for(var e=0,i=[this.background,this.grid,this.loadingAnimation];e<i.length;e++){var n=i[e];n.style.width="".concat(t.image.width,"px"),n.style.height="".concat(t.image.height,"px")}for(var s=0,r=[this.content,this.text];s<r.length;s++){var a=r[s];a.style.width="".concat(t.image.width+2*t.offset,"px"),a.style.height="".concat(t.image.height+2*t.offset,"px")}}.call(this,r),i.call(this,r)):this.loadingAnimation.classList.remove("cvat_canvas_hidden");else if(e===a.ZOOM||e===a.FIT)n.call(this,r),i.call(this,r);else if(e===a.MOVE)n.call(this,r);else if(e===a.OBJECTS){(function(t,e){var i=this.content.getScreenCTM().inverse().multiply(this.background.getScreenCTM());this.deactivate();for(var n=0,s=Object.keys(this.svgShapes);n<s.length;n++){var r=s[n];r in this.svgTexts&&this.svgTexts[r].remove(),this.svgShapes[r].remove()}this.svgTexts={},this.svgShapes={},this.addObjects(i,t,e)}).call(this,this.controller.objects,r);var o=new CustomEvent("canvas.setup");this.canvas.dispatchEvent(o)}else if(e===a.GRID){var h=r.grid;this.gridPattern.setAttribute("width","".concat(h.width)),this.gridPattern.setAttribute("height","".concat(h.height))}else if(e===a.FOCUS)(function(t,e){var r=this.svgShapes[t.clientID];if(r){var a=null,o=r.node.getBBox();a=e.angle/90%2?Math.min(Math.max(Math.min(e.canvas.width/o.height,e.canvas.height/o.width),s.MIN),s.MAX):Math.min(Math.max(Math.min(e.canvas.width/o.width,e.canvas.height/o.height),s.MIN),s.MAX),i.call(this,Object.assign({},e,{scale:a}));var h=R(I(this.content,[o.x+o.width/2,o.y+o.height/2]),2),l=h[0],c=h[1],u=this.canvas.clientWidth/2+this.canvas.offsetLeft,d=this.canvas.clientHeight/2+this.canvas.offsetTop,f=Object.assign({},e,{top:e.top+d-c,left:e.left+u-l,scale:a});this.controller.geometry=f,n.call(this,f)}}).call(this,this.controller.focusData,r);else if(e===a.ACTIVATE)this.activate(r,this.controller.activeElement);else if(e===a.DRAW){var l=this.controller.drawData;l.enabled?(this.mode=B.DRAW,this.deactivate()):this.mode=B.IDLE,this.drawHandler.draw(l,r)}}},{key:"html",value:function(){return this.canvas}},{key:"addObjects",value:function(t,e,i){var n=!0,s=!1,r=void 0;try{for(var a,o=e[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var h=a.value;if("tag"===h.objectType)this.addTag(h,i);else{for(var l=h.points,c=[],u=0;u<=l.length-1;u+=2){var d=this.background.createSVGPoint();d.x=l[u],d.y=l[u+1],d=d.matrixTransform(t),c.push(d.x,d.y)}if("rectangle"===h.shapeType)this.svgShapes[h.clientID]=this.addRect(c,h,i);else{var f=c.reduce(function(t,e,i){return i%2?"".concat(t).concat(e," "):"".concat(t).concat(e,",")},"");"polygon"===h.shapeType?this.svgShapes[h.clientID]=this.addPolygon(f,h,i):"polyline"===h.shapeType?this.svgShapes[h.clientID]=this.addPolyline(f,h,i):"points"===h.shapeType&&(this.svgShapes[h.clientID]=this.addPoints(f,h,i))}"all"===h.visibility&&(this.svgTexts[h.clientID]=this.addText(h),this.updateTextPosition(this.svgTexts[h.clientID],this.svgShapes[h.clientID]))}}}catch(t){s=!0,r=t}finally{try{n||null==o.return||o.return()}finally{if(s)throw r}}}},{key:"deactivate",value:function(){if(this.activeElement){var t=this.activeElement.state,e=this.svgShapes[this.activeElement.state.clientID];e.draggable(!1),"points"!==t.shapeType&&this.selectize(!1,e,null),e.resize(!1);var i=this.svgTexts[t.clientID];i&&"shape"===t.visibility&&(i.remove(),delete this.svgTexts[t.clientID]),this.activeElement=null}}},{key:"selectize",value:function(t,e,i){t?e.selectize(t,{deepSelect:!0,pointSize:y.BASE_POINT_SIZE/i.scale,rotationPoint:!1,pointType:function(t,n){var s=this.nested.circle(this.options.pointSize).stroke("black").fill(e.node.getAttribute("fill")).center(t,n).attr({"stroke-width":y.BASE_STROKE_WIDTH/(3*i.scale)});return s.node.addEventListener("mouseenter",function(){s.attr({"stroke-width":2*s.attr("stroke-width")}),s.addClass("cvat_canvas_selected_point")}),s.node.addEventListener("mouseleave",function(){s.attr({"stroke-width":s.attr("stroke-width")/2}),s.removeClass("cvat_canvas_selected_point")}),s}}):e.selectize(!1,{deepSelect:!0})}},{key:"activate",value:function(t,e){var i=this;if(this.activeElement){if(this.activeElement.state.clientID===e.clientID)return;this.deactivate()}var n=this.controller.objects.filter(function(t){return t.clientID===e.clientID})[0];this.activeElement={attributeID:e.attributeID,state:n};var s=this.svgShapes[e.clientID],r=this.svgTexts[e.clientID];r||"shape"!==n.visibility||(r=this.addText(n),this.svgTexts[n.clientID]=r,this.updateTextPosition(r,s));var a=this;this.content.append(s.node),s.draggable().on("dragstart",function(){i.mode=B.DRAG,r&&r.addClass("cvat_canvas_hidden")}).on("dragend",function(){i.mode=B.IDLE,r&&(r.removeClass("cvat_canvas_hidden"),a.updateTextPosition(r,s))}),"points"!==n.shapeType&&this.selectize(!0,s,t),s.resize().on("resizestart",function(){i.mode=B.RESIZE,r&&r.addClass("cvat_canvas_hidden")}).on("resizedone",function(){i.mode=B.IDLE,r&&(r.removeClass("cvat_canvas_hidden"),a.updateTextPosition(r,s))})}},{key:"updateTextPosition",value:function(t,e){var i=e.node.getBBox(),n=R(I(this.content,[i.x,i.y,i.x+i.width,i.y+i.height]),4),s=n[0],r=n[1],a=n[2],o=n[3],h=[(i={x:Math.min(s,a),y:Math.min(r,o),width:Math.max(s,a)-Math.min(s,a),height:Math.max(r,o)-Math.min(r,o)}).x+i.width,i.y],l=h[0],c=h[1];if(l+t.node.getBBox().width+y.TEXT_MARGIN>this.canvas.offsetWidth){var u=[i.x,i.y];l=u[0],c=u[1]}var d=R(z(this.text,[l+y.TEXT_MARGIN,c]),2),f=d[0],p=d[1];t.move(f,p);var m=!0,v=!1,g=void 0;try{for(var x,w=t.lines().members[Symbol.iterator]();!(m=(x=w.next()).done);m=!0){x.value.attr("x",t.attr("x"))}}catch(t){v=!0,g=t}finally{try{m||null==w.return||w.return()}finally{if(v)throw g}}}},{key:"addText",value:function(t){var e=t.label,i=t.clientID,n=t.attributes,s=e.attributes.reduce(function(t,e){return t[e.id]=e.name,t},{});return this.adoptedText.text(function(t){t.tspan("".concat(e.name," ").concat(i)).style("text-transform","uppercase");for(var r=0,a=Object.keys(n);r<a.length;r++){var o=a[r];t.tspan("".concat(s[o],": ").concat(n[o])).attr({attrID:o,dy:"1em",x:0})}}).move(0,0).addClass("cvat_canvas_text")}},{key:"addRect",value:function(t,e,i){var n=R(t,4),s=n[0],r=n[1],a=n[2],o=n[3];return this.adoptedContent.rect().size(a-s,o-r).attr({clientID:e.clientID,"color-rendering":"optimizeQuality",fill:e.color,"shape-rendering":"geometricprecision",stroke:F(e.color,50),"stroke-width":y.BASE_STROKE_WIDTH/i.scale,zOrder:e.zOrder}).move(s,r).addClass("cvat_canvas_shape")}},{key:"addPolygon",value:function(t,e,i){return this.adoptedContent.polygon(t).attr({clientID:e.clientID,"color-rendering":"optimizeQuality",fill:e.color,"shape-rendering":"geometricprecision",stroke:F(e.color,50),"stroke-width":y.BASE_STROKE_WIDTH/i.scale,zOrder:e.zOrder}).addClass("cvat_canvas_shape")}},{key:"addPolyline",value:function(t,e,i){return this.adoptedContent.polyline(t).attr({clientID:e.clientID,"color-rendering":"optimizeQuality",fill:e.color,"shape-rendering":"geometricprecision",stroke:F(e.color,50),"stroke-width":y.BASE_STROKE_WIDTH/i.scale,zOrder:e.zOrder}).addClass("cvat_canvas_shape")}},{key:"addPoints",value:function(t,e,i){var n=this.adoptedContent.polyline(t).attr({clientID:e.clientID,"color-rendering":"optimizeQuality",fill:e.color,"shape-rendering":"geometricprecision",zOrder:e.zOrder}).addClass("cvat_canvas_shape");return this.selectize(!0,n,i),n.remove=function(){this.selectize(!1,n),n.constructor.prototype.remove.call(n)}.bind(this),n.attr("fill","none"),n}},{key:"addTag",value:function(t,e){console.log(t,e)}}]),t}();function W(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}i.d(e,"Canvas",function(){return U}),i.d(e,"Rotation",function(){return r});var U=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.model=new f(e),this.controller=new m(this.model),this.view=new H(this.model,this.controller)}var e,i,n;return e=t,(i=[{key:"html",value:function(){return this.view.html()}},{key:"setup",value:function(t,e){this.model.setup(t,e)}},{key:"activate",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.model.activate(t,e)}},{key:"rotate",value:function(t,e){this.model.rotate(t,e)}},{key:"focus",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.model.focus(t,e)}},{key:"fit",value:function(){this.model.fit()}},{key:"grid",value:function(t,e){this.model.grid(t,e)}},{key:"draw",value:function(t){this.model.draw(t)}},{key:"split",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.model.split(t)}},{key:"group",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.model.group(t)}},{key:"merge",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.model.merge(t)}},{key:"cancel",value:function(){this.model.cancel()}}])&&W(e.prototype,i),n&&W(e,n),t}()}]);
//# sourceMappingURL=cvat-canvas.node.js.map