jQuery&&function(){var a=$(window),K=$(document);$.extend($.fn,{contextMenu:function(l,s){if(l.menu==undefined)return false;if(l.inSpeed==undefined)l.inSpeed=150;if(l.outSpeed==undefined)l.outSpeed=75;if(l.inSpeed==0)l.inSpeed=-1;if(l.outSpeed==0)l.outSpeed=-1;$(this).each(function(){var v=$(this),G=$(v).offset(),e=$("#"+l.menu);e.addClass("contextMenu");$(this).bind("mousedown",function(f){$(this).mouseup(function(k){var n=$(this);n.unbind("mouseup");if(f.button===2||l.allowLeft||f.ctrlKey&&svgedit.browser.isMac()){k.stopPropagation(); $(".contextMenu").hide();if(v.hasClass("disabled"))return false;var F=k.pageX,B=k.pageY;k=a.width()-e.width();var A=a.height()-e.height();if(F>k-15)F=k-15;if(B>A-30)B=A-30;K.unbind("click");e.css({top:B,left:F}).fadeIn(l.inSpeed);e.find("A").mouseover(function(){e.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){e.find("LI.hover").removeClass("hover")});K.keypress(function(O){switch(O.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:K.trigger("click")}});e.find("A").unbind("mouseup");e.find("LI:not(.disabled) A").mouseup(function(){K.unbind("click").unbind("keypress"); $(".contextMenu").hide();s&&s($(this).attr("href").substr(1),$(n),{x:F-G.left,y:B-G.top,docX:F,docY:B});return false});setTimeout(function(){K.click(function(){K.unbind("click").unbind("keypress");e.fadeOut(l.outSpeed);return false})},0)}})});if($.browser.mozilla)$("#"+l.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+l.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+l.menu).each(function(){$(this).bind("mousedown.disableTextSelect", function(){return false})});$(v).add($("UL.contextMenu")).bind("contextmenu",function(){return false})});return $(this)},disableContextMenuItems:function(l){if(l==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(l!=undefined)for(var s=l.split(","),v=0;v=0,G=K.indexOf("Gecko/")>=0,e=K.indexOf("MSIE")>=0,f=K.indexOf("Chrome/")>=0,k=K.indexOf("Windows")>=0,n=K.indexOf("Macintosh")>= 0,F="ontouchstart"in window,B=!!l.querySelector,A=!!document.evaluate,O=function(){var ia=document.createElementNS("http://www.w3.org/2000/svg","path");ia.setAttribute("d","M0,0 10,10");var da=ia.pathSegList;ia=ia.createSVGPathSegLinetoAbs(5,5);try{da.replaceItem(ia,0);return true}catch(Ya){}return false}(),Z=function(){var ia=document.createElementNS("http://www.w3.org/2000/svg","path");ia.setAttribute("d","M0,0 10,10");var da=ia.pathSegList;ia=ia.createSVGPathSegLinetoAbs(5,5);try{da.insertItemBefore(ia, 0);return true}catch(Ya){}return false}(),N=function(){var ia=document.createElementNS("http://www.w3.org/2000/svg","svg"),da=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(ia);da.setAttribute("x",5);ia.appendChild(da);var Ya=document.createElementNS("http://www.w3.org/2000/svg","text");Ya.textContent="a";da.appendChild(Ya);da=Ya.getStartPositionOfChar(0).x;document.documentElement.removeChild(ia);return da===0}(),L=function(){var ia=document.createElementNS("http://www.w3.org/2000/svg", "svg");document.documentElement.appendChild(ia);var da=document.createElementNS("http://www.w3.org/2000/svg","path");da.setAttribute("d","M0,0 C0,0 10,10 10,0");ia.appendChild(da);da=da.getBBox();document.documentElement.removeChild(ia);return da.height>4&&da.height<5}(),na=function(){var ia=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(ia);var da=document.createElementNS("http://www.w3.org/2000/svg","path");da.setAttribute("d","M0,0 10,0");var Ya= document.createElementNS("http://www.w3.org/2000/svg","path");Ya.setAttribute("d","M5,0 15,0");var kb=document.createElementNS("http://www.w3.org/2000/svg","g");kb.appendChild(da);kb.appendChild(Ya);ia.appendChild(kb);da=kb.getBBox();document.documentElement.removeChild(ia);return da.width==15}(),ca=function(){var ia=document.createElementNS("http://www.w3.org/2000/svg","rect");ia.setAttribute("x",0.1);(ia=ia.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the latest version in which the problems have been fixed."); return ia}(),oa=function(){var ia=document.createElementNS("http://www.w3.org/2000/svg","rect");ia.setAttribute("style","vector-effect:non-scaling-stroke");return ia.style.vectorEffect==="non-scaling-stroke"}(),pa=function(){var ia=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,da=l.createSVGTransform();ia.appendItem(da);return ia.getItem(0)==da}();svgedit.browser.isOpera=function(){return s};svgedit.browser.isWebkit=function(){return v};svgedit.browser.isGecko=function(){return G}; svgedit.browser.isIE=function(){return e};svgedit.browser.isChrome=function(){return f};svgedit.browser.isWindows=function(){return k};svgedit.browser.isMac=function(){return n};svgedit.browser.isTouch=function(){return F};svgedit.browser.supportsSelectors=function(){return B};svgedit.browser.supportsXpath=function(){return A};svgedit.browser.supportsPathReplaceItem=function(){return O};svgedit.browser.supportsPathInsertItemBefore=function(){return Z};svgedit.browser.supportsPathBBox=function(){return L}; svgedit.browser.supportsHVLineContainerBBox=function(){return na};svgedit.browser.supportsGoodTextCharPos=function(){return N};svgedit.browser.supportsEditableText=function(){return s};svgedit.browser.supportsGoodDecimals=function(){return ca};svgedit.browser.supportsNonScalingStroke=function(){return oa};svgedit.browser.supportsNativeTransformLists=function(){return pa}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{}; (function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),K={};svgedit.transformlist.SVGTransformList=function(l){this._elem=l||null;this._xforms=[];this._update=function(){var s="";a.createSVGMatrix();for(var v=0;v=0)return this._xforms[s];throw{code:1};};this.insertItemBefore=function(s,v){var G=null;if(v>=0)if(v=0){this._removeFromOtherLists(s);G=this._xforms[v]=s;this._list._update()}return G};this.removeItem=function(s){if(s=0){for(var v=this._xforms[s],G=Array(this.numberOfItems- 1),e=0;e1;)s=K[l-1].multiply(s);if(Math.abs(s.a)<1.0E-14)s.a=0;if(Math.abs(s.b)<1.0E-14)s.b=0;if(Math.abs(s.c)<1.0E-14)s.c=0;if(Math.abs(s.d)< 1.0E-14)s.d=0;if(Math.abs(s.e)<1.0E-14)s.e=0;if(Math.abs(s.f)<1.0E-14)s.f=0;return s};svgedit.math.hasMatrixTransform=function(K){if(!K)return false;for(var l=K.numberOfItems;l--;){var s=K.getItem(l);if(s.type==1&&!svgedit.math.isIdentity(s.matrix))return true}return false};svgedit.math.transformBox=function(K,l,s,v,G){var e={x:K,y:l},f={x:K+s,y:l};s={x:K+s,y:l+v};K={x:K,y:l+v};l=svgedit.math.transformPoint;e=l(e.x,e.y,G);var k=v=e.x,n=e.y,F=e.y;f=l(f.x,f.y,G);v=Math.min(v,f.x);k=Math.max(k,f.x); n=Math.min(n,f.y);F=Math.max(F,f.y);K=l(K.x,K.y,G);v=Math.min(v,K.x);k=Math.max(k,K.x);n=Math.min(n,K.y);F=Math.max(F,K.y);s=l(s.x,s.y,G);v=Math.min(v,s.x);k=Math.max(k,s.x);n=Math.min(n,s.y);F=Math.max(F,s.y);return{tl:e,tr:f,bl:K,br:s,aabox:{x:v,y:n,width:k-v,height:F-n}}};svgedit.math.transformListToTransform=function(K,l,s){if(K==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());l=l==undefined?0:l;s=s==undefined?K.numberOfItems-1:s;l=parseInt(l);s=parseInt(s);if(l>s){var v=s;s=l; l=v}v=a.createSVGMatrix();for(l=l;l<=s;++l){var G=l>=0&&lK.x&&l.yK.y}})();svgedit=svgedit||{}; (function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],K=["y","y1","cy","ry","height"],l=$.merge(["r","radius"],a);$.merge(l,K);var s,v={px:1};svgedit.units.init=function(e){s=e;e=document.createElementNS("http://www.w3.org/2000/svg","svg");document.body.appendChild(e);var f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("width","1em");f.setAttribute("height","1ex");f.setAttribute("x","1in");e.appendChild(f);f=f.getBBox();document.body.removeChild(e); e=f.x;v.em=f.width;v.ex=f.height;v["in"]=e;v.cm=e/2.54;v.mm=e/25.4;v.pt=e/72;v.pc=e/6;v["%"]=0};svgedit.units.getTypeMap=function(){return v};svgedit.units.shortFloat=function(e){var f=s.getRoundDigits();if(isNaN(e)){if($.isArray(e))return svgedit.units.shortFloat(e[0])+","+svgedit.units.shortFloat(e[1])}else return+(+e).toFixed(f);return parseFloat(e).toFixed(f)-0};svgedit.units.convertUnit=function(e,f){f=f||s.getBaseUnit();return svgedit.unit.shortFloat(e/v[f])};svgedit.units.setUnitAttr=function(e, f,k){isNaN(k)||e.getAttribute(f);e.setAttribute(f,k)};var G={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(e){var f=e.tagName,k=s.getBaseUnit();if(f=G[f])for(var n=f.length,F=0;F=0?k*n:K.indexOf(e)>=0?k*F:k*Math.sqrt(n*n+F*F)/Math.sqrt(2)}else{n=f.substr(-2);k=f.substr(0,f.length-2);return k*v[n]}};svgedit.units.isValidUnit=function(e,f,k){var n=false;if(l.indexOf(e)>=0)if(isNaN(f)){f=f.toLowerCase();$.each(v,function(A){if(!n)if(RegExp("^-?[\\d\\.]+"+A+"$").test(f))n=true})}else n=true;else if(e=="id"){e=false;try{var F=s.getElement(f); e=F==null||F===k}catch(B){}return e}else n=true;return n}})();svgedit=svgedit||{}; (function(){function a(e){if(svgedit.browser.supportsHVLineContainerBBox())try{return e.getBBox()}catch(f){}var k=$.data(e,"ref"),n=null;if(k){var F=$(k).children().clone().attr("visibility","hidden");$(G).append(F);n=F.filter("line, path")}else n=$(e).find("line, path");var B=false;if(n.length){n.each(function(){var A=this.getBBox();if(!A.width||!A.height)B=true});if(B){e=k?F:$(e).children();ret=getStrokedBBox(e)}else ret=e.getBBox()}else ret=e.getBBox();k&&F.remove();return ret}if(!svgedit.utilities)svgedit.utilities= {};var K="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),l=null,s=null,v=null,G=null;svgedit.utilities.init=function(e){l=e;s=e.getDOMDocument();v=e.getDOMContainer();G=e.getSVGRoot()};svgedit.utilities.toXml=function(e){return $("

").text(e).html()};svgedit.utilities.fromXml=function(e){return $("

").html(e).text()};svgedit.utilities.encode64=function(e){e=svgedit.utilities.convertToXMLReferences(e);if(window.btoa)return window.btoa(e); var f=Array(Math.floor((e.length+2)/3)*4),k,n,F,B,A,O,Z=0,N=0;do{k=e.charCodeAt(Z++);n=e.charCodeAt(Z++);F=e.charCodeAt(Z++);B=k>>2;k=(k&3)<<4|n>>4;A=(n&15)<<2|F>>6;O=F&63;if(isNaN(n))A=O=64;else if(isNaN(F))O=64;f[N++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(B);f[N++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(k);f[N++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(A);f[N++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(O)}while(Z< e.length);return f.join("")};svgedit.utilities.decode64=function(e){if(window.atob)return window.atob(e);var f="",k,n,F="",B,A="",O=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(O++));n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(O++));B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(O++));A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(O++)); k=k<<2|n>>4;n=(n&15)<<4|B>>2;F=(B&3)<<6|A;f+=String.fromCharCode(k);if(B!=64)f+=String.fromCharCode(n);if(A!=64)f+=String.fromCharCode(F)}while(O127)f+="&#"+n+";"}return f};svgedit.utilities.text2xml=function(e){if(e.indexOf("=0)e=e.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var f;try{var k=window.DOMParser? new DOMParser:new ActiveXObject("Microsoft.XMLDOM");k.async=false}catch(n){throw Error("XML Parser could not be instantiated");}try{f=k.loadXML?k.loadXML(e)?k:false:k.parseFromString(e,"text/xml")}catch(F){throw Error("Error parsing XML string");}return f};svgedit.utilities.bboxToObj=function(e){return{x:e.x,y:e.y,width:e.width,height:e.height}};svgedit.utilities.walkTree=function(e,f){if(e&&e.nodeType==1){f(e);for(var k=e.childNodes.length;k--;)svgedit.utilities.walkTree(e.childNodes.item(k),f)}}; svgedit.utilities.walkTreePost=function(e,f){if(e&&e.nodeType==1){for(var k=e.childNodes.length;k--;)svgedit.utilities.walkTree(e.childNodes.item(k),f);f(e)}};svgedit.utilities.getUrlFromAttr=function(e){if(e)if(e.indexOf('url("')===0)return e.substring(5,e.indexOf('"',6));else if(e.indexOf("url('")===0)return e.substring(5,e.indexOf("'",6));else if(e.indexOf("url(")===0)return e.substring(4,e.indexOf(")"));return null};svgedit.utilities.getHref=function(e){return e.getAttributeNS("http://www.w3.org/1999/xlink", "href")};svgedit.utilities.setHref=function(e,f){e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f)};svgedit.utilities.findDefs=function(e){e=l.getSVGContent().documentElement;var f=e.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return f=f.length>0?f[0]:e.insertBefore(e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),e.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(e){var f=e.pathSegList,k=f.numberOfItems;e=[[],[]];var n=f.getItem(0), F=[n.x,n.y];for(n=0;n= 0){var n=k.split(":");e[n[1]]=K[n[0]]}else e[k]=k=="xmlns"?"http://www.w3.org/2000/xmlns/":null});s[v]=e});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(v){if(v.nodeType==3){v.nodeValue=v.nodeValue.replace(/^\s+|\s+$/g,"");v.nodeValue.length||v.parentNode.removeChild(v)}if(v.nodeType==1){var G=v.parentNode;if(v.ownerDocument&&G){var e=l[v.nodeName],f=s[v.nodeName];if(e!=undefined){for(var k=[],n=v.attributes.length;n--;){var F=v.attributes.item(n),B=F.nodeName, A=F.localName,O=F.namespaceURI;if(!(f.hasOwnProperty(A)&&O==f[A]&&O!="http://www.w3.org/2000/xmlns/")&&!(O=="http://www.w3.org/2000/xmlns/"&&a[F.nodeValue])){B.indexOf("se:")==0&&k.push([B,F.nodeValue]);v.removeAttributeNS(O,A)}if(svgedit.browser.isGecko())switch(B){case "transform":case "gradientTransform":case "patternTransform":A=F.nodeValue.replace(/(\d)-/g,"$1 -");v.setAttribute(B,A)}if(B=="style"){F=F.nodeValue.split(";");for(B=F.length;B--;){A=F[B].split(":");e.indexOf(A[0])>=0&&v.setAttribute(A[0], A[1])}v.removeAttribute("style")}}$.each(k,function(Z,N){v.setAttributeNS("http://svg-edit.googlecode.com",N[0],N[1])});if((n=svgedit.utilities.getHref(v))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(v.nodeName)>=0)if(n[0]!="#"){svgedit.utilities.setHref(v,"");v.removeAttributeNS("http://www.w3.org/1999/xlink","href")}if(v.nodeName=="use"&&!svgedit.utilities.getHref(v))G.removeChild(v);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start", "mask","stroke"],function(Z,N){var L=v.getAttribute(N);if(L)if((L=svgedit.utilities.getUrlFromAttr(L))&&L[0]!=="#"){v.setAttribute(N,"");v.removeAttribute(N)}});for(n=v.childNodes.length;n--;)svgedit.sanitize.sanitizeSvg(v.childNodes.item(n))}}else{for(e=[];v.hasChildNodes();)e.push(G.insertBefore(v.firstChild,v));G.removeChild(v);for(n=e.length;n--;)svgedit.sanitize.sanitizeSvg(e[n])}}}}})();svgedit=svgedit||{}; (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,K,l,s){this.elem=a;this.text=s?"Move "+a.tagName+" to "+s:"Move "+a.tagName;this.oldNextSibling=K;this.oldParent=l;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,K){this.elem=a;this.text=K||"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,K,l,s){this.elem=a;this.text=s||"Delete "+a.tagName;this.nextSibling=K;this.parent=l;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,K,l){this.elem=a;this.text=l?"Change "+a.tagName+" "+l:"Change "+a.tagName;this.newValues={};this.oldValues=K;for(var s in K)this.newValues[s]=s=="#text"?a.textContent:s=="#href"?svgedit.utilities.getHref(a):a.getAttribute(s)};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 K=false,l;for(l in this.newValues){if(this.newValues[l])if(l=="#text")this.elem.textContent=this.newValues[l];else l=="#href"?svgedit.utilities.setHref(this.elem,this.newValues[l]):this.elem.setAttribute(l,this.newValues[l]);else if(l=="#text")this.elem.textContent="";else{this.elem.setAttribute(l,"");this.elem.removeAttribute(l)}if(l== "transform")K=true}if(!K)if(K=svgedit.utilities.getRotationAngle(this.elem)){l=elem.getBBox();K=["rotate(",K," ",l.x+l.width/2,",",l.y+l.height/2,")"].join("");K!=elem.getAttribute("transform")&&elem.setAttribute("transform",K)}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 K=false,l;for(l in this.oldValues){if(this.oldValues[l])if(l== "#text")this.elem.textContent=this.oldValues[l];else l=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[l]):this.elem.setAttribute(l,this.oldValues[l]);else if(l=="#text")this.elem.textContent="";else this.elem.removeAttribute(l);if(l=="transform")K=true}if(!K)if(K=svgedit.utilities.getRotationAngle(this.elem)){l=elem.getBBox();K=["rotate(",K," ",l.x+l.width/2,",",l.y+l.height/2,")"].join("");K!=elem.getAttribute("transform")&&elem.setAttribute("transform",K)}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);for(var K=this.stack.length,l=0;l=0;K--)this.stack[K].unapply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY, this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],K=this.stack.length;K--;)for(var l=this.stack[K].elements(),s=l.length;s--;)a.indexOf(l[s])==-1&&a.push(l[s]);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,K){for(var l=++this.undoChangeStackPointer,s=K.length,v=Array(s),G=Array(s);s--;){var e=K[s];if(e!=null){G[s]=e;v[s]=e.getAttribute(a)}}this.undoableChangeStack[l]= {attrName:a,oldValues:v,elements:G}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,K=this.undoableChangeStack[a],l=K.elements.length,s=K.attrName,v=new svgedit.history.BatchCommand("Change "+s);l--;){var G=K.elements[l];if(G!=null){var e={};e[s]=K.oldValues[l];e[s]!=G.getAttribute(s)&&v.addSubCommand(new svgedit.history.ChangeElementCommand(G,e,s))}}this.undoableChangeStack[a]=null;return v}})();svgedit=svgedit||{}; (function(){if(!svgedit.select)svgedit.select={};var a,K,l,s;svgedit.browser.isTouch()?s=10:s=4;svgedit.select.Selector=function(v,G){this.id=v;this.selectedElement=G;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#22C","stroke-width":"1","stroke-dasharray":"5,5",style:"pointer-events:none"}}));this.gripCoords= {nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(v){this.locked=true;this.selectedElement=v;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(v){var G=[];v=Math.round(v/45);if(v<0)v+=8;for(var e in l.selectorGrips)G.push(e);for(;v>0;){G.push(G.shift());v--}v=0;for(e in l.selectorGrips){l.selectorGrips[e].setAttribute("style", "cursor:"+G[v]+"-resize");v++}};svgedit.select.Selector.prototype.showGrips=function(v){l.selectorGripsGroup.setAttribute("display",v?"inline":"none");var G=this.selectedElement;this.hasGrips=v;if(G&&v){this.selectorGroup.appendChild(l.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(G))}};svgedit.select.Selector.prototype.resize=function(){var v=this.selectorRect,G=l,e=G.selectorGrips,f=this.selectedElement,k=f.getAttribute("stroke-width"),n=a.currentZoom(),F=1/n;if(f.getAttribute("stroke")!== "none"&&!isNaN(k))F+=k/2;var B=f.tagName;if(B==="text")F+=2/n;k=svgedit.transformlist.getTransformList(f);k=svgedit.math.transformListToTransform(k).matrix;k.e*=n;k.f*=n;var A=svgedit.utilities.getBBox(f);if(B==="g"&&!$.data(f,"gsvg"))if(B=a.getStrokedBBox(f.childNodes))A=B;B=A.x;var O=A.y,Z=A.width;A=A.height;F*=n;n=svgedit.math.transformBox(B*n,O*n,Z*n,A*n,k);k=n.aabox;B=k.x-F;O=k.y-F;Z=k.width+F*2;var N=k.height+F*2;k=B+Z/2;A=O+N/2;if(f=svgedit.utilities.getRotationAngle(f)){B=a.svgRoot().createSVGTransform(); B.setRotate(-f,k,A);B=B.matrix;n.tl=svgedit.math.transformPoint(n.tl.x,n.tl.y,B);n.tr=svgedit.math.transformPoint(n.tr.x,n.tr.y,B);n.bl=svgedit.math.transformPoint(n.bl.x,n.bl.y,B);n.br=svgedit.math.transformPoint(n.br.x,n.br.y,B);B=n.tl;Z=B.x;N=B.y;var L=B.x,na=B.y;B=Math.min;O=Math.max;Z=B(Z,B(n.tr.x,B(n.bl.x,n.br.x)))-F;N=B(N,B(n.tr.y,B(n.bl.y,n.br.y)))-F;L=O(L,O(n.tr.x,O(n.bl.x,n.br.x)))+F;na=O(na,O(n.tr.y,O(n.bl.y,n.br.y)))+F;B=Z;O=N;Z=L-Z;N=na-N}F=a.svgRoot().suspendRedraw(100);v.setAttribute("d", "M"+B+","+O+" L"+(B+Z)+","+O+" "+(B+Z)+","+(O+N)+" "+B+","+(O+N)+"z");this.selectorGroup.setAttribute("transform",f?"rotate("+[f,k,A].join(",")+")":"");this.gripCoords={nw:[B,O],ne:[B+Z,O],sw:[B,O+N],se:[B+Z,O+N],n:[B+Z/2,O],w:[B,O+N/2],e:[B+Z,O+N/2],s:[B+Z/2,O+N]};for(var ca in this.gripCoords){v=this.gripCoords[ca];e[ca].setAttribute("cx",v[0]);e[ca].setAttribute("cy",v[1])}G.rotateGripConnector.setAttribute("x1",B+Z/2);G.rotateGripConnector.setAttribute("y1",O);G.rotateGripConnector.setAttribute("x2", B+Z/2);G.rotateGripConnector.setAttribute("y2",O-s*5);G.rotateGrip.setAttribute("cx",B+Z/2);G.rotateGrip.setAttribute("cy",O-s*5);a.svgRoot().unsuspendRedraw(F)};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 v in this.selectorGrips){var G= a.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+v,fill:"#22C",r:s,style:"cursor:"+v+"-resize","stroke-width":2,"pointer-events":"all"}});$.data(G,"dir",v);$.data(G,"type","resize");this.selectorGrips[v]=this.selectorGripsGroup.appendChild(G)}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:s,stroke:"#22C","stroke-width":2,style:"cursor:url("+K.imgPath+"rotate.png) 12 12, auto;"}}));$.data(this.rotateGrip,"type","rotate");if(!$("#canvasBackground").length){v=K.dimensions;v=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:v[0],height:v[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});G=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1, stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});v.appendChild(G);a.svgRoot().insertBefore(v,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(v){if(v==null)return null;var G=this.selectors.length;if(typeof this.selectorMap[v.id]=="object"){this.selectorMap[v.id].locked=true;return this.selectorMap[v.id]}for(var e=0;e element";this.svgElem_=s;this.obj_num=0;this.idPrefix=v||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_= "";var G=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(G&&l!=K.NEVER_RANDOMIZE)this.nonce_=G;else l==K.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(s){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+s):$(this.svgElem_).find("[id="+s+"]")[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(s){this.svgElem_.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:se","http://svg-edit.googlecode.com");this.svgElem_.setAttributeNS("http://svg-edit.googlecode.com","se:nonce",s);this.nonce_=s};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 s= this.obj_num,v=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();v=true}else this.obj_num++;for(var G=this.getId();this.getElem_(G);){if(v){this.obj_num=s;v=false}this.obj_num++;G=this.getId()}if(v)this.obj_num=s;return G};svgedit.draw.Drawing.prototype.releaseId=function(s){var v=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof s!="string"||s.indexOf(v)!=0)return false;s=parseInt(s.substr(v.length));if(typeof s!="number"||s<=0||this.releasedNums.indexOf(s)!=-1)return false; this.releasedNums.push(s);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length};svgedit.draw.Drawing.prototype.hasLayer=function(s){for(var v=0;v=0&&s1){var s=this.current_layer.parentNode.removeChild(this.current_layer);this.identifyLayers();return s}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];for(var s=this.svgElem_.childNodes.length,v=[],G=[],e=null,f=false,k=0;k0||!f){for(k=1;G.indexOf("Layer "+k)>=0;)k++;G="Layer "+k;e=s.createElementNS("http://www.w3.org/2000/svg","g");f=s.createElementNS("http://www.w3.org/2000/svg","title");f.textContent=G; e.appendChild(f);for(f=0;f1))for(var G=0;G0){f=Z element";this.elem=f;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 f=this.elem.pathSegList,k=f.numberOfItems; this.segs=[];this.selected_pts=[];this.first_seg=null;for(var n=0;n=k?null:f[n+1],O=n-1<0?null:f[n-1];if(B.type===2){if(O&&O.type!==1){A=f[F];A.next=f[F+1];A.next.prev=A;A.addGrip()}F=n}else if(A&&A.type===1){B.next=f[F+1];B.next.prev=B;B.mate=f[F];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(A){if(B.type!==1){B.addGrip();if(A&&A.type!==2){B.next= A;B.next.prev=B}}}else if(B.type!==1){A=f[F];A.next=f[F+1];A.next.prev=A;A.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=f[F]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var k=this.segs.length,n=0;n').documentElement, true);a.appendChild(k);var n=f.createElementNS(s,"svg");(e.clearSvgContentElement=function(){for(;n.firstChild;)n.removeChild(n.firstChild);$(n).attr({id:"svgcontent",width:G[0],height:G[1],x:G[0],y:G[1],overflow:v.show_outside_canvas?"visible":"hidden",xmlns:s,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(k);var b=f.createComment(" Created with SVG-edit - http://svg-edit.googlecode.com/ ");n.appendChild(b)})();var F="svg_";e.setIdPrefix=function(b){F= b};e.current_drawing_=new svgedit.draw.Drawing(n,F);var B=e.getCurrentDrawing=function(){return e.current_drawing_},A=1,O=null,Z={shape:{fill:(v.initFill.color=="none"?"":"#")+v.initFill.color,fill_paint:null,fill_opacity:v.initFill.opacity,stroke:"#"+v.initStroke.color,stroke_paint:null,stroke_opacity:v.initStroke.opacity,stroke_width:v.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:v.initOpacity}};Z.text=$.extend(true,{},Z.shape);$.extend(Z.text,{fill:"#000000", stroke_width:0,font_size:24,font_family:"serif"});var N=Z.shape,L=Array(1),na=this.addSvgElementFromJson=function(b){var c=svgedit.utilities.getElem(b.attr.id),d=B().getCurrentLayer();if(c&&b.element!=c.tagName){d.removeChild(c);c=null}if(!c){c=f.createElementNS(s,b.element);if(d)(O||d).appendChild(c)}b.curStyles&&svgedit.utilities.assignAttributes(c,{fill:N.fill,stroke:N.stroke,"stroke-width":N.stroke_width,"stroke-dasharray":N.stroke_dasharray,"stroke-linejoin":N.stroke_linejoin,"stroke-linecap":N.stroke_linecap, "stroke-opacity":N.stroke_opacity,"fill-opacity":N.fill_opacity,opacity:N.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(c,b.attr,100);svgedit.utilities.cleanupElement(c);return c},ca=e.getTransformList=svgedit.transformlist.getTransformList,oa=svgedit.math.transformPoint,pa=e.matrixMultiply=svgedit.math.matrixMultiply,ia=e.hasMatrixTransform=svgedit.math.hasMatrixTransform,da=e.transformListToTransform=svgedit.math.transformListToTransform,Ya=svgedit.math.snapToAngle, kb=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return v.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return n.getAttribute("height")/A},getWidth:function(){return n.getAttribute("width")/A},getRoundDigits:function(){return Na.round_digits}});var ba=e.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return k},getSelectedElements:function(){return L}, getSVGContent:function(){return n}});var sb=e.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,ib=e.getHref=svgedit.utilities.getHref,lb=e.setHref=svgedit.utilities.setHref,Tb=svgedit.utilities.getPathBBox;e.getBBox=svgedit.utilities.getBBox;var bb=e.getRotationAngle=svgedit.utilities.getRotationAngle,va=e.getElem=svgedit.utilities.getElem,Ga=e.assignAttributes=svgedit.utilities.assignAttributes,Oa=this.cleanupElement=svgedit.utilities.cleanupElement,hb=svgedit.sanitize.getNSMap(),ja=e.sanitizeSvg= svgedit.sanitize.sanitizeSvg,Ca=svgedit.history.MoveElementCommand,Ha=svgedit.history.InsertElementCommand,Pa=svgedit.history.RemoveElementCommand,Ia=svgedit.history.ChangeElementCommand,ua=svgedit.history.BatchCommand;e.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(b,c){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 m=c.elements();e.pathActions.clear();ha("changed",m);m= c.type();d=b==d.AFTER_APPLY;if(m==Ca.type())(d?c.newParent:c.oldParent)==n&&e.identifyLayers();else if(m==Ha.type()||m==Pa.type()){c.parent==n&&e.identifyLayers();if(m==Ha.type())d&&tb(c.elem);else d||tb(c.elem);c.elem.tagName==="use"&&Gb(c.elem)}else if(m==Ia.type()){c.elem.tagName=="title"&&c.elem.parentNode.parentNode==n&&e.identifyLayers();d=d?c.newValues:c.oldValues;d.stdDeviation&&e.setBlurOffsets(c.elem.parentNode,d.stdDeviation)}}}});var ma=function(b){e.undoMgr.addCommandToHistory(b)};svgedit.select.init(v, {createSVGElement:function(b){return e.addSvgElementFromJson(b)},svgRoot:function(){return k},svgContent:function(){return n},currentZoom:function(){return A},getStrokedBBox:function(b){return e.getStrokedBBox([b])}});var ra=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return A},getSVGRoot:function(){return k}});svgedit.utilities.snapToGrid=function(b){var c=v.snappingStep,d=v.baseUnit;if(d!=="px")c*=svgedit.units.getTypeMap()[d];return b=Math.round(b/ c)*c};var la=svgedit.utilities.snapToGrid,ub={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"},Hb=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],Ab=$.data,Ib=document.createElementNS(s,"animate");$(Ib).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(k);var tb=function(b){var c= $(b).attr(Hb),d;for(d in c){var m=c[d];if(m&&m.indexOf("url(")===0){m=sb(m).substr(1);if(!va(m)){Xa().appendChild(Ub[m]);delete Ub[m]}}}b=b.getElementsByTagName("*");if(b.length){c=0;for(d=b.length;c=0)u=t=e.convertToPath(w,true);else if(w.tagName=="rect"){var C=w.getAttribute("rx"),E=w.getAttribute("ry");if(C||E)u=t=e.convertToPath(w,true)}if(!t){var H=w.cloneNode(true),I=document.createElementNS(s,"g"),P=w.parentNode;P.appendChild(I);I.appendChild(H);u=svgedit.utilities.bboxToObj(I.getBBox());P.removeChild(I)}}return u}catch(W){console.log(w,W);return null}},d;$.each(b,function(){if(!d)if(this.parentNode)d=c(this)}); if(d==null)return null;var m=d.x+d.width,i=d.y+d.height,z=d.x,o=d.y,h=function(w){var u=w.getAttribute("stroke-width"),t=0;if(w.getAttribute("stroke")!="none"&&!isNaN(u))t+=u/2;return t},q=[];$.each(b,function(w,u){var t=c(u);if(t){var C=h(u);z=Math.min(z,t.x-C);o=Math.min(o,t.y-C);q.push(t)}});d.x=z;d.y=o;$.each(b,function(w,u){var t=q[w];if(t&&u.nodeType==1){var C=h(u);m=Math.max(m,t.x+t.width+C);i=Math.max(i,t.y+t.height+C)}});d.width=m-z;d.height=i-o;return d};var Lb=this.getVisibleElements=function(b){b|| (b=$(n).children());var c=[];$(b).children().each(function(d,m){try{m.getBBox()&&c.push(m)}catch(i){}});return c.reverse()},jc=this.getVisibleElementsAndBBoxes=function(b){b||(b=$(n).children());var c=[];$(b).children().each(function(d,m){try{m.getBBox()&&c.push({elem:m,bbox:getStrokedBBox([m])})}catch(i){}});return c.reverse()},cc=this.groupSvgElem=function(b){var c=document.createElementNS(s,"g");b.parentNode.replaceChild(c,b);$(c).append(b).data("gsvg",b)[0].id=Fa()},vb=function(b){var c=document.createElementNS(b.namespaceURI, b.nodeName);$.each(b.attributes,function(m,i){i.localName!="-moz-math-font-style"&&c.setAttributeNS(i.namespaceURI,i.nodeName,i.nodeValue)});c.removeAttribute("id");c.id=Fa();if(svgedit.browser.isWebkit()&&b.nodeName=="path"){var d=qa.convertPath(b);c.setAttribute("d",d)}$.each(b.childNodes,function(m,i){switch(i.nodeType){case 1:c.appendChild(vb(i));break;case 3:c.textContent=i.nodeValue}});if($(b).data("gsvg"))$(c).data("gsvg",c.firstChild);else if($(b).data("symbol")){b=$(b).data("symbol");$(c).data("ref", b).data("symbol",b)}else c.tagName=="image"&&Mb(c);return c},db,Fa,ha;(function(b){var c={};db=b.getId=function(){return B().getId()};Fa=b.getNextId=function(){return B().getNextId()};ha=b.call=function(d,m){if(c[d])return c[d](this,m)};b.bind=function(d,m){var i=c[d];c[d]=m;return i}})(e);this.prepareSvg=function(b){this.sanitizeSvg(b.documentElement);b=b.getElementsByTagNameNS(s,"path");for(var c=0,d=b.length;c0&&i.getItem(0).type==4&&i.removeItem(0);if(b!=0){z=oa(z,o,da(i).matrix); o=k.createSVGTransform();o.setRotate(b,z.x,z.y);i.numberOfItems?i.insertItemBefore(o,0):i.appendItem(o)}else i.numberOfItems==0&&d.removeAttribute("transform");if(!c){i=d.getAttribute("transform");d.setAttribute("transform",m);Va("transform",i,L);ha("changed",L)}va("pathpointgrip_container");d=ra.requestSelector(L[0]);d.resize();d.updateGripCursors(b)};var Ob=this.recalculateAllSelectedDimensions=function(){for(var b=new ua(cb=="none"?"position":"size"),c=L.length;c--;){var d=Ta(L[c]);d&&b.addSubCommand(d)}if(!b.isEmpty()){ma(b); ha("changed",L)}},Xb=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],kc=function(b){console.log([b.a,b.b,b.c,b.d,b.e,b.f])},Fb=this.remapElement=function(b,c,d){var m=v.gridSnapping&&b.parentNode.parentNode.localName==="svg",i=function(){if(m)for(var t in c)c[t]=la(c[t]);Ga(b,c,1E3,true)};box=svgedit.utilities.getBBox(b);for(var z=0;z<2;z++){var o=z===0?"fill":"stroke",h=b.getAttribute(o);if(h&&h.indexOf("url(")===0)if(d.a<0||d.d<0){h=rb(h).cloneNode(true);if(d.a<0){var q= h.getAttribute("x1"),w=h.getAttribute("x2");h.setAttribute("x1",-(q-1));h.setAttribute("x2",-(w-1))}if(d.d<0){q=h.getAttribute("y1");w=h.getAttribute("y2");h.setAttribute("y1",-(q-1));h.setAttribute("y2",-(w-1))}h.id=Fa();Xa().appendChild(h);b.setAttribute(o,"url(#"+h.id+")")}}z=b.tagName;if(z==="g"||z==="text"||z==="use")if(d.a==1&&d.b==0&&d.c==0&&d.d==1&&(d.e!=0||d.f!=0)){o=da(b).matrix;o=pa(o.inverse(),d,o);c.x=parseFloat(c.x)+o.e;c.y=parseFloat(c.y)+o.f}else{o=ca(b);h=k.createSVGTransform();h.setMatrix(pa(da(o).matrix, d));o.clear();o.appendItem(h)}switch(z){case "foreignObject":case "rect":case "image":if(z==="image"&&(d.a<0||d.d<0)){o=ca(b);h=k.createSVGTransform();h.setMatrix(pa(da(o).matrix,d));o.clear();o.appendItem(h)}else{o=oa(c.x,c.y,d);c.width=d.a*c.width;c.height=d.d*c.height;c.x=o.x+Math.min(0,c.width);c.y=o.y+Math.min(0,c.height);c.width=Math.abs(c.width);c.height=Math.abs(c.height)}i();break;case "ellipse":z=oa(c.cx,c.cy,d);c.cx=z.x;c.cy=z.y;c.rx=d.a*c.rx;c.ry=d.d*c.ry;c.rx=Math.abs(c.rx);c.ry=Math.abs(c.ry); i();break;case "circle":z=oa(c.cx,c.cy,d);c.cx=z.x;c.cy=z.y;d=svgedit.math.transformBox(box.x,box.y,box.width,box.height,d);c.r=Math.min((d.tr.x-d.tl.x)/2,(d.bl.y-d.tl.y)/2);if(c.r)c.r=Math.abs(c.r);i();break;case "line":o=oa(c.x1,c.y1,d);q=oa(c.x2,c.y2,d);c.x1=o.x;c.y1=o.y;c.x2=q.x;c.y2=q.y;case "text":case "use":i();break;case "g":(d=$(b).data("gsvg"))&&Ga(d,c,1E3,true);break;case "polyline":case "polygon":i=c.points.length;for(z=0;z0){for(var d=c.numberOfItems;d--;){var m=c.getItem(d);if(m.type=== 0)c.removeItem(d);else if(m.type===1)svgedit.math.isIdentity(m.matrix)&&c.removeItem(d);else m.type===4&&m.angle===0&&c.removeItem(d)}if(c.numberOfItems===1&&bb(b))return null}if(!c||c.numberOfItems==0){b.removeAttribute("transform");return null}if(c){d=c.numberOfItems;for(var i=[];d--;){m=c.getItem(d);if(m.type===1)i.push([m.matrix,d]);else if(i.length)i=[]}if(i.length===2){d=k.createSVGTransformFromMatrix(pa(i[1][0],i[0][0]));c.removeItem(i[0][1]);c.removeItem(i[1][1]);c.insertItemBefore(d,i[1][1])}d= c.numberOfItems;if(d>=2&&c.getItem(d-2).type===1&&c.getItem(d-1).type===2){i=k.createSVGTransform();m=pa(c.getItem(d-2).matrix,c.getItem(d-1).matrix);i.setMatrix(m);c.removeItem(d-2);c.removeItem(d-2);c.appendItem(i)}}switch(b.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(c.numberOfItems===1&&c.getItem(0).type===1||c.numberOfItems===2&&c.getItem(0).type===1&&c.getItem(0).type===4)return null}var z=$(b).data("gsvg");d=new ua("Transform");var o={},h=null;m=[];switch(b.tagName){case "line":m= ["x1","y1","x2","y2"];break;case "circle":m=["cx","cy","r"];break;case "ellipse":m=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":m=["width","height","x","y"];break;case "use":case "text":m=["x","y"];break;case "polygon":case "polyline":h={};h.points=b.getAttribute("points");i=b.points;var q=i.numberOfItems;o.points=Array(q);for(var w=0;w1.0E-10?Math.sin(w)/(1-Math.cos(w)):2/w;for(w=0;w=3&&c.getItem(E-2).type==3&&c.getItem(E-3).type==2&&c.getItem(E-1).type==2){w=3;var I=c.getItem(E-3).matrix,P=c.getItem(E-2).matrix,W=c.getItem(E-1).matrix;q=b.childNodes;for(u=q.length;u--;){var Y=q.item(u);m=z=0;if(Y.nodeType==1){var R=ca(Y);if(R){m=da(R).matrix;z=bb(Y);var T=Qa,V=[];Qa=Y.getAttribute("transform");if(z||ia(R)){var aa= k.createSVGTransform();aa.setMatrix(pa(I,P,W,m));R.clear();R.appendItem(aa);V.push(aa)}else{z=pa(m.inverse(),W,m);aa=k.createSVGMatrix();aa.e=-z.e;aa.f=-z.f;m=pa(aa.inverse(),m.inverse(),I,P,W,m,z.inverse());var Ja=k.createSVGTransform(),Za=k.createSVGTransform(),mb=k.createSVGTransform();Ja.setTranslate(z.e,z.f);Za.setScale(m.a,m.d);mb.setTranslate(aa.e,aa.f);R.appendItem(mb);R.appendItem(Za);R.appendItem(Ja);V.push(mb);V.push(Za);V.push(Ja)}d.addSubCommand(Ta(Y));Qa=T}}}c.removeItem(E-1);c.removeItem(E- 2);c.removeItem(E-3)}else if(E>=3&&c.getItem(E-1).type==1){w=3;m=da(c).matrix;aa=k.createSVGTransform();aa.setMatrix(m);c.clear();c.appendItem(aa)}else if((E==1||E>1&&c.getItem(1).type!=3)&&c.getItem(0).type==2){w=2;z=da(c).matrix;c.removeItem(0);m=da(c).matrix.inverse();m=pa(m,z);z=m.e;m=m.f;if(z!=0||m!=0){q=b.childNodes;u=q.length;for(E=[];u--;){Y=q.item(u);if(Y.nodeType==1){if(Y.getAttribute("clip-path")){T=Y.getAttribute("clip-path");if(E.indexOf(T)===-1){dc(T,z,m);E.push(T)}}T=Qa;Qa=Y.getAttribute("transform"); if(R=ca(Y)){I=k.createSVGTransform();I.setTranslate(z,m);R.numberOfItems?R.insertItemBefore(I,0):R.appendItem(I);d.addSubCommand(Ta(Y));R=b.getElementsByTagNameNS(s,"use");Y="#"+Y.id;for(I=R.length;I--;){P=R.item(I);if(Y==ib(P)){W=k.createSVGTransform();W.setTranslate(-z,-m);ca(P).insertItemBefore(W,0);d.addSubCommand(Ta(P))}}Qa=T}}}E=[];Qa=T}}else if(E==1&&c.getItem(0).type==1&&!i){w=1;m=c.getItem(0).matrix;q=b.childNodes;for(u=q.length;u--;){Y=q.item(u);if(Y.nodeType==1){T=Qa;Qa=Y.getAttribute("transform"); if(R=ca(Y)){z=pa(m,da(R).matrix);E=k.createSVGTransform();E.setMatrix(z);R.clear();R.appendItem(E,0);d.addSubCommand(Ta(Y));Qa=T;T=Y.getAttribute("stroke-width");Y.getAttribute("stroke")!=="none"&&!isNaN(T)&&Y.setAttribute("stroke-width",T*((Math.abs(z.a)+Math.abs(z.d))/2))}}}c.clear()}else{if(i){t=k.createSVGTransform();t.setRotate(i,C.x,C.y);c.numberOfItems?c.insertItemBefore(t,0):c.appendItem(t)}c.numberOfItems==0&&b.removeAttribute("transform");return null}if(w==2){if(i){C={x:t.x+H.e,y:t.y+H.f}; t=k.createSVGTransform();t.setRotate(i,C.x,C.y);c.numberOfItems?c.insertItemBefore(t,0):c.appendItem(t)}}else if(w==3){m=da(c).matrix;H=k.createSVGTransform();H.setRotate(i,t.x,t.y);H=H.matrix;t=k.createSVGTransform();t.setRotate(i,C.x,C.y);C=t.matrix.inverse();T=m.inverse();C=pa(T,C,H,m);z=C.e;m=C.f;if(z!=0||m!=0){q=b.childNodes;for(u=q.length;u--;){Y=q.item(u);if(Y.nodeType==1){T=Qa;Qa=Y.getAttribute("transform");R=ca(Y);I=k.createSVGTransform();I.setTranslate(z,m);R.numberOfItems?R.insertItemBefore(I, 0):R.appendItem(I);d.addSubCommand(Ta(Y));Qa=T}}}if(i)c.numberOfItems?c.insertItemBefore(t,0):c.appendItem(t)}}else{i=svgedit.utilities.getBBox(b);if(!i&&b.tagName!="path")return null;m=k.createSVGMatrix();if(z=bb(b)){t={x:i.x+i.width/2,y:i.y+i.height/2};C=oa(i.x+i.width/2,i.y+i.height/2,da(c).matrix);w=z*Math.PI/180;q=Math.abs(w)>1.0E-10?Math.sin(w)/(1-Math.cos(w)):2/w;for(w=0;w=3&&c.getItem(E-2).type==3&&c.getItem(E-3).type==2&&c.getItem(E-1).type==2){w=3;m=da(c,E-3,E-1).matrix;c.removeItem(E-1);c.removeItem(E-2);c.removeItem(E-3)}else if(E== 4&&c.getItem(E-1).type==1){w=3;m=da(c).matrix;aa=k.createSVGTransform();aa.setMatrix(m);c.clear();c.appendItem(aa);m=k.createSVGMatrix()}else if((E==1||E>1&&c.getItem(1).type!=3)&&c.getItem(0).type==2){w=2;H=c.getItem(0).matrix;T=da(c,1).matrix;i=T.inverse();m=pa(i,H,T);c.removeItem(0)}else if(E==1&&c.getItem(0).type==1&&!z){m=da(c).matrix;switch(b.tagName){case "line":o=$(b).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":o.points=b.getAttribute("points");if(o.points){i=b.points;q=i.numberOfItems; o.points=Array(q);for(w=0;w1&&i.showGrips(false)}}}ha("selected",L);c||L.length==1?ra.requestSelector(L[0]).showGrips(true):ra.requestSelector(L[0]).showGrips(false);for(L.sort(function(z,o){if(z&&o&&z.compareDocumentPosition)return 3- (o.compareDocumentPosition(z)&6);else if(z==null)return 1});L[0]==null;)L.shift(0)}},Wa=this.selectOnly=function(b,c){za(true);gb(b,c)};this.removeFromSelection=function(b){if(L[0]!=null)if(b.length!=0){var c=Array(L.length);j=0;len=L.length;for(var d=0;d=0&&b.id!="svgcanvas")for(;b.nodeName!="foreignObject";){b=b.parentNode;if(!b)return k}var c=B().getCurrentLayer();if([k,a,n,c].indexOf(b)>=0)return k;if($(b).closest("#selectorParentGroup").length)return ra.selectorParentGroup;for(;b.parentNode!==(O||c);)b=b.parentNode;return b};(function(){var b=null,c=null,d=null,m= null,i=null,z={},o={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(h){if(!(e.spaceKey||h.button===1)){var q=h.button===2;h.altKey&&svgCanvas.cloneSelectedElements(0,0);nb=$('#svgcontent g')[0].getScreenCTM().inverse();var w=oa(h.pageX,h.pageY,nb),u=w.x*A,t=w.y*A;h.preventDefault();if(q){sa="select";Vb=w}w=u/A;t=t/A;var C=Pb(h);if(C.tagName==="a"&&C.childNodes.length===1)C=C.firstChild;u=m=c=w;var E=i=d=t;if(v.gridSnapping){w=la(w);t=la(t);c=la(c);d=la(d)}if(C==ra.selectorParentGroup&&L[0]!=null){C= h.target;var H=Ab(C,"type");if(H=="rotate")sa="rotate";else if(H=="resize"){sa="resize";cb=Ab(C,"dir")}C=L[0]}Qa=C.getAttribute("transform");H=ca(C);switch(sa){case "select":xa=true;cb="none";if(q)xa=false;if(C!=k){if(L.indexOf(C)==-1){h.shiftKey||za(true);gb([C]);La=C;qa.clear()}if(!q)for(q=0;q0&&e.removeFromSelection(t);C.length>0&&gb(C);break;case "resize":t=ca(q);H=(I=ia(t))?z:svgedit.utilities.getBBox(q);E=H.x;P=H.y;var W=H.width,Y=H.height;C=x-c;H=y-d;if(v.gridSnapping){C=la(C);H=la(H);Y=la(Y);W=la(W)}var R=bb(q);if(R){var T=Math.sqrt(C*C+H*H);H=Math.atan2(H,C)-R*Math.PI/180;C=T*Math.cos(H);H=T*Math.sin(H)}if(cb.indexOf("n")==-1&&cb.indexOf("s")==-1)H=0;if(cb.indexOf("e")==-1&&cb.indexOf("w")==-1)C=0;var V=T=0,aa=Y?(Y+H)/Y:1,Ja=W?(W+C)/W:1;if(cb.indexOf("n")>= 0){aa=Y?(Y-H)/Y:1;V=Y}if(cb.indexOf("w")>=0){Ja=W?(W-C)/W:1;T=W}C=k.createSVGTransform();H=k.createSVGTransform();W=k.createSVGTransform();if(v.gridSnapping){E=la(E);T=la(T);P=la(P);V=la(V)}C.setTranslate(-(E+T),-(P+V));if(h.shiftKey)if(Ja==1)Ja=aa;else aa=Ja;H.setScale(Ja,aa);W.setTranslate(E+T,P+V);if(I){I=R?1:0;t.replaceItem(C,2+I);t.replaceItem(H,1+I);t.replaceItem(W,0+I)}else{I=t.numberOfItems;t.replaceItem(W,I-3);t.replaceItem(H,I-2);t.replaceItem(C,I-1)}ra.requestSelector(q).resize();ha("transition", L);break;case "zoom":C*=A;E*=A;Ga(wa,{x:Math.min(m*A,C),y:Math.min(i*A,E),width:Math.abs(C-m*A),height:Math.abs(E-i*A)},100);break;case "text":Ga(t,{x:x,y:y},1E3);break;case "line":E=null;window.opera||k.suspendRedraw(1E3);if(v.gridSnapping){x=la(x);y=la(y)}C=x;I=y;if(h.shiftKey){I=Ya(c,d,C,I);C=I.x;I=I.y}t.setAttributeNS(null,"x2",C);t.setAttributeNS(null,"y2",I);window.opera||k.unsuspendRedraw(E);break;case "foreignObject":case "square":case "rect":case "image":C=Math.abs(x-c);I=Math.abs(y-d);if(sa== "square"||h.shiftKey){C=I=Math.max(C,I);E=c=0?q.indexOf(",", t+1)>=0:q.indexOf(" ",q.indexOf(" ")+1)>=0)E=qa.smoothPolylineIntoPath(E);break;case "line":q=$(E).attr(["x1","x2","y1","y2"]);H=q.x1!=q.x2||q.y1!=q.y2;break;case "foreignObject":case "square":case "rect":case "image":q=$(E).attr(["width","height"]);H=q.width!=0||q.height!=0||sa==="image";break;case "circle":H=E.getAttribute("r")!=0;break;case "ellipse":q=$(E).attr(["rx","ry"]);H=q.rx!=null||q.ry!=null;break;case "fhellipse":if(o.maxx-o.minx>0&&o.maxy-o.miny>0){E=na({element:"ellipse",curStyles:true, attr:{cx:(o.minx+o.maxx)/2,cy:(o.miny+o.maxy)/2,rx:(o.maxx-o.minx)/2,ry:(o.maxy-o.miny)/2,id:db()}});ha("changed",[E]);H=true}break;case "fhrect":if(o.maxx-o.minx>0&&o.maxy-o.miny>0){E=na({element:"rect",curStyles:true,attr:{x:o.minx,y:o.miny,width:o.maxx-o.minx,height:o.maxy-o.miny,id:db()}});ha("changed",[E]);H=true}break;case "text":H=true;Wa([E]);Ra.start(E);break;case "path":E=null;xa=true;q=qa.mouseUp(h,E,u,w);E=q.element;H=q.keep;break;case "pathedit":H=true;E=null;qa.mouseUp(h);break;case "textedit":H= false;E=null;Ra.mouseUp(h,u,w);break;case "rotate":H=true;E=null;sa="select";q=e.undoMgr.finishUndoableChange();q.isEmpty()||ma(q);Ob();ha("changed",L)}u=Db("mouseUp",{event:h,mouse_x:u,mouse_y:w},true);$.each(u,function(W,Y){if(Y){H=Y.keep||H;E=Y.element;xa=Y.started||xa}});if(!H&&E!=null){B().releaseId(db());E.parentNode.removeChild(E);E=null;for(u=h.target;u.parentNode.parentNode.tagName=="g";)u=u.parentNode;if((sa!="path"||!drawn_path)&&u.parentNode.id!="selectorParentGroup"&&u.id!="svgcanvas"&& u.id!="svgroot"){e.setMode("select");Wa([u],true)}}else if(E!=null){e.addedNew=true;h=0.2;var I;if(Ib.beginElement&&E.getAttribute("opacity")!=N.opacity){I=$(Ib).clone().attr({to:N.opacity,dur:h}).appendTo(E);try{I[0].beginElement()}catch(P){}}else h=0;setTimeout(function(){I&&I.remove();E.setAttribute("opacity",N.opacity);E.setAttribute("style","pointer-events:inherit");Oa(E);if(sa==="path")qa.toEditMode(E);else v.selectNew&&Wa([E],true);ma(new Ha(E));ha("changed",[E])},h*1E3)}Qa=null}}});$(a).bind("mousewheel DOMMouseScroll", function(h){if(h.shiftKey){h.preventDefault();nb=n.getScreenCTM().inverse();var q=oa(h.pageX,h.pageY,nb);q={x:q.x,y:q.y,width:0,height:0};if(h.wheelDelta)if(h.wheelDelta>=120)q.factor=2;else{if(h.wheelDelta<=-120)q.factor=0.5}else if(h.detail)if(h.detail>0)q.factor=0.5;else if(h.detail<0)q.factor=2;q.factor&&ha("zoomed",q)}})})();var Mb=function(b){$(b).click(function(c){c.preventDefault()})},Ra=e.textActions=function(){function b(R){var T=w.value==="";$(w).focus();if(!arguments.length)if(T)R=0;else{if(w.selectionEnd!== w.selectionStart)return;R=w.selectionEnd}var V;V=E[R];T||w.setSelectionRange(R,R);u=va("text_cursor");if(!u){u=document.createElementNS(s,"line");Ga(u,{id:"text_cursor",stroke:"#333","stroke-width":1});u=va("selectorParentGroup").appendChild(u)}C||(C=setInterval(function(){var aa=u.getAttribute("display")==="none";u.setAttribute("display",aa?"inline":"none")},600));T=z(V.x,H.y);V=z(V.x,H.y+H.height);Ga(u,{x1:T.x,y1:T.y,x2:V.x,y2:V.y,visibility:"visible",display:"inline"});t&&t.setAttribute("d","")} function c(R,T,V){if(R===T)b(T);else{V||w.setSelectionRange(R,T);t=va("text_selectblock");if(!t){t=document.createElementNS(s,"path");Ga(t,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});va("selectorParentGroup").appendChild(t)}R=E[R];var aa=E[T];u.setAttribute("visibility","hidden");T=z(R.x,H.y);V=z(R.x+(aa.x-R.x),H.y);var Ja=z(R.x,H.y+H.height);R=z(R.x+(aa.x-R.x),H.y+H.height);Ga(t,{d:"M"+T.x+","+T.y+" L"+V.x+","+V.y+" "+R.x+","+R.y+" "+Ja.x+","+Ja.y+"z",display:"inline"})}} function d(R,T){var V=k.createSVGPoint();V.x=R;V.y=T;if(E.length==1)return 0;V=q.getCharNumAtPosition(V);if(V<0){V=E.length-2;if(R<=E[0].x)V=0}else if(V>=E.length-2)V=E.length-2;var aa=E[V];R>aa.x+aa.width/2&&V++;return V}function m(R,T,V){var aa=w.selectionStart;R=d(R,T);c(Math.min(aa,R),Math.max(aa,R),!V)}function i(R,T){var V={x:R,y:T};V.x/=A;V.y/=A;if(I){var aa=oa(V.x,V.y,I.inverse());V.x=aa.x;V.y=aa.y}return V}function z(R,T){var V={x:R,y:T};if(I){var aa=oa(V.x,V.y,I);V.x=aa.x;V.y=aa.y}V.x*= A;V.y*=A;return V}function o(R){c(0,q.textContent.length);$(this).unbind(R)}function h(R){if(Y&&q){var T=oa(R.pageX,R.pageY,nb);T=i(T.x*A,T.y*A);T=d(T.x,T.y);var V=q.textContent,aa=V.substr(0,T).replace(/[a-z0-9]+$/i,"").length;V=V.substr(T).match(/^[a-z0-9]+/i);c(aa,(V?V[0].length:0)+T);$(R.target).click(o);setTimeout(function(){$(R.target).unbind("click",o)},300)}}var q,w,u,t,C,E=[],H,I,P,W,Y;return{select:function(R,T,V){q=R;Ra.toEditMode(T,V)},start:function(R){q=R;Ra.toEditMode()},mouseDown:function(R, T,V,aa){R=i(V,aa);w.focus();b(d(R.x,R.y));P=V;W=aa},mouseMove:function(R,T){var V=i(R,T);m(V.x,V.y)},mouseUp:function(R,T,V){var aa=i(T,V);m(aa.x,aa.y,true);R.target!==q&&TP-2&&VW-2&&Ra.toSelectMode(true)},setCursor:b,toEditMode:function(R,T){Y=false;sa="textedit";ra.requestSelector(q).showGrips(false);ra.requestSelector(q);Ra.init();$(q).css("cursor","text");if(arguments.length){var V=i(R,T);b(d(V.x,V.y))}else b();setTimeout(function(){Y=true},300)},toSelectMode:function(R){sa="select"; clearInterval(C);C=null;t&&$(t).attr("display","none");u&&$(u).attr("visibility","hidden");$(q).css("cursor","move");if(R){za();$(q).css("cursor","move");ha("selected",[q]);gb([q],true)}q&&!q.textContent.length&&e.deleteSelectedElements();$(w).blur();q=false},setInputElem:function(R){w=R},clear:function(){sa=="textedit"&&Ra.toSelectMode()},init:function(){if(q){if(!q.parentNode){q=L[0];ra.requestSelector(q).showGrips(false)}var R=q.textContent.length,T=q.getAttribute("transform");H=svgedit.utilities.getBBox(q); I=T?kb(q):null;E=Array(R);w.focus();$(q).unbind("dblclick",h).dblclick(h);if(!R)var V={x:H.x+H.width/2,width:0};for(T=0;T=0&&this.selected_pts.push(q)}this.selected_pts.sort();h=this.selected_pts.length;for(o=Array(h);h--;){w=this.segs[this.selected_pts[h]];w.select(true);o[h]=w.ptgrip}qa.canDeleteNodes=true;qa.closed_subpath= this.subpathIsClosed(this.selected_pts[0]);ha("selected",o)};var i=c=null,z=false;return{mouseDown:function(o,h,q,w){if(sa==="path"){mouse_x=q;mouse_y=w;w=mouse_x/A;h=mouse_y/A;q=va("path_stretch_line");d=[w,h];if(v.gridSnapping){w=la(w);h=la(h);mouse_x=la(mouse_x);mouse_y=la(mouse_y)}if(!q){q=document.createElementNS(s,"path");Ga(q,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});q=va("selectorParentGroup").appendChild(q)}q.setAttribute("display","inline");var u=null;if(i){u= i.pathSegList;for(var t=u.numberOfItems,C=6/A,E=false;t;){t--;var H=u.getItem(t),I=H.x;H=H.y;if(w>=I-C&&w<=I+C&&h>=H-C&&h<=H+C){E=true;break}}C=db();svgedit.path.removePath_(C);C=va(C);I=u.numberOfItems;if(E){if(t<=1&&I>=2){w=u.getItem(0).x;h=u.getItem(0).y;o=q.pathSegList.getItem(1);o=o.pathSegType===4?i.createSVGPathSegLinetoAbs(w,h):i.createSVGPathSegCurvetoCubicAbs(w,h,o.x1/A,o.y1/A,w,h);w=i.createSVGPathSegClosePath();u.appendItem(o);u.appendItem(w)}else if(I<3)return u=false;$(q).remove();element= C;i=null;xa=false;if(b){svgedit.path.path.matrix&&Fb(C,{},svgedit.path.path.matrix.inverse());q=C.getAttribute("d");o=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",o+q);$(C).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();qa.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Pb(o))){console.log("Clicked outside canvas");return false}u=i.pathSegList.numberOfItems;t=i.pathSegList.getItem(u- 1);C=t.x;t=t.y;if(o.shiftKey){o=Ya(C,t,w,h);w=o.x;h=o.y}o=q.pathSegList.getItem(1);o=o.pathSegType===4?i.createSVGPathSegLinetoAbs(Eb(w),Eb(h)):i.createSVGPathSegCurvetoCubicAbs(Eb(w),Eb(h),o.x1/A,o.y1/A,o.x2/A,o.y2/A);i.pathSegList.appendItem(o);w*=A;h*=A;q.setAttribute("d",["M",w,h,w,h].join(" "));q=u;if(b)q+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(q,w,h)}}else{d_attr="M"+w+","+h+" ";i=na({element:"path",curStyles:true,attr:{d:d_attr,id:Fa(),opacity:N.opacity/2}});q.setAttribute("d", ["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));q=b?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(q,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();C=o.target.id;if(C.substr(0,14)=="pathpointgrip_"){h=svgedit.path.path.cur_pt=parseInt(C.substr(14));svgedit.path.path.dragging=[q,w];u=svgedit.path.path.segs[h];if(o.shiftKey)u.selected?svgedit.path.path.removePtFromSelection(h):svgedit.path.path.addPtsToSelection(h);else{if(svgedit.path.path.selected_pts.length<= 1||!u.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(h)}}else if(C.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[q,w];o=C.split("_")[1].split("c");h=o[0]-0;svgedit.path.path.selectPt(h,o[1]-0)}if(!svgedit.path.path.dragging){if(wa==null)wa=ra.getRubberBandBox();Ga(wa,{x:q*A,y:w*A,width:0,height:0,display:"inline"},100)}}},mouseMove:function(o,h){z=true;if(sa==="path"){if(i){var q=i.pathSegList,w=q.numberOfItems-1;if(d){var u=svgedit.path.addCtrlGrip("1c1"), t=svgedit.path.addCtrlGrip("0c2");u.setAttribute("cx",o);u.setAttribute("cy",h);u.setAttribute("display","inline");u=d[0];var C=d[1];q.getItem(w);var E=u+(u-o/A),H=C+(C-h/A);t.setAttribute("cx",E*A);t.setAttribute("cy",H*A);t.setAttribute("display","inline");t=svgedit.path.getCtrlLine(1);Ga(t,{x1:o,y1:h,x2:E*A,y2:H*A,display:"inline"});if(w===0)m=[o,h];else{var I=q.getItem(w-1);q=I.x;t=I.y;if(I.pathSegType===6){q+=q-I.x2;t+=t-I.y2}else if(m){q=m[0]/A;t=m[1]/A}svgedit.path.replacePathSeg(6,w,[u,C, q,t,E,H],i)}}else if(u=va("path_stretch_line")){w=q.getItem(w);if(w.pathSegType===6)svgedit.path.replacePathSeg(6,1,[o,h,(w.x+(w.x-w.x2))*A,(w.y+(w.y-w.y2))*A,o,h],u);else m?svgedit.path.replacePathSeg(6,1,[o,h,m[0],m[1],o,h],u):svgedit.path.replacePathSeg(4,1,[o,h],u)}}}else if(svgedit.path.path.dragging){u=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);C=svgedit.path.getPointFromGrip({x:o,y:h},svgedit.path.path);w=C.x-u.x;u=C.y- u.y;svgedit.path.path.dragging=[o,h];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(w,u):svgedit.path.path.movePts(w,u)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var P=wa.getBBox(),W=svgedit.path.getGripPt(this);P=svgedit.math.rectsIntersect(P,{x:W.x,y:W.y,width:0,height:0});this.select(P);P&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(o,h){if(sa==="path"){d=null;if(!i){h=va(db());xa=false;m=null}return{keep:true, element:h}}if(svgedit.path.path.dragging){var q=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();z&&svgedit.path.path.endChanges("Move path point(s)");!o.shiftKey&&!z&&svgedit.path.path.selectPt(q)}else if(wa&&wa.getAttribute("display")!="none"){wa.setAttribute("display","none");wa.getAttribute("width")<=2&&wa.getAttribute("height")<=2&&qa.toSelectMode(o.target)}else qa.toSelectMode(o.target);z=false},toEditMode:function(o){svgedit.path.path= svgedit.path.getPath_(o);sa="pathedit";za();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);b=false},toSelectMode:function(o){var h=o==svgedit.path.path.elem;sa="select";svgedit.path.path.show(false);c=false;za();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(h){ha("selected",[o]);gb([o],true)}},addSubPath:function(o){if(o){sa="path";b=true}else{qa.clear(true);qa.toEditMode(svgedit.path.path.elem)}},select:function(o){if(c=== o){qa.toEditMode(o);sa="pathedit"}else c=o},reorient:function(){var o=L[0];if(o)if(bb(o)!=0){var h=new ua("Reorient path"),q={d:o.getAttribute("d"),transform:o.getAttribute("transform")};h.addSubCommand(new Ia(o,q));za();this.resetOrientation(o);ma(h);svgedit.path.getPath_(o).show(false).matrix=null;this.clear();gb([o],true);ha("changed",L)}},clear:function(){c=null;if(i){var o=va(db());$(va("path_stretch_line")).remove();$(o).remove();$(va("pathpointgrip_container")).find("*").attr("display","none"); i=m=null;xa=false}else sa=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(o){if(o==null||o.nodeName!="path")return false;var h=ca(o),q=da(h).matrix;h.clear();o.removeAttribute("transform");h=o.pathSegList;for(var w=h.numberOfItems,u=0;u0){C=w.getItem(u-1).pathSegType;if(C===2){t(u-1,1);q();break}else if(C===1&&w.numberOfItems-1===u){t(u,1);q();break}}}return false};q();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){qa.toSelectMode(svgedit.path.path.elem);e.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){o=$(svgedit.path.path.elem);o.attr("d", o.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(o){var h=o.points,q=h.numberOfItems;if(q>=4){var w=h.getItem(0),u=null;o=[];o.push(["M",w.x,",",w.y," C"].join(""));for(var t=1;t<=q-4;t+=3){var C=h.getItem(t),E=h.getItem(t+1),H=h.getItem(t+2);if(u)if((w=svgedit.path.smoothControlPoints(u,C,w))&&w.length==2){C=o[o.length-1].split(",");C[2]=w[0].x;C[3]=w[0].y;o[o.length-1]=C.join(",");C=w[1]}o.push([C.x,C.y,E.x,E.y,H.x,H.y].join(","));w=H;u=E}for(o.push("L");t< q;++t){E=h.getItem(t);o.push([E.x,E.y].join(","))}o=o.join(" ");o=na({element:"path",curStyles:true,attr:{id:db(),d:o,fill:"none"}})}return o},setSegType:function(o){svgedit.path.path.setSegType(o)},moveNode:function(o,h){var q=svgedit.path.path.selected_pts;if(q.length){svgedit.path.path.storeD();q=svgedit.path.path.segs[q[0]];var w={x:0,y:0};w[o]=h-q.item[o];q.move(w.x,w.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(o){for(var h=o.pathSegList,q=h.numberOfItems,w,u=0;u0;);qa.clear(true);$.each(n.childNodes,function(d,m){d&&m.nodeType===8&&m.data.indexOf("Created with")>=0&&n.insertBefore(m,n.firstChild)});if(O){Qb();Wa([O])}var b=[];$(n).find("g:data(gsvg)").each(function(){for(var d=this.attributes,m=d.length,i=0;i=0;q--){h=o.item(q);t=m(h.nodeValue);if(!(C.indexOf(h.localName)>=0))if(t!="")if(t.indexOf("pointer-events")!==0)if(!(h.localName==="class"&&t.indexOf("se_")===0)){d.push(" ");if(h.localName==="d")t=qa.convertPath(b,true);if(isNaN(t)){if(z.test(t))t=svgedit.units.shortFloat(t)+i}else t=svgedit.units.shortFloat(t);if(/*Na.apply&&*/b.nodeName==="image"&&h.localName==="href"/*&&Na.images&&Na.images==="embed"*/){var E= Jb[t];if(E)t=E}if(!h.namespaceURI||h.namespaceURI==s||hb[h.namespaceURI]){d.push(h.nodeName);d.push('="');d.push(t);d.push('"')}}}}if(b.hasChildNodes()){d.push(">");c++;o=false;for(q=0;q");break;case 8:d.push("\n"); d.push(Array(c+1).join(" "));d.push("