svgedit={NS:{HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://svg-edit.googlecode.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"}};svgedit.getReverseNS=function(){var a={};$.each(this.NS,function(I,o){a[o]=I.toLowerCase()});return a};(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(I,o){var c,i=this.length;if(!i)return a.apply(this,arguments);for(c=0;cq-15)D=q-15;if(u>A-30)u=A-30;I.unbind("click");e.css({top:u,left:D}).fadeIn(o.inSpeed);e.find("A").mouseover(function(){e.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){e.find("LI.hover").removeClass("hover")});I.keypress(function(p){switch(p.keyCode){case 38:if(e.find("LI.hover").length){e.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover"); e.find("LI.hover").length||e.find("LI:last").addClass("hover")}else e.find("LI:last").addClass("hover");break;case 40:if(e.find("LI.hover").length==0)e.find("LI:first").addClass("hover");else{e.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");e.find("LI.hover").length||e.find("LI:first").addClass("hover")}break;case 13:e.find("LI.hover A").trigger("click");break;case 27:I.trigger("click")}});e.find("A").unbind("mouseup");e.find("LI:not(.disabled) A").mouseup(function(){I.unbind("click").unbind("keypress"); $(".contextMenu").hide();c&&c($(this).attr("href").substr(1),$(w),{x:D-s.left,y:u-s.top,docX:D,docY:u});return false});setTimeout(function(){I.click(function(){I.unbind("click").unbind("keypress");e.fadeOut(o.outSpeed);return false})},0)}})});if($.browser.mozilla)$("#"+o.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+o.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+o.menu).each(function(){$(this).bind("mousedown.disableTextSelect", function(){return false})});$(i).add($("UL.contextMenu")).bind("contextmenu",function(){return false})});return $(this)},disableContextMenuItems:function(o){if(o==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(o!=undefined)for(var c=o.split(","),i=0;i=0,e=o.indexOf("Gecko/")>=0,g=o.indexOf("MSIE")>=0,q=o.indexOf("Chrome/")>=0,w=o.indexOf("Windows")>=0,D=o.indexOf("Macintosh")>=0,u="ontouchstart"in window, A=!!c.querySelector,p=!!document.evaluate,v=function(){var ea=document.createElementNS(a.SVG,"path");ea.setAttribute("d","M0,0 10,10");var ka=ea.pathSegList;ea=ea.createSVGPathSegLinetoAbs(5,5);try{ka.replaceItem(ea,0);return true}catch(Ia){}return false}(),t=function(){var ea=document.createElementNS(a.SVG,"path");ea.setAttribute("d","M0,0 10,10");var ka=ea.pathSegList;ea=ea.createSVGPathSegLinetoAbs(5,5);try{ka.insertItemBefore(ea,0);return true}catch(Ia){}return false}(),m=function(){var ea=document.createElementNS(a.SVG, "svg"),ka=document.createElementNS(a.SVG,"svg");document.documentElement.appendChild(ea);ka.setAttribute("x",5);ea.appendChild(ka);var Ia=document.createElementNS(a.SVG,"text");Ia.textContent="a";ka.appendChild(Ia);ka=Ia.getStartPositionOfChar(0).x;document.documentElement.removeChild(ea);return ka===0}(),L=function(){var ea=document.createElementNS(a.SVG,"svg");document.documentElement.appendChild(ea);var ka=document.createElementNS(a.SVG,"path");ka.setAttribute("d","M0,0 C0,0 10,10 10,0");ea.appendChild(ka); ka=ka.getBBox();document.documentElement.removeChild(ea);return ka.height>4&&ka.height<5}(),R=function(){var ea=document.createElementNS(a.SVG,"svg");document.documentElement.appendChild(ea);var ka=document.createElementNS(a.SVG,"path");ka.setAttribute("d","M0,0 10,0");var Ia=document.createElementNS(a.SVG,"path");Ia.setAttribute("d","M5,0 15,0");var Ba=document.createElementNS(a.SVG,"g");Ba.appendChild(ka);Ba.appendChild(Ia);ea.appendChild(Ba);ka=Ba.getBBox();document.documentElement.removeChild(ea); return ka.width==15}(),da=function(){var ea=document.createElementNS(a.SVG,"rect");ea.setAttribute("x",0.1);(ea=ea.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the latest version in which the problems have been fixed.');return ea}(),qa=function(){var ea=document.createElementNS(a.SVG,"rect");ea.setAttribute("style","vector-effect:non-scaling-stroke");return ea.style.vectorEffect=== "non-scaling-stroke"}(),fa=function(){var ea=document.createElementNS(a.SVG,"rect").transform.baseVal,ka=c.createSVGTransform();ea.appendItem(ka);return ea.getItem(0)==ka}();svgedit.browser.isOpera=function(){return i};svgedit.browser.isWebkit=function(){return s};svgedit.browser.isGecko=function(){return e};svgedit.browser.isIE=function(){return g};svgedit.browser.isChrome=function(){return q};svgedit.browser.isWindows=function(){return w};svgedit.browser.isMac=function(){return D};svgedit.browser.isTouch= function(){return u};svgedit.browser.supportsSelectors=function(){return A};svgedit.browser.supportsXpath=function(){return p};svgedit.browser.supportsPathReplaceItem=function(){return v};svgedit.browser.supportsPathInsertItemBefore=function(){return t};svgedit.browser.supportsPathBBox=function(){return L};svgedit.browser.supportsHVLineContainerBBox=function(){return R};svgedit.browser.supportsGoodTextCharPos=function(){return m};svgedit.browser.supportsEditableText=function(){return i};svgedit.browser.supportsGoodDecimals= function(){return da};svgedit.browser.supportsNonScalingStroke=function(){return qa};svgedit.browser.supportsNativeTransformLists=function(){return fa}}else window.location="browser-not-supported.html"})();(function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS(svgedit.NS.SVG,"svg"),I={};svgedit.transformlist.SVGTransformList=function(o){this._elem=o||null;this._xforms=[];this._update=function(){var c="";a.createSVGMatrix();var i;for(i=0;i=0)return this._xforms[c];throw{code:1};};this.insertItemBefore=function(c,i){var s=null;if(i>=0)if(i=0){this._removeFromOtherLists(c);s=this._xforms[i]=c;this._list._update()}return s};this.removeItem=function(c){if(c=0){var i=this._xforms[c],s=Array(this.numberOfItems-1),e;for(e=0;e1;)c=I[o-1].multiply(c);if(Math.abs(c.a)<1.0E-14)c.a=0;if(Math.abs(c.b)<1.0E-14)c.b=0;if(Math.abs(c.c)<1.0E-14)c.c=0;if(Math.abs(c.d)< 1.0E-14)c.d=0;if(Math.abs(c.e)<1.0E-14)c.e=0;if(Math.abs(c.f)<1.0E-14)c.f=0;return c};svgedit.math.hasMatrixTransform=function(I){if(!I)return false;for(var o=I.numberOfItems;o--;){var c=I.getItem(o);if(c.type==1&&!svgedit.math.isIdentity(c.matrix))return true}return false};svgedit.math.transformBox=function(I,o,c,i,s){var e=svgedit.math.transformPoint,g=e(I,o,s),q=e(I+c,o,s),w=e(I,o+i,s);I=e(I+c,o+i,s);o=Math.min(g.x,q.x,w.x,I.x);c=Math.min(g.y,q.y,w.y,I.y);return{tl:g,tr:q,bl:w,br:I,aabox:{x:o, y:c,width:Math.max(g.x,q.x,w.x,I.x)-o,height:Math.max(g.y,q.y,w.y,I.y)-c}}};svgedit.math.transformListToTransform=function(I,o,c){if(I==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());o=o||0;c=c||I.numberOfItems-1;o=parseInt(o,10);c=parseInt(c,10);if(o>c){var i=c;c=o;o=i}i=a.createSVGMatrix();for(o=o;o<=c;++o){var s=o>=0&&oI.x&&o.yI.y}})();(function(){if(!svgedit.units)svgedit.units={};var a=svgedit.NS,I=["x","x1","cx","rx","width"],o=["y","y1","cy","ry","height"],c=["r","radius"].concat(I,o),i,s={};svgedit.units.init=function(g){i=g;g=document.createElementNS(a.SVG,"svg");document.body.appendChild(g);var q=document.createElementNS(a.SVG,"rect");q.setAttribute("width","1em");q.setAttribute("height","1ex");q.setAttribute("x","1in");g.appendChild(q);q=q.getBBox();document.body.removeChild(g);g=q.x;s={em:q.width,ex:q.height,"in":g,cm:g/ 2.54,mm:g/25.4,pt:g/72,pc:g/6,px:1,"%":0}};svgedit.units.getTypeMap=function(){return s};svgedit.units.shortFloat=function(g){var q=i.getRoundDigits();if(!isNaN(g))return+(+g).toFixed(q);if($.isArray(g))return svgedit.units.shortFloat(g[0])+","+svgedit.units.shortFloat(g[1]);return parseFloat(g).toFixed(q)-0};svgedit.units.convertUnit=function(g,q){q=q||i.getBaseUnit();return svgedit.units.shortFloat(g/s[q])};svgedit.units.setUnitAttr=function(g,q,w){g.setAttribute(q,w)};var e={line:["x1","x2","y1", "y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],foreignObject:["x","y","width","height"],rect:["x","y","width","height"],image:["x","y","width","height"],use:["x","y","width","height"],text:["x","y"]};svgedit.units.convertAttrs=function(g){var q=g.tagName,w=i.getBaseUnit();if(q=e[q]){var D=q.length,u;for(u=0;u=0)return w*D;if(o.indexOf(g)>=0)return w*u;return w*Math.sqrt(D*D+u*u)/Math.sqrt(2)}D=q.substr(-2);w=q.substr(0,q.length-2);return w*s[D]};svgedit.units.isValidUnit=function(g,q,w){var D=false;if(c.indexOf(g)>=0)if(isNaN(q)){q=q.toLowerCase();$.each(s,function(p){if(!D)if(RegExp("^-?[\\d\\.]+"+p+"$").test(q))D=true})}else D=true;else if(g=="id"){g=false;try{var u=i.getElement(q);g=u==null||u===w}catch(A){}return g}return D= true}})();(function(){function a(g){if(svgedit.browser.supportsHVLineContainerBBox())try{return g.getBBox()}catch(q){}var w=$.data(g,"ref"),D=null,u;if(w){u=$(w).children().clone().attr("visibility","hidden");$(e).append(u);D=u.filter("line, path")}else D=$(g).find("line, path");var A=false;if(D.length){D.each(function(){var p=this.getBBox();if(!p.width||!p.height)A=true});if(A){g=w?u:$(g).children();g=getStrokedBBox(g)}else g=g.getBBox()}else g=g.getBBox();w&&u.remove();return g}if(!svgedit.utilities)svgedit.utilities= {};var I=svgedit.NS,o="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),c=null,i=null,s=null,e=null;svgedit.utilities.init=function(g){c=g;i=g.getDOMDocument();s=g.getDOMContainer();e=g.getSVGRoot()};svgedit.utilities.toXml=function(g){return g.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/,"'")};svgedit.utilities.fromXml=function(g){return $("

").html(g).text()};svgedit.utilities.encode64= function(g){g=svgedit.utilities.encodeUTF8(g);if(window.btoa)return window.btoa(g);var q=Array(Math.floor((g.length+2)/3)*4),w,D,u,A,p,v,t=0,m=0;do{w=g.charCodeAt(t++);D=g.charCodeAt(t++);u=g.charCodeAt(t++);A=w>>2;w=(w&3)<<4|D>>4;p=(D&15)<<2|u>>6;v=u&63;if(isNaN(D))p=v=64;else if(isNaN(u))v=64;q[m++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(A);q[m++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(w);q[m++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(p); q[m++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(v)}while(t>4;D=(D&15)<<4|A>>2;u=(A&3)<<6|p;q+=String.fromCharCode(w);if(A!=64)q+=String.fromCharCode(D);if(p!=64)q+=String.fromCharCode(u)}while(v127&&p<2048)v=String.fromCharCode(p>> 6|192,p&63|128);else if((p&63488)!=55296)v=String.fromCharCode(p>>12|224,p>>6&63|128,p&63|128);else{if((p&64512)!=55296)throw new RangeError("Unmatched trail surrogate at "+A);v=g.charCodeAt(++A);if((v&64512)!=56320)throw new RangeError("Unmatched lead surrogate at "+(A-1));p=((p&1023)<<10)+(v&1023)+65536;v=String.fromCharCode(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}if(v!==null){if(D>w)q+=g.slice(w,D);q+=v;w=D=A+1}}if(D>w)q+=g.slice(w,u);return q};svgedit.utilities.convertToXMLReferences=function(g){var q, w="";for(q=0;q127)w+="&#"+D+";"}return w};svgedit.utilities.text2xml=function(g){if(g.indexOf("=0)g=g.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var q,w;try{w=window.DOMParser?new DOMParser:new ActiveXObject("Microsoft.XMLDOM");w.async=false}catch(D){throw Error("XML Parser could not be instantiated");}try{q=w.loadXML?w.loadXML(g)?w:false:w.parseFromString(g,"text/xml")}catch(u){throw Error("Error parsing XML string"); }return q};svgedit.utilities.bboxToObj=function(g){return{x:g.x,y:g.y,width:g.width,height:g.height}};svgedit.utilities.walkTree=function(g,q){if(g&&g.nodeType==1){q(g);for(var w=g.childNodes.length;w--;)svgedit.utilities.walkTree(g.childNodes.item(w),q)}};svgedit.utilities.walkTreePost=function(g,q){if(g&&g.nodeType==1){for(var w=g.childNodes.length;w--;)svgedit.utilities.walkTree(g.childNodes.item(w),q);q(g)}};svgedit.utilities.getUrlFromAttr=function(g){if(g){if(g.indexOf('url("')===0)return g.substring(5, g.indexOf('"',6));if(g.indexOf("url('")===0)return g.substring(5,g.indexOf("'",6));if(g.indexOf("url(")===0)return g.substring(4,g.indexOf(")"))}return null};svgedit.utilities.getHref=function(g){return g.getAttributeNS(I.XLINK,"href")};svgedit.utilities.setHref=function(g,q){g.setAttributeNS(I.XLINK,"xlink:href",q)};svgedit.utilities.findDefs=function(){var g=c.getSVGContent(),q=g.getElementsByTagNameNS(I.SVG,"defs");if(q.length>0)q=q[0];else{q=g.ownerDocument.createElementNS(I.SVG,"defs");g.firstChild? g.insertBefore(q,g.firstChild.nextSibling):g.appendChild(q)}return q};svgedit.utilities.getPathBBox=function(g){var q=g.pathSegList,w=q.numberOfItems;g=[[],[]];var D=q.getItem(0),u=[D.x,D.y];for(D=0;D|:\\"+(q||"")+"-]","g"),"\\$&")}})();(function(){if(!svgedit.sanitize)svgedit.sanitize={};var a=svgedit.NS,I=svgedit.getReverseNS(),o={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask", "opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class","clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin", "stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters","filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display", "fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class", "clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id", "class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class","clip-path","clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity", "stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit", "stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id", "r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class", "clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],"switch":["class","id","requiredFeatures","systemLanguage"],symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit", "stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures", "spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class", "clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[], mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth","height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing", "width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},c={};$.each(o,function(i,s){var e={};$.each(s,function(g,q){if(q.indexOf(":")>=0){var w=q.split(":");e[w[1]]=a[w[0].toUpperCase()]}else e[q]=q=="xmlns"?a.XMLNS:null});c[i]=e});svgedit.sanitize.sanitizeSvg=function(i){if(i.nodeType==3){i.nodeValue=i.nodeValue.replace(/^\s+|\s+$/g,"");i.nodeValue.length===0&&i.parentNode.removeChild(i)}if(i.nodeType==1){var s= i.parentNode;if(i.ownerDocument&&s){var e=o[i.nodeName],g=c[i.nodeName],q;if(typeof e!=="undefined"){var w=[];for(q=i.attributes.length;q--;){var D=i.attributes.item(q),u=D.nodeName,A=D.localName,p=D.namespaceURI;if(!(g.hasOwnProperty(A)&&p==g[A]&&p!=a.XMLNS)&&!(p==a.XMLNS&&I[D.nodeValue])){u.indexOf("se:")===0&&w.push([u,D.nodeValue]);i.removeAttributeNS(p,A)}if(svgedit.browser.isGecko())switch(u){case "transform":case "gradientTransform":case "patternTransform":A=D.nodeValue.replace(/(\d)-/g,"$1 -"); i.setAttribute(u,A)}if(u=="style"){D=D.nodeValue.split(";");for(u=D.length;u--;){p=D[u].split(":");A=$.trim(p[0]);p=$.trim(p[1]);e.indexOf(A)>=0&&i.setAttribute(A,p)}i.removeAttribute("style")}}$.each(w,function(v,t){i.setAttributeNS(a.SE,t[0],t[1])});if((q=svgedit.utilities.getHref(i))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(i.nodeName)>=0)if(q[0]!="#"){svgedit.utilities.setHref(i,"");i.removeAttributeNS(a.XLINK,"href")}if(i.nodeName=="use"&&!svgedit.utilities.getHref(i))s.removeChild(i); else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],function(v,t){var m=i.getAttribute(t);if(m)if((m=svgedit.utilities.getUrlFromAttr(m))&&m[0]!=="#"){i.setAttribute(t,"");i.removeAttribute(t)}});for(q=i.childNodes.length;q--;)svgedit.sanitize.sanitizeSvg(i.childNodes.item(q))}}else{for(e=[];i.hasChildNodes();)e.push(s.insertBefore(i.firstChild,i));s.removeChild(i);for(q=e.length;q--;)svgedit.sanitize.sanitizeSvg(e[q])}}}}})();(function(){if(!svgedit.history)svgedit.history={};svgedit.history.HistoryEventTypes={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"};svgedit.history.MoveElementCommand=function(a,I,o,c){this.elem=a;this.text=c?"Move "+a.tagName+" to "+c:"Move "+a.tagName;this.oldNextSibling=I;this.oldParent=o;this.newNextSibling=a.nextSibling;this.newParent=a.parentNode};svgedit.history.MoveElementCommand.type=function(){return"svgedit.history.MoveElementCommand"}; svgedit.history.MoveElementCommand.prototype.type=svgedit.history.MoveElementCommand.type;svgedit.history.MoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.MoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.MoveElementCommand.prototype.unapply= function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.InsertElementCommand=function(a,I){this.elem=a;this.text=I||"Create "+a.tagName;this.parent=a.parentNode;this.nextSibling=this.elem.nextSibling};svgedit.history.InsertElementCommand.type= function(){return"svgedit.history.InsertElementCommand"};svgedit.history.InsertElementCommand.prototype.type=svgedit.history.InsertElementCommand.type;svgedit.history.InsertElementCommand.prototype.getText=function(){return this.text};svgedit.history.InsertElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY, this)};svgedit.history.InsertElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);this.parent=this.elem.parentNode;this.elem=this.elem.parentNode.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.InsertElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.RemoveElementCommand=function(a,I,o,c){this.elem=a;this.text=c||"Delete "+a.tagName; this.nextSibling=I;this.parent=o;svgedit.transformlist.removeElementFromListMap(a)};svgedit.history.RemoveElementCommand.type=function(){return"svgedit.history.RemoveElementCommand"};svgedit.history.RemoveElementCommand.prototype.type=svgedit.history.RemoveElementCommand.type;svgedit.history.RemoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.RemoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this); svgedit.transformlist.removeElementFromListMap(this.elem);this.parent=this.elem.parentNode;this.elem=this.parent.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.RemoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.nextSibling==null&&window.console&&console.log("Error: reference element was lost"); this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.ChangeElementCommand=function(a,I,o){this.elem=a;this.text=o?"Change "+a.tagName+" "+o:"Change "+a.tagName;this.newValues={};this.oldValues=I;for(var c in I)this.newValues[c]=c=="#text"?a.textContent:c=="#href"?svgedit.utilities.getHref(a):a.getAttribute(c)};svgedit.history.ChangeElementCommand.type= function(){return"svgedit.history.ChangeElementCommand"};svgedit.history.ChangeElementCommand.prototype.type=svgedit.history.ChangeElementCommand.type;svgedit.history.ChangeElementCommand.prototype.getText=function(){return this.text};svgedit.history.ChangeElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var I=false,o;for(o in this.newValues){if(this.newValues[o])if(o=="#text")this.elem.textContent=this.newValues[o];else o=="#href"? svgedit.utilities.setHref(this.elem,this.newValues[o]):this.elem.setAttribute(o,this.newValues[o]);else if(o=="#text")this.elem.textContent="";else{this.elem.setAttribute(o,"");this.elem.removeAttribute(o)}if(o=="transform")I=true}if(!I)if(I=svgedit.utilities.getRotationAngle(this.elem)){o=elem.getBBox();I=["rotate(",I," ",o.x+o.width/2,",",o.y+o.height/2,")"].join("");I!=elem.getAttribute("transform")&&elem.setAttribute("transform",I)}a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY, this);return true};svgedit.history.ChangeElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var I=false,o;for(o in this.oldValues){if(this.oldValues[o])if(o=="#text")this.elem.textContent=this.oldValues[o];else o=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[o]):this.elem.setAttribute(o,this.oldValues[o]);else if(o=="#text")this.elem.textContent="";else this.elem.removeAttribute(o);if(o=="transform")I=true}if(!I)if(I= svgedit.utilities.getRotationAngle(this.elem)){o=elem.getBBox();I=["rotate(",I," ",o.x+o.width/2,",",o.y+o.height/2,")"].join("");I!=elem.getAttribute("transform")&&elem.setAttribute("transform",I)}svgedit.transformlist.removeElementFromListMap(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.BatchCommand=function(a){this.text=a||"Batch Command"; this.stack=[]};svgedit.history.BatchCommand.type=function(){return"svgedit.history.BatchCommand"};svgedit.history.BatchCommand.prototype.type=svgedit.history.BatchCommand.type;svgedit.history.BatchCommand.prototype.getText=function(){return this.text};svgedit.history.BatchCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var I,o=this.stack.length;for(I=0;I=0;I--)this.stack[I].unapply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],I=this.stack.length;I--;)for(var o=this.stack[I].elements(),c=o.length;c--;)a.indexOf(o[c])==-1&&a.push(o[c]);return a};svgedit.history.BatchCommand.prototype.addSubCommand= function(a){this.stack.push(a)};svgedit.history.BatchCommand.prototype.isEmpty=function(){return this.stack.length===0};svgedit.history.UndoManager=function(a){this.handler_=a||null;this.undoStackPointer=0;this.undoStack=[];this.undoChangeStackPointer=-1;this.undoableChangeStack=[]};svgedit.history.UndoManager.prototype.resetUndoStack=function(){this.undoStack=[];this.undoStackPointer=0};svgedit.history.UndoManager.prototype.getUndoStackSize=function(){return this.undoStackPointer};svgedit.history.UndoManager.prototype.getRedoStackSize= function(){return this.undoStack.length-this.undoStackPointer};svgedit.history.UndoManager.prototype.getNextUndoCommandText=function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}; svgedit.history.UndoManager.prototype.redo=function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)};svgedit.history.UndoManager.prototype.addCommandToHistory=function(a){if(this.undoStackPointer0)this.undoStack=this.undoStack.splice(0,this.undoStackPointer);this.undoStack.push(a);this.undoStackPointer=this.undoStack.length};svgedit.history.UndoManager.prototype.beginUndoableChange= function(a,I){for(var o=++this.undoChangeStackPointer,c=I.length,i=Array(c),s=Array(c);c--;){var e=I[c];if(e!=null){s[c]=e;i[c]=e.getAttribute(a)}}this.undoableChangeStack[o]={attrName:a,oldValues:i,elements:s}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,I=this.undoableChangeStack[a],o=I.elements.length,c=I.attrName,i=new svgedit.history.BatchCommand("Change "+c);o--;){var s=I.elements[o];if(s!=null){var e={};e[c]=I.oldValues[o];e[c]!= s.getAttribute(c)&&i.addSubCommand(new svgedit.history.ChangeElementCommand(s,e,c))}}this.undoableChangeStack[a]=null;return i}})();var svgedit=svgedit||{}; (function(){if(!svgedit.coords)svgedit.coords={};var a=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],I=null;svgedit.coords.init=function(o){I=o};svgedit.coords.remapElement=function(o,c,i){var s,e,g=function(v,t){return svgedit.math.transformPoint(v,t,i)},q=I.getGridSnapping()&&o.parentNode.parentNode.localName==="svg",w=function(){var v;if(q)for(v in c)c[v]=svgedit.utilities.snapToGrid(c[v]);svgedit.utilities.assignAttributes(o,c,1E3,true)},D=svgedit.utilities.getBBox(o); for(s=0;s<2;s++){e=s===0?"fill":"stroke";var u=o.getAttribute(e);if(u&&u.indexOf("url(")===0)if(i.a<0||i.d<0){u=svgedit.utilities.getRefElem(u).cloneNode(true);if(i.a<0){var A=u.getAttribute("x1"),p=u.getAttribute("x2");u.setAttribute("x1",-(A-1));u.setAttribute("x2",-(p-1))}if(i.d<0){A=u.getAttribute("y1");p=u.getAttribute("y2");u.setAttribute("y1",-(A-1));u.setAttribute("y2",-(p-1))}u.id=I.getDrawing().getNextId();svgedit.utilities.findDefs().appendChild(u);o.setAttribute(e,"url(#"+u.id+")")}}s= o.tagName;if(s==="g"||s==="text"||s=="tspan"||s==="use")if(i.a==1&&i.b==0&&i.c==0&&i.d==1&&(i.e!=0||i.f!=0)){e=svgedit.math.transformListToTransform(o).matrix;e=svgedit.math.matrixMultiply(e.inverse(),i,e);c.x=parseFloat(c.x)+e.e;c.y=parseFloat(c.y)+e.f}else{e=svgedit.transformlist.getTransformList(o);u=svgroot.createSVGTransform();u.setMatrix(svgedit.math.matrixMultiply(svgedit.math.transformListToTransform(e).matrix,i));e.clear();e.appendItem(u)}switch(s){case "foreignObject":case "rect":case "image":if(s=== "image"&&(i.a<0||i.d<0)){e=svgedit.transformlist.getTransformList(o);u=svgroot.createSVGTransform();u.setMatrix(svgedit.math.matrixMultiply(svgedit.math.transformListToTransform(e).matrix,i));e.clear();e.appendItem(u)}else{u=g(c.x,c.y);c.width=i.a*c.width;c.height=i.d*c.height;c.x=u.x+Math.min(0,c.width);c.y=u.y+Math.min(0,c.height);c.width=Math.abs(c.width);c.height=Math.abs(c.height)}w();break;case "ellipse":g=g(c.cx,c.cy);c.cx=g.x;c.cy=g.y;c.rx=i.a*c.rx;c.ry=i.d*c.ry;c.rx=Math.abs(c.rx);c.ry=Math.abs(c.ry); w();break;case "circle":g=g(c.cx,c.cy);c.cx=g.x;c.cy=g.y;g=svgedit.math.transformBox(D.x,D.y,D.width,D.height,i);c.r=Math.min((g.tr.x-g.tl.x)/2,(g.bl.y-g.tl.y)/2);if(c.r)c.r=Math.abs(c.r);w();break;case "line":u=g(c.x1,c.y1);A=g(c.x2,c.y2);c.x1=u.x;c.y1=u.y;c.x2=A.x;c.y2=A.y;case "text":case "tspan":case "use":w();break;case "g":(g=$(o).data("gsvg"))&&svgedit.utilities.assignAttributes(g,c,1E3,true);break;case "polyline":case "polygon":w=c.points.length;for(s=0;s=0)return null; var c=I.getSVGRoot(),i=svgedit.transformlist.getTransformList(o),s;if(i&&i.numberOfItems>0){for(s=i.numberOfItems;s--;){var e=i.getItem(s);if(e.type===0)i.removeItem(s);else if(e.type===1)svgedit.math.isIdentity(e.matrix)&&i.removeItem(s);else e.type===4&&e.angle===0&&i.removeItem(s)}if(i.numberOfItems===1&&svgedit.utilities.getRotationAngle(o))return null}if(!i||i.numberOfItems==0){o.setAttribute("transform","");o.removeAttribute("transform");return null}if(i){s=i.numberOfItems;for(var g=[];s--;){e= i.getItem(s);if(e.type===1)g.push([e.matrix,s]);else if(g.length)g=[]}if(g.length===2){s=c.createSVGTransformFromMatrix(svgedit.math.matrixMultiply(g[1][0],g[0][0]));i.removeItem(g[0][1]);i.removeItem(g[1][1]);i.insertItemBefore(s,g[1][1])}s=i.numberOfItems;if(s>=2&&i.getItem(s-2).type===1&&i.getItem(s-1).type===2){g=c.createSVGTransform();e=svgedit.math.matrixMultiply(i.getItem(s-2).matrix,i.getItem(s-1).matrix);g.setMatrix(e);i.removeItem(s-2);i.removeItem(s-2);i.appendItem(g)}}switch(o.tagName){case "line":case "polyline":case "polygon":case "path":break; default:if(i.numberOfItems===1&&i.getItem(0).type===1||i.numberOfItems===2&&i.getItem(0).type===1&&i.getItem(0).type===4)return null}var q=$(o).data("gsvg");s=new svgedit.history.BatchCommand("Transform");var w={},D=null;e=[];switch(o.tagName){case "line":e=["x1","y1","x2","y2"];break;case "circle":e=["cx","cy","r"];break;case "ellipse":e=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":e=["width","height","x","y"];break;case "use":case "text":case "tspan":e=["x","y"];break; case "polygon":case "polyline":D={};D.points=o.getAttribute("points");g=o.points;var u=g.numberOfItems;w.points=Array(u);var A;for(A=0;A1.0E-10?Math.sin(A)/(1-Math.cos(A)):2/A;for(A=0;A=3&&i.getItem(m-2).type==3&&i.getItem(m-3).type==2&&i.getItem(m-1).type==2){A=3;var R=i.getItem(m-3).matrix,da=i.getItem(m-2).matrix,qa=i.getItem(m-1).matrix;u=o.childNodes;for(p=u.length;p--;){var fa=u.item(p);e=q=0;if(fa.nodeType==1){var ea=svgedit.transformlist.getTransformList(fa);if(ea){e=svgedit.math.transformListToTransform(ea).matrix;q=svgedit.utilities.getRotationAngle(fa);var ka=I.getStartTransform(), Ia=[];I.setStartTransform(fa.getAttribute("transform"));if(q||svgedit.math.hasMatrixTransform(ea)){var Ba=c.createSVGTransform();Ba.setMatrix(svgedit.math.matrixMultiply(R,da,qa,e));ea.clear();ea.appendItem(Ba);Ia.push(Ba)}else{q=svgedit.math.matrixMultiply(e.inverse(),qa,e);Ba=c.createSVGMatrix();Ba.e=-q.e;Ba.f=-q.f;e=svgedit.math.matrixMultiply(Ba.inverse(),e.inverse(),R,da,qa,e,q.inverse());var Lb=c.createSVGTransform(),kb=c.createSVGTransform(),ib=c.createSVGTransform();Lb.setTranslate(q.e,q.f); kb.setScale(e.a,e.d);ib.setTranslate(Ba.e,Ba.f);ea.appendItem(ib);ea.appendItem(kb);ea.appendItem(Lb);Ia.push(ib);Ia.push(kb);Ia.push(Lb)}s.addSubCommand(svgedit.recalculate.recalculateDimensions(fa));I.setStartTransform(ka)}}}i.removeItem(m-1);i.removeItem(m-2);i.removeItem(m-3)}else if(m>=3&&i.getItem(m-1).type==1){A=3;e=svgedit.math.transformListToTransform(i).matrix;Ba=c.createSVGTransform();Ba.setMatrix(e);i.clear();i.appendItem(Ba)}else if((m==1||m>1&&i.getItem(1).type!=3)&&i.getItem(0).type== 2){A=2;q=svgedit.math.transformListToTransform(i).matrix;i.removeItem(0);e=svgedit.math.transformListToTransform(i).matrix.inverse();e=svgedit.math.matrixMultiply(e,q);q=e.e;e=e.f;if(q!=0||e!=0){u=o.childNodes;p=u.length;for(m=[];p--;){fa=u.item(p);if(fa.nodeType==1){if(fa.getAttribute("clip-path")){ka=fa.getAttribute("clip-path");if(m.indexOf(ka)===-1){svgedit.recalculate.updateClipPath(ka,q,e);m.push(ka)}}ka=I.getStartTransform();I.setStartTransform(fa.getAttribute("transform"));if(ea=svgedit.transformlist.getTransformList(fa)){R= c.createSVGTransform();R.setTranslate(q,e);ea.numberOfItems?ea.insertItemBefore(R,0):ea.appendItem(R);s.addSubCommand(svgedit.recalculate.recalculateDimensions(fa));ea=o.getElementsByTagNameNS(a.SVG,"use");fa="#"+fa.id;for(R=ea.length;R--;){da=ea.item(R);if(fa==svgedit.utilities.getHref(da)){qa=c.createSVGTransform();qa.setTranslate(-q,-e);svgedit.transformlist.getTransformList(da).insertItemBefore(qa,0);s.addSubCommand(svgedit.recalculate.recalculateDimensions(da))}}I.setStartTransform(ka)}}}m=[]; I.setStartTransform(ka)}}else if(m==1&&i.getItem(0).type==1&&!g){A=1;e=i.getItem(0).matrix;u=o.childNodes;for(p=u.length;p--;){fa=u.item(p);if(fa.nodeType==1){ka=I.getStartTransform();I.setStartTransform(fa.getAttribute("transform"));if(ea=svgedit.transformlist.getTransformList(fa)){q=svgedit.math.matrixMultiply(e,svgedit.math.transformListToTransform(ea).matrix);m=c.createSVGTransform();m.setMatrix(q);ea.clear();ea.appendItem(m,0);s.addSubCommand(svgedit.recalculate.recalculateDimensions(fa));I.setStartTransform(ka); ka=fa.getAttribute("stroke-width");fa.getAttribute("stroke")!=="none"&&!isNaN(ka)&&fa.setAttribute("stroke-width",ka*((Math.abs(q.a)+Math.abs(q.d))/2))}}}i.clear()}else{if(g){c=c.createSVGTransform();c.setRotate(g,t.x,t.y);i.numberOfItems?i.insertItemBefore(c,0):i.appendItem(c)}i.numberOfItems==0&&o.removeAttribute("transform");return null}if(A==2){if(g){t={x:v.x+L.e,y:v.y+L.f};c=c.createSVGTransform();c.setRotate(g,t.x,t.y);i.numberOfItems?i.insertItemBefore(c,0):i.appendItem(c)}}else if(A==3){e= svgedit.math.transformListToTransform(i).matrix;L=c.createSVGTransform();L.setRotate(g,v.x,v.y);L=L.matrix;v=c.createSVGTransform();v.setRotate(g,t.x,t.y);t=v.matrix.inverse();ka=e.inverse();t=svgedit.math.matrixMultiply(ka,t,L,e);q=t.e;e=t.f;if(q!=0||e!=0){u=o.childNodes;for(p=u.length;p--;){fa=u.item(p);if(fa.nodeType==1){ka=I.getStartTransform();I.setStartTransform(fa.getAttribute("transform"));ea=svgedit.transformlist.getTransformList(fa);R=c.createSVGTransform();R.setTranslate(q,e);ea.numberOfItems? ea.insertItemBefore(R,0):ea.appendItem(R);s.addSubCommand(svgedit.recalculate.recalculateDimensions(fa));I.setStartTransform(ka)}}}if(g)i.numberOfItems?i.insertItemBefore(v,0):i.appendItem(v)}}else{g=svgedit.utilities.getBBox(o);if(!g&&o.tagName!="path")return null;e=c.createSVGMatrix();if(q=svgedit.utilities.getRotationAngle(o)){v={x:g.x+g.width/2,y:g.y+g.height/2};t=svgedit.math.transformPoint(g.x+g.width/2,g.y+g.height/2,svgedit.math.transformListToTransform(i).matrix);A=q*Math.PI/180;u=Math.abs(A)> 1.0E-10?Math.sin(A)/(1-Math.cos(A)):2/A;for(A=0;A=3&&i.getItem(m-2).type==3&&i.getItem(m-3).type==2&&i.getItem(m-1).type==2){A=3;e=svgedit.math.transformListToTransform(i,m-3,m-1).matrix;i.removeItem(m-1);i.removeItem(m-2);i.removeItem(m-3)}else if(m==4&&i.getItem(m-1).type==1){A=3;e=svgedit.math.transformListToTransform(i).matrix;Ba=c.createSVGTransform();Ba.setMatrix(e);i.clear();i.appendItem(Ba);e=c.createSVGMatrix()}else if((m== 1||m>1&&i.getItem(1).type!=3)&&i.getItem(0).type==2){A=2;L=i.getItem(0).matrix;ka=svgedit.math.transformListToTransform(i,1).matrix;g=ka.inverse();e=svgedit.math.matrixMultiply(g,L,ka);i.removeItem(0)}else if(m==1&&i.getItem(0).type==1&&!q){e=svgedit.math.transformListToTransform(i).matrix;switch(o.tagName){case "line":w=$(o).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":w.points=o.getAttribute("points");if(w.points){g=o.points;u=g.numberOfItems;w.points=Array(u);for(A=0;A0;){e.push(e.shift());i--}i=0;for(s in o.selectorGrips){o.selectorGrips[s].setAttribute("style","cursor:"+e[i]+ "-resize");i++}};svgedit.select.Selector.prototype.showGrips=function(i){o.selectorGripsGroup.setAttribute("display",i?"inline":"none");var s=this.selectedElement;this.hasGrips=i;if(s&&i){this.selectorGroup.appendChild(o.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(s))}};svgedit.select.Selector.prototype.resize=function(){var i=this.selectorRect,s=o,e=s.selectorGrips,g=this.selectedElement,q=g.getAttribute("stroke-width"),w=a.currentZoom(),D=1/w;if(g.getAttribute("stroke")!== "none"&&!isNaN(q))D+=q/2;var u=g.tagName;if(u==="text")D+=2/w;q=svgedit.transformlist.getTransformList(g);q=svgedit.math.transformListToTransform(q).matrix;q.e*=w;q.f*=w;var A=svgedit.utilities.getBBox(g);if(u==="g"&&!$.data(g,"gsvg"))if(u=a.getStrokedBBox(g.childNodes))A=u;u=A.x;var p=A.y,v=A.width;A=A.height;D*=w;w=svgedit.math.transformBox(u*w,p*w,v*w,A*w,q);q=w.aabox;u=q.x-D;p=q.y-D;v=q.width+D*2;var t=q.height+D*2;q=u+v/2;A=p+t/2;if(g=svgedit.utilities.getRotationAngle(g)){u=a.svgRoot().createSVGTransform(); u.setRotate(-g,q,A);u=u.matrix;w.tl=svgedit.math.transformPoint(w.tl.x,w.tl.y,u);w.tr=svgedit.math.transformPoint(w.tr.x,w.tr.y,u);w.bl=svgedit.math.transformPoint(w.bl.x,w.bl.y,u);w.br=svgedit.math.transformPoint(w.br.x,w.br.y,u);u=w.tl;v=u.x;t=u.y;var m=u.x,L=u.y;u=Math.min;p=Math.max;v=u(v,u(w.tr.x,u(w.bl.x,w.br.x)))-D;t=u(t,u(w.tr.y,u(w.bl.y,w.br.y)))-D;m=p(m,p(w.tr.x,p(w.bl.x,w.br.x)))+D;L=p(L,p(w.tr.y,p(w.bl.y,w.br.y)))+D;u=v;p=t;v=m-v;t=L-t}D=a.svgRoot().suspendRedraw(100);i.setAttribute("d", "M"+u+","+p+" L"+(u+v)+","+p+" "+(u+v)+","+(p+t)+" "+u+","+(p+t)+"z");this.selectorGroup.setAttribute("transform",g?"rotate("+[g,q,A].join(",")+")":"");this.gripCoords={nw:[u,p],ne:[u+v,p],sw:[u,p+t],se:[u+v,p+t],n:[u+v/2,p],w:[u,p+t/2],e:[u+v,p+t/2],s:[u+v/2,p+t]};for(var R in this.gripCoords){i=this.gripCoords[R];e[R].setAttribute("cx",i[0]);e[R].setAttribute("cy",i[1])}s.rotateGripConnector.setAttribute("x1",u+v/2);s.rotateGripConnector.setAttribute("y1",p);s.rotateGripConnector.setAttribute("x2", u+v/2);s.rotateGripConnector.setAttribute("y2",p-c*5);s.rotateGrip.setAttribute("cx",u+v/2);s.rotateGrip.setAttribute("cy",p-c*5);a.svgRoot().unsuspendRedraw(D)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.rotateGrip=this.rotateGripConnector=this.selectorGripsGroup=null;this.initGroup()};svgedit.select.SelectorManager.prototype.initGroup= function(){this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup);this.selectorParentGroup=a.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}});this.selectorGripsGroup=a.createSVGElement({element:"g",attr:{display:"none"}});this.selectorParentGroup.appendChild(this.selectorGripsGroup);a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var i in this.selectorGrips){var s= a.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+i,fill:"#22C",r:c,style:"cursor:"+i+"-resize","stroke-width":2,"pointer-events":"all"}});$.data(s,"dir",i);$.data(s,"type","resize");this.selectorGrips[i]=this.selectorGripsGroup.appendChild(s)}this.rotateGripConnector=this.selectorGripsGroup.appendChild(a.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}}));this.rotateGrip=this.selectorGripsGroup.appendChild(a.createSVGElement({element:"circle", attr:{id:"selectorGrip_rotate",fill:"lime",r:c,stroke:"#22C","stroke-width":2,style:"cursor:url("+I.imgPath+"rotate.png) 12 12, auto;"}}));$.data(this.rotateGrip,"type","rotate");if(!$("#canvasBackground").length){i=I.dimensions;i=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:i[0],height:i[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});s=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1, stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});i.appendChild(s);a.svgRoot().insertBefore(i,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(i){if(i==null)return null;var s,e=this.selectors.length;if(typeof this.selectorMap[i.id]=="object"){this.selectorMap[i.id].locked=true;return this.selectorMap[i.id]}for(s=0;s element";this.svgElem_=i;this.obj_num=0;this.idPrefix=s||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_= "";var e=this.svgElem_.getAttributeNS(a.SE,"nonce");if(e&&c!=o.NEVER_RANDOMIZE)this.nonce_=e;else c==o.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(i){if(this.svgElem_.querySelector)return this.svgElem_.querySelector("#"+i);return $(this.svgElem_).find("[id="+i+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_};svgedit.draw.Drawing.prototype.setNonce= function(i){this.svgElem_.setAttributeNS(a.XMLNS,"xmlns:se",a.SE);this.svgElem_.setAttributeNS(a.SE,"se:nonce",i);this.nonce_=i};svgedit.draw.Drawing.prototype.clearNonce=function(){this.nonce_=""};svgedit.draw.Drawing.prototype.getId=function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num};svgedit.draw.Drawing.prototype.getNextId=function(){var i=this.obj_num,s=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();s=true}else this.obj_num++; for(var e=this.getId();this.getElem_(e);){if(s){this.obj_num=i;s=false}this.obj_num++;e=this.getId()}if(s)this.obj_num=i;return e};svgedit.draw.Drawing.prototype.releaseId=function(i){var s=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof i!=="string"||i.indexOf(s)!==0)return false;i=parseInt(i.substr(s.length),10);if(typeof i!=="number"||i<=0||this.releasedNums.indexOf(i)!=-1)return false;this.releasedNums.push(i);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length}; svgedit.draw.Drawing.prototype.hasLayer=function(i){var s;for(s=0;s=0&&i1){var i=this.current_layer.parentNode.removeChild(this.current_layer); this.identifyLayers();return i}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];var i=this.svgElem_.childNodes.length,s=[],e=[],g=null,q=false,w;for(w=0;w0||!q){for(w=1;e.indexOf("Layer "+w)>=0;)w++;e="Layer "+w;g=i.createElementNS(a.SVG,"g");q=i.createElementNS(a.SVG,"title");q.textContent=e;g.appendChild(q);for(q=0;q1)){var e;for(e=0;e0){p=qa element";this.elem=p;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var p=this.elem.pathSegList,v=p.numberOfItems; this.segs=[];this.selected_pts=[];this.first_seg=null;var t;for(t=0;t=v?null:p[t+1],da=t-1<0?null:p[t-1];if(L.type===2){if(da&&da.type!==1){R=p[m];R.next=p[m+1];R.next.prev=R;R.addGrip()}m=t}else if(R&&R.type===1){L.next=p[m+1];L.next.prev=L;L.mate=p[m];L.addGrip();if(this.first_seg==null)this.first_seg=L}else if(R){if(L.type!==1){L.addGrip();if(R&&R.type!== 2){L.next=R;L.next.prev=L}}}else if(L.type!==1){R=p[m];R.next=p[m+1];R.next.prev=R;R.addGrip();L.addGrip();if(!this.first_seg)this.first_seg=p[m]}}return this};svgedit.path.Path.prototype.eachSeg=function(p){var v,t=this.segs.length;for(v=0;v').documentElement,true);a.appendChild(q);var w=g.createElementNS(c.SVG,"svg");(e.clearSvgContentElement=function(){for(;w.firstChild;)w.removeChild(w.firstChild);$(w).attr({id:"svgcontent", width:s[0],height:s[1],x:s[0],y:s[1],overflow:i.show_outside_canvas?"visible":"hidden",xmlns:c.SVG,"xmlns:se":c.SE,"xmlns:xlink":c.XLINK}).appendTo(q);var b=g.createComment(" Created with SVG-edit - http://svg-edit.googlecode.com/ ");w.appendChild(b)})();var D="svg_";e.setIdPrefix=function(b){D=b};e.current_drawing_=new svgedit.draw.Drawing(w,D);var u=e.getCurrentDrawing=function(){return e.current_drawing_},A=1,p=null,v={shape:{fill:(i.initFill.color=="none"?"":"#")+i.initFill.color,fill_paint:null, fill_opacity:i.initFill.opacity,stroke:"#"+i.initStroke.color,stroke_paint:null,stroke_opacity:i.initStroke.opacity,stroke_width:i.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:i.initOpacity}};v.text=$.extend(true,{},v.shape);$.extend(v.text,{fill:"#000000",stroke_width:0,font_size:24,font_family:"serif"});var t=v.shape,m=Array(1),L=this.addSvgElementFromJson=function(b){var f=svgedit.utilities.getElem(b.attr.id),d=u().getCurrentLayer();if(f&&b.element!= f.tagName){d.removeChild(f);f=null}if(!f){f=g.createElementNS(c.SVG,b.element);if(d)(p||d).appendChild(f)}b.curStyles&&svgedit.utilities.assignAttributes(f,{fill:t.fill,stroke:t.stroke,"stroke-width":t.stroke_width,"stroke-dasharray":t.stroke_dasharray,"stroke-linejoin":t.stroke_linejoin,"stroke-linecap":t.stroke_linecap,"stroke-opacity":t.stroke_opacity,"fill-opacity":t.fill_opacity,opacity:t.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(f,b.attr,100);svgedit.utilities.cleanupElement(f); return f};e.getTransformList=svgedit.transformlist.getTransformList;var R=svgedit.math.transformPoint,da=e.matrixMultiply=svgedit.math.matrixMultiply,qa=e.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=e.transformListToTransform=svgedit.math.transformListToTransform;svgedit.units.init({getBaseUnit:function(){return i.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return w.getAttribute("height")/A},getWidth:function(){return w.getAttribute("width")/A},getRoundDigits:function(){return Ma.round_digits}}); e.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return g},getDOMContainer:function(){return a},getSVGRoot:function(){return q},getSelectedElements:function(){return m},getSVGContent:function(){return w},getBaseUnit:function(){return i.baseUnit},getStepSize:function(){return i.stepSize}});var ea=e.findDefs=svgedit.utilities.findDefs,ka=e.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,Ia=e.getHref=svgedit.utilities.getHref,Ba=e.setHref=svgedit.utilities.setHref, Lb=svgedit.utilities.getPathBBox;e.getBBox=svgedit.utilities.getBBox;e.getRotationAngle=svgedit.utilities.getRotationAngle;var kb=e.getElem=svgedit.utilities.getElem;e.getRefElem=svgedit.utilities.getRefElem;var ib=e.assignAttributes=svgedit.utilities.assignAttributes,ta=this.cleanupElement=svgedit.utilities.cleanupElement;svgedit.coords.init({getDrawing:function(){return u()},getGridSnapping:function(){return i.gridSnapping}});var pb=this.remapElement=svgedit.coords.remapElement;svgedit.recalculate.init({getSVGRoot:function(){return q}, getStartTransform:function(){return lb},setStartTransform:function(b){lb=b}});var Mb=this.recalculateDimensions=svgedit.recalculate.recalculateDimensions,ab=svgedit.getReverseNS(),Nb=e.sanitizeSvg=svgedit.sanitize.sanitizeSvg,Ab=svgedit.history.MoveElementCommand,bb=svgedit.history.InsertElementCommand,Wa=svgedit.history.RemoveElementCommand,jb=svgedit.history.ChangeElementCommand,Xb=svgedit.history.BatchCommand;e.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(b,f){var d=svgedit.history.HistoryEventTypes; if(b==d.BEFORE_UNAPPLY||b==d.BEFORE_APPLY)e.clearSelection();else if(b==d.AFTER_APPLY||b==d.AFTER_UNAPPLY){var r=f.elements();e.pathActions.clear();ma("changed",r);r=f.type();d=b==d.AFTER_APPLY;if(r==Ab.type())(d?f.newParent:f.oldParent)==w&&e.identifyLayers();else if(r==bb.type()||r==Wa.type()){f.parent==w&&e.identifyLayers();if(r==bb.type())d&&Bb(f.elem);else d||Bb(f.elem);f.elem.tagName==="use"&&Cb(f.elem)}else if(r==jb.type()){f.elem.tagName=="title"&&f.elem.parentNode.parentNode==w&&e.identifyLayers(); d=d?f.newValues:f.oldValues;d.stdDeviation&&e.setBlurOffsets(f.elem.parentNode,d.stdDeviation)}}}});var Y=function(b){e.undoMgr.addCommandToHistory(b)};svgedit.select.init(i,{createSVGElement:function(b){return e.addSvgElementFromJson(b)},svgRoot:function(){return q},svgContent:function(){return w},currentZoom:function(){return A},getStrokedBBox:function(b){return e.getStrokedBBox([b])}});var va=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return A}, getSVGRoot:function(){return q}});var qb={exportNoBlur:"Blurred elements will appear as un-blurred",exportNoforeignObject:"foreignObject elements will not appear",exportNoDashArray:"Strokes will appear filled",exportNoText:"Text may not appear as expected"},Ob=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],Db=$.data,ub=document.createElementNS(c.SVG,"animate");$(ub).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(q);var Bb=function(b){var f, d=$(b).attr(Ob);for(f in d){var r=d[f];if(r&&r.indexOf("url(")===0){r=svgedit.utilities.getUrlFromAttr(r).substr(1);if(!kb(r)){svgedit.utilities.findDefs().appendChild(Eb[r]);delete Eb[r]}}}f=b.getElementsByTagName("*");if(f.length){b=0;for(l=f.length;b=0)K=C=e.convertToPath(G,true);else if(G.tagName=="rect"){var O=G.getAttribute("rx"),T=G.getAttribute("ry");if(O||T)K=C=e.convertToPath(G,true)}if(!C){var V=G.cloneNode(true),X=document.createElementNS(c.SVG,"g"),ca=G.parentNode;ca.appendChild(X);X.appendChild(V);K=svgedit.utilities.bboxToObj(X.getBBox());ca.removeChild(X)}}return K}catch(S){console.log(G, S);return null}},d;$.each(b,function(){if(!d)if(this.parentNode)d=f(this)});if(d==null)return null;var r=d.x+d.width,j=d.y+d.height,E=d.x,n=d.y,z=function(G){var K=G.getAttribute("stroke-width"),C=0;if(G.getAttribute("stroke")!="none"&&!isNaN(K))C+=K/2;return C},B=[];$.each(b,function(G,K){var C=f(K);if(C){var O=z(K);E=Math.min(E,C.x-O);n=Math.min(n,C.y-O);B.push(C)}});d.x=E;d.y=n;$.each(b,function(G,K){var C=B[G];if(C&&K.nodeType==1){var O=z(K);r=Math.max(r,C.x+C.width+O);j=Math.max(j,C.y+C.height+ O)}});d.width=r-E;d.height=j-n;return d};var sb=this.getVisibleElements=function(b){b||(b=$(w).children());var f=[];$(b).children().each(function(d,r){try{r.getBBox()&&f.push(r)}catch(j){}});return f.reverse()},cb=this.getVisibleElementsAndBBoxes=function(b){b||(b=$(w).children());var f=[];$(b).children().each(function(d,r){try{r.getBBox()&&f.push({elem:r,bbox:getStrokedBBox([r])})}catch(j){}});return f.reverse()},Pb=this.groupSvgElem=function(b){var f=document.createElementNS(c.SVG,"g");b.parentNode.replaceChild(f, b);$(f).append(b).data("gsvg",b)[0].id=Ga()},ob=function(b){var f=document.createElementNS(b.namespaceURI,b.nodeName);$.each(b.attributes,function(r,j){j.localName!="-moz-math-font-style"&&f.setAttributeNS(j.namespaceURI,j.nodeName,j.nodeValue)});f.removeAttribute("id");f.id=Ga();if(svgedit.browser.isWebkit()&&b.nodeName=="path"){var d=ra.convertPath(b);f.setAttribute("d",d)}$.each(b.childNodes,function(r,j){switch(j.nodeType){case 1:f.appendChild(ob(j));break;case 3:f.textContent=j.nodeValue}}); if($(b).data("gsvg"))$(f).data("gsvg",f.firstChild);else if($(b).data("symbol")){b=$(b).data("symbol");$(f).data("ref",b).data("symbol",b)}else f.tagName=="image"&&wb(f);return f},Ya,Ga,ma,La,ra;(function(b){var f={};Ya=b.getId=function(){return u().getId()};Ga=b.getNextId=function(){return u().getNextId()};ma=b.call=function(d,r){if(f[d])return f[d](this,r)};b.bind=function(d,r){var j=f[d];f[d]=r;return j}})(e);this.prepareSvg=function(b){this.sanitizeSvg(b.documentElement);var f,d,r=b.getElementsByTagNameNS(c.SVG, "path");b=0;for(d=r.length;b0&&j.getItem(0).type==4&&j.removeItem(0);if(b!=0){E=svgedit.math.transformPoint(E,n,svgedit.math.transformListToTransform(j).matrix);n=q.createSVGTransform();n.setRotate(b,E.x,E.y);j.numberOfItems?j.insertItemBefore(n,0):j.appendItem(n)}else j.numberOfItems==0&&d.removeAttribute("transform");if(!f){j=d.getAttribute("transform");d.setAttribute("transform",r);Va("transform",j,m);ma("changed",m)}svgedit.utilities.getElem("pathpointgrip_container");d=va.requestSelector(m[0]);d.resize(); d.updateGripCursors(b)};var Qb=this.recalculateAllSelectedDimensions=function(){for(var b=new svgedit.history.BatchCommand(db=="none"?"position":"size"),f=m.length;f--;){var d=svgedit.recalculate.recalculateDimensions(m[f]);d&&b.addSubCommand(d)}if(!b.isEmpty()){Y(b);ma("changed",m)}},gc=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Yb=function(b){console.log([b.a,b.b,b.c,b.d,b.e,b.f])},fb=null,za=this.clearSelection=function(b){if(m[0]!=null){var f,d,r=m.length; for(f=0;f1&&j.showGrips(false)}}}ma("selected",m);f||m.length==1?va.requestSelector(m[0]).showGrips(true):va.requestSelector(m[0]).showGrips(false); for(m.sort(function(E,n){if(E&&n&&E.compareDocumentPosition)return 3-(n.compareDocumentPosition(E)&6);if(E==null)return 1});m[0]==null;)m.shift(0)}},Za=this.selectOnly=function(b,f){za(true);gb(b,f)};this.removeFromSelection=function(b){if(m[0]!=null)if(b.length!=0){var f,d=0,r=Array(m.length),j=m.length;for(f=0;f=0&&b.id!="svgcanvas")for(;b.nodeName!="foreignObject";){b=b.parentNode;if(!b)return q}var f=u().getCurrentLayer();if([q,a,w,f].indexOf(b)>=0)return q;if($(b).closest("#selectorParentGroup").length)return va.selectorParentGroup;for(;b.parentNode!==(p||f);)b=b.parentNode;return b};(function(){var b=null,f=null,d=null,r=null,j=null, E={},n={minx:null,miny:null,maxx:null,maxy:null},z=0,B={x:0,y:0},G={x:0,y:0},K={x:0,y:0},C={x:0,y:0},O,T,V={x:0,y:0},X={x:0,y:0},ca=function(S){var M={x:0,y:0},J=B,N=G,P=K,aa=C,ha=1/6,pa=S*S,Aa=pa*S,ba=[[-1,3,-3,1],[3,-6,3,0],[-3,0,3,0],[1,4,1,0]];M.x=ha*((J.x*ba[0][0]+N.x*ba[0][1]+P.x*ba[0][2]+aa.x*ba[0][3])*Aa+(J.x*ba[1][0]+N.x*ba[1][1]+P.x*ba[1][2]+aa.x*ba[1][3])*pa+(J.x*ba[2][0]+N.x*ba[2][1]+P.x*ba[2][2]+aa.x*ba[2][3])*S+(J.x*ba[3][0]+N.x*ba[3][1]+P.x*ba[3][2]+aa.x*ba[3][3]));M.y=ha*((J.y*ba[0][0]+ N.y*ba[0][1]+P.y*ba[0][2]+aa.y*ba[0][3])*Aa+(J.y*ba[1][0]+N.y*ba[1][1]+P.y*ba[1][2]+aa.y*ba[1][3])*pa+(J.y*ba[2][0]+N.y*ba[2][1]+P.y*ba[2][2]+aa.y*ba[2][3])*S+(J.y*ba[3][0]+N.y*ba[3][1]+P.y*ba[3][2]+aa.y*ba[3][3]));return{x:M.x,y:M.y}};$(a).mousedown(function(S){if(!(e.spaceKey||S.button===1)){var M=S.button===2;S.altKey&&svgCanvas.cloneSelectedElements(0,0);fb=$("#svgcontent g")[0].getScreenCTM().inverse();var J=svgedit.math.transformPoint(S.pageX,S.pageY,fb),N=J.x*A,P=J.y*A;S.preventDefault();if(M){ua= "select";Oa=J}J=N/A;P=P/A;var aa=Ib(S);if(aa.tagName==="a"&&aa.childNodes.length===1)aa=aa.firstChild;r=f=N=J;var ha=P;j=d=P;if(i.gridSnapping){J=svgedit.utilities.snapToGrid(J);P=svgedit.utilities.snapToGrid(P);f=svgedit.utilities.snapToGrid(f);d=svgedit.utilities.snapToGrid(d)}if(aa==va.selectorParentGroup&&m[0]!=null){aa=S.target;var pa=Db(aa,"type");if(pa=="rotate")ua="rotate";else if(pa=="resize"){ua="resize";db=Db(aa,"dir")}aa=m[0]}lb=aa.getAttribute("transform");var Aa;pa=svgedit.transformlist.getTransformList(aa); switch(ua){case "select":ya=true;db="none";if(M)ya=false;if(aa!=q){if(m.indexOf(aa)==-1){S.shiftKey||za(true);gb([aa]);Ua=aa;ra.clear()}if(!M)for(M=0;M0&&e.removeFromSelection(ba);J.length>0&&gb(J);break;case "resize":ba=svgedit.transformlist.getTransformList(ha); N=(M=svgedit.math.hasMatrixTransform(ba))?E:svgedit.utilities.getBBox(ha);P=N.x;wa=N.y;var Da=N.width,$a=N.height;J=x-f;N=y-d;if(i.gridSnapping){J=svgedit.utilities.snapToGrid(J);N=svgedit.utilities.snapToGrid(N);$a=svgedit.utilities.snapToGrid($a);Da=svgedit.utilities.snapToGrid(Da)}if(aa=svgedit.utilities.getRotationAngle(ha)){var hb=Math.sqrt(J*J+N*N);N=Math.atan2(N,J)-aa*Math.PI/180;J=hb*Math.cos(N);N=hb*Math.sin(N)}if(db.indexOf("n")==-1&&db.indexOf("s")==-1)N=0;if(db.indexOf("e")==-1&&db.indexOf("w")== -1)J=0;var Jb=hb=0,Rb=$a?($a+N)/$a:1,Kb=Da?(Da+J)/Da:1;if(db.indexOf("n")>=0){Rb=$a?($a-N)/$a:1;Jb=$a}if(db.indexOf("w")>=0){Kb=Da?(Da-J)/Da:1;hb=Da}J=q.createSVGTransform();N=q.createSVGTransform();Da=q.createSVGTransform();if(i.gridSnapping){P=svgedit.utilities.snapToGrid(P);hb=svgedit.utilities.snapToGrid(hb);wa=svgedit.utilities.snapToGrid(wa);Jb=svgedit.utilities.snapToGrid(Jb)}J.setTranslate(-(P+hb),-(wa+Jb));if(S.shiftKey)if(Kb==1)Kb=Rb;else Rb=Kb;N.setScale(Kb,Rb);Da.setTranslate(P+hb,wa+ Jb);if(M){M=aa?1:0;ba.replaceItem(J,2+M);ba.replaceItem(N,1+M);ba.replaceItem(Da,Number(M))}else{M=ba.numberOfItems;ba.replaceItem(Da,M-3);ba.replaceItem(N,M-2);ba.replaceItem(J,M-1)}va.requestSelector(ha).resize();ma("transition",m);break;case "zoom":J*=A;P*=A;svgedit.utilities.assignAttributes(Ca,{x:Math.min(r*A,J),y:Math.min(j*A,P),width:Math.abs(J-r*A),height:Math.abs(P-j*A)},100);break;case "text":svgedit.utilities.assignAttributes(ba,{x:x,y:y},1E3);break;case "line":P=null;window.opera||q.suspendRedraw(1E3); if(i.gridSnapping){x=svgedit.utilities.snapToGrid(x);y=svgedit.utilities.snapToGrid(y)}J=x;M=y;if(S.shiftKey){M=svgedit.math.snapToAngle(f,d,J,M);J=M.x;M=M.y}ba.setAttributeNS(null,"x2",J);ba.setAttributeNS(null,"y2",M);window.opera||q.unsuspendRedraw(P);break;case "foreignObject":case "square":case "rect":case "image":J=Math.abs(x-f);M=Math.abs(y-d);if(ua=="square"||S.shiftKey){J=M=Math.max(J,M);P=f0.8){b+=+V.x+","+V.y+" ";ba.setAttributeNS(null,"points",b);z-=0.8}}B={x:G.x,y:G.y};G={x:K.x,y:K.y};K={x:C.x,y:C.y};break;case "path":case "pathedit":x*=A;y*=A;if(i.gridSnapping){x=svgedit.utilities.snapToGrid(x);y=svgedit.utilities.snapToGrid(y);f=svgedit.utilities.snapToGrid(f);d=svgedit.utilities.snapToGrid(d)}if(S.shiftKey){if(M=svgedit.path.path){ba=M.dragging?M.dragging[0]:f;M=M.dragging?M.dragging[1]:d}else{ba=f;M=d}M=svgedit.math.snapToAngle(ba,M,x,y);x=M.x;y=M.y}if(Ca&& Ca.getAttribute("display")!=="none"){J*=A;P*=A;svgedit.utilities.assignAttributes(Ca,{x:Math.min(r*A,J),y:Math.min(j*A,P),width:Math.abs(J-r*A),height:Math.abs(P-j*A)},100)}ra.mouseMove(x,y);break;case "textedit":x*=A;y*=A;La.mouseMove(Aa,pa);break;case "rotate":N=svgedit.utilities.getBBox(ha);J=N.x+N.width/2;M=N.y+N.height/2;ba=svgedit.math.getMatrix(ha);ba=svgedit.math.transformPoint(J,M,ba);J=ba.x;M=ba.y;aa=(Math.atan2(M-y,J-x)*(180/Math.PI)-90)%360;if(i.gridSnapping)aa=svgedit.utilities.snapToGrid(aa); if(S.shiftKey)aa=Math.round(aa/45)*45;e.setRotationAngle(aa<-180?360+aa:aa,true);ma("transition",m)}nb("mouseMove",{event:S,mouse_x:Aa,mouse_y:pa,selected:ha})}}).click(function(S){S.preventDefault();return false}).dblclick(function(S){var M=S.target.parentNode;if(M!==p){var J=Ib(S),N=J.tagName;if(N==="text"&&ua!=="textedit"){S=svgedit.math.transformPoint(S.pageX,S.pageY,fb);La.select(J,S.x,S.y)}if((N==="g"||N==="a")&&svgedit.utilities.getRotationAngle(J)){tb(J);J=m[0];za(true)}p&&Sb();M.tagName!== "g"&&M.tagName!=="a"||M===u().getCurrentLayer()||J===va.selectorParentGroup||hc(J)}}).mouseup(function(S){if(S.button!==2){var M=Ua;Ua=null;if(ya){var J=svgedit.math.transformPoint(S.pageX,S.pageY,fb),N=J.x*A;J=J.y*A;var P=N/A,aa=J/A,ha=svgedit.utilities.getElem(Ya()),pa=false;ya=false;switch(ua){case "resize":case "multiselect":if(Ca!=null){Ca.setAttribute("display","none");rb=[]}ua="select";case "select":if(m[0]!=null){if(m[1]==null){N=m[0];switch(N.tagName){case "g":case "use":case "image":case "foreignObject":break; default:Ta.fill=N.getAttribute("fill");Ta.fill_opacity=N.getAttribute("fill-opacity");Ta.stroke=N.getAttribute("stroke");Ta.stroke_opacity=N.getAttribute("stroke-opacity");Ta.stroke_width=N.getAttribute("stroke-width");Ta.stroke_dasharray=N.getAttribute("stroke-dasharray");Ta.stroke_linejoin=N.getAttribute("stroke-linejoin");Ta.stroke_linecap=N.getAttribute("stroke-linecap")}if(N.tagName=="text"){Sa.font_size=N.getAttribute("font-size");Sa.font_family=N.getAttribute("font-family")}va.requestSelector(N).showGrips(true)}Qb(); if(P!=r||aa!=j){N=m.length;for(S=0;S=0?M.indexOf(",",P+1)>=0:M.indexOf(" ",M.indexOf(" ")+1)>=0)ha=ra.smoothPolylineIntoPath(ha);break;case "line":M=$(ha).attr(["x1","x2","y1","y2"]);pa=M.x1!=M.x2||M.y1!=M.y2;break;case "foreignObject":case "square":case "rect":case "image":M=$(ha).attr(["width","height"]);pa=M.width!=0||M.height!=0||ua==="image"; break;case "circle":pa=ha.getAttribute("r")!=0;break;case "ellipse":M=$(ha).attr(["rx","ry"]);pa=M.rx!=null||M.ry!=null;break;case "fhellipse":if(n.maxx-n.minx>0&&n.maxy-n.miny>0){ha=L({element:"ellipse",curStyles:true,attr:{cx:(n.minx+n.maxx)/2,cy:(n.miny+n.maxy)/2,rx:(n.maxx-n.minx)/2,ry:(n.maxy-n.miny)/2,id:Ya()}});ma("changed",[ha]);pa=true}break;case "fhrect":if(n.maxx-n.minx>0&&n.maxy-n.miny>0){ha=L({element:"rect",curStyles:true,attr:{x:n.minx,y:n.miny,width:n.maxx-n.minx,height:n.maxy-n.miny, id:Ya()}});ma("changed",[ha]);pa=true}break;case "text":pa=true;Za([ha]);La.start(ha);break;case "path":ha=null;ya=true;M=ra.mouseUp(S,ha,N,J);ha=M.element;pa=M.keep;break;case "pathedit":pa=true;ha=null;ra.mouseUp(S);break;case "textedit":pa=false;ha=null;La.mouseUp(S,N,J);break;case "rotate":pa=true;ha=null;ua="select";M=e.undoMgr.finishUndoableChange();M.isEmpty()||Y(M);Qb();ma("changed",m)}N=nb("mouseUp",{event:S,mouse_x:N,mouse_y:J},true);$.each(N,function(wa,Da){if(Da){pa=Da.keep||pa;ha=Da.element; ya=Da.started||ya}});if(!pa&&ha!=null){u().releaseId(Ya());ha.parentNode.removeChild(ha);ha=null;for(N=S.target;N.parentNode.parentNode.tagName=="g";)N=N.parentNode;if((ua!="path"||!drawn_path)&&N.parentNode.id!="selectorParentGroup"&&N.id!="svgcanvas"&&N.id!="svgroot"){e.setMode("select");Za([N],true)}}else if(ha!=null){e.addedNew=true;S=0.2;var Aa;if(ub.beginElement&&ha.getAttribute("opacity")!=t.opacity){Aa=$(ub).clone().attr({to:t.opacity,dur:S}).appendTo(ha);try{Aa[0].beginElement()}catch(ba){}}else S= 0;setTimeout(function(){Aa&&Aa.remove();ha.setAttribute("opacity",t.opacity);ha.setAttribute("style","pointer-events:inherit");ta(ha);if(ua==="path")ra.toEditMode(ha);else i.selectNew&&Za([ha],true);Y(new svgedit.history.InsertElementCommand(ha));ma("changed",[ha])},S*1E3)}lb=null}}});$(a).bind("mousewheel DOMMouseScroll",function(S){S.preventDefault();S=S.originalEvent;fb=$("#svgcontent g")[0].getScreenCTM().inverse();var M=svgedit.math.transformPoint(S.pageX,S.pageY,fb);M={x:M.x,y:M.y,width:0,height:0}; if(S=S.wheelDelta?S.wheelDelta:S.detail?-S.detail:0){M.factor=Math.max(0.75,Math.min(4/3,S));ma("zoomed",M)}})})();var wb=function(b){$(b).click(function(f){f.preventDefault()})};La=e.textActions=function(){function b(J){var N=G.value==="";$(G).focus();if(!arguments.length)if(N)J=0;else{if(G.selectionEnd!==G.selectionStart)return;J=G.selectionEnd}var P;P=T[J];N||G.setSelectionRange(J,J);K=svgedit.utilities.getElem("text_cursor");if(!K){K=document.createElementNS(c.SVG,"line");svgedit.utilities.assignAttributes(K, {id:"text_cursor",stroke:"#333","stroke-width":1});K=svgedit.utilities.getElem("selectorParentGroup").appendChild(K)}O||(O=setInterval(function(){var aa=K.getAttribute("display")==="none";K.setAttribute("display",aa?"inline":"none")},600));N=E(P.x,V.y);P=E(P.x,V.y+V.height);svgedit.utilities.assignAttributes(K,{x1:N.x,y1:N.y,x2:P.x,y2:P.y,visibility:"visible",display:"inline"});C&&C.setAttribute("d","")}function f(J,N,P){if(J===N)b(N);else{P||G.setSelectionRange(J,N);C=svgedit.utilities.getElem("text_selectblock"); if(!C){C=document.createElementNS(c.SVG,"path");svgedit.utilities.assignAttributes(C,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});svgedit.utilities.getElem("selectorParentGroup").appendChild(C)}J=T[J];var aa=T[N];K.setAttribute("visibility","hidden");N=E(J.x,V.y);P=E(J.x+(aa.x-J.x),V.y);var ha=E(J.x,V.y+V.height);J=E(J.x+(aa.x-J.x),V.y+V.height);svgedit.utilities.assignAttributes(C,{d:"M"+N.x+","+N.y+" L"+P.x+","+P.y+" "+J.x+","+J.y+" "+ha.x+","+ha.y+"z",display:"inline"})}} function d(J,N){var P=q.createSVGPoint();P.x=J;P.y=N;if(T.length==1)return 0;P=B.getCharNumAtPosition(P);if(P<0){P=T.length-2;if(J<=T[0].x)P=0}else if(P>=T.length-2)P=T.length-2;var aa=T[P];J>aa.x+aa.width/2&&P++;return P}function r(J,N,P){var aa=G.selectionStart;J=d(J,N);f(Math.min(aa,J),Math.max(aa,J),!P)}function j(J,N){var P={x:J,y:N};P.x/=A;P.y/=A;if(X){var aa=svgedit.math.transformPoint(P.x,P.y,X.inverse());P.x=aa.x;P.y=aa.y}return P}function E(J,N){var P={x:J,y:N};if(X){var aa=svgedit.math.transformPoint(P.x, P.y,X);P.x=aa.x;P.y=aa.y}P.x*=A;P.y*=A;return P}function n(J){f(0,B.textContent.length);$(this).unbind(J)}function z(J){if(M&&B){var N=svgedit.math.transformPoint(J.pageX,J.pageY,fb);N=j(N.x*A,N.y*A);N=d(N.x,N.y);var P=B.textContent,aa=P.substr(0,N).replace(/[a-z0-9]+$/i,"").length;P=P.substr(N).match(/^[a-z0-9]+/i);f(aa,(P?P[0].length:0)+N);$(J.target).click(n);setTimeout(function(){$(J.target).unbind("click",n)},300)}}var B,G,K,C,O,T=[],V,X,ca,S,M;return{select:function(J,N,P){B=J;La.toEditMode(N, P)},start:function(J){B=J;La.toEditMode()},mouseDown:function(J,N,P,aa){J=j(P,aa);G.focus();b(d(J.x,J.y));ca=P;S=aa},mouseMove:function(J,N){var P=j(J,N);r(P.x,P.y)},mouseUp:function(J,N,P){var aa=j(N,P);r(aa.x,aa.y,true);J.target!==B&&Nca-2&&PS-2&&La.toSelectMode(true)},setCursor:b,toEditMode:function(J,N){M=false;ua="textedit";va.requestSelector(B).showGrips(false);va.requestSelector(B);La.init();$(B).css("cursor","text");if(arguments.length){var P=j(J,N);b(d(P.x,P.y))}else b(); setTimeout(function(){M=true},300)},toSelectMode:function(J){ua="select";clearInterval(O);O=null;C&&$(C).attr("display","none");K&&$(K).attr("visibility","hidden");$(B).css("cursor","move");if(J){za();$(B).css("cursor","move");ma("selected",[B]);gb([B],true)}B&&!B.textContent.length&&e.deleteSelectedElements();$(G).blur();B=false},setInputElem:function(J){G=J},clear:function(){ua=="textedit"&&La.toSelectMode()},init:function(){if(B){var J,N;if(!B.parentNode){B=m[0];va.requestSelector(B).showGrips(false)}var P= B.textContent.length;J=B.getAttribute("transform");V=svgedit.utilities.getBBox(B);X=J?svgedit.math.getMatrix(B):null;T=Array(P);G.focus();$(B).unbind("dblclick",z).dblclick(z);P||(N={x:V.x+V.width/2,width:0});for(J=0;J=0&&this.selected_pts.push(G)}this.selected_pts.sort(); z=this.selected_pts.length;for(n=Array(z);z--;){B=this.segs[this.selected_pts[z]];B.select(true);n[z]=B.ptgrip}ra.canDeleteNodes=true;ra.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);ma("selected",n)};var j=f=null,E=false;return{mouseDown:function(n,z,B,G){var K;if(ua==="path"){mouse_x=B;mouse_y=G;G=mouse_x/A;z=mouse_y/A;B=svgedit.utilities.getElem("path_stretch_line");d=[G,z];if(i.gridSnapping){G=svgedit.utilities.snapToGrid(G);z=svgedit.utilities.snapToGrid(z);mouse_x=svgedit.utilities.snapToGrid(mouse_x); mouse_y=svgedit.utilities.snapToGrid(mouse_y)}if(!B){B=document.createElementNS(c.SVG,"path");svgedit.utilities.assignAttributes(B,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});B=svgedit.utilities.getElem("selectorParentGroup").appendChild(B)}B.setAttribute("display","inline");var C=null;if(j){C=j.pathSegList;var O=C.numberOfItems;K=6/A;for(var T=false;O;){O--;var V=C.getItem(O),X=V.x;V=V.y;if(G>=X-K&&G<=X+K&&z>=V-K&&z<=V+K){T=true;break}}K=Ya();svgedit.path.removePath_(K); K=svgedit.utilities.getElem(K);X=C.numberOfItems;if(T){if(O<=1&&X>=2){G=C.getItem(0).x;z=C.getItem(0).y;n=B.pathSegList.getItem(1);n=n.pathSegType===4?j.createSVGPathSegLinetoAbs(G,z):j.createSVGPathSegCurvetoCubicAbs(G,z,n.x1/A,n.y1/A,G,z);G=j.createSVGPathSegClosePath();C.appendItem(n);C.appendItem(G)}else if(X<3)return C=false;$(B).remove();element=K;j=null;ya=false;if(b){svgedit.path.path.matrix&&svgedit.coords.remapElement(K,{},svgedit.path.path.matrix.inverse());B=K.getAttribute("d");n=$(svgedit.path.path.elem).attr("d"); $(svgedit.path.path.elem).attr("d",n+B);$(K).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();ra.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Ib(n))){console.log("Clicked outside canvas");return false}C=j.pathSegList.numberOfItems;O=j.pathSegList.getItem(C-1);K=O.x;O=O.y;if(n.shiftKey){n=svgedit.math.snapToAngle(K,O,G,z);G=n.x;z=n.y}n=B.pathSegList.getItem(1);n=n.pathSegType===4?j.createSVGPathSegLinetoAbs(Gb(G), Gb(z)):j.createSVGPathSegCurvetoCubicAbs(Gb(G),Gb(z),n.x1/A,n.y1/A,n.x2/A,n.y2/A);j.pathSegList.appendItem(n);G*=A;z*=A;B.setAttribute("d",["M",G,z,G,z].join(" "));B=C;if(b)B+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(B,G,z)}}else{d_attr="M"+G+","+z+" ";j=L({element:"path",curStyles:true,attr:{d:d_attr,id:Ga(),opacity:t.opacity/2}});B.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));B=b?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(B,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD(); K=n.target.id;if(K.substr(0,14)=="pathpointgrip_"){z=svgedit.path.path.cur_pt=parseInt(K.substr(14));svgedit.path.path.dragging=[B,G];C=svgedit.path.path.segs[z];if(n.shiftKey)C.selected?svgedit.path.path.removePtFromSelection(z):svgedit.path.path.addPtsToSelection(z);else{if(svgedit.path.path.selected_pts.length<=1||!C.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(z)}}else if(K.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[B,G];n=K.split("_")[1].split("c"); z=Number(n[0]);svgedit.path.path.selectPt(z,Number(n[1]))}if(!svgedit.path.path.dragging){if(Ca==null)Ca=va.getRubberBandBox();svgedit.utilities.assignAttributes(Ca,{x:B*A,y:G*A,width:0,height:0,display:"inline"},100)}}},mouseMove:function(n,z){E=true;if(ua==="path"){if(j){var B=j.pathSegList,G=B.numberOfItems-1;if(d){var K=svgedit.path.addCtrlGrip("1c1"),C=svgedit.path.addCtrlGrip("0c2");K.setAttribute("cx",n);K.setAttribute("cy",z);K.setAttribute("display","inline");K=d[0];var O=d[1];B.getItem(G); var T=K+(K-n/A),V=O+(O-z/A);C.setAttribute("cx",T*A);C.setAttribute("cy",V*A);C.setAttribute("display","inline");C=svgedit.path.getCtrlLine(1);svgedit.utilities.assignAttributes(C,{x1:n,y1:z,x2:T*A,y2:V*A,display:"inline"});if(G===0)r=[n,z];else{B=B.getItem(G-1);C=B.x;var X=B.y;if(B.pathSegType===6){C+=C-B.x2;X+=X-B.y2}else if(r){C=r[0]/A;X=r[1]/A}svgedit.path.replacePathSeg(6,G,[K,O,C,X,T,V],j)}}else if(K=svgedit.utilities.getElem("path_stretch_line")){G=B.getItem(G);if(G.pathSegType===6)svgedit.path.replacePathSeg(6, 1,[n,z,(G.x+(G.x-G.x2))*A,(G.y+(G.y-G.y2))*A,n,z],K);else r?svgedit.path.replacePathSeg(6,1,[n,z,r[0],r[1],n,z],K):svgedit.path.replacePathSeg(4,1,[n,z],K)}}}else if(svgedit.path.path.dragging){K=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);O=svgedit.path.getPointFromGrip({x:n,y:z},svgedit.path.path);G=O.x-K.x;K=O.y-K.y;svgedit.path.path.dragging=[n,z];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(G,K):svgedit.path.path.movePts(G, K)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var ca=Ca.getBBox(),S=svgedit.path.getGripPt(this);ca=svgedit.math.rectsIntersect(ca,{x:S.x,y:S.y,width:0,height:0});this.select(ca);ca&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(n,z){if(ua==="path"){d=null;if(!j){z=svgedit.utilities.getElem(Ya());ya=false;r=null}return{keep:true,element:z}}if(svgedit.path.path.dragging){var B=svgedit.path.path.cur_pt;svgedit.path.path.dragging= false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();E&&svgedit.path.path.endChanges("Move path point(s)");!n.shiftKey&&!E&&svgedit.path.path.selectPt(B)}else if(Ca&&Ca.getAttribute("display")!="none"){Ca.setAttribute("display","none");Ca.getAttribute("width")<=2&&Ca.getAttribute("height")<=2&&ra.toSelectMode(n.target)}else ra.toSelectMode(n.target);E=false},toEditMode:function(n){svgedit.path.path=svgedit.path.getPath_(n);ua="pathedit";za();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox= svgedit.utilities.getBBox(svgedit.path.path.elem);b=false},toSelectMode:function(n){var z=n==svgedit.path.path.elem;ua="select";svgedit.path.path.show(false);f=false;za();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(z){ma("selected",[n]);gb([n],true)}},addSubPath:function(n){if(n){ua="path";b=true}else{ra.clear(true);ra.toEditMode(svgedit.path.path.elem)}},select:function(n){if(f===n){ra.toEditMode(n);ua="pathedit"}else f=n},reorient:function(){var n=m[0];if(n)if(svgedit.utilities.getRotationAngle(n)!= 0){var z=new svgedit.history.BatchCommand("Reorient path"),B={d:n.getAttribute("d"),transform:n.getAttribute("transform")};z.addSubCommand(new svgedit.history.ChangeElementCommand(n,B));za();this.resetOrientation(n);Y(z);svgedit.path.getPath_(n).show(false).matrix=null;this.clear();gb([n],true);ma("changed",m)}},clear:function(){f=null;if(j){var n=svgedit.utilities.getElem(Ya());$(svgedit.utilities.getElem("path_stretch_line")).remove();$(n).remove();$(svgedit.utilities.getElem("pathpointgrip_container")).find("*").attr("display", "none");j=r=null;ya=false}else ua=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(n){if(n==null||n.nodeName!="path")return false;var z=svgedit.transformlist.getTransformList(n),B=svgedit.math.transformListToTransform(z).matrix;z.clear();n.removeAttribute("transform");z=n.pathSegList;var G=z.numberOfItems,K;for(K=0;K0){O=G.getItem(K-1).pathSegType;if(O===2){C(K-1,1);B();break}else if(O===1&&G.numberOfItems-1===K){C(K,1);B();break}}}return false};B();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){ra.toSelectMode(svgedit.path.path.elem); e.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){n=$(svgedit.path.path.elem);n.attr("d",n.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(n){var z=n.points,B=z.numberOfItems;if(B>=4){var G=z.getItem(0),K=null,C=[];C.push(["M",G.x,",",G.y," C"].join(""));for(n=1;n<=B-4;n+=3){var O=z.getItem(n),T=z.getItem(n+1),V=z.getItem(n+2);if(K)if((G=svgedit.path.smoothControlPoints(K,O,G))&&G.length== 2){O=C[C.length-1].split(",");O[2]=G[0].x;O[3]=G[0].y;C[C.length-1]=O.join(",");O=G[1]}C.push([O.x,O.y,T.x,T.y,V.x,V.y].join(","));G=V;K=T}for(C.push("L");n0;);ra.clear(true);$.each(w.childNodes,function(d,r){d&&r.nodeType===8&&r.data.indexOf("Created with")>= 0&&w.insertBefore(r,w.firstChild)});if(p){Sb();Za([p])}var b=[];$(w).find("g:data(gsvg)").each(function(){var d=this.attributes,r=d.length,j;for(j=0;j=0;B--){z=n.item(B); C=r(z.nodeValue);if(!(O.indexOf(z.localName)>=0))if(C!="")if(C.indexOf("pointer-events")!==0)if(!(z.localName==="class"&&C.indexOf("se_")===0)){d.push(" ");if(z.localName==="d")C=ra.convertPath(b,true);if(isNaN(C)){if(E.test(C))C=svgedit.units.shortFloat(C)+j}else C=svgedit.units.shortFloat(C);if(Ma.apply&&b.nodeName==="image"&&z.localName==="href"&&Ma.images&&Ma.images==="embed"){var T=Na[C];if(T)C=T}if(!z.namespaceURI||z.namespaceURI==c.SVG||ab[z.namespaceURI]){d.push(z.nodeName);d.push('="');d.push(C); d.push('"')}}}}if(b.hasChildNodes()){d.push(">");f++;n=false;for(B=0;B");break;case 8:d.push("\n");d.push(Array(f+1).join(" "));d.push("