UNPKG

mark-tool-js

Version:
2 lines 105 kB
/*! For license information please see index.min.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.MatkToolJs=e():t.MatkToolJs=e()}(self,(()=>(()=>{var __webpack_modules__={547:function(){(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.pageX-(e||0),this.p.y=i.pageY,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,o=i.x-this.startPoints.point.x,a=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?o=(n=r.minX)-this.startPoints.box.x:null!=r.maxX&&n>r.maxX-e.width&&(o=(n=r.maxX-e.width)-this.startPoints.box.x),null!=r.minY&&s<r.minY?a=(s=r.minY)-this.startPoints.box.y:null!=r.maxY&&s>r.maxY-e.height&&(a=(s=r.maxY-e.height)-this.startPoints.box.y),null!=r.snapToGrid&&(n-=n%r.snapToGrid,s-=s%r.snapToGrid,o-=o%r.snapToGrid,a-=a%r.snapToGrid),this.el instanceof SVG.G?this.el.matrix(this.startPoints.transform).transform({x:o,y:a},!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)},608:function(t,e,i){var n,s;s="undefined"!=typeof window?window:this,n=function(){return function(t,e){function i(t,e,i,n){return i+n.replace(p.regex.dots," .")}function n(t){for(var e=t.slice(0),i=e.length;i--;)Array.isArray(e[i])&&(e[i]=n(e[i]));return e}function s(t){return t.toLowerCase().replace(/-(.)/g,(function(t,e){return e.toUpperCase()}))}function r(t){return t.charAt(0).toUpperCase()+t.slice(1)}function o(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function a(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 h(t,e,i){return{x:e*t.a+i*t.c+0,y:e*t.b+i*t.d+0}}function u(t){return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}function c(t,e){t.cx=null==t.cx?e.bbox().cx:t.cx,t.cy=null==t.cy?e.bbox().cy:t.cy}function l(e){for(var i=e.childNodes.length-1;i>=0;i--)e.childNodes[i]instanceof t.SVGElement&&l(e.childNodes[i]);return p.adopt(e).id(p.eid(e.nodeName))}function f(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 d(t){return Math.abs(t)>1e-37?t:0}var p=(void 0!==this?this:t).SVG=function(t){if(p.supported)return t=new p.Doc(t),p.parser.draw||p.prepare(),t};if(p.ns="http://www.w3.org/2000/svg",p.xmlns="http://www.w3.org/2000/xmlns/",p.xlink="http://www.w3.org/1999/xlink",p.svgjs="http://svgjs.com/svgjs",p.supported=!!e.createElementNS&&!!e.createElementNS(p.ns,"svg").createSVGRect,!p.supported)return!1;p.did=1e3,p.eid=function(t){return"Svgjs"+r(t)+p.did++},p.create=function(t){var i=e.createElementNS(this.ns,t);return i.setAttribute("id",this.eid(t)),i},p.extend=function(){var t,e,i,n;for(e=(t=[].slice.call(arguments)).pop(),n=t.length-1;n>=0;n--)if(t[n])for(i in e)t[n].prototype[i]=e[i];p.Set&&p.Set.inherit&&p.Set.inherit()},p.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,p.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&p.extend(e,t.extend),t.construct&&p.extend(t.parent||p.Container,t.construct),e},p.adopt=function(e){return e?e.instance?e.instance:((i="svg"==e.nodeName?e.parentNode instanceof t.SVGElement?new p.Nested:new p.Doc:"linearGradient"==e.nodeName?new p.Gradient("linear"):"radialGradient"==e.nodeName?new p.Gradient("radial"):p[r(e.nodeName)]?new(p[r(e.nodeName)]):new p.Element(e)).type=e.nodeName,i.node=e,e.instance=i,i instanceof p.Doc&&i.namespace().defs(),i.setData(JSON.parse(e.getAttribute("svgjs:data"))||{}),i):null;var i},p.prepare=function(){var t=e.getElementsByTagName("body")[0],i=(t?new p.Doc(t):p.adopt(e.documentElement).nested()).size(2,0);p.parser={body:t||e.documentElement,draw:i.style("opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden").attr("focusable","false").node,poly:i.polyline().node,path:i.path().node,native:p.create("svg")}},p.parser={native:p.create("svg")},e.addEventListener("DOMContentLoaded",(function(){p.parser.draw||p.prepare()}),!1),p.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},p.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}))}},p.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"}},p.Color=function(t){var e;this.r=0,this.g=0,this.b=0,t&&("string"==typeof t?p.regex.isRgb.test(t)?(e=p.regex.rgb.exec(t.replace(p.regex.whitespace,"")),this.r=parseInt(e[1]),this.g=parseInt(e[2]),this.b=parseInt(e[3])):p.regex.isHex.test(t)&&(e=p.regex.hex.exec(function(t){return 4==t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}(t)),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))},p.extend(p.Color,{toString:function(){return this.toHex()},toHex:function(){return"#"+o(this.r)+o(this.g)+o(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 p.Color(t),this},at:function(t){return this.destination?(t=t<0?0:t>1?1:t,new p.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}}),p.Color.test=function(t){return t+="",p.regex.isHex.test(t)||p.regex.isRgb.test(t)},p.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},p.Color.isColor=function(t){return p.Color.isRgb(t)||p.Color.test(t)},p.Array=function(t,e){0==(t=(t||[]).valueOf()).length&&e&&(t=e.valueOf()),this.value=this.parse(t)},p.extend(p.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,i=this.value.length,n=[];e<i;e++)n.push(this.value[e]+(this.destination[e]-this.value[e])*t);return new p.Array(n)},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(p.regex.delimiter).map(parseFloat)},reverse:function(){return this.value.reverse(),this},clone:function(){var t=new this.constructor;return t.value=n(this.value),t}}),p.PointArray=function(t,e){p.Array.call(this,t,e||[[0,0]])},p.PointArray.prototype=new p.Array,p.PointArray.prototype.constructor=p.PointArray,p.extend(p.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,i=this.value.length,n=[];e<i;e++)n.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 p.PointArray(n)},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(p.regex.delimiter).map(parseFloat);t.length%2!=0&&t.pop();for(var i=0,n=t.length;i<n;i+=2)e.push([t[i],t[i+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 p.parser.poly.setAttribute("points",this.toString()),p.parser.poly.getBBox()}});for(var m={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]]}},v="mlhvqtcsaz".split(""),g=0,x=v.length;g<x;++g)m[v[g]]=function(t){return function(e,i,n){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 s=0,r=e.length;s<r;++s)e[s]=e[s]+(s%2?i.y:i.x);return m[t](e,i,n)}}(v[g].toUpperCase());p.PathArray=function(t,e){p.Array.call(this,t,e||[["M",0,0]])},p.PathArray.prototype=new p.Array,p.PathArray.prototype.constructor=p.PathArray,p.extend(p.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,i,n;for(t=new p.PathArray(t),n=this.value.length===t.value.length,e=0,i=this.value.length;n&&e<i;e++)n=this.value[e][0]===t.value[e][0];return n},morph:function(t){return t=new p.PathArray(t),this.equalCommands(t)?this.destination=t:this.destination=null,this},at:function(t){if(!this.destination)return this;var e,i,n,s,r=this.value,o=this.destination.value,a=[],h=new p.PathArray;for(e=0,i=r.length;e<i;e++){for(a[e]=[r[e][0]],n=1,s=r[e].length;n<s;n++)a[e][n]=r[e][n]+(o[e][n]-r[e][n])*t;"A"===a[e][0]&&(a[e][4]=+(0!=a[e][4]),a[e][5]=+(0!=a[e][5]))}return h.value=a,h},parse:function(t){if(t instanceof p.PathArray)return t.valueOf();var e,n={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(p.regex.numbersWithDots,i).replace(p.regex.pathLetters," $& ").replace(p.regex.hyphen,"$1 -").trim().split(p.regex.delimiter):t.reduce((function(t,e){return[].concat.call(t,e)}),[]);var s=[],r=new p.Point,o=new p.Point,a=0,h=t.length;do{p.regex.isPathLetter.test(t[a])?(e=t[a],++a):"M"==e?e="L":"m"==e&&(e="l"),s.push(m[e].call(null,t.slice(a,a+=n[e.toUpperCase()]).map(parseFloat),r,o))}while(h>a);return s},bbox:function(){return p.parser.path.setAttribute("d",this.toString()),p.parser.path.getBBox()}}),p.Number=p.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(p.regex.numberAndUnit))&&(this.value=parseFloat(e[1]),"%"==e[5]?this.value/=100:"s"==e[5]&&(this.value*=1e3),this.unit=e[5]):t instanceof p.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 p.Number(t),new p.Number(this+t,this.unit||t.unit)},minus:function(t){return t=new p.Number(t),new p.Number(this-t,this.unit||t.unit)},times:function(t){return t=new p.Number(t),new p.Number(this*t,this.unit||t.unit)},divide:function(t){return t=new p.Number(t),new p.Number(this/t,this.unit||t.unit)},to:function(t){var e=new p.Number(this);return"string"==typeof t&&(e.unit=t),e},morph:function(t){return this.destination=new p.Number(t),t.relative&&(this.destination.value+=this.value),this},at:function(t){return this.destination?new p.Number(this.destination).minus(this).times(t).plus(this):this}}}),p.Element=p.invent({create:function(t){this._stroke=p.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 i=a(this,t,e);return this.width(new p.Number(i.width)).height(new p.Number(i.height))},clone:function(t){this.writeDataToDom();var e=l(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(p.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 p.get(this.attr(t))},parent:function(e){var i=this;if(!i.node.parentNode)return null;if(i=p.adopt(i.node.parentNode),!e)return i;for(;i&&i.node instanceof t.SVGElement;){if("string"==typeof e?i.matches(e):i instanceof e)return i;if(!i.node.parentNode||"#document"==i.node.parentNode.nodeName||"#document-fragment"==i.node.parentNode.nodeName)return null;i=p.adopt(i.node.parentNode)}},doc:function(){return this instanceof p.Doc?this:this.parent(p.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 i=e.createElement("svg");if(!(t&&this instanceof p.Parent))return i.appendChild(t=e.createElement("svg")),this.writeDataToDom(),t.appendChild(this.node.cloneNode(!0)),i.innerHTML.replace(/^<svg>/,"").replace(/<\/svg>$/,"");i.innerHTML="<svg>"+t.replace(/\n/,"").replace(/<([\w:-]+)([^<]+?)\/>/g,"<$1$2></$1>")+"</svg>";for(var n=0,s=i.firstChild.childNodes.length;n<s;n++)this.node.appendChild(i.firstChild.firstChild);return this},writeDataToDom:function(){return(this.each||this.lines)&&(this.each?this:this.lines()).each((function(){this.writeDataToDom()})),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)}}}),p.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)}},p.morph=function(t){return function(e,i){return new p.MorphObj(e,i).at(t)}},p.Situation=p.invent({create:function(t){this.init=!1,this.reversed=!1,this.reversing=!1,this.duration=new p.Number(t.duration).valueOf(),this.delay=new p.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={}}}),p.FX=p.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,i){"object"==typeof t&&(e=t.ease,i=t.delay,t=t.duration);var n=new p.Situation({duration:t||1e3,delay:i||0,ease:p.easing[e||"-"]||e});return this.queue(n),this},delay:function(t){var e=new p.Situation({duration:t,delay:0,ease:p.easing["-"]});return this.queue(e)},target:function(t){return t&&t instanceof p.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 p.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 p.Situation?this.start():this.situation.call(this)),this},initAnimations:function(){var t,e,i,n=this.situation;if(n.init)return this;for(t in n.animations)for(i=this.target()[t](),Array.isArray(i)||(i=[i]),Array.isArray(n.animations[t])||(n.animations[t]=[n.animations[t]]),e=i.length;e--;)n.animations[t][e]instanceof p.Number&&(i[e]=new p.Number(i[e])),n.animations[t][e]=i[e].morph(n.animations[t][e]);for(t in n.attrs)n.attrs[t]=new p.MorphObj(this.target().attr(t),n.attrs[t]);for(t in n.styles)n.styles[t]=new p.MorphObj(this.target().style(t),n.styles[t]);return n.initialTransformation=this.target().matrixify(),n.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(),i=function(i){i.detail.situation==e&&t.call(this,i.detail.pos,p.morph(i.detail.pos),i.detail.eased,e)};return this.target().off("during.fx",i).on("during.fx",i),this.after((function(){this.off("during.fx",i)})),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,p.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,i,n=this,s=this.target(),r=this.situation;for(t in r.animations)i=[].concat(r.animations[t]).map((function(t){return"string"!=typeof t&&t.at?t.at(r.ease(n.pos),n.pos):t})),s[t].apply(s,i);for(t in r.attrs)i=[t].concat(r.attrs[t]).map((function(t){return"string"!=typeof t&&t.at?t.at(r.ease(n.pos),n.pos):t})),s.attr.apply(s,i);for(t in r.styles)i=[t].concat(r.styles[t]).map((function(t){return"string"!=typeof t&&t.at?t.at(r.ease(n.pos),n.pos):t})),s.style.apply(s,i);if(r.transforms.length){for(i=r.initialTransformation,t=0,e=r.transforms.length;t<e;t++){var o=r.transforms[t];o instanceof p.Matrix?i=o.relative?i.multiply((new p.Matrix).morph(o).at(r.ease(this.pos))):i.morph(o).at(r.ease(this.pos)):(o.relative||o.undo(i.extract()),i=i.multiply(o.at(r.ease(this.pos))))}s.matrix(i)}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:p.Element,construct:{animate:function(t,e,i){return(this.fx||(this.fx=new p.FX(this))).animate(t,e,i)},delay:function(t){return(this.fx||(this.fx=new p.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}}}),p.MorphObj=p.invent({create:function(t,e){return p.Color.isColor(e)?new p.Color(t).morph(e):p.regex.delimiter.test(t)?p.regex.pathLetters.test(t)?new p.PathArray(t).morph(e):new p.Array(t).morph(e):p.regex.numberAndUnit.test(e)?new p.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}}}),p.extend(p.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 p.G)return this.transform({x:t},e),this;var i=new p.Number(t);return i.relative=e,this.add("x",i)},y:function(t,e){if(this.target()instanceof p.G)return this.transform({y:t},e),this;var i=new p.Number(t);return i.relative=e,this.add("y",i)},cx:function(t){return this.add("cx",new p.Number(t))},cy:function(t){return this.add("cy",new p.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 i;return this.target()instanceof p.Text?this.attr("font-size",t):(t&&e||(i=this.target().bbox()),t||(t=i.width/i.height*e),e||(e=i.height/i.width*t),this.add("width",new p.Number(t)).add("height",new p.Number(e))),this},width:function(t){return this.add("width",new p.Number(t))},height:function(t){return this.add("height",new p.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 p.Number(t)):this},viewbox:function(t,e,i,n){return this.target()instanceof p.Container&&this.add("viewbox",new p.ViewBox(t,e,i,n)),this},update:function(t){if(this.target()instanceof p.Stop){if("number"==typeof t||t instanceof p.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}}),p.Box=p.invent({create:function(t,e,i,n){if(!("object"!=typeof t||t instanceof p.Element))return p.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=i,this.height=n),f(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,f(e)},transform:function(t){var e,i=1/0,n=-1/0,s=1/0,r=-1/0;return[new p.Point(this.x,this.y),new p.Point(this.x2,this.y),new p.Point(this.x,this.y2),new p.Point(this.x2,this.y2)].forEach((function(e){e=e.transform(t),i=Math.min(i,e.x),n=Math.max(n,e.x),s=Math.min(s,e.y),r=Math.max(r,e.y)})),(e=new this.constructor).x=i,e.width=n-i,e.y=s,e.height=r-s,f(e),e}}}),p.BBox=p.invent({create:function(t){if(p.Box.apply(this,[].slice.call(arguments)),t instanceof p.Element){var i;try{if(e.documentElement.contains){if(!e.documentElement.contains(t.node))throw new Exception("Element not in the dom")}else{for(var n=t.node;n.parentNode;)n=n.parentNode;if(n!=e)throw new Exception("Element not in the dom")}i=t.node.getBBox()}catch(e){if(t instanceof p.Shape){var s=t.clone(p.parser.draw.instance).show();i=s.node.getBBox(),s.remove()}else i={x:t.node.clientLeft,y:t.node.clientTop,width:t.node.clientWidth,height:t.node.clientHeight}}p.Box.call(this,i)}},inherit:p.Box,parent:p.Element,construct:{bbox:function(){return new p.BBox(this)}}}),p.BBox.prototype.constructor=p.BBox,p.extend(p.Element,{tbox:function(){return console.warn("Use of TBox is deprecated and mapped to RBox. Use .rbox() instead."),this.rbox(this.doc())}}),p.RBox=p.invent({create:function(t){p.Box.apply(this,[].slice.call(arguments)),t instanceof p.Element&&p.Box.call(this,t.node.getBoundingClientRect())},inherit:p.Box,parent:p.Element,extend:{addOffset:function(){return this.x+=t.pageXOffset,this.y+=t.pageYOffset,this}},construct:{rbox:function(t){return t?new p.RBox(this).transform(t.screenCTM().inverse()):new p.RBox(this).addOffset()}}}),p.RBox.prototype.constructor=p.RBox,p.Matrix=p.invent({create:function(t){var e,i=u([1,0,0,1,0,0]);for(t=t instanceof p.Element?t.matrixify():"string"==typeof t?u(t.split(p.regex.delimiter).map(parseFloat)):6==arguments.length?u([].slice.call(arguments)):Array.isArray(t)?u(t):"object"==typeof t?t:i,e=w.length-1;e>=0;--e)this[w[e]]=null!=t[w[e]]?t[w[e]]:i[w[e]]},extend:{extract:function(){var t=h(this,0,1),e=h(this,1,0),i=180/Math.PI*Math.atan2(t.y,t.x)-90;return{x:this.e,y:this.f,transformedX:(this.e*Math.cos(i*Math.PI/180)+this.f*Math.sin(i*Math.PI/180))/Math.sqrt(this.a*this.a+this.b*this.b),transformedY:(this.f*Math.cos(i*Math.PI/180)+this.e*Math.sin(-i*Math.PI/180))/Math.sqrt(this.c*this.c+this.d*this.d),skewX:-i,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:i,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f,matrix:new p.Matrix(this)}},clone:function(){return new p.Matrix(this)},morph:function(t){return this.destination=new p.Matrix(t),this},at:function(t){return this.destination?new p.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}):this},multiply:function(t){return new p.Matrix(this.native().multiply(function(t){return t instanceof p.Matrix||(t=new p.Matrix(t)),t}(t).native()))},inverse:function(){return new p.Matrix(this.native().inverse())},translate:function(t,e){return new p.Matrix(this.native().translate(t||0,e||0))},scale:function(t,e,i,n){return 1==arguments.length?e=t:3==arguments.length&&(n=i,i=e,e=t),this.around(i,n,new p.Matrix(t,0,0,e,0,0))},rotate:function(t,e,i){return t=p.utils.radians(t),this.around(e,i,new p.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,i,n){return 1==arguments.length?e=t:3==arguments.length&&(n=i,i=e,e=t),t=p.utils.radians(t),e=p.utils.radians(e),this.around(i,n,new p.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,i){return this.multiply(new p.Matrix(1,0,0,1,t||0,e||0)).multiply(i).multiply(new p.Matrix(1,0,0,1,-t||0,-e||0))},native:function(){for(var t=p.parser.native.createSVGMatrix(),e=w.length-1;e>=0;e--)t[w[e]]=this[w[e]];return t},toString:function(){return"matrix("+d(this.a)+","+d(this.b)+","+d(this.c)+","+d(this.d)+","+d(this.e)+","+d(this.f)+")"}},parent:p.Element,construct:{ctm:function(){return new p.Matrix(this.node.getCTM())},screenCTM:function(){if(this instanceof p.Nested){var t=this.rect(1,1),e=t.node.getScreenCTM();return t.remove(),new p.Matrix(e)}return new p.Matrix(this.node.getScreenCTM())}}}),p.Point=p.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 p.Point(this)},morph:function(t,e){return this.destination=new p.Point(t,e),this},at:function(t){return this.destination?new p.Point({x:this.x+(this.destination.x-this.x)*t,y:this.y+(this.destination.y-this.y)*t}):this},native:function(){var t=p.parser.native.createSVGPoint();return t.x=this.x,t.y=this.y,t},transform:function(t){return new p.Point(this.native().matrixTransform(t.native()))}}}),p.extend(p.Element,{point:function(t,e){return new p.Point(t,e).transform(this.screenCTM().inverse())}}),p.extend(p.Element,{attr:function(t,e,i){if(null==t){for(t={},i=(e=this.node.attributes).length-1;i>=0;i--)t[e[i].nodeName]=p.regex.isNumber.test(e[i].nodeValue)?parseFloat(e[i].nodeValue):e[i].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))?p.defaults.attrs[t]:p.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||(p.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof p.Image&&(e=this.doc().defs().pattern(0,0,(function(){this.add(e)})))),"number"==typeof e?e=new p.Number(e):p.Color.isColor(e)?e=new p.Color(e):Array.isArray(e)&&(e=new p.Array(e)),"leading"==t?this.leading&&this.leading(e):"string"==typeof i?this.node.setAttributeNS(i,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!=t&&"x"!=t||this.rebuild(t,e)}return this}}),p.extend(p.Element,{transform:function(t,e){var i,n,s=this;if("object"!=typeof t)return i=new p.Matrix(s).extract(),"string"==typeof t?i[t]:i;if(i=new p.Matrix(s),e=!!e||!!t.relative,null!=t.a)i=e?i.multiply(new p.Matrix(t)):new p.Matrix(t);else if(null!=t.rotation)c(t,s),i=e?i.rotate(t.rotation,t.cx,t.cy):i.rotate(t.rotation-i.extract().rotation,t.cx,t.cy);else if(null!=t.scale||null!=t.scaleX||null!=t.scaleY){if(c(t,s),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=i.extract();t.scaleX=1*t.scaleX/r.scaleX,t.scaleY=1*t.scaleY/r.scaleY}i=i.scale(t.scaleX,t.scaleY,t.cx,t.cy)}else null!=t.skew||null!=t.skewX||null!=t.skewY?(c(t,s),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||(r=i.extract(),i=i.multiply((new p.Matrix).skew(r.skewX,r.skewY,t.cx,t.cy).inverse())),i=i.skew(t.skewX,t.skewY,t.cx,t.cy)):t.flip?("x"==t.flip||"y"==t.flip?t.offset=null==t.offset?s.bbox()["c"+t.flip]:t.offset:null==t.offset?(n=s.bbox(),t.flip=n.cx,t.offset=n.cy):t.flip=t.offset,i=(new p.Matrix).flip(t.flip,t.offset)):null==t.x&&null==t.y||(e?i=i.translate(t.x,t.y):(null!=t.x&&(i.e=t.x),null!=t.y&&(i.f=t.y)));return this.attr("transform",i)}}),p.extend(p.FX,{transform:function(t,e){var i,n,s=this.target();return"object"!=typeof t?(i=new p.Matrix(s).extract(),"string"==typeof t?i[t]:i):(e=!!e||!!t.relative,null!=t.a?i=new p.Matrix(t):null!=t.rotation?(c(t,s),i=new p.Rotate(t.rotation,t.cx,t.cy)):null!=t.scale||null!=t.scaleX||null!=t.scaleY?(c(t,s),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,i=new p.Scale(t.scaleX,t.scaleY,t.cx,t.cy)):null!=t.skewX||null!=t.skewY?(c(t,s),t.skewX=null!=t.skewX?t.skewX:0,t.skewY=null!=t.skewY?t.skewY:0,i=new p.Skew(t.skewX,t.skewY,t.cx,t.cy)):t.flip?("x"==t.flip||"y"==t.flip?t.offset=null==t.offset?s.bbox()["c"+t.flip]:t.offset:null==t.offset?(n=s.bbox(),t.flip=n.cx,t.offset=n.cy):t.flip=t.offset,i=(new p.Matrix).flip(t.flip,t.offset)):null==t.x&&null==t.y||(i=new p.Translate(t.x,t.y)),i?(i.relative=e,this.last().transforms.push(i),this._callStart()):this)}}),p.extend(p.Element,{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(p.regex.transforms).slice(0,-1).map((function(t){var e=t.trim().split("(");return[e[0],e[1].split(p.regex.delimiter).map((function(t){return parseFloat(t)}))]})).reduce((function(t,e){return"matrix"==e[0]?t.multiply(u(e[1])):t[e[0]].apply(t,e[1])}),new p.Matrix)},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())}}),p.Transformation=p.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(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=[],i=0,n=this.arguments.length;i<n;++i)e.push(this[this.arguments[i]]);var s=this._undo||new p.Matrix;return s=(new p.Matrix).morph(p.Matrix.prototype[this.method].apply(s,e)).at(t),this.inversed?s.inverse():s},undo:function(t){for(var e=0,i=this.arguments.length;e<i;++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(p[r(this.method)])(t,!0).at(1),this}}}),p.Translate=p.invent({parent:p.Matrix,inherit:p.Transformation,create:function(t,e){this.constructor.apply(this,[].slice.call(arguments))},extend:{arguments:["transformedX","transformedY"],method:"translate"}}),p.Rotate=p.invent({parent:p.Matrix,inherit:p.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 p.Matrix).rotate((new p.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}}}),p.Scale=p.invent({parent:p.Matrix,inherit:p.Transformation,create:function(t,e){this.constructor.apply(this,[].slice.call(arguments))},extend:{arguments:["scaleX","scaleY","cx","cy"],method:"scale"}}),p.Skew=p.invent({parent:p.Matrix,inherit:p.Transformation,create:function(t,e){this.constructor.apply(this,[].slice.call(arguments))},extend:{arguments:["skewX","skewY","cx","cy"],method:"skew"}}),p.extend(p.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(!p.regex.isCss.test(t))return this.node.style[s(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[s(t)]=null===e||p.regex.isBlank.test(e)?"":e;return this}}),p.Parent=p.invent({create:function(t){this.constructor.call(this,t)},inherit:p.Element,extend:{children:function(){return p.utils.map(p.utils.filterSVGElements(this.node.childNodes),(function(t){return p.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 p.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 i,n,s=this.children();for(i=0,n=s.length;i<n;i++)s[i]instanceof p.Element&&t.apply(s[i],[i,s]),e&&s[i]instanceof p.Container&&s[i].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()}}}),p.extend(p.Parent,{ungroup:function(t,e){return 0===e||this instanceof p.Defs||this.node==p.parser.draw||(t=t||(this instanceof p.Doc?this:this.parent(p.Parent)),e=e||1/0,this.each((function(){return this instanceof p.Defs?this:this instanceof p.Parent?this.ungroup(t,e-1):this.toParent(t)})),this.node.firstChild||this.remove()),this},flatten:function(t,e){return this.ungroup(t,e)}}),p.Container=p.invent({create:function(t){this.constructor.call(this,t)},inherit:p.Parent}),p.ViewBox=p.invent({create:function(t){var e,i,n,s,r,o,a,h=1,u=1,c=/[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/gi;if(t instanceof p.Element){for(o=t,a=t,r=(t.attr("viewBox")||"").match(c),t.bbox,n=new p.Number(t.width()),s=new p.Number(t.height());"%"==n.unit;)h*=n.value,n=new p.Number(o instanceof p.Doc?o.parent().offsetWidth:o.parent().width()),o=o.parent();for(;"%"==s.unit;)u*=s.value,s=new p.Number(a instanceof p.Doc?a.parent().offsetHeight:a.parent().height()),a=a.parent();this.x=0,this.y=0,this.width=n*h,this.height=s*u,this.zoom=1,r&&(e=parseFloat(r[0]),i=parseFloat(r[1]),n=parseFloat(r[2]),s=parseFloat(r[3]),this.zoom=this.width/this.height>n/s?this.height/s:this.width/n,this.x=e,this.y=i,this.width=n,this.height=s)}else t="string"==typeof t?t.match(c).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):[0,0,0,0],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,i,n){return this.destination=new p.ViewBox(t,e,i,n),this},at:function(t){return this.destination?new p.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:p.Container,construct:{viewbox:function(t,e,i,n){return 0==arguments.length?new p.ViewBox(this):this.attr("viewBox",new p.ViewBox(t,e,i,n))}}}),["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].forEach((function(t){p.Element.prototype[t]=function(e){return null==e?p.off(this,t):p.on(this,t,e),this}})),p.listenerId=0,p.on=function(t,e,i,n,s){var r=i.bind(n||t),o=t instanceof p.Element?t.node:t;o.instance=o.instance||{_events:{}};var a=o.instance._events;i._svgjsListenerId||(i._svgjsListenerId=++p.listenerId),e.split(p.regex.delimiter).forEach((function(t){var e=t.split(".")[0],n=t.split(".")[1]||"*";a[e]=a[e]||{},a[e][n]=a[e][n]||{},a[e][n][i._svgjsListenerId]=r,o.addEventListener(e,r,s||!1)}))},p.off=function(t,e,i,n){var s=t instanceof p.Element?t.node:t;if(s.instance&&("function"!=typeof i||(i=i._svgjsListenerId))){var r=s.instance._events;(e||"").split(p.regex.delimiter).forEach((function(t){var e,o,a=t&&t.split(".")[0],h=t&&t.split(".")[1];if(i)r[a]&&r[a][h||"*"]&&(s.removeEventListener(a,r[a][h||"*"][i],n||!1),delete r[a][h||"*"][i]);else if(a&&h){if(r[a]&&r[a][h]){for(o in r[a][h])p.off(s,[a,h].join("."),o);delete r[a][h]}}else if(h)for(t in r)for(e in r[t])h===e&&p.off(s,[t,h].join("."));else if(a){if(r[a]){for(e in r[a])p.off(s,[a,e].join("."));delete r[a]}}else{for(t in r)p.off(s,t);s.instance._events={}}}))}},p.extend(p.Element,{on:function(t,e,i,n){return p.on(this,t,e,i,n),this},off:function(t,e){return p.off(this.node,t,e),this},fire:function(e,i){return e instanceof t.Event?this.node.dispatchEvent(e):this.node.dispatchEvent(e=new t.CustomEvent(e,{detail:i,cancelable:!0})),this._event=e,this},event:function(){return this._event}}),p.Defs=p.invent({create:"defs",inherit:p.Container}),p.G=p.invent({create:"g",inherit:p.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 p.G)}}}),p.Doc=p.invent({create:function(t){t&&("svg"==(t="string"==typeof t?e.getElementById(t):t).nodeName?this.constructor.call(this,t):(this.constructor.call(this,p.create("svg")),t.appendChild(this.node),this.size("100%","100%")),this.namespace().defs())},inherit:p.Container,extend:{namespace:function(){return this.attr({xmlns:p.ns,version:"1.1"}).attr("xmlns:xlink",p.xlink,p.xmlns).attr("xmlns:svgjs",p.svgjs,p.xmlns)},defs:function(){var t;return this._defs||((t=this.node.getElementsByTagName("defs")[0])?this._defs=p.adopt(t):this._defs=new p.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,p.parser.draw.parentNode||this.node.appendChild(p.parser.draw),this},clone:function(t){this.writeDataToDom();var e=this.node,i=l(e.cloneNode(!0));return t?(t.node||t).appendChild(i.node):e.parentNode.insertBefore(i.node,e.nextSibling),i}}}),p.extend(p.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.si