better cursor handling on resize, move and rotate

master
Mark MacKay 2012-06-28 19:14:04 -05:00
parent 9955f006e3
commit c13ac3cb44
3 changed files with 284 additions and 266 deletions

View File

@ -1940,10 +1940,22 @@ span.zoom_tool img {
cursor: url(images/pencil.png) 0 20, crosshair;
}
#workarea.rotate {
#workarea.rotate * {
cursor: url(images/rotate.png) 12 12, auto;
}
#workarea.n-resize * {cursor: n-resize !important;}
#workarea.e-resize * {cursor: e-resize !important;}
#workarea.w-resize * {cursor: w-resize !important;}
#workarea.s-resize * {cursor: s-resize !important;}
#workarea.ne-resize * {cursor: ne-resize !important;}
#workarea.se-resize * {cursor: se-resize !important;}
#workarea.nw-resize * {cursor: nw-resize !important;}
#workarea.sw-resize * {cursor: sw-resize !important;}
#workarea.zoom {
cursor: crosshair;
cursor:-moz-zoom-in;

View File

@ -2730,6 +2730,12 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
started = true;
}
});
if (current_mode) {
document.getElementById("workarea").className =
(current_mode == "resize")
? evt.target.style.cursor
: current_mode
}
};
// in this function we do not record any state changes yet (but we do update

View File

@ -3,14 +3,14 @@ true;else{l[e+d]=true;l[e+a.hotkeys.shiftNums[d]]=true;if(e==="shift+")l[a.hotke
106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta",219:"[",221:"]"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:n}})})(jQuery);(function(a,n){function f(ba){return typeof ba==="string"}function c(ba){var S=e.call(arguments,1);return function(){return ba.apply(this,S.concat(e.call(arguments)))}}function m(ba,S,U,ra,la){var ma;if(ra!==d){S=U.match(ba?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);U=S[3]||"";if(la===2&&f(ra))ra=ra.replace(ba?ea:ca,"");else{ma=o(S[2]);ra=f(ra)?o[ba?fa:O](ra):ra;ra=la===2?ra:la===1?a.extend({},ra,ma):a.extend({},ma,ra);ra=u(ra);if(ba)ra=ra.replace(qa,l)}ba=S[1]+(ba?"#":ra||!S[1]?"?":"")+ra+U}else ba=
S(U!==d?U:n[sa][ja]);return ba}function p(ba,S,U){if(S===d||typeof S==="boolean"){U=S;S=u[ba?fa:O]()}else S=f(S)?S.replace(ba?ea:ca,""):S;return o(S,U)}function b(ba,S,U,ra){if(!f(U)&&typeof U!=="object"){ra=U;U=S;S=d}return this.each(function(){var la=a(this),ma=S||da()[(this.nodeName||"").toLowerCase()]||"",Y=ma&&la.attr(ma)||"";la.attr(ma,u[ba](Y,U,ra))})}var d,e=Array.prototype.slice,l=decodeURIComponent,u=a.param,z,o,L,T=a.bbq=a.bbq||{},N,J,da,V=a.event.special,O="querystring",fa="fragment",
sa="location",ja="href",ca=/^.*\?|#.*$/g,ea=/^.*\#/,qa,pa={};u[O]=c(m,0,function(ba){return ba.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});u[fa]=z=c(m,1,function(ba){return ba.replace(/^[^#]*#?(.*)$/,"$1")});z.noEscape=function(ba){ba=ba||"";ba=a.map(ba.split(""),encodeURIComponent);qa=RegExp(ba.join("|"),"g")};z.noEscape(",/");a.deparam=o=function(ba,S){var U={},ra={"true":true,"false":false,"null":null};a.each(ba.replace(/\+/g," ").split("&"),function(la,ma){var Y=ma.split("="),za=l(Y[0]),Ia=U,
Qa=0,Ka=za.split("]["),Ua=Ka.length-1;if(/\[/.test(Ka[0])&&/\]$/.test(Ka[Ua])){Ka[Ua]=Ka[Ua].replace(/\]$/,"");Ka=Ka.shift().split("[").concat(Ka);Ua=Ka.length-1}else Ua=0;if(Y.length===2){Y=l(Y[1]);if(S)Y=Y&&!isNaN(Y)?+Y:Y==="undefined"?d:ra[Y]!==d?ra[Y]:Y;if(Ua)for(;Qa<=Ua;Qa++){za=Ka[Qa]===""?Ia.length:Ka[Qa];Ia=Ia[za]=Qa<Ua?Ia[za]||(Ka[Qa+1]&&isNaN(Ka[Qa+1])?{}:[]):Y}else if(a.isArray(U[za]))U[za].push(Y);else U[za]=U[za]!==d?[U[za],Y]:Y}else if(za)U[za]=S?d:""});return U};o[O]=c(p,0);o[fa]=L=
Qa=0,La=za.split("]["),Ua=La.length-1;if(/\[/.test(La[0])&&/\]$/.test(La[Ua])){La[Ua]=La[Ua].replace(/\]$/,"");La=La.shift().split("[").concat(La);Ua=La.length-1}else Ua=0;if(Y.length===2){Y=l(Y[1]);if(S)Y=Y&&!isNaN(Y)?+Y:Y==="undefined"?d:ra[Y]!==d?ra[Y]:Y;if(Ua)for(;Qa<=Ua;Qa++){za=La[Qa]===""?Ia.length:La[Qa];Ia=Ia[za]=Qa<Ua?Ia[za]||(La[Qa+1]&&isNaN(La[Qa+1])?{}:[]):Y}else if(a.isArray(U[za]))U[za].push(Y);else U[za]=U[za]!==d?[U[za],Y]:Y}else if(za)U[za]=S?d:""});return U};o[O]=c(p,0);o[fa]=L=
c(p,1);a.elemUrlAttr||(a.elemUrlAttr=function(ba){return a.extend(pa,ba)})({a:ja,base:ja,iframe:"src",img:"src",input:"src",form:"action",link:ja,script:"src"});da=a.elemUrlAttr;a.fn[O]=c(b,O);a.fn[fa]=c(b,fa);T.pushState=N=function(ba,S){if(f(ba)&&/^#/.test(ba)&&S===d)S=2;var U=ba!==d;U=z(n[sa][ja],U?ba:{},U?S:2);n[sa][ja]=U+(/#/.test(U)?"":"#")};T.getState=J=function(ba,S){return ba===d||typeof ba==="boolean"?L(ba):L(S)[ba]};T.removeState=function(ba){var S={};if(ba!==d){S=J();a.each(a.isArray(ba)?
ba:arguments,function(U,ra){delete S[ra]})}N(S,2)};V.hashchange=a.extend(V.hashchange,{add:function(ba){function S(ra){var la=ra[fa]=z();ra.getState=function(ma,Y){return ma===d||typeof ma==="boolean"?o(la,ma):o(la,Y)[ma]};U.apply(this,arguments)}var U;if(a.isFunction(ba)){U=ba;return S}else{U=ba.handler;ba.handler=S}}})})(jQuery,this);
(function(a,n,f){function c(z){z=z||n[b][d];return z.replace(/^[^#]*#?(.*)$/,"$1")}var m,p=a.event.special,b="location",d="href",e=document.documentMode,l=a.browser.msie&&(e===f||e<8),u="onhashchange"in n&&!l;a.hashchangeDelay=100;p.hashchange=a.extend(p.hashchange,{setup:function(){if(u)return false;a(m.start)},teardown:function(){if(u)return false;a(m.stop)}});m=function(){function z(){N=J=function(da){return da};if(l){T=a('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;
J=function(){return c(T.document[b][d])};N=function(da,V){if(da!==V){var O=T.document;O.open().close();O[b].hash="#"+da}};N(c())}}var o={},L,T,N,J;o.start=function(){if(!L){var da=c();N||z();(function V(){var O=c(),fa=J(da);if(O!==da){N(da=O,fa);a(n).trigger("hashchange")}else if(fa!==da)n[b][d]=n[b][d].replace(/#.*/,"")+"#"+fa;L=setTimeout(V,a.hashchangeDelay)})()}};o.stop=function(){if(!T){L&&clearTimeout(L);L=0}};return o}()})(jQuery,this);(function(a){var n={},f;a.svgIcons=function(c,m){function p(ba,S){if(ba!=="ajax"){if(da)return;var U=(T=ja[0].contentDocument)&&T.getElementById("svg_eof");if(!U&&!(S&&U)){V++;if(V<50)setTimeout(p,20);else{d();da=true}return}da=true}L=a(T.firstChild).children();if(m.no_img)setTimeout(function(){J||b()},500);else{U=sa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";N=a(new Image).attr({src:U,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}}
function b(ba,S){if(!J){if(m.no_img)ba=false;if(ba){var U=a(document.createElement("div"));U.hide().appendTo("body")}if(S){var ra=m.fallback_path?m.fallback_path:"";a.each(S,function(Ua,Wa){a("#"+Ua);var La=a(new Image).attr({"class":"svg_icon",src:ra+Wa,width:z,height:o,alt:"icon"});pa(La,Ua)})}else for(var la=L.length,ma=0;ma<la;ma++){var Y=L[ma],za=Y.id;if(za==="svg_eof")break;a("#"+za);Y=Y.getElementsByTagNameNS(l,"svg")[0];var Ia=document.createElementNS(l,"svg");Ia.setAttributeNS(l,"viewBox",
[0,0,z,o].join(" "));var Qa=Y.getAttribute("width"),Ka=Y.getAttribute("height");Y.removeAttribute("width");Y.removeAttribute("height");Y.getAttribute("viewBox")||Y.setAttribute("viewBox",[0,0,Qa,Ka].join(" "));Ia.setAttribute("xmlns",l);Ia.setAttribute("width",z);Ia.setAttribute("height",o);Ia.setAttribute("xmlns:xlink",u);Ia.setAttribute("class","svg_icon");fa||(Y=Y.cloneNode(true));Ia.appendChild(Y);if(ba){fa||Ia.cloneNode(true);U.empty().append(Ia);Y=sa+e(U.html());Y=a(new Image).attr({"class":"svg_icon",
src:Y})}else Y=f(a(Ia),ma);pa(Y,za)}m.placement&&a.each(m.placement,function(Ua,Wa){n[Wa]&&a(Ua).each(function(La){var Ga=n[Wa].clone();if(La>0&&!ba)Ga=f(Ga,La,true);qa(a(this),Ga,Wa)})});if(!S){ba&&U.remove();ja&&ja.remove();N&&N.remove()}m.resize&&a.resizeSvgIcons(m.resize);J=true;m.callback&&m.callback(n)}}function d(){if(c.indexOf(".svgz")!=-1){var ba=c.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(ba,m)}else m.fallback&&b(false,m.fallback)}function e(ba){if(window.btoa)return window.btoa(ba);
function b(ba,S){if(!J){if(m.no_img)ba=false;if(ba){var U=a(document.createElement("div"));U.hide().appendTo("body")}if(S){var ra=m.fallback_path?m.fallback_path:"";a.each(S,function(Ua,Wa){a("#"+Ua);var Ma=a(new Image).attr({"class":"svg_icon",src:ra+Wa,width:z,height:o,alt:"icon"});pa(Ma,Ua)})}else for(var la=L.length,ma=0;ma<la;ma++){var Y=L[ma],za=Y.id;if(za==="svg_eof")break;a("#"+za);Y=Y.getElementsByTagNameNS(l,"svg")[0];var Ia=document.createElementNS(l,"svg");Ia.setAttributeNS(l,"viewBox",
[0,0,z,o].join(" "));var Qa=Y.getAttribute("width"),La=Y.getAttribute("height");Y.removeAttribute("width");Y.removeAttribute("height");Y.getAttribute("viewBox")||Y.setAttribute("viewBox",[0,0,Qa,La].join(" "));Ia.setAttribute("xmlns",l);Ia.setAttribute("width",z);Ia.setAttribute("height",o);Ia.setAttribute("xmlns:xlink",u);Ia.setAttribute("class","svg_icon");fa||(Y=Y.cloneNode(true));Ia.appendChild(Y);if(ba){fa||Ia.cloneNode(true);U.empty().append(Ia);Y=sa+e(U.html());Y=a(new Image).attr({"class":"svg_icon",
src:Y})}else Y=f(a(Ia),ma);pa(Y,za)}m.placement&&a.each(m.placement,function(Ua,Wa){n[Wa]&&a(Ua).each(function(Ma){var Ga=n[Wa].clone();if(Ma>0&&!ba)Ga=f(Ga,Ma,true);qa(a(this),Ga,Wa)})});if(!S){ba&&U.remove();ja&&ja.remove();N&&N.remove()}m.resize&&a.resizeSvgIcons(m.resize);J=true;m.callback&&m.callback(n)}}function d(){if(c.indexOf(".svgz")!=-1){var ba=c.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(ba,m)}else m.fallback&&b(false,m.fallback)}function e(ba){if(window.btoa)return window.btoa(ba);
var S=Array(Math.floor((ba.length+2)/3)*4),U,ra,la,ma,Y,za,Ia=0,Qa=0;do{U=ba.charCodeAt(Ia++);ra=ba.charCodeAt(Ia++);la=ba.charCodeAt(Ia++);ma=U>>2;U=(U&3)<<4|ra>>4;Y=(ra&15)<<2|la>>6;za=la&63;if(isNaN(ra))Y=za=64;else if(isNaN(la))za=64;S[Qa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);S[Qa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(U);S[Qa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Y);S[Qa++]=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(za)}while(Ia<ba.length);return S.join("")}var l="http://www.w3.org/2000/svg",u="http://www.w3.org/1999/xlink",z=m.w?m.w:24,o=m.h?m.h:24,L,T,N,J=false,da=false,V=0,O=navigator.userAgent,fa=!!window.opera;O.indexOf("Safari/")>-1&&O.indexOf("Chrome/");var sa="data:image/svg+xml;charset=utf-8;base64,";if(m.svgz){var ja=a('<object data="'+c+'" type=image/svg+xml>').appendTo("body").hide();try{T=ja[0].contentDocument;ja.load(p);
p(0,true)}catch(ca){d()}}else{var ea=new DOMParser;a.ajax({url:c,dataType:"string",success:function(ba){if(ba){T=ea.parseFromString(ba,"text/xml");a(function(){p("ajax")})}else a(d)},error:function(ba){if(window.opera)a(function(){d()});else if(ba.responseText){T=ea.parseFromString(ba.responseText,"text/xml");T.childNodes.length||a(d);a(function(){p("ajax")})}else a(d)}})}var qa=function(ba,S,U,ra){fa&&S.css("visibility","hidden");if(m.replace){ra&&S.attr("id",U);(U=ba.attr("class"))&&S.attr("class",
@ -19,12 +19,12 @@ la;ma++){var Ia=ra[ma];Ia.getAttribute("fill")===Y&&Ia.setAttribute("fill",za);I
e);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode.style.width=e+"px";this.parentNode.style.height=l+"px"}})})}})(jQuery);(function(){function a(c,m,p){c=document.createElementNS(n.svg,c);if(f)for(var b in m)c.setAttribute(b,m[b]);else for(b in m){var d=m[b],e=c[b];if(e&&e.constructor==="SVGLength")e.baseVal.value=d;else c.setAttribute(b,d)}p&&p.appendChild(c);return c}var n={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};if(!window.console)window.console=new function(){this.log=function(){};this.dir=function(){}};$.jGraduate={Paint:function(c){c=c||{};this.alpha=isNaN(c.alpha)?100:c.alpha;if(c.copy){this.type=
c.copy.type;this.alpha=c.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=c.copy.solidColor;break;case "linearGradient":this.linearGradient=c.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=c.copy.radialGradient.cloneNode(true)}}else if(c.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=c.linearGradient.cloneNode(true)}else if(c.radialGradient){this.type=
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=c.radialGradient.cloneNode(true)}else if(c.solidColor){this.type="solidColor";this.solidColor=c.solidColor}else{this.type="none";this.radialGradient=this.linearGradient=this.solidColor=null}}};jQuery.fn.jGraduateDefaults={paint:new $.jGraduate.Paint,window:{pickerTitle:"Drag markers to pick a paint"},images:{clientPath:"images/"},newstop:"inverse"};var f=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(c){var m=
arguments;return this.each(function(){function p(na,Z,ta,M,I){var X=I||a("stop",{"stop-color":Z,"stop-opacity":ta,offset:na},ea);if(I){Z=I.getAttribute("stop-color");ta=I.getAttribute("stop-opacity");na=I.getAttribute("offset")}else ea.appendChild(X);if(ta===null)ta=1;I=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+na*fa)+", 26)"},Gb);var Ma=
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:Z,"fill-opacity":ta,transform:"translate("+(10+na*fa)+", 26)",stroke:"#000","stroke-width":1.5},Gb);$(Ma).mousedown(function(Xa){b(this);Sa=lb;da.mousemove(l).mouseup(d);Ea=Nb.offset();Xa.preventDefault();return false}).data("stop",X).data("bg",I).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Xa=this,db=+X.getAttribute("stop-opacity")||
arguments;return this.each(function(){function p(na,Z,ta,M,I){var X=I||a("stop",{"stop-color":Z,"stop-opacity":ta,offset:na},ea);if(I){Z=I.getAttribute("stop-color");ta=I.getAttribute("stop-opacity");na=I.getAttribute("offset")}else ea.appendChild(X);if(ta===null)ta=1;I=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+na*fa)+", 26)"},Gb);var Na=
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:Z,"fill-opacity":ta,transform:"translate("+(10+na*fa)+", 26)",stroke:"#000","stroke-width":1.5},Gb);$(Na).mousedown(function(Xa){b(this);Sa=lb;da.mousemove(l).mouseup(d);Ea=Nb.offset();Xa.preventDefault();return false}).data("stop",X).data("bg",I).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Xa=this,db=+X.getAttribute("stop-opacity")||
1,tb=X.getAttribute("stop-color")||1,xb=(parseFloat(db)*255).toString(16);xb.length<2;)xb="0"+xb;Z=tb.substr(1)+xb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:z.images.clientPath},color:{active:Z,alphaSupport:true}},function(Hb){tb=Hb.val("hex")?"#"+Hb.val("hex"):"none";db=Hb.val("a")!==null?Hb.val("a")/256:1;Xa.setAttribute("fill",tb);Xa.setAttribute("fill-opacity",db);X.setAttribute("stop-color",
tb);X.setAttribute("stop-opacity",db);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(ea).find("stop").each(function(){var Xa=$(this);if(+this.getAttribute("offset")>na){if(!Z){var db=this.getAttribute("stop-color"),tb=this.getAttribute("stop-opacity");X.setAttribute("stop-color",db);Ma.setAttribute("fill",db);X.setAttribute("stop-opacity",tb===null?1:tb);Ma.setAttribute("fill-opacity",
tb===null?1:tb)}Xa.before(X);return false}});M&&b(Ma);return X}function b(na){lb&&lb.setAttribute("stroke","#000");na.setAttribute("stroke","blue");lb=na;lb.parentNode.appendChild(lb)}function d(){da.unbind("mousemove",l);if(Ja.getAttribute("display")!=="none"){Ja.setAttribute("display","none");var na=$(lb),Z=na.data("stop");na=na.data("bg");$([lb,Z,na]).remove()}Sa=null}function e(){var na=$a?"rotate("+$a+","+Na+","+mb+") ":"";Za===1&&Ra===1?ea.removeAttribute("gradientTransform"):ea.setAttribute("gradientTransform",
na+"translate("+-Na*(Za-1)+","+-mb*(Ra-1)+") scale("+Za+","+Ra+")")}function l(na){var Z=na.pageX-Ea.left;na=na.pageY-Ea.top;Z=Z<10?10:Z>fa+10?fa+10:Z;var ta="translate("+Z+", 26)";if(na<-60||na>130){Ja.setAttribute("display","block");Ja.setAttribute("transform",ta)}else Ja.setAttribute("display","none");Sa.setAttribute("transform",ta);$.data(Sa,"bg").setAttribute("transform",ta);$.data(Sa,"stop").setAttribute("offset",(Z-10)/fa);var M=0;$(ea).find("stop").each(function(){var I=this.getAttribute("offset"),
tb);X.setAttribute("stop-opacity",db);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(ea).find("stop").each(function(){var Xa=$(this);if(+this.getAttribute("offset")>na){if(!Z){var db=this.getAttribute("stop-color"),tb=this.getAttribute("stop-opacity");X.setAttribute("stop-color",db);Na.setAttribute("fill",db);X.setAttribute("stop-opacity",tb===null?1:tb);Na.setAttribute("fill-opacity",
tb===null?1:tb)}Xa.before(X);return false}});M&&b(Na);return X}function b(na){lb&&lb.setAttribute("stroke","#000");na.setAttribute("stroke","blue");lb=na;lb.parentNode.appendChild(lb)}function d(){da.unbind("mousemove",l);if(Ja.getAttribute("display")!=="none"){Ja.setAttribute("display","none");var na=$(lb),Z=na.data("stop");na=na.data("bg");$([lb,Z,na]).remove()}Sa=null}function e(){var na=$a?"rotate("+$a+","+Ka+","+mb+") ":"";Za===1&&Ra===1?ea.removeAttribute("gradientTransform"):ea.setAttribute("gradientTransform",
na+"translate("+-Ka*(Za-1)+","+-mb*(Ra-1)+") scale("+Za+","+Ra+")")}function l(na){var Z=na.pageX-Ea.left;na=na.pageY-Ea.top;Z=Z<10?10:Z>fa+10?fa+10:Z;var ta="translate("+Z+", 26)";if(na<-60||na>130){Ja.setAttribute("display","block");Ja.setAttribute("transform",ta)}else Ja.setAttribute("display","none");Sa.setAttribute("transform",ta);$.data(Sa,"bg").setAttribute("transform",ta);$.data(Sa,"stop").setAttribute("offset",(Z-10)/fa);var M=0;$(ea).find("stop").each(function(){var I=this.getAttribute("offset"),
X=$(this);if(I<M){X.prev().before(X);Fa=$(ea).find("stop")}M=I})}var u=$(this),z=$.extend(true,{},jQuery.fn.jGraduateDefaults,c),o=u.attr("id"),L="#"+u.attr("id")+" ";if(L){var T=function(){switch(u.paint.type){case "radialGradient":u.paint.linearGradient=null;break;case "linearGradient":u.paint.radialGradient=null;break;case "solidColor":u.paint.radialGradient=u.paint.linearGradient=null}$.isFunction(u.okCallback)&&u.okCallback(u.paint);u.hide()},N=function(){$.isFunction(u.cancelCallback)&&u.cancelCallback();
u.hide()};$.extend(true,u,{paint:new $.jGraduate.Paint({copy:z.paint}),okCallback:$.isFunction(m[1])&&m[1]||null,cancelCallback:$.isFunction(m[2])&&m[2]||null});u.position();var J=null,da=$(window);if(u.paint.type=="none")u.paint=$.jGraduate.Paint({solidColor:"ffffff"});u.addClass("jGraduate_Picker");u.html('<ul class="jGraduate_tabs"><li class="jGraduate_tab_color jGraduate_tab_current" data-type="col">Solid Color</li><li class="jGraduate_tab_lingrad" data-type="lg">Linear Gradient</li><li class="jGraduate_tab_radgrad" data-type="rg">Radial Gradient</li></ul><div class="jGraduate_colPick"></div><div class="jGraduate_gradPick"></div><div class="jGraduate_LightBox"></div><div id="'+
o+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var V=$(L+"> .jGraduate_colPick"),O=$(L+"> .jGraduate_gradPick");O.html('<div id="'+o+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+z.window.pickerTitle+'</h2><div id="'+o+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+o+'_jGraduate_StopSlider" class="jGraduate_StopSlider"></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_lg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Begin Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+
@ -36,12 +36,12 @@ o+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+z.images.clientP
'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_AngleInput" size="3" value="0"/>\u00ba&nbsp;</label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+o+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+o+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+z.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+
o+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+o+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var fa=256,sa=fa-0,ja=fa-0,ca,ea,qa,pa={};$(".jGraduate_SliderBar").width(145);var ba=$("#"+o+"_jGraduate_GradContainer")[0],S=a("svg",{id:o+"_jgraduate_svg",width:fa,height:fa,xmlns:n.svg},ba);ca=ca||u.paint.type;var U=ea=u.paint[ca],ra=u.paint.alpha,la=ca==="solidColor";switch(ca){case "solidColor":case "linearGradient":if(!la){ea.id=o+"_lg_jgraduate_grad";
U=ea=S.appendChild(ea)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},S);if(ca==="linearGradient")break;case "radialGradient":if(!la){ea.id=o+"_rg_jgraduate_grad";U=ea=S.appendChild(ea)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},S)}if(la){U=ea=$("#"+o+"_lg_jgraduate_grad")[0];J=u.paint[ca];p(0,"#"+J,1);var ma=typeof z.newstop;if(ma==="string")switch(z.newstop){case "same":p(1,"#"+J,1);break;case "inverse":ma="";for(var Y=0;Y<6;Y+=2){J.substr(Y,2);var za=(255-parseInt(J.substr(Y,2),16)).toString(16);
if(za.length<2)za=0+za;ma+=za}p(1,"#"+ma,1);break;case "white":p(1,"#ffffff",1);break;case "black":p(1,"#000000",1)}else if(ma==="object")p(1,z.newstop.color||"#"+J,"opac"in z.newstop?z.newstop.opac:1)}J=parseFloat(U.getAttribute("x1")||0);ma=parseFloat(U.getAttribute("y1")||0);Y=parseFloat(U.getAttribute("x2")||1);za=parseFloat(U.getAttribute("y2")||0);var Ia=parseFloat(U.getAttribute("cx")||0.5),Qa=parseFloat(U.getAttribute("cy")||0.5),Ka=parseFloat(U.getAttribute("fx")||Ia),Ua=parseFloat(U.getAttribute("fy")||
Qa);qa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:sa,height:ja,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":ra/100},S);var Wa=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*fa,left:J*fa}).data("coord","start").appendTo(ba),La=Wa.clone().text(2).css({top:za*fa,left:Y*fa}).attr("title","End stop").data("coord","end").appendTo(ba),Ga=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Qa*fa,left:Ia*
fa}).data("coord","center").appendTo(ba),Oa=Ga.clone().text("F").css({top:Ua*fa,left:Ka*fa,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(ba);Oa[0].id=o+"_jGraduate_focusCoord";$(L+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(na,Z){var ta=ea.getAttribute(Z),M=isNaN(Z[1]);ta||(ta=M?"0.5":Z==="x2"?"1.0":"0.0");pa[Z]=$("#"+o+"_jGraduate_"+Z).val(ta).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(Z[0]==="f"&&!nb))if(M&&ca==="radialGradient"||!M&&ca==="linearGradient")ea.setAttribute(Z,this.value);var I=M?Z[0]==="c"?Ga:Oa:Z[1]==="1"?Wa:La,X=Z.indexOf("x")>=0?"left":"top";I.css(X,this.value*fa)}).change()});var Fa,Gb,Nb=$("#"+o+"_jGraduate_StopSlider"),lb,ab,Sa,Ja=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},ab),Ea,Za=1,Ra=1,$a=0,Na=Ia,mb=Qa;ab=a("svg",{width:"100%",height:45},Nb[0]);ba=a("pattern",{width:16,
if(za.length<2)za=0+za;ma+=za}p(1,"#"+ma,1);break;case "white":p(1,"#ffffff",1);break;case "black":p(1,"#000000",1)}else if(ma==="object")p(1,z.newstop.color||"#"+J,"opac"in z.newstop?z.newstop.opac:1)}J=parseFloat(U.getAttribute("x1")||0);ma=parseFloat(U.getAttribute("y1")||0);Y=parseFloat(U.getAttribute("x2")||1);za=parseFloat(U.getAttribute("y2")||0);var Ia=parseFloat(U.getAttribute("cx")||0.5),Qa=parseFloat(U.getAttribute("cy")||0.5),La=parseFloat(U.getAttribute("fx")||Ia),Ua=parseFloat(U.getAttribute("fy")||
Qa);qa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:sa,height:ja,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":ra/100},S);var Wa=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*fa,left:J*fa}).data("coord","start").appendTo(ba),Ma=Wa.clone().text(2).css({top:za*fa,left:Y*fa}).attr("title","End stop").data("coord","end").appendTo(ba),Ga=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Qa*fa,left:Ia*
fa}).data("coord","center").appendTo(ba),Oa=Ga.clone().text("F").css({top:Ua*fa,left:La*fa,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(ba);Oa[0].id=o+"_jGraduate_focusCoord";$(L+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(na,Z){var ta=ea.getAttribute(Z),M=isNaN(Z[1]);ta||(ta=M?"0.5":Z==="x2"?"1.0":"0.0");pa[Z]=$("#"+o+"_jGraduate_"+Z).val(ta).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(Z[0]==="f"&&!nb))if(M&&ca==="radialGradient"||!M&&ca==="linearGradient")ea.setAttribute(Z,this.value);var I=M?Z[0]==="c"?Ga:Oa:Z[1]==="1"?Wa:Ma,X=Z.indexOf("x")>=0?"left":"top";I.css(X,this.value*fa)}).change()});var Fa,Gb,Nb=$("#"+o+"_jGraduate_StopSlider"),lb,ab,Sa,Ja=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},ab),Ea,Za=1,Ra=1,$a=0,Ka=Ia,mb=Qa;ab=a("svg",{width:"100%",height:45},Nb[0]);ba=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},ab);a("image",{width:16,height:16},ba).setAttributeNS(n.xlink,"xlink:href",z.images.clientPath+"map-opacity.png");$(ab).click(function(na){Ea=Nb.offset();if(na.target.tagName!=="path"){var Z=na.pageX-Ea.left-8;Z=Z<10?10:Z>fa+10?fa+10:Z;p(Z/fa,0,0,true);na.stopPropagation()}});$(ab).mouseover(function(){ab.appendChild(Ja)});Gb=a("g",{},ab);a("line",{x1:10,y1:15,x2:fa+10,y2:15,"stroke-width":2,stroke:"#000"},ab);var Ab=O.find(".jGraduate_spreadMethod").change(function(){ea.setAttribute("spreadMethod",
$(this).val())}),cb=null,jb=function(na){var Z=na.pageX-wb.left,ta=na.pageY-wb.top;Z=Z<0?0:Z>fa?fa:Z;ta=ta<0?0:ta>fa?fa:ta;cb.css("left",Z).css("top",ta);Z/=sa;ta/=ja;var M=cb.data("coord"),I=ea;switch(M){case "start":pa.x1.val(Z);pa.y1.val(ta);I.setAttribute("x1",Z);I.setAttribute("y1",ta);break;case "end":pa.x2.val(Z);pa.y2.val(ta);I.setAttribute("x2",Z);I.setAttribute("y2",ta);break;case "center":pa.cx.val(Z);pa.cy.val(ta);I.setAttribute("cx",Z);I.setAttribute("cy",ta);Na=Z;mb=ta;e();break;case "focus":pa.fx.val(Z);
$(this).val())}),cb=null,jb=function(na){var Z=na.pageX-wb.left,ta=na.pageY-wb.top;Z=Z<0?0:Z>fa?fa:Z;ta=ta<0?0:ta>fa?fa:ta;cb.css("left",Z).css("top",ta);Z/=sa;ta/=ja;var M=cb.data("coord"),I=ea;switch(M){case "start":pa.x1.val(Z);pa.y1.val(ta);I.setAttribute("x1",Z);I.setAttribute("y1",ta);break;case "end":pa.x2.val(Z);pa.y2.val(ta);I.setAttribute("x2",Z);I.setAttribute("y2",ta);break;case "center":pa.cx.val(Z);pa.cy.val(ta);I.setAttribute("cx",Z);I.setAttribute("cy",ta);Ka=Z;mb=ta;e();break;case "focus":pa.fx.val(Z);
pa.fy.val(ta);I.setAttribute("fx",Z);I.setAttribute("fy",ta);e()}na.preventDefault()},kb=function(){cb=null;da.unbind("mousemove",jb).unbind("mouseup",kb)};Fa=ea.getElementsByTagNameNS(n.svg,"stop");if(Ca<2){for(;Ca<2;){ea.appendChild(document.createElementNS(n.svg,"stop"));++Ca}Fa=ea.getElementsByTagNameNS(n.svg,"stop")}var Ca=Fa.length;for(Y=0;Y<Ca;Y++)p(0,0,0,0,Fa[Y]);Ab.val(ea.getAttribute("spreadMethod")||"pad");var wb,nb=false;qa.setAttribute("fill-opacity",ra/100);$("#"+o+" div.grad_coord").mousedown(function(na){na.preventDefault();
cb=$(this);cb.offset();wb=cb.parent().offset();da.mousemove(jb).mouseup(kb)});$("#"+o+"_jGraduate_Ok").bind("click",function(){u.paint.type=ca;u.paint[ca]=ea.cloneNode(true);u.paint.solidColor=null;T()});$("#"+o+"_jGraduate_Cancel").bind("click",function(){N()});if(ca==="radialGradient")if(nb)Oa.show();else{Oa.hide();pa.fx.val("");pa.fy.val("")}$("#"+o+"_jGraduate_match_ctr")[0].checked=!nb;var yb,Bb;$("#"+o+"_jGraduate_match_ctr").change(function(){nb=!this.checked;Oa.toggle(nb);pa.fx.val("");pa.fy.val("");
var na=ea;if(nb){var Z=yb||0.5,ta=Bb||0.5;na.setAttribute("fx",Z);na.setAttribute("fy",ta);pa.fx.val(Z);pa.fy.val(ta)}else{yb=na.getAttribute("fx");Bb=na.getAttribute("fy");na.removeAttribute("fx");na.removeAttribute("fy")}});Fa=ea.getElementsByTagNameNS(n.svg,"stop");Ca=Fa.length;if(Ca<2){for(;Ca<2;){ea.appendChild(document.createElementNS(n.svg,"stop"));++Ca}Fa=ea.getElementsByTagNameNS(n.svg,"stop")}var ob;ra=O=0;if(ca==="radialGradient"){S=ea.gradientTransform.baseVal;if(S.numberOfItems===2){Ca=
@ -51,7 +51,7 @@ S.getItem(0);S=S.getItem(1);if(Ca.type===2&&S.type===3){Ca=S.matrix;if(Ca.a!==1)
ob.offset.left-parseInt(ob.parent.css("border-left-width"));if(Z>145)Z=145;if(Z<=0)Z=0;var ta=Z-5;Z/=145;switch(ob.type){case "radius":Z=Math.pow(Z*2,2.5);if(Z>0.98&&Z<1.02)Z=1;if(Z<=0.01)Z=0.01;ea.setAttribute("r",Z);break;case "opacity":u.paint.alpha=parseInt(Z*100);qa.setAttribute("fill-opacity",Z);break;case "ellip":Ra=Za=1;if(Z<0.5){Z/=0.5;Za=Z<=0?0.01:Z}else if(Z>0.5){Z/=0.5;Z=2-Z;Ra=Z<=0?0.01:Z}e();Z-=1;if(Ra===Z+1)Z=Math.abs(Z);break;case "angle":Z-=0.5;$a=Z*=180;e();Z/=100}ob.elem.css({"margin-left":ta});
Z=Math.round(Z*100);ob.input.val(Z);na.preventDefault()},Kb=function(){da.unbind("mousemove",Cb).unbind("mouseup",Kb);ob=null};for(O=(u.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=u.paint.solidColor=="none"?"":u.paint.solidColor+O;la||(J=Fa[0].getAttribute("stop-color"));$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});V.jPicker({window:{title:z.window.pickerTitle},images:{clientPath:z.images.clientPath},color:{active:J,alphaSupport:true}},
function(na){u.paint.type="solidColor";u.paint.alpha=na.val("ahex")?Math.round(na.val("a")/255*100):100;u.paint.solidColor=na.val("hex")?na.val("hex"):"none";u.paint.radialGradient=null;T()},null,function(){N()});var Ib=$(L+" .jGraduate_tabs li");Ib.click(function(){Ib.removeClass("jGraduate_tab_current");$(this).addClass("jGraduate_tab_current");$(L+" > div").hide();var na=$(this).attr("data-type");$(L+" .jGraduate_gradPick").show();if(na==="rg"||na==="lg"){$(".jGraduate_"+na+"_field").show();$(".jGraduate_"+
(na==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+na+"_jgraduate_grad)");ca=na==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(u.paint.alpha).change();var Z=$("#"+o+"_"+na+"_jgraduate_grad")[0];if(ea!==Z){var ta=$(ea).find("stop");$(Z).empty().append(ta);ea=Z;Z=Ab.val();ea.setAttribute("spreadMethod",Z)}nb=na==="rg"&&ea.getAttribute("fx")!=null&&!(Ia==Ka&&Qa==Ua);$("#"+o+"_jGraduate_focusCoord").toggle(nb);if(nb)$("#"+
(na==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+na+"_jgraduate_grad)");ca=na==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(u.paint.alpha).change();var Z=$("#"+o+"_"+na+"_jgraduate_grad")[0];if(ea!==Z){var ta=$(ea).find("stop");$(Z).empty().append(ta);ea=Z;Z=Ab.val();ea.setAttribute("spreadMethod",Z)}nb=na==="rg"&&ea.getAttribute("fx")!=null&&!(Ia==La&&Qa==Ua);$("#"+o+"_jGraduate_focusCoord").toggle(nb);if(nb)$("#"+
o+"_jGraduate_match_ctr")[0].checked=false}else{$(L+" .jGraduate_gradPick").hide();$(L+" .jGraduate_colPick").show()}});$(L+" > div").hide();Ib.removeClass("jGraduate_tab_current");var Rb;switch(u.paint.type){case "linearGradient":Rb=$(L+" .jGraduate_tab_lingrad");break;case "radialGradient":Rb=$(L+" .jGraduate_tab_radgrad");break;default:Rb=$(L+" .jGraduate_tab_color")}u.show();setTimeout(function(){Rb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();$.fn.SpinButton=function(a){function n(f,c){for(var m=f[c],p=document.body;(f=f.offsetParent)&&f!=p;)if(!$.browser.msie||f.currentStyle.position!="relative")m+=f[c];return m}return this.each(function(){this.repeating=false;this.spinCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&a.step?Number(a.step):1,stepfunc:a&&a.stepfunc?a.stepfunc:false,page:a&&a.page?Number(a.page):10,upClass:a&&a.upClass?a.upClass:"up",downClass:a&&a.downClass?
a.downClass:"down",reset:a&&a.reset?a.reset:this.value,delay:a&&a.delay?Number(a.delay):500,interval:a&&a.interval?Number(a.interval):100,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.spinCfg.smallStep=a&&a.smallStep?a.smallStep:this.spinCfg.step/2;this.adjustValue=function(f){f=isNaN(this.value)?this.spinCfg.reset:$.isFunction(this.spinCfg.stepfunc)?this.spinCfg.stepfunc(this,f):Number((Number(this.value)+Number(f)).toFixed(5));if(this.spinCfg.min!==
null)f=Math.max(f,this.spinCfg.min);if(this.spinCfg.max!==null)f=Math.min(f,this.spinCfg.max);this.value=f;$.isFunction(this.spinCfg.callback)&&this.spinCfg.callback(this)};$(this).addClass(a&&a.spinClass?a.spinClass:"spin-button").mousemove(function(f){var c=f.pageX||f.x,m=f.pageY||f.y;f=f.target||f.srcElement;var p=svgEditor.tool_scale||1,b=$(f).height()/2;c=c>n(f,"offsetLeft")+f.offsetWidth*p-this.spinCfg._btn_width?m<n(f,"offsetTop")+b*p?1:-1:0;if(c!==this.spinCfg._direction){switch(c){case 1:$(this).removeClass(this.spinCfg.downClass).addClass(this.spinCfg.upClass);
@ -195,195 +195,195 @@ dy-=newcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-angle;return{x:(r*Mat
1;L=z.getItem(o);var T=L.pathSegType;if(T!=1){var N=b(L.x,L.y);N=[N.x,N.y];if(L.x1!=null&&L.x2!=null){c_vals1=b(L.x1,L.y1);c_vals2=b(L.x2,L.y2);N.splice(N.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(T,o,N)}}svgedit.utilities.getBBox(d);z=svgroot.createSVGTransform();d=svgedit.transformlist.getTransformList(d);z.setRotate(e*180/Math.PI,u,l);d.replaceItem(z,0)}};svgedit.path.clearData=function(){m={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(n,f){var c=this.length;if(!c)return a.apply(this,arguments);for(var m=0;m<c;m++){var p=this[m];if(p.namespaceURI==="http://www.w3.org/2000/svg")if(f!==undefined)p.setAttribute(n,f);else if($.isArray(n)){c=n.length;for(m={};c--;){var b=n[c],d=p.getAttribute(b);if(d||d==="0")d=isNaN(d)?d:d-0;m[b]=d}return m}else if(typeof n==="object")for(b in n)p.setAttribute(b,n[b]);else{if((d=p.getAttribute(n))||d==="0")d=isNaN(d)?d:d-0;return d}else return a.apply(this,
arguments)}return this}})();
$.SvgCanvas=function(a,n){function f(g,h){for(var k=svgedit.utilities.getBBox(g),v=0;v<2;v++){var t=v===0?"fill":"stroke",E=g.getAttribute(t);if(E&&E.indexOf("url(")===0){E=X(E);if(E.tagName==="linearGradient"){var w=E.getAttribute("x1")||0,s=E.getAttribute("y1")||0,A=E.getAttribute("x2")||1,F=E.getAttribute("y2")||0;w=k.width*w+k.x;s=k.height*s+k.y;A=k.width*A+k.x;F=k.height*F+k.y;w=O(w,s,h);F=O(A,F,h);A={};A.x1=(w.x-k.x)/k.width;A.y1=(w.y-k.y)/k.height;A.x2=(F.x-k.x)/k.width;A.y2=(F.y-k.y)/k.height;
E=E.cloneNode(true);$(E).attr(A);E.id=M();ub().appendChild(E);g.setAttribute(t,"url(#"+E.id+")")}}}}var c="http://www.w3.org/2000/svg",m={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};n&&$.extend(m,n);var p=m.dimensions,b=this,d=a.ownerDocument,e=d.importNode(svgedit.utilities.text2xml('<svg id="svgroot" xmlns="'+c+'" xlinkns="http://www.w3.org/1999/xlink" width="'+p[0]+'" height="'+p[1]+'" x="'+p[0]+'" y="'+p[1]+'" overflow="visible"><defs><filter id="canvashadow" filterUnits="objectBoundingBox"><feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/><feOffset in="blur" dx="5" dy="5" result="offsetBlur"/><feMerge><feMergeNode in="offsetBlur"/><feMergeNode in="SourceGraphic"/></feMerge></filter></defs></svg>').documentElement,
$.SvgCanvas=function(a,n){function f(g,h){for(var k=svgedit.utilities.getBBox(g),v=0;v<2;v++){var s=v===0?"fill":"stroke",E=g.getAttribute(s);if(E&&E.indexOf("url(")===0){E=X(E);if(E.tagName==="linearGradient"){var w=E.getAttribute("x1")||0,t=E.getAttribute("y1")||0,A=E.getAttribute("x2")||1,F=E.getAttribute("y2")||0;w=k.width*w+k.x;t=k.height*t+k.y;A=k.width*A+k.x;F=k.height*F+k.y;w=O(w,t,h);F=O(A,F,h);A={};A.x1=(w.x-k.x)/k.width;A.y1=(w.y-k.y)/k.height;A.x2=(F.x-k.x)/k.width;A.y2=(F.y-k.y)/k.height;
E=E.cloneNode(true);$(E).attr(A);E.id=M();ub().appendChild(E);g.setAttribute(s,"url(#"+E.id+")")}}}}var c="http://www.w3.org/2000/svg",m={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};n&&$.extend(m,n);var p=m.dimensions,b=this,d=a.ownerDocument,e=d.importNode(svgedit.utilities.text2xml('<svg id="svgroot" xmlns="'+c+'" xlinkns="http://www.w3.org/1999/xlink" width="'+p[0]+'" height="'+p[1]+'" x="'+p[0]+'" y="'+p[1]+'" overflow="visible"><defs><filter id="canvashadow" filterUnits="objectBoundingBox"><feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/><feOffset in="blur" dx="5" dy="5" result="offsetBlur"/><feMerge><feMergeNode in="offsetBlur"/><feMergeNode in="SourceGraphic"/></feMerge></filter></defs></svg>').documentElement,
true);a.appendChild(e);var l=d.createElementNS(c,"svg");(b.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:p[0],height:p[1],x:p[0],y:p[1],overflow:m.show_outside_canvas?"visible":"hidden",xmlns:c,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(e);var g=d.createComment(" Created with SVG-edit - http://svg-edit.googlecode.com/ ");l.appendChild(g)})();var u="svg_";b.setIdPrefix=function(g){u=
g};b.current_drawing_=new svgedit.draw.Drawing(l,u);var z=b.getCurrentDrawing=function(){return b.current_drawing_},o=1,L=null,T={shape:{fill:(m.initFill.color=="none"?"":"#")+m.initFill.color,fill_paint:null,fill_opacity:m.initFill.opacity,stroke:"#"+m.initStroke.color,stroke_paint:null,stroke_opacity:m.initStroke.opacity,stroke_width:m.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:m.initOpacity}};T.text=$.extend(true,{},T.shape);$.extend(T.text,{fill:"#000000",
stroke_width:0,font_size:24,font_family:"Junction"});var N=T.shape,J=Array(1),da=this.addSvgElementFromJson=function(g){var h=svgedit.utilities.getElem(g.attr.id),k=z().getCurrentLayer();if(h&&g.element!=h.tagName){k.removeChild(h);h=null}if(!h){h=d.createElementNS(c,g.element);if(k)(L||k).appendChild(h)}g.curStyles&&svgedit.utilities.assignAttributes(h,{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(h,g.attr,100);svgedit.utilities.cleanupElement(h);return h},V=b.getTransformList=svgedit.transformlist.getTransformList,O=svgedit.math.transformPoint,fa=b.matrixMultiply=svgedit.math.matrixMultiply,sa=b.hasMatrixTransform=svgedit.math.hasMatrixTransform,ja=b.transformListToTransform=svgedit.math.transformListToTransform,ca=svgedit.math.snapToAngle,
ea=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return m.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return Za.round_digits}});var qa=b.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return d},getDOMContainer:function(){return a},getSVGRoot:function(){return e},getSelectedElements:function(){return J},
getSVGContent:function(){return l}});var pa=b.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,ba=b.getHref=svgedit.utilities.getHref,S=b.setHref=svgedit.utilities.setHref,U=svgedit.utilities.getPathBBox;b.getBBox=svgedit.utilities.getBBox;var ra=b.getRotationAngle=svgedit.utilities.getRotationAngle,la=b.getElem=svgedit.utilities.getElem,ma=b.assignAttributes=svgedit.utilities.assignAttributes,Y=this.cleanupElement=svgedit.utilities.cleanupElement,za=svgedit.sanitize.getNSMap(),Ia=b.sanitizeSvg=svgedit.sanitize.sanitizeSvg,
Qa=svgedit.history.MoveElementCommand,Ka=svgedit.history.InsertElementCommand,Ua=svgedit.history.RemoveElementCommand,Wa=svgedit.history.ChangeElementCommand,La=svgedit.history.BatchCommand;b.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(g,h){var k=svgedit.history.HistoryEventTypes;if(g==k.BEFORE_UNAPPLY||g==k.BEFORE_APPLY)b.clearSelection();else if(g==k.AFTER_APPLY||g==k.AFTER_UNAPPLY){var v=h.elements();b.pathActions.clear();I("changed",v);v=h.type();k=g==k.AFTER_APPLY;if(v==
Qa.type()){k=k?h.newParent:h.oldParent;k==l&&b.identifyLayers()}else if(v==Ka.type()||v==Ua.type()){h.parent==l&&b.identifyLayers();if(v==Ka.type())k&&ab(h.elem);else k||ab(h.elem);h.elem.tagName==="use"&&Ub(h.elem)}else if(v==Wa.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&b.identifyLayers();k=k?h.newValues:h.oldValues;k.stdDeviation&&b.setBlurOffsets(h.elem.parentNode,k.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){v=h.elem;if(!v.getAttribute("x")&&!v.getAttribute("y")){k=
v.parentNode;var t=v.nextSibling;k.removeChild(v);k.insertBefore(v,t)}}}}}});var Ga=function(g){b.undoMgr.addCommandToHistory(g)};svgedit.select.init(m,{createSVGElement:function(g){return b.addSvgElementFromJson(g)},svgRoot:function(){return e},svgContent:function(){return l},currentZoom:function(){return o},getStrokedBBox:function(g){return b.getStrokedBBox([g])}});var Oa=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return o},getSVGRoot:function(){return e}});
Qa=svgedit.history.MoveElementCommand,La=svgedit.history.InsertElementCommand,Ua=svgedit.history.RemoveElementCommand,Wa=svgedit.history.ChangeElementCommand,Ma=svgedit.history.BatchCommand;b.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(g,h){var k=svgedit.history.HistoryEventTypes;if(g==k.BEFORE_UNAPPLY||g==k.BEFORE_APPLY)b.clearSelection();else if(g==k.AFTER_APPLY||g==k.AFTER_UNAPPLY){var v=h.elements();b.pathActions.clear();I("changed",v);v=h.type();k=g==k.AFTER_APPLY;if(v==
Qa.type()){k=k?h.newParent:h.oldParent;k==l&&b.identifyLayers()}else if(v==La.type()||v==Ua.type()){h.parent==l&&b.identifyLayers();if(v==La.type())k&&ab(h.elem);else k||ab(h.elem);h.elem.tagName==="use"&&Ub(h.elem)}else if(v==Wa.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&b.identifyLayers();k=k?h.newValues:h.oldValues;k.stdDeviation&&b.setBlurOffsets(h.elem.parentNode,k.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){v=h.elem;if(!v.getAttribute("x")&&!v.getAttribute("y")){k=
v.parentNode;var s=v.nextSibling;k.removeChild(v);k.insertBefore(v,s)}}}}}});var Ga=function(g){b.undoMgr.addCommandToHistory(g)};svgedit.select.init(m,{createSVGElement:function(g){return b.addSvgElementFromJson(g)},svgRoot:function(){return e},svgContent:function(){return l},currentZoom:function(){return o},getStrokedBBox:function(g){return b.getStrokedBBox([g])}});var Oa=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return o},getSVGRoot:function(){return e}});
svgedit.utilities.snapToGrid=function(g){var h=m.snappingStep,k=m.baseUnit;if(k!=="px")h*=svgedit.units.getTypeMap()[k];return g=Math.round(g/h)*h};var Fa=svgedit.utilities.snapToGrid,Gb={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"},Nb=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],lb=$.data,
ab=function(g){var h=$(g).attr(Nb),k;for(k in h){var v=h[k];if(v&&v.indexOf("url(")===0){v=pa(v).substr(1);if(!la(v)){ub().appendChild(Bb[v]);delete Bb[v]}}}g=g.getElementsByTagName("*");if(g.length){h=0;for(k=g.length;h<k;h++)ab(g[h])}},Sa={},Ja=m.imgPath+"logo.png",Ea=[],Za={round_digits:5},Ra=false,$a=null,Na="select",mb="none",Ab={},cb=T.text,jb=N,kb=null,Ca=null,wb=[],nb={},yb=null,Bb={};b.clipBoard=[];var ob=this.runExtensions=function(g,h,k){var v=false;if(k)v=[];$.each(nb,function(t,E){if(g in
ab=function(g){var h=$(g).attr(Nb),k;for(k in h){var v=h[k];if(v&&v.indexOf("url(")===0){v=pa(v).substr(1);if(!la(v)){ub().appendChild(Bb[v]);delete Bb[v]}}}g=g.getElementsByTagName("*");if(g.length){h=0;for(k=g.length;h<k;h++)ab(g[h])}},Sa={},Ja=m.imgPath+"logo.png",Ea=[],Za={round_digits:5},Ra=false,$a=null,Ka="select",mb="none",Ab={},cb=T.text,jb=N,kb=null,Ca=null,wb=[],nb={},yb=null,Bb={};b.clipBoard=[];var ob=this.runExtensions=function(g,h,k){var v=false;if(k)v=[];$.each(nb,function(s,E){if(g in
E)if(k)v.push(E[g](h));else v=E[g](h)});return v};this.addExtension=function(g,h){if(g in nb)console.log('Cannot add extension "'+g+'", an extension by that name already exists"');else{var k=$.isFunction(h)?h($.extend(b.getPrivateMethods(),{svgroot:e,svgcontent:l,nonce:z().getNonce(),selectorManager:Oa})):h;nb[g]=k;I("extension_added",k)}};var Cb=this.round=function(g){return parseInt(g*o)/o},Kb=this.getIntersectionList=function(g){if(Ca==null)return null;var h=L||z().getCurrentLayer();wb.length||
(wb=Rb(h));var k=null;try{k=h.getIntersectionList(g,null)}catch(v){}if(k==null||typeof k.item!="function"){k=[];if(g)g=g;else{g=Ca.getBBox();h={};for(var t in g)h[t]=g[t]/o;g=h}for(t=wb.length;t--;)g.width&&g.width&&svgedit.math.rectsIntersect(g,wb[t].bbox)&&k.push(wb[t].elem)}return k};getStrokedBBox=this.getStrokedBBox=function(g){g||(g=Ib());if(!g.length)return false;var h=function(F){try{var C=svgedit.utilities.getBBox(F),D=svgedit.utilities.getRotationAngle(F);if(D&&D%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(F))){D=
false;if(["ellipse","path","line","polyline","polygon"].indexOf(F.tagName)>=0)C=D=b.convertToPath(F,true);else if(F.tagName=="rect"){var G=F.getAttribute("rx"),H=F.getAttribute("ry");if(G||H)C=D=b.convertToPath(F,true)}if(!D){var P=F.cloneNode(true),R=document.createElementNS(c,"g"),aa=F.parentNode;aa.appendChild(R);R.appendChild(P);C=svgedit.utilities.bboxToObj(R.getBBox());aa.removeChild(R)}}return C}catch(ua){console.log(F,ua);return null}},k;$.each(g,function(){if(!k)if(this.parentNode)k=h(this)});
if(k==null)return null;var v=k.x+k.width,t=k.y+k.height,E=k.x,w=k.y,s=function(F){var C=F.getAttribute("stroke-width"),D=0;if(F.getAttribute("stroke")!="none"&&!isNaN(C))D+=C/2;return D},A=[];$.each(g,function(F,C){var D=h(C);if(D){var G=s(C);E=Math.min(E,D.x-G);w=Math.min(w,D.y-G);A.push(D)}});k.x=E;k.y=w;$.each(g,function(F,C){var D=A[F];if(D&&C.nodeType==1){var G=s(C);v=Math.max(v,D.x+D.width+G);t=Math.max(t,D.y+D.height+G)}});k.width=v-E;k.height=t-w;return k};var Ib=this.getVisibleElements=function(g){g||
(g=$(l).children());var h=[];$(g).children().each(function(k,v){try{v.getBBox()&&h.push(v)}catch(t){}});return h.reverse()},Rb=this.getVisibleElementsAndBBoxes=function(g){g||(g=$(l).children());var h=[];$(g).children().each(function(k,v){try{v.getBBox()&&h.push({elem:v,bbox:getStrokedBBox([v])})}catch(t){}});return h.reverse()},na=this.groupSvgElem=function(g){var h=document.createElementNS(c,"g");g.parentNode.replaceChild(h,g);$(h).append(g).data("gsvg",g)[0].id=M()},Z=function(g){var h=document.createElementNS(g.namespaceURI,
g.nodeName);h.removeAttribute("id");$.each(g.attributes,function(v,t){t.localName!="-moz-math-font-style"&&h.setAttributeNS(t.namespaceURI,t.nodeName,t.nodeValue)});if(svgedit.browser.isWebkit()&&g.nodeName=="path"){var k=Va.convertPath(g);h.setAttribute("d",k)}$.each(g.childNodes,function(v,t){switch(t.nodeType){case 1:h.appendChild(Z(t));break;case 3:h.textContent=t.nodeValue}});if($(g).data("gsvg"))$(h).data("gsvg",h.firstChild);else if($(g).data("symbol")){g=$(g).data("symbol");$(h).data("ref",
g).data("symbol",g)}else h.tagName=="image"&&Zb(h);h.id=M();console.log(h);return h},ta,M,I;(function(g){var h={};ta=g.getId=function(){return z().getId()};M=g.getNextId=function(){return z().getNextId()};I=g.call=function(k,v){if(h[k])return h[k](this,v)};g.bind=function(k,v){var t=h[k];h[k]=v;return t}})(b);this.prepareSvg=function(g){this.sanitizeSvg(g.documentElement);g=g.getElementsByTagNameNS(c,"path");for(var h=0,k=g.length;h<k;++h){var v=g[h];v.setAttribute("d",Va.convertPath(v));Va.fixEnd(v)}};
var X=this.getRefElem=function(g){return la(pa(g).substr(1))},Ma=function(g){if(!svgedit.browser.isGecko())return g;var h=g.cloneNode(true);g.parentNode.insertBefore(h,g);g.parentNode.removeChild(g);Oa.releaseSelector(g);J[0]=h;Oa.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(g,h){g=parseFloat(g);var k=J[0],v=k.getAttribute("transform"),t=svgedit.utilities.getBBox(k),E=t.x+t.width/2,w=t.y+t.height/2;t=V(k);t.numberOfItems>0&&t.getItem(0).type==4&&t.removeItem(0);if(g!=
0){E=O(E,w,ja(t).matrix);w=e.createSVGTransform();w.setRotate(g,E.x,E.y);t.numberOfItems?t.insertItemBefore(w,0):t.appendItem(w)}else t.numberOfItems==0&&k.removeAttribute("transform");if(!h){t=k.getAttribute("transform");k.setAttribute("transform",v);vb("transform",t,J);I("changed",J)}la("pathpointgrip_container");k=Oa.requestSelector(J[0]);k.resize();k.updateGripCursors(g)};var Xa=this.recalculateAllSelectedDimensions=function(){for(var g=new La(mb=="none"?"position":"size"),h=J.length;h--;){var k=
pb(J[h]);k&&g.addSubCommand(k)}if(!g.isEmpty()){Ga(g);I("changed",J)}},db=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],tb=function(g){console.log([g.a,g.b,g.c,g.d,g.e,g.f])},xb=this.remapElement=function(g,h,k){var v=m.gridSnapping&&g.parentNode.parentNode.localName==="svg",t=function(){if(v)for(var D in h)h[D]=Fa(h[D]);ma(g,h,1E3,true)};box=svgedit.utilities.getBBox(g);for(var E=0;E<2;E++){var w=E===0?"fill":"stroke",s=g.getAttribute(w);if(s&&s.indexOf("url(")===
0)if(k.a<0||k.d<0){s=X(s).cloneNode(true);if(k.a<0){var A=s.getAttribute("x1"),F=s.getAttribute("x2");s.setAttribute("x1",-(A-1));s.setAttribute("x2",-(F-1))}if(k.d<0){A=s.getAttribute("y1");F=s.getAttribute("y2");s.setAttribute("y1",-(A-1));s.setAttribute("y2",-(F-1))}s.id=M();ub().appendChild(s);g.setAttribute(w,"url(#"+s.id+")")}}E=g.tagName;if(E==="g"||E==="text"||E==="use")if(k.a==1&&k.b==0&&k.c==0&&k.d==1&&(k.e!=0||k.f!=0)){w=ja(g).matrix;w=fa(w.inverse(),k,w);h.x=parseFloat(h.x)+w.e;h.y=parseFloat(h.y)+
w.f}else{w=V(g);s=e.createSVGTransform();s.setMatrix(fa(ja(w).matrix,k));w.clear();w.appendItem(s)}switch(E){case "foreignObject":case "rect":case "image":if(E==="image"&&(k.a<0||k.d<0)){w=V(g);s=e.createSVGTransform();s.setMatrix(fa(ja(w).matrix,k));w.clear();w.appendItem(s)}else{w=O(h.x,h.y,k);h.width=k.a*h.width;h.height=k.d*h.height;h.x=w.x+Math.min(0,h.width);h.y=w.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}t();break;case "ellipse":E=O(h.cx,h.cy,k);h.cx=E.x;
h.cy=E.y;h.rx=k.a*h.rx;h.ry=k.d*h.ry;h.rx=Math.abs(h.rx);h.ry=Math.abs(h.ry);t();break;case "circle":E=O(h.cx,h.cy,k);h.cx=E.x;h.cy=E.y;E=svgedit.math.transformBox(box.x,box.y,box.width,box.height,k);h.r=Math.min((E.tr.x-E.tl.x)/2,(E.bl.y-E.tl.y)/2);if(h.r)h.r=Math.abs(h.r);t();break;case "line":w=O(h.x1,h.y1,k);A=O(h.x2,h.y2,k);h.x1=w.x;h.y1=w.y;h.x2=A.x;h.y2=A.y;case "text":k=g.querySelectorAll("tspan");for(E=k.length;E--;){w=qa("x",g.getAttribute("x"));s=qa("x",k[E].getAttribute("x"));A=qa("y",
g.getAttribute("y"));F=qa("y",k[E].getAttribute("y"));var C={};if(!isNaN(w)&&!isNaN(s)&&w!=0&&s!=0&&h.x)C.x=h.x-(w-s);if(!isNaN(A)&&!isNaN(F)&&A!=0&&F!=0&&h.y)C.y=h.y-(A-F);if(C.x||C.y)ma(k[E],C,1E3,true)}t();break;case "use":t();break;case "g":(t=$(g).data("gsvg"))&&ma(t,h,1E3,true);break;case "polyline":case "polygon":t=h.points.length;for(E=0;E<t;++E){F=h.points[E];F=O(F.x,F.y,k);h.points[E].x=F.x;h.points[E].y=F.y}t=h.points.length;k="";for(E=0;E<t;++E){F=h.points[E];k+=F.x+","+F.y+" "}g.setAttribute("points",
k);break;case "path":w=g.pathSegList;t=w.numberOfItems;h.d=Array(t);for(E=0;E<t;++E){s=w.getItem(E);h.d[E]={type:s.pathSegType,x:s.x,y:s.y,x1:s.x1,y1:s.y1,x2:s.x2,y2:s.y2,r1:s.r1,r2:s.r2,angle:s.angle,largeArcFlag:s.largeArcFlag,sweepFlag:s.sweepFlag}}t=h.d.length;E=h.d[0];C=O(E.x,E.y,k);h.d[0].x=C.x;h.d[0].y=C.y;for(E=1;E<t;++E){s=h.d[E];w=s.type;if(w%2==0){F=O(s.x!=undefined?s.x:C.x,s.y!=undefined?s.y:C.y,k);w=O(s.x1,s.y1,k);A=O(s.x2,s.y2,k);s.x=F.x;s.y=F.y;s.x1=w.x;s.y1=w.y;s.x2=A.x;s.y2=A.y}else{s.x=
k.a*s.x;s.y=k.d*s.y;s.x1=k.a*s.x1;s.y1=k.d*s.y1;s.x2=k.a*s.x2;s.y2=k.d*s.y2}s.r1=k.a*s.r1;s.r2=k.d*s.r2}k="";t=h.d.length;for(E=0;E<t;++E){s=h.d[E];w=s.type;k+=db[w];switch(w){case 13:case 12:k+=s.x+" ";break;case 15:case 14:k+=s.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:k+=s.x+","+s.y+" ";break;case 7:case 6:k+=s.x1+","+s.y1+" "+s.x2+","+s.y2+" "+s.x+","+s.y+" ";break;case 9:case 8:k+=s.x1+","+s.y1+" "+s.x+","+s.y+" ";break;case 11:case 10:k+=s.r1+","+s.r2+" "+s.angle+" "+ +s.largeArcFlag+
" "+ +s.sweepFlag+" "+s.x+","+s.y+" ";break;case 17:case 16:k+=s.x2+","+s.y2+" "+s.x+","+s.y+" "}}g.setAttribute("d",k)}},Hb=function(g,h,k){g=X(g).firstChild;var v=V(g),t=e.createSVGTransform();t.setTranslate(h,k);v.appendItem(t);pb(g)},pb=this.recalculateDimensions=function(g){if(g==null)return null;var h=V(g);if(h&&h.numberOfItems>0){for(var k=h.numberOfItems;k--;){var v=h.getItem(k);if(v.type===0)h.removeItem(k);else if(v.type===1)svgedit.math.isIdentity(v.matrix)&&h.removeItem(k);else v.type===
4&&v.angle===0&&h.removeItem(k)}if(h.numberOfItems===1&&ra(g))return null}if(!h||h.numberOfItems==0){g.removeAttribute("transform");return null}if(h){k=h.numberOfItems;for(var t=[];k--;){v=h.getItem(k);if(v.type===1)t.push([v.matrix,k]);else if(t.length)t=[]}if(t.length===2){k=e.createSVGTransformFromMatrix(fa(t[1][0],t[0][0]));h.removeItem(t[0][1]);h.removeItem(t[1][1]);h.insertItemBefore(k,t[1][1])}k=h.numberOfItems;if(k>=2&&h.getItem(k-2).type===1&&h.getItem(k-1).type===2){t=e.createSVGTransform();
v=fa(h.getItem(k-2).matrix,h.getItem(k-1).matrix);t.setMatrix(v);h.removeItem(k-2);h.removeItem(k-2);h.appendItem(t)}}switch(g.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var E=$(g).data("gsvg");k=new La("Transform");var w={},s=null;v=[];switch(g.tagName){case "line":v=["x1","y1","x2","y2"];break;case "circle":v=["cx","cy","r"];break;case "ellipse":v=
["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":v=["width","height","x","y"];break;case "use":case "text":case "tspan":v=["x","y"];break;case "polygon":case "polyline":s={};s.points=g.getAttribute("points");t=g.points;var A=t.numberOfItems;w.points=Array(A);for(var F=0;F<A;++F){var C=t.getItem(F);w.points[F]={x:C.x,y:C.y}}break;case "path":s={};s.d=g.getAttribute("d");w.d=g.getAttribute("d")}if(v.length){w=$(g).attr(v);$.each(w,function(Jb,Ob){w[Jb]=qa(Jb,Ob)})}else if(E)w=
{x:$(E).attr("x")||0,y:$(E).attr("y")||0};if(s==null){s=$.extend(true,{},w);$.each(s,function(Jb,Ob){s[Jb]=qa(Jb,Ob)})}s.transform=$a?$a:"";if(g.tagName=="g"&&!E||g.tagName=="a"){t=svgedit.utilities.getBBox(g);var D={x:t.x+t.width/2,y:t.y+t.height/2},G=O(t.x+t.width/2,t.y+t.height/2,ja(h).matrix);v=e.createSVGMatrix();if(t=ra(g)){F=t*Math.PI/180;A=Math.abs(F)>1.0E-10?Math.sin(F)/(1-Math.cos(F)):2/F;for(F=0;F<h.numberOfItems;++F){v=h.getItem(F);if(v.type==4){v=v.matrix;D.y=(A*v.e+v.f)/2;D.x=(v.e-A*
v.f)/2;h.removeItem(F);break}}}F=v=E=0;var H=h.numberOfItems;if(H)var P=h.getItem(0).matrix;if(H>=3&&h.getItem(H-2).type==3&&h.getItem(H-3).type==2&&h.getItem(H-1).type==2){F=3;var R=h.getItem(H-3).matrix,aa=h.getItem(H-2).matrix,ua=h.getItem(H-1).matrix;A=g.childNodes;for(C=A.length;C--;){var wa=A.item(C);v=E=0;if(wa.nodeType==1){var ha=V(wa);if(ha){v=ja(ha).matrix;E=ra(wa);var ka=$a,oa=[];$a=wa.getAttribute("transform");if(E||sa(ha)){var xa=e.createSVGTransform();xa.setMatrix(fa(R,aa,ua,v));ha.clear();
ha.appendItem(xa);oa.push(xa)}else{E=fa(v.inverse(),ua,v);xa=e.createSVGMatrix();xa.e=-E.e;xa.f=-E.f;v=fa(xa.inverse(),v.inverse(),R,aa,ua,v,E.inverse());var eb=e.createSVGTransform(),Db=e.createSVGTransform(),Pb=e.createSVGTransform();eb.setTranslate(E.e,E.f);Db.setScale(v.a,v.d);Pb.setTranslate(xa.e,xa.f);ha.appendItem(Pb);ha.appendItem(Db);ha.appendItem(eb);oa.push(Pb);oa.push(Db);oa.push(eb)}k.addSubCommand(pb(wa));$a=ka}}}h.removeItem(H-1);h.removeItem(H-2);h.removeItem(H-3)}else if(H>=3&&h.getItem(H-
1).type==1){F=3;v=ja(h).matrix;xa=e.createSVGTransform();xa.setMatrix(v);h.clear();h.appendItem(xa)}else if((H==1||H>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){F=2;E=ja(h).matrix;h.removeItem(0);v=ja(h).matrix.inverse();v=fa(v,E);E=v.e;v=v.f;if(E!=0||v!=0){A=g.childNodes;C=A.length;for(H=[];C--;){wa=A.item(C);if(wa.nodeType==1){if(wa.getAttribute("clip-path")){ka=wa.getAttribute("clip-path");if(H.indexOf(ka)===-1){Hb(ka,E,v);H.push(ka)}}ka=$a;$a=wa.getAttribute("transform");if(ha=V(wa)){R=e.createSVGTransform();
R.setTranslate(E,v);ha.numberOfItems?ha.insertItemBefore(R,0):ha.appendItem(R);k.addSubCommand(pb(wa));ha=g.getElementsByTagNameNS(c,"use");wa="#"+wa.id;for(R=ha.length;R--;){aa=ha.item(R);if(wa==ba(aa)){ua=e.createSVGTransform();ua.setTranslate(-E,-v);V(aa).insertItemBefore(ua,0);k.addSubCommand(pb(aa))}}$a=ka}}}H=[];$a=ka}}else if(H==1&&h.getItem(0).type==1&&!t){F=1;v=h.getItem(0).matrix;A=g.childNodes;for(C=A.length;C--;){wa=A.item(C);if(wa.nodeType==1){ka=$a;$a=wa.getAttribute("transform");if(ha=
V(wa)){E=fa(v,ja(ha).matrix);H=e.createSVGTransform();H.setMatrix(E);ha.clear();ha.appendItem(H,0);k.addSubCommand(pb(wa));$a=ka;ka=wa.getAttribute("stroke-width");wa.getAttribute("stroke")!=="none"&&!isNaN(ka)&&wa.setAttribute("stroke-width",ka*((Math.abs(E.a)+Math.abs(E.d))/2))}}}h.clear()}else{if(t){D=e.createSVGTransform();D.setRotate(t,G.x,G.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}h.numberOfItems==0&&g.removeAttribute("transform");return null}if(F==2){if(t){G={x:D.x+P.e,y:D.y+
P.f};D=e.createSVGTransform();D.setRotate(t,G.x,G.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else if(F==3){v=ja(h).matrix;P=e.createSVGTransform();P.setRotate(t,D.x,D.y);P=P.matrix;D=e.createSVGTransform();D.setRotate(t,G.x,G.y);G=D.matrix.inverse();ka=v.inverse();G=fa(ka,G,P,v);E=G.e;v=G.f;if(E!=0||v!=0){A=g.childNodes;for(C=A.length;C--;){wa=A.item(C);if(wa.nodeType==1){ka=$a;$a=wa.getAttribute("transform");ha=V(wa);R=e.createSVGTransform();R.setTranslate(E,v);ha.numberOfItems?
ha.insertItemBefore(R,0):ha.appendItem(R);k.addSubCommand(pb(wa));$a=ka}}}if(t)h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else{t=svgedit.utilities.getBBox(g);if(!t&&g.tagName!="path")return null;v=e.createSVGMatrix();if(E=ra(g)){D={x:t.x+t.width/2,y:t.y+t.height/2};G=O(t.x+t.width/2,t.y+t.height/2,ja(h).matrix);F=E*Math.PI/180;A=Math.abs(F)>1.0E-10?Math.sin(F)/(1-Math.cos(F)):2/F;for(F=0;F<h.numberOfItems;++F){v=h.getItem(F);if(v.type==4){v=v.matrix;D.y=(A*v.e+v.f)/2;D.x=(v.e-A*v.f)/
2;h.removeItem(F);break}}}F=0;H=h.numberOfItems;if(!svgedit.browser.isWebkit())if((P=g.getAttribute("fill"))&&P.indexOf("url(")===0){P=X(P);ka="pattern";if(P.tagName!==ka)ka="gradient";if(P.getAttribute(ka+"Units")==="userSpaceOnUse"){v=ja(h).matrix;t=V(P);t=ja(t).matrix;v=fa(v,t);t="matrix("+[v.a,v.b,v.c,v.d,v.e,v.f].join(",")+")";P.setAttribute(ka+"Transform",t)}}if(H>=3&&h.getItem(H-2).type==3&&h.getItem(H-3).type==2&&h.getItem(H-1).type==2){F=3;v=ja(h,H-3,H-1).matrix;h.removeItem(H-1);h.removeItem(H-
2);h.removeItem(H-3)}else if(H==4&&h.getItem(H-1).type==1){F=3;v=ja(h).matrix;xa=e.createSVGTransform();xa.setMatrix(v);h.clear();h.appendItem(xa);v=e.createSVGMatrix()}else if((H==1||H>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){F=2;P=h.getItem(0).matrix;ka=ja(h,1).matrix;t=ka.inverse();v=fa(t,P,ka);h.removeItem(0)}else if(H==1&&h.getItem(0).type==1&&!E){v=ja(h).matrix;switch(g.tagName){case "line":w=$(g).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":w.points=g.getAttribute("points");
if(w.points){t=g.points;A=t.numberOfItems;w.points=Array(A);for(F=0;F<A;++F){C=t.getItem(F);w.points[F]={x:C.x,y:C.y}}}case "path":w.d=g.getAttribute("d");F=1;h.clear()}}else{F=4;if(E){D=e.createSVGTransform();D.setRotate(E,G.x,G.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}h.numberOfItems==0&&g.removeAttribute("transform");return null}if(F==1||F==2||F==3)xb(g,w,v);if(F==2){if(E){sa(h)||(G={x:D.x+v.e,y:D.y+v.f});D=e.createSVGTransform();D.setRotate(E,G.x,G.y);h.numberOfItems?h.insertItemBefore(D,
0):h.appendItem(D)}}else if(F==3&&E){v=ja(h).matrix;P=e.createSVGTransform();P.setRotate(E,D.x,D.y);P=P.matrix;D=e.createSVGTransform();D.setRotate(E,G.x,G.y);G=D.matrix.inverse();ka=v.inverse();G=fa(ka,G,P,v);xb(g,w,G);if(E)h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}h.numberOfItems==0&&g.removeAttribute("transform");k.addSubCommand(new Wa(g,s));return k},Lb=null,bb=this.clearSelection=function(g){if(J[0]!=null)for(var h=J.length,k=0;k<h;++k){var v=J[k];if(v==null)break;Oa.releaseSelector(v);
J[k]=null}g||I("selected",J)},qb=this.addToSelection=function(g,h){if(g.length!=0){for(var k=0;k<J.length;){if(J[k]==null)break;++k}for(var v=g.length;v--;){var t=g[v];if(t&&svgedit.utilities.getBBox(t)){if(t.tagName==="a"&&t.childNodes.length===1)t=t.firstChild;if(J.indexOf(t)==-1){J[k]=t;k++;t=Oa.requestSelector(t);J.length>1&&t.showGrips(false)}}}I("selected",J);h||J.length==1?Oa.requestSelector(J[0]).showGrips(true):Oa.requestSelector(J[0]).showGrips(false);for(J.sort(function(E,w){if(E&&w&&E.compareDocumentPosition)return 3-
(w.compareDocumentPosition(E)&6);else if(E==null)return 1});J[0]==null;)J.shift(0)}},Qb=this.selectOnly=function(g,h){bb(true);qb(g,h)};this.removeFromSelection=function(g){if(J[0]!=null)if(g.length!=0){var h=Array(J.length);j=0;len=J.length;for(var k=0;k<len;++k){var v=J[k];if(v)if(g.indexOf(v)==-1){h[j]=v;j++}else Oa.releaseSelector(v)}J=h}};this.selectAllInCurrentLayer=function(){var g=z().getCurrentLayer();if(g){Na="select";Qb($(L||g).children())}};var $b=this.getMouseTarget=function(g){if(g==
(wb=Rb(h));var k=null;try{k=h.getIntersectionList(g,null)}catch(v){}if(k==null||typeof k.item!="function"){k=[];if(g)g=g;else{g=Ca.getBBox();h={};for(var s in g)h[s]=g[s]/o;g=h}for(s=wb.length;s--;)g.width&&g.width&&svgedit.math.rectsIntersect(g,wb[s].bbox)&&k.push(wb[s].elem)}return k};getStrokedBBox=this.getStrokedBBox=function(g){g||(g=Ib());if(!g.length)return false;var h=function(F){try{var C=svgedit.utilities.getBBox(F),D=svgedit.utilities.getRotationAngle(F);if(D&&D%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(F))){D=
false;if(["ellipse","path","line","polyline","polygon"].indexOf(F.tagName)>=0)C=D=b.convertToPath(F,true);else if(F.tagName=="rect"){var G=F.getAttribute("rx"),H=F.getAttribute("ry");if(G||H)C=D=b.convertToPath(F,true)}if(!D){var P=F.cloneNode(true),Q=document.createElementNS(c,"g"),aa=F.parentNode;aa.appendChild(Q);Q.appendChild(P);C=svgedit.utilities.bboxToObj(Q.getBBox());aa.removeChild(Q)}}return C}catch(ua){console.log(F,ua);return null}},k;$.each(g,function(){if(!k)if(this.parentNode)k=h(this)});
if(k==null)return null;var v=k.x+k.width,s=k.y+k.height,E=k.x,w=k.y,t=function(F){var C=F.getAttribute("stroke-width"),D=0;if(F.getAttribute("stroke")!="none"&&!isNaN(C))D+=C/2;return D},A=[];$.each(g,function(F,C){var D=h(C);if(D){var G=t(C);E=Math.min(E,D.x-G);w=Math.min(w,D.y-G);A.push(D)}});k.x=E;k.y=w;$.each(g,function(F,C){var D=A[F];if(D&&C.nodeType==1){var G=t(C);v=Math.max(v,D.x+D.width+G);s=Math.max(s,D.y+D.height+G)}});k.width=v-E;k.height=s-w;return k};var Ib=this.getVisibleElements=function(g){g||
(g=$(l).children());var h=[];$(g).children().each(function(k,v){try{v.getBBox()&&h.push(v)}catch(s){}});return h.reverse()},Rb=this.getVisibleElementsAndBBoxes=function(g){g||(g=$(l).children());var h=[];$(g).children().each(function(k,v){try{v.getBBox()&&h.push({elem:v,bbox:getStrokedBBox([v])})}catch(s){}});return h.reverse()},na=this.groupSvgElem=function(g){var h=document.createElementNS(c,"g");g.parentNode.replaceChild(h,g);$(h).append(g).data("gsvg",g)[0].id=M()},Z=function(g){var h=document.createElementNS(g.namespaceURI,
g.nodeName);h.removeAttribute("id");$.each(g.attributes,function(v,s){s.localName!="-moz-math-font-style"&&h.setAttributeNS(s.namespaceURI,s.nodeName,s.nodeValue)});if(svgedit.browser.isWebkit()&&g.nodeName=="path"){var k=Va.convertPath(g);h.setAttribute("d",k)}$.each(g.childNodes,function(v,s){switch(s.nodeType){case 1:h.appendChild(Z(s));break;case 3:h.textContent=s.nodeValue}});if($(g).data("gsvg"))$(h).data("gsvg",h.firstChild);else if($(g).data("symbol")){g=$(g).data("symbol");$(h).data("ref",
g).data("symbol",g)}else h.tagName=="image"&&Zb(h);h.id=M();console.log(h);return h},ta,M,I;(function(g){var h={};ta=g.getId=function(){return z().getId()};M=g.getNextId=function(){return z().getNextId()};I=g.call=function(k,v){if(h[k])return h[k](this,v)};g.bind=function(k,v){var s=h[k];h[k]=v;return s}})(b);this.prepareSvg=function(g){this.sanitizeSvg(g.documentElement);g=g.getElementsByTagNameNS(c,"path");for(var h=0,k=g.length;h<k;++h){var v=g[h];v.setAttribute("d",Va.convertPath(v));Va.fixEnd(v)}};
var X=this.getRefElem=function(g){return la(pa(g).substr(1))},Na=function(g){if(!svgedit.browser.isGecko())return g;var h=g.cloneNode(true);g.parentNode.insertBefore(h,g);g.parentNode.removeChild(g);Oa.releaseSelector(g);J[0]=h;Oa.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(g,h){g=parseFloat(g);var k=J[0],v=k.getAttribute("transform"),s=svgedit.utilities.getBBox(k),E=s.x+s.width/2,w=s.y+s.height/2;s=V(k);s.numberOfItems>0&&s.getItem(0).type==4&&s.removeItem(0);if(g!=
0){E=O(E,w,ja(s).matrix);w=e.createSVGTransform();w.setRotate(g,E.x,E.y);s.numberOfItems?s.insertItemBefore(w,0):s.appendItem(w)}else s.numberOfItems==0&&k.removeAttribute("transform");if(!h){s=k.getAttribute("transform");k.setAttribute("transform",v);vb("transform",s,J);I("changed",J)}la("pathpointgrip_container");k=Oa.requestSelector(J[0]);k.resize();k.updateGripCursors(g)};var Xa=this.recalculateAllSelectedDimensions=function(){for(var g=new Ma(mb=="none"?"position":"size"),h=J.length;h--;){var k=
pb(J[h]);k&&g.addSubCommand(k)}if(!g.isEmpty()){Ga(g);I("changed",J)}},db=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],tb=function(g){console.log([g.a,g.b,g.c,g.d,g.e,g.f])},xb=this.remapElement=function(g,h,k){var v=m.gridSnapping&&g.parentNode.parentNode.localName==="svg",s=function(){if(v)for(var D in h)h[D]=Fa(h[D]);ma(g,h,1E3,true)};box=svgedit.utilities.getBBox(g);for(var E=0;E<2;E++){var w=E===0?"fill":"stroke",t=g.getAttribute(w);if(t&&t.indexOf("url(")===
0)if(k.a<0||k.d<0){t=X(t).cloneNode(true);if(k.a<0){var A=t.getAttribute("x1"),F=t.getAttribute("x2");t.setAttribute("x1",-(A-1));t.setAttribute("x2",-(F-1))}if(k.d<0){A=t.getAttribute("y1");F=t.getAttribute("y2");t.setAttribute("y1",-(A-1));t.setAttribute("y2",-(F-1))}t.id=M();ub().appendChild(t);g.setAttribute(w,"url(#"+t.id+")")}}E=g.tagName;if(E==="g"||E==="text"||E==="use")if(k.a==1&&k.b==0&&k.c==0&&k.d==1&&(k.e!=0||k.f!=0)){w=ja(g).matrix;w=fa(w.inverse(),k,w);h.x=parseFloat(h.x)+w.e;h.y=parseFloat(h.y)+
w.f}else{w=V(g);t=e.createSVGTransform();t.setMatrix(fa(ja(w).matrix,k));w.clear();w.appendItem(t)}switch(E){case "foreignObject":case "rect":case "image":if(E==="image"&&(k.a<0||k.d<0)){w=V(g);t=e.createSVGTransform();t.setMatrix(fa(ja(w).matrix,k));w.clear();w.appendItem(t)}else{w=O(h.x,h.y,k);h.width=k.a*h.width;h.height=k.d*h.height;h.x=w.x+Math.min(0,h.width);h.y=w.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}s();break;case "ellipse":E=O(h.cx,h.cy,k);h.cx=E.x;
h.cy=E.y;h.rx=k.a*h.rx;h.ry=k.d*h.ry;h.rx=Math.abs(h.rx);h.ry=Math.abs(h.ry);s();break;case "circle":E=O(h.cx,h.cy,k);h.cx=E.x;h.cy=E.y;E=svgedit.math.transformBox(box.x,box.y,box.width,box.height,k);h.r=Math.min((E.tr.x-E.tl.x)/2,(E.bl.y-E.tl.y)/2);if(h.r)h.r=Math.abs(h.r);s();break;case "line":w=O(h.x1,h.y1,k);A=O(h.x2,h.y2,k);h.x1=w.x;h.y1=w.y;h.x2=A.x;h.y2=A.y;case "text":k=g.querySelectorAll("tspan");for(E=k.length;E--;){w=qa("x",g.getAttribute("x"));t=qa("x",k[E].getAttribute("x"));A=qa("y",
g.getAttribute("y"));F=qa("y",k[E].getAttribute("y"));var C={};if(!isNaN(w)&&!isNaN(t)&&w!=0&&t!=0&&h.x)C.x=h.x-(w-t);if(!isNaN(A)&&!isNaN(F)&&A!=0&&F!=0&&h.y)C.y=h.y-(A-F);if(C.x||C.y)ma(k[E],C,1E3,true)}s();break;case "use":s();break;case "g":(s=$(g).data("gsvg"))&&ma(s,h,1E3,true);break;case "polyline":case "polygon":s=h.points.length;for(E=0;E<s;++E){F=h.points[E];F=O(F.x,F.y,k);h.points[E].x=F.x;h.points[E].y=F.y}s=h.points.length;k="";for(E=0;E<s;++E){F=h.points[E];k+=F.x+","+F.y+" "}g.setAttribute("points",
k);break;case "path":w=g.pathSegList;s=w.numberOfItems;h.d=Array(s);for(E=0;E<s;++E){t=w.getItem(E);h.d[E]={type:t.pathSegType,x:t.x,y:t.y,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,r1:t.r1,r2:t.r2,angle:t.angle,largeArcFlag:t.largeArcFlag,sweepFlag:t.sweepFlag}}s=h.d.length;E=h.d[0];C=O(E.x,E.y,k);h.d[0].x=C.x;h.d[0].y=C.y;for(E=1;E<s;++E){t=h.d[E];w=t.type;if(w%2==0){F=O(t.x!=undefined?t.x:C.x,t.y!=undefined?t.y:C.y,k);w=O(t.x1,t.y1,k);A=O(t.x2,t.y2,k);t.x=F.x;t.y=F.y;t.x1=w.x;t.y1=w.y;t.x2=A.x;t.y2=A.y}else{t.x=
k.a*t.x;t.y=k.d*t.y;t.x1=k.a*t.x1;t.y1=k.d*t.y1;t.x2=k.a*t.x2;t.y2=k.d*t.y2}t.r1=k.a*t.r1;t.r2=k.d*t.r2}k="";s=h.d.length;for(E=0;E<s;++E){t=h.d[E];w=t.type;k+=db[w];switch(w){case 13:case 12:k+=t.x+" ";break;case 15:case 14:k+=t.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:k+=t.x+","+t.y+" ";break;case 7:case 6:k+=t.x1+","+t.y1+" "+t.x2+","+t.y2+" "+t.x+","+t.y+" ";break;case 9:case 8:k+=t.x1+","+t.y1+" "+t.x+","+t.y+" ";break;case 11:case 10:k+=t.r1+","+t.r2+" "+t.angle+" "+ +t.largeArcFlag+
" "+ +t.sweepFlag+" "+t.x+","+t.y+" ";break;case 17:case 16:k+=t.x2+","+t.y2+" "+t.x+","+t.y+" "}}g.setAttribute("d",k)}},Hb=function(g,h,k){g=X(g).firstChild;var v=V(g),s=e.createSVGTransform();s.setTranslate(h,k);v.appendItem(s);pb(g)},pb=this.recalculateDimensions=function(g){if(g==null)return null;var h=V(g);if(h&&h.numberOfItems>0){for(var k=h.numberOfItems;k--;){var v=h.getItem(k);if(v.type===0)h.removeItem(k);else if(v.type===1)svgedit.math.isIdentity(v.matrix)&&h.removeItem(k);else v.type===
4&&v.angle===0&&h.removeItem(k)}if(h.numberOfItems===1&&ra(g))return null}if(!h||h.numberOfItems==0){g.removeAttribute("transform");return null}if(h){k=h.numberOfItems;for(var s=[];k--;){v=h.getItem(k);if(v.type===1)s.push([v.matrix,k]);else if(s.length)s=[]}if(s.length===2){k=e.createSVGTransformFromMatrix(fa(s[1][0],s[0][0]));h.removeItem(s[0][1]);h.removeItem(s[1][1]);h.insertItemBefore(k,s[1][1])}k=h.numberOfItems;if(k>=2&&h.getItem(k-2).type===1&&h.getItem(k-1).type===2){s=e.createSVGTransform();
v=fa(h.getItem(k-2).matrix,h.getItem(k-1).matrix);s.setMatrix(v);h.removeItem(k-2);h.removeItem(k-2);h.appendItem(s)}}switch(g.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var E=$(g).data("gsvg");k=new Ma("Transform");var w={},t=null;v=[];switch(g.tagName){case "line":v=["x1","y1","x2","y2"];break;case "circle":v=["cx","cy","r"];break;case "ellipse":v=
["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":v=["width","height","x","y"];break;case "use":case "text":case "tspan":v=["x","y"];break;case "polygon":case "polyline":t={};t.points=g.getAttribute("points");s=g.points;var A=s.numberOfItems;w.points=Array(A);for(var F=0;F<A;++F){var C=s.getItem(F);w.points[F]={x:C.x,y:C.y}}break;case "path":t={};t.d=g.getAttribute("d");w.d=g.getAttribute("d")}if(v.length){w=$(g).attr(v);$.each(w,function(Jb,Ob){w[Jb]=qa(Jb,Ob)})}else if(E)w=
{x:$(E).attr("x")||0,y:$(E).attr("y")||0};if(t==null){t=$.extend(true,{},w);$.each(t,function(Jb,Ob){t[Jb]=qa(Jb,Ob)})}t.transform=$a?$a:"";if(g.tagName=="g"&&!E||g.tagName=="a"){s=svgedit.utilities.getBBox(g);var D={x:s.x+s.width/2,y:s.y+s.height/2},G=O(s.x+s.width/2,s.y+s.height/2,ja(h).matrix);v=e.createSVGMatrix();if(s=ra(g)){F=s*Math.PI/180;A=Math.abs(F)>1.0E-10?Math.sin(F)/(1-Math.cos(F)):2/F;for(F=0;F<h.numberOfItems;++F){v=h.getItem(F);if(v.type==4){v=v.matrix;D.y=(A*v.e+v.f)/2;D.x=(v.e-A*
v.f)/2;h.removeItem(F);break}}}F=v=E=0;var H=h.numberOfItems;if(H)var P=h.getItem(0).matrix;if(H>=3&&h.getItem(H-2).type==3&&h.getItem(H-3).type==2&&h.getItem(H-1).type==2){F=3;var Q=h.getItem(H-3).matrix,aa=h.getItem(H-2).matrix,ua=h.getItem(H-1).matrix;A=g.childNodes;for(C=A.length;C--;){var wa=A.item(C);v=E=0;if(wa.nodeType==1){var ha=V(wa);if(ha){v=ja(ha).matrix;E=ra(wa);var ka=$a,oa=[];$a=wa.getAttribute("transform");if(E||sa(ha)){var xa=e.createSVGTransform();xa.setMatrix(fa(Q,aa,ua,v));ha.clear();
ha.appendItem(xa);oa.push(xa)}else{E=fa(v.inverse(),ua,v);xa=e.createSVGMatrix();xa.e=-E.e;xa.f=-E.f;v=fa(xa.inverse(),v.inverse(),Q,aa,ua,v,E.inverse());var eb=e.createSVGTransform(),Db=e.createSVGTransform(),Pb=e.createSVGTransform();eb.setTranslate(E.e,E.f);Db.setScale(v.a,v.d);Pb.setTranslate(xa.e,xa.f);ha.appendItem(Pb);ha.appendItem(Db);ha.appendItem(eb);oa.push(Pb);oa.push(Db);oa.push(eb)}k.addSubCommand(pb(wa));$a=ka}}}h.removeItem(H-1);h.removeItem(H-2);h.removeItem(H-3)}else if(H>=3&&h.getItem(H-
1).type==1){F=3;v=ja(h).matrix;xa=e.createSVGTransform();xa.setMatrix(v);h.clear();h.appendItem(xa)}else if((H==1||H>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){F=2;E=ja(h).matrix;h.removeItem(0);v=ja(h).matrix.inverse();v=fa(v,E);E=v.e;v=v.f;if(E!=0||v!=0){A=g.childNodes;C=A.length;for(H=[];C--;){wa=A.item(C);if(wa.nodeType==1){if(wa.getAttribute("clip-path")){ka=wa.getAttribute("clip-path");if(H.indexOf(ka)===-1){Hb(ka,E,v);H.push(ka)}}ka=$a;$a=wa.getAttribute("transform");if(ha=V(wa)){Q=e.createSVGTransform();
Q.setTranslate(E,v);ha.numberOfItems?ha.insertItemBefore(Q,0):ha.appendItem(Q);k.addSubCommand(pb(wa));ha=g.getElementsByTagNameNS(c,"use");wa="#"+wa.id;for(Q=ha.length;Q--;){aa=ha.item(Q);if(wa==ba(aa)){ua=e.createSVGTransform();ua.setTranslate(-E,-v);V(aa).insertItemBefore(ua,0);k.addSubCommand(pb(aa))}}$a=ka}}}H=[];$a=ka}}else if(H==1&&h.getItem(0).type==1&&!s){F=1;v=h.getItem(0).matrix;A=g.childNodes;for(C=A.length;C--;){wa=A.item(C);if(wa.nodeType==1){ka=$a;$a=wa.getAttribute("transform");if(ha=
V(wa)){E=fa(v,ja(ha).matrix);H=e.createSVGTransform();H.setMatrix(E);ha.clear();ha.appendItem(H,0);k.addSubCommand(pb(wa));$a=ka;ka=wa.getAttribute("stroke-width");wa.getAttribute("stroke")!=="none"&&!isNaN(ka)&&wa.setAttribute("stroke-width",ka*((Math.abs(E.a)+Math.abs(E.d))/2))}}}h.clear()}else{if(s){D=e.createSVGTransform();D.setRotate(s,G.x,G.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}h.numberOfItems==0&&g.removeAttribute("transform");return null}if(F==2){if(s){G={x:D.x+P.e,y:D.y+
P.f};D=e.createSVGTransform();D.setRotate(s,G.x,G.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else if(F==3){v=ja(h).matrix;P=e.createSVGTransform();P.setRotate(s,D.x,D.y);P=P.matrix;D=e.createSVGTransform();D.setRotate(s,G.x,G.y);G=D.matrix.inverse();ka=v.inverse();G=fa(ka,G,P,v);E=G.e;v=G.f;if(E!=0||v!=0){A=g.childNodes;for(C=A.length;C--;){wa=A.item(C);if(wa.nodeType==1){ka=$a;$a=wa.getAttribute("transform");ha=V(wa);Q=e.createSVGTransform();Q.setTranslate(E,v);ha.numberOfItems?
ha.insertItemBefore(Q,0):ha.appendItem(Q);k.addSubCommand(pb(wa));$a=ka}}}if(s)h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else{s=svgedit.utilities.getBBox(g);if(!s&&g.tagName!="path")return null;v=e.createSVGMatrix();if(E=ra(g)){D={x:s.x+s.width/2,y:s.y+s.height/2};G=O(s.x+s.width/2,s.y+s.height/2,ja(h).matrix);F=E*Math.PI/180;A=Math.abs(F)>1.0E-10?Math.sin(F)/(1-Math.cos(F)):2/F;for(F=0;F<h.numberOfItems;++F){v=h.getItem(F);if(v.type==4){v=v.matrix;D.y=(A*v.e+v.f)/2;D.x=(v.e-A*v.f)/
2;h.removeItem(F);break}}}F=0;H=h.numberOfItems;if(!svgedit.browser.isWebkit())if((P=g.getAttribute("fill"))&&P.indexOf("url(")===0){P=X(P);ka="pattern";if(P.tagName!==ka)ka="gradient";if(P.getAttribute(ka+"Units")==="userSpaceOnUse"){v=ja(h).matrix;s=V(P);s=ja(s).matrix;v=fa(v,s);s="matrix("+[v.a,v.b,v.c,v.d,v.e,v.f].join(",")+")";P.setAttribute(ka+"Transform",s)}}if(H>=3&&h.getItem(H-2).type==3&&h.getItem(H-3).type==2&&h.getItem(H-1).type==2){F=3;v=ja(h,H-3,H-1).matrix;h.removeItem(H-1);h.removeItem(H-
2);h.removeItem(H-3)}else if(H==4&&h.getItem(H-1).type==1){F=3;v=ja(h).matrix;xa=e.createSVGTransform();xa.setMatrix(v);h.clear();h.appendItem(xa);v=e.createSVGMatrix()}else if((H==1||H>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){F=2;P=h.getItem(0).matrix;ka=ja(h,1).matrix;s=ka.inverse();v=fa(s,P,ka);h.removeItem(0)}else if(H==1&&h.getItem(0).type==1&&!E){v=ja(h).matrix;switch(g.tagName){case "line":w=$(g).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":w.points=g.getAttribute("points");
if(w.points){s=g.points;A=s.numberOfItems;w.points=Array(A);for(F=0;F<A;++F){C=s.getItem(F);w.points[F]={x:C.x,y:C.y}}}case "path":w.d=g.getAttribute("d");F=1;h.clear()}}else{F=4;if(E){D=e.createSVGTransform();D.setRotate(E,G.x,G.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}h.numberOfItems==0&&g.removeAttribute("transform");return null}if(F==1||F==2||F==3)xb(g,w,v);if(F==2){if(E){sa(h)||(G={x:D.x+v.e,y:D.y+v.f});D=e.createSVGTransform();D.setRotate(E,G.x,G.y);h.numberOfItems?h.insertItemBefore(D,
0):h.appendItem(D)}}else if(F==3&&E){v=ja(h).matrix;P=e.createSVGTransform();P.setRotate(E,D.x,D.y);P=P.matrix;D=e.createSVGTransform();D.setRotate(E,G.x,G.y);G=D.matrix.inverse();ka=v.inverse();G=fa(ka,G,P,v);xb(g,w,G);if(E)h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}h.numberOfItems==0&&g.removeAttribute("transform");k.addSubCommand(new Wa(g,t));return k},Lb=null,bb=this.clearSelection=function(g){if(J[0]!=null)for(var h=J.length,k=0;k<h;++k){var v=J[k];if(v==null)break;Oa.releaseSelector(v);
J[k]=null}g||I("selected",J)},qb=this.addToSelection=function(g,h){if(g.length!=0){for(var k=0;k<J.length;){if(J[k]==null)break;++k}for(var v=g.length;v--;){var s=g[v];if(s&&svgedit.utilities.getBBox(s)){if(s.tagName==="a"&&s.childNodes.length===1)s=s.firstChild;if(J.indexOf(s)==-1){J[k]=s;k++;s=Oa.requestSelector(s);J.length>1&&s.showGrips(false)}}}I("selected",J);h||J.length==1?Oa.requestSelector(J[0]).showGrips(true):Oa.requestSelector(J[0]).showGrips(false);for(J.sort(function(E,w){if(E&&w&&E.compareDocumentPosition)return 3-
(w.compareDocumentPosition(E)&6);else if(E==null)return 1});J[0]==null;)J.shift(0)}},Qb=this.selectOnly=function(g,h){bb(true);qb(g,h)};this.removeFromSelection=function(g){if(J[0]!=null)if(g.length!=0){var h=Array(J.length);j=0;len=J.length;for(var k=0;k<len;++k){var v=J[k];if(v)if(g.indexOf(v)==-1){h[j]=v;j++}else Oa.releaseSelector(v)}J=h}};this.selectAllInCurrentLayer=function(){var g=z().getCurrentLayer();if(g){Ka="select";Qb($(L||g).children())}};var $b=this.getMouseTarget=function(g){if(g==
null)return null;g=g.target;if(g.correspondingUseElement)g=g.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(g.namespaceURI)>=0&&g.id!="svgcanvas")for(;g.nodeName!="foreignObject";){g=g.parentNode;if(!g)return e}var h=z().getCurrentLayer();if([e,a,l,h].indexOf(g)>=0)return e;if($(g).closest("#selectorParentGroup").length)return Oa.selectorParentGroup;for(;g.parentNode!==(L||h);)g=g.parentNode;return g};(function(){var g=null,h=null,k=null,v=
null,t=null,E={},w={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(s){if(!(b.spaceKey||s.button===1)){var A=s.button===2;s.altKey&&svgCanvas.cloneSelectedElements(0,0);Lb=l.getScreenCTM().inverse();var F=O(s.pageX,s.pageY,Lb),C=F.x*o,D=F.y*o;s.preventDefault();if(A){Na="select";yb=F}F=C/o;D=D/o;var G=$b(s);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;C=v=h=F;var H=t=k=D;if(m.gridSnapping){F=Fa(F);D=Fa(D);h=Fa(h);k=Fa(k)}if(G==Oa.selectorParentGroup&&J[0]!=null){G=s.target;
var P=lb(G,"type");if(P=="rotate"){Na="rotate";current_rotate_mode=lb(G,"dir")}else if(P=="resize"){Na="resize";mb=lb(G,"dir")}G=J[0]}$a=G.getAttribute("transform");P=V(G);switch(Na){case "select":Ra=true;mb="none";if(A)Ra=false;if(G!=e){if(J.indexOf(G)==-1){s.shiftKey||bb(true);qb([G]);kb=G;Va.clear()}if(!A)for(A=0;A<J.length;++A)if(J[A]!=null){var R=V(J[A]);R.numberOfItems?R.insertItemBefore(e.createSVGTransform(),0):R.appendItem(e.createSVGTransform())}}else if(!A){bb();Na="multiselect";if(Ca==
null)Ca=Oa.getRubberBandBox();v*=o;t*=o;ma(Ca,{x:v,y:t,width:0,height:0,display:"inline"},100)}break;case "zoom":Ra=true;if(Ca==null)Ca=Oa.getRubberBandBox();ma(Ca,{x:C*o,y:C*o,width:0,height:0,display:"inline"},100);break;case "resize":Ra=true;h=F;k=D;E=svgedit.utilities.getBBox($("#selectedBox0")[0]);var aa={};$.each(E,function(ua,wa){aa[ua]=wa/o});E=aa;A=ra(G)?1:0;if(sa(P)){P.insertItemBefore(e.createSVGTransform(),A);P.insertItemBefore(e.createSVGTransform(),A);P.insertItemBefore(e.createSVGTransform(),
A)}else{P.appendItem(e.createSVGTransform());P.appendItem(e.createSVGTransform());P.appendItem(e.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(F=svgedit.browser.isChrome())R=function(ua){var wa=ua.getAttributeNS(null,"stroke");ua.removeAttributeNS(null,"stroke");setTimeout(function(){ua.setAttributeNS(null,"stroke",wa)},1)};G.style.vectorEffect="non-scaling-stroke";F&&R(G);D=G.getElementsByTagName("*");C=D.length;for(A=0;A<C;A++){D[A].style.vectorEffect="non-scaling-stroke";
F&&R(D[A])}}}break;case "fhellipse":case "fhrect":case "fhpath":Ra=true;g=C+","+H+" ";R=N.stroke_width==0?1:N.stroke_width;da({element:"polyline",curStyles:true,attr:{points:g,id:M(),fill:"none",opacity:N.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});w.minx=C;w.maxx=C;w.miny=H;w.maxy=H;break;case "image":Ra=true;R=da({element:"image",attr:{x:F,y:D,width:0,height:0,id:M(),opacity:N.opacity/2,style:"pointer-events:inherit"}});S(R,Ja);Zb(R);break;case "square":case "rect":Ra=true;
h=F;k=D;da({element:"rect",curStyles:true,attr:{x:F,y:D,width:0,height:0,id:M(),opacity:N.opacity/2}});break;case "line":Ra=true;R=N.stroke_width==0?1:N.stroke_width;da({element:"line",curStyles:true,attr:{x1:F,y1:D,x2:F,y2:D,id:M(),stroke:N.stroke,"stroke-width":R,"stroke-dasharray":N.stroke_dasharray,"stroke-linejoin":N.stroke_linejoin,"stroke-linecap":N.stroke_linecap,"stroke-opacity":N.stroke_opacity,fill:"none",opacity:N.opacity/2,style:"pointer-events:none"}});break;case "circle":Ra=true;da({element:"circle",
curStyles:true,attr:{cx:F,cy:D,r:0,id:M(),opacity:N.opacity/2}});break;case "ellipse":Ra=true;da({element:"ellipse",curStyles:true,attr:{cx:F,cy:D,rx:0,ry:0,id:M(),opacity:N.opacity/2}});break;case "text":Ra=true;da({element:"text",curStyles:true,attr:{x:F,y:D,id:M(),fill:cb.fill,"stroke-width":cb.stroke_width,"font-size":cb.font_size,"font-family":cb.font_family,"text-anchor":"left","xml:space":"preserve",opacity:N.opacity}});break;case "path":case "pathedit":h*=o;k*=o;Va.mouseDown(s,G,h,k);Ra=true;
break;case "textedit":h*=o;k*=o;rb.mouseDown(s,G,h,k);Ra=true;break;case "rotate":Ra=true;b.undoMgr.beginUndoableChange("transform",J);document.getElementById("workarea").className="rotate"}s=ob("mouseDown",{event:s,start_x:h,start_y:k,selectedElements:J},true);$.each(s,function(ua,wa){if(wa&&wa.started)Ra=true})}}).mousemove(function(s){if(Ra)if(!(s.button===1||b.spaceKey)){var A=J[0],F=O(s.pageX,s.pageY,Lb),C=F.x*o;F=F.y*o;var D=la(ta()),G=x=C/o,H=y=F/o;if(m.gridSnapping){x=Fa(x);y=Fa(y)}s.preventDefault();
switch(Na){case "select":if(J[0]!==null){G=x-h;var P=y-k;if(m.gridSnapping){G=Fa(G);P=Fa(P)}if(s.shiftKey){var R=ca(h,k,x,y);x=R.x;y=R.y}if(G!=0||P!=0){R=J.length;for(H=0;H<R;++H){A=J[H];if(A==null)break;var aa=e.createSVGTransform();D=V(A);aa.setTranslate(G,P);D.numberOfItems?D.replaceItem(aa,0):D.appendItem(aa);Oa.requestSelector(A).resize()}I("transition",J)}}break;case "multiselect":G*=o;H*=o;ma(Ca,{x:Math.min(v,G),y:Math.min(t,H),width:Math.abs(G-v),height:Math.abs(H-t)},100);D=[];G=[];aa=Kb();
R=J.length;for(H=0;H<R;++H){P=aa.indexOf(J[H]);if(P==-1)D.push(J[H]);else aa[P]=null}R=aa.length;for(H=0;H<R;++H)aa[H]&&G.push(aa[H]);D.length>0&&b.removeFromSelection(D);G.length>0&&qb(G);break;case "resize":D=V(A);G=(R=sa(D))?E:svgedit.utilities.getBBox(A);H=G.x;aa=G.y;var ua=G.width,wa=G.height;G=x-h;P=y-k;if(m.gridSnapping){G=Fa(G);P=Fa(P);wa=Fa(wa);ua=Fa(ua)}var ha=ra(A);if(ha){var ka=Math.sqrt(G*G+P*P);P=Math.atan2(P,G)-ha*Math.PI/180;G=ka*Math.cos(P);P=ka*Math.sin(P)}if(mb.indexOf("n")==-1&&
mb.indexOf("s")==-1)P=0;if(mb.indexOf("e")==-1&&mb.indexOf("w")==-1)G=0;var oa=ka=0,xa=wa?(wa+P)/wa:1,eb=ua?(ua+G)/ua:1;if(mb.indexOf("n")>=0){xa=wa?(wa-P)/wa:1;oa=wa}if(mb.indexOf("w")>=0){eb=ua?(ua-G)/ua:1;ka=ua}G=e.createSVGTransform();P=e.createSVGTransform();ua=e.createSVGTransform();if(m.gridSnapping){H=Fa(H);ka=Fa(ka);aa=Fa(aa);oa=Fa(oa)}G.setTranslate(-(H+ka),-(aa+oa));if(s.shiftKey)if(eb==1)eb=xa;else xa=eb;P.setScale(eb,xa);ua.setTranslate(H+ka,aa+oa);if(R){R=ha?1:0;D.replaceItem(G,2+R);
D.replaceItem(P,1+R);D.replaceItem(ua,0+R)}else{R=D.numberOfItems;D.replaceItem(ua,R-3);D.replaceItem(P,R-2);D.replaceItem(G,R-1)}Oa.requestSelector(A).resize();I("transition",J);break;case "zoom":G*=o;H*=o;ma(Ca,{x:Math.min(v*o,G),y:Math.min(t*o,H),width:Math.abs(G-v*o),height:Math.abs(H-t*o)},100);break;case "text":ma(D,{x:x,y:y},1E3);break;case "line":G=null;window.opera||e.suspendRedraw(1E3);if(m.gridSnapping){x=Fa(x);y=Fa(y)}H=x;R=y;if(s.shiftKey){R=ca(h,k,H,R);H=R.x;R=R.y}D.setAttributeNS(null,
"x2",H);D.setAttributeNS(null,"y2",R);window.opera||e.unsuspendRedraw(G);break;case "foreignObject":case "square":case "rect":case "image":G=Math.abs(x-h);R=Math.abs(y-k);if(Na=="square"||s.shiftKey){G=R=Math.max(G,R);H=h<x?h:h-G;aa=k<y?k:k-R}else{H=Math.min(h,x);aa=Math.min(k,y)}if(m.gridSnapping){G=Fa(G);R=Fa(R);H=Fa(H);aa=Fa(aa)}ma(D,{width:G,height:R,x:H,y:aa},1E3);break;case "circle":G=$(D).attr(["cx","cy"]);R=G.cx;H=G.cy;G=Math.sqrt((x-R)*(x-R)+(y-H)*(y-H));if(m.gridSnapping)G=Fa(G);D.setAttributeNS(null,
"r",G);break;case "ellipse":G=$(D).attr(["cx","cy"]);R=G.cx;H=G.cy;G=null;window.opera||e.suspendRedraw(1E3);if(m.gridSnapping){x=Fa(x);R=Fa(R);y=Fa(y);H=Fa(H)}D.setAttributeNS(null,"rx",Math.abs(x-R));D.setAttributeNS(null,"ry",Math.abs(s.shiftKey?x-R:y-H));window.opera||e.unsuspendRedraw(G);break;case "fhellipse":case "fhrect":w.minx=Math.min(G,w.minx);w.maxx=Math.max(G,w.maxx);w.miny=Math.min(H,w.miny);w.maxy=Math.max(H,w.maxy);case "fhpath":g+=+G+","+H+" ";D.setAttributeNS(null,"points",g);break;
case "path":case "pathedit":x*=o;y*=o;if(m.gridSnapping){x=Fa(x);y=Fa(y);h=Fa(h);k=Fa(k)}if(s.shiftKey){if(R=svgedit.path.path){D=R.dragging?R.dragging[0]:h;R=R.dragging?R.dragging[1]:k}else{D=h;R=k}R=ca(D,R,x,y);x=R.x;y=R.y}if(Ca&&Ca.getAttribute("display")!=="none"){G*=o;H*=o;ma(Ca,{x:Math.min(v*o,G),y:Math.min(t*o,H),width:Math.abs(G-v*o),height:Math.abs(H-t*o)},100)}Va.mouseMove(s,x,y);break;case "textedit":x*=o;y*=o;rb.mouseMove(C,F);break;case "rotate":G=svgedit.utilities.getBBox(A);R=G.x+G.width/
2;H=G.y+G.height/2;D=ea(A);D=O(R,H,D);R=D.x;H=D.y;D=G.x;aa=G.y;if(current_rotate_mode=="nw")D=G.x+G.width;if(current_rotate_mode=="se")aa=G.y+G.height;if(current_rotate_mode=="sw"){D=G.x+G.width;aa=G.y+G.height}compensation_angle=(Math.atan2(H-aa,R-D)*(180/Math.PI)-90)%360;ha=(Math.atan2(H-y,R-x)*(180/Math.PI)-90)%360;ha+=compensation_angle;if(m.gridSnapping)ha=Fa(ha);if(s.shiftKey)ha=Math.round(ha/45)*45;b.setRotationAngle(ha<-180?360+ha:ha,true);I("transition",J)}ob("mouseMove",{event:s,mouse_x:C,
mouse_y:F,selected:A})}}).click(function(s){s.preventDefault();return false}).dblclick(function(s){var A=s.target.parentNode;if(A!==L){var F=$b(s),C=F.tagName;if(C==="text"&&Na!=="textedit"){s=O(s.pageX,s.pageY,Lb);rb.select(F,s.x,s.y)}if((C==="g"||C==="a")&&ra(F)){fc(F);F=J[0];bb(true)}L&&ac();A.tagName!=="g"&&A.tagName!=="a"||A===z().getCurrentLayer()||F===Oa.selectorParentGroup||nc(F)}}).mouseup(function(s){if(s.button!==2){var A=kb;kb=null;if(Ra){var F=O(s.pageX,s.pageY,Lb),C=F.x*o;F=F.y*o;var D=
C/o,G=F/o,H=la(ta()),P=false;Ra=false;switch(Na){case "resize":case "multiselect":if(Ca!=null){Ca.setAttribute("display","none");wb=[]}Na="select";case "select":if(J[0]!=null){if(J[1]==null){C=J[0];switch(C.tagName){case "g":case "use":case "image":case "foreignObject":break;default:jb.fill=C.getAttribute("fill");jb.fill_opacity=C.getAttribute("fill-opacity");jb.stroke=C.getAttribute("stroke");jb.stroke_opacity=C.getAttribute("stroke-opacity");jb.stroke_width=C.getAttribute("stroke-width");jb.stroke_dasharray=
C.getAttribute("stroke-dasharray");jb.stroke_linejoin=C.getAttribute("stroke-linejoin");jb.stroke_linecap=C.getAttribute("stroke-linecap")}if(C.tagName=="text"){cb.font_size=C.getAttribute("font-size");cb.font_family=C.getAttribute("font-family")}Oa.requestSelector(C).showGrips(true)}Xa();if(D!=v||G!=t){s=J.length;for(C=0;C<s;++C){if(J[C]==null)break;J[C].firstChild||Oa.requestSelector(J[C]).resize()}}else{C=s.target;if(J[0].nodeName==="path"&&J[1]==null)Va.select(J[0]);else s.shiftKey&&A!=C&&b.removeFromSelection([C])}if(svgedit.browser.supportsNonScalingStroke())if(s=
J[0]){s.removeAttribute("style");svgedit.utilities.walkTree(s,function(ua){ua.removeAttribute("style")})}}return;case "zoom":Ca!=null&&Ca.setAttribute("display","none");I("zoomed",{x:Math.min(v,D),y:Math.min(t,G),width:Math.abs(D-v),height:Math.abs(G-t),factor:s.altKey?0.5:2});return;case "fhpath":A=H.getAttribute("points");D=A.indexOf(",");if(P=D>=0?A.indexOf(",",D+1)>=0:A.indexOf(" ",A.indexOf(" ")+1)>=0)H=Va.smoothPolylineIntoPath(H);break;case "line":A=$(H).attr(["x1","x2","y1","y2"]);P=A.x1!=
A.x2||A.y1!=A.y2;break;case "foreignObject":case "square":case "rect":case "image":A=$(H).attr(["width","height"]);P=A.width!=0||A.height!=0||Na==="image";break;case "circle":P=H.getAttribute("r")!=0;break;case "ellipse":A=$(H).attr(["rx","ry"]);P=A.rx!=null||A.ry!=null;break;case "fhellipse":if(w.maxx-w.minx>0&&w.maxy-w.miny>0){H=da({element:"ellipse",curStyles:true,attr:{cx:(w.minx+w.maxx)/2,cy:(w.miny+w.maxy)/2,rx:(w.maxx-w.minx)/2,ry:(w.maxy-w.miny)/2,id:ta()}});I("changed",[H]);P=true}break;
case "fhrect":if(w.maxx-w.minx>0&&w.maxy-w.miny>0){H=da({element:"rect",curStyles:true,attr:{x:w.minx,y:w.miny,width:w.maxx-w.minx,height:w.maxy-w.miny,id:ta()}});I("changed",[H]);P=true}break;case "text":P=true;Qb([H]);rb.start(H);break;case "path":H=null;Ra=true;A=Va.mouseUp(s,H,C,F);H=A.element;P=A.keep;break;case "pathedit":P=true;H=null;Va.mouseUp(s);break;case "textedit":P=false;H=null;rb.mouseUp(s,C,F);break;case "rotate":P=true;H=null;Na="select";A=b.undoMgr.finishUndoableChange();A.isEmpty()||
Ga(A);Xa();I("changed",J)}C=ob("mouseUp",{event:s,mouse_x:C,mouse_y:F},true);$.each(C,function(ua,wa){if(wa){P=wa.keep||P;H=wa.element;Ra=wa.started||Ra}});if(!P&&H!=null){z().releaseId(ta());H.parentNode.removeChild(H);H=null;for(C=s.target;C.parentNode.parentNode.tagName=="g";)C=C.parentNode;if((Na!="path"||!drawn_path)&&C.parentNode.id!="selectorParentGroup"&&C.id!="svgcanvas"&&C.id!="svgroot"){b.setMode("select");Qb([C],true)}}else if(H!=null){b.addedNew=true;s=0.2;var R;if(false.beginElement&&
H.getAttribute("opacity")!=N.opacity){R=$(false).clone().attr({to:N.opacity,dur:s}).appendTo(H);try{R[0].beginElement()}catch(aa){}}else s=0;setTimeout(function(){R&&R.remove();H.setAttribute("opacity",N.opacity);H.setAttribute("style","pointer-events:inherit");Y(H);if(Na==="path")Va.toEditMode(H);else m.selectNew&&Qb([H],true);Ga(new Ka(H));I("changed",[H])},s*1E3)}$a=null}}});$(a).bind("mousewheel DOMMouseScroll",function(s){if(s.shiftKey){s.preventDefault();Lb=l.getScreenCTM().inverse();var A=
O(s.pageX,s.pageY,Lb);A={x:A.x,y:A.y,width:0,height:0};if(s.wheelDelta)if(s.wheelDelta>=120)A.factor=2;else{if(s.wheelDelta<=-120)A.factor=0.5}else if(s.detail)if(s.detail>0)A.factor=0.5;else if(s.detail<0)A.factor=2;A.factor&&I("zoomed",A)}})})();var Zb=function(g){$(g).click(function(h){h.preventDefault()})},rb=b.textActions=function(){function g(ha){var ka=F.value==="";$(F).focus();if(!arguments.length)if(ka)ha=0;else{if(F.selectionEnd!==F.selectionStart)return;ha=F.selectionEnd}var oa;oa=H[ha];
ka||F.setSelectionRange(ha,ha);C=la("text_cursor");if(!C){C=document.createElementNS(c,"line");ma(C,{id:"text_cursor",stroke:"#333","stroke-width":1});C=la("selectorParentGroup").appendChild(C)}G||(G=setInterval(function(){var xa=C.getAttribute("display")==="none";C.setAttribute("display",xa?"inline":"none")},600));ka=E(oa.x,P.y);oa=E(oa.x,P.y+P.height);ma(C,{x1:ka.x,y1:ka.y,x2:oa.x,y2:oa.y,visibility:"visible",display:"inline"});D&&D.setAttribute("d","")}function h(ha,ka,oa){if(ha===ka)g(ka);else{oa||
F.setSelectionRange(ha,ka);D=la("text_selectblock");if(!D){D=document.createElementNS(c,"path");ma(D,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});la("selectorParentGroup").appendChild(D)}ha=H[ha];var xa=H[ka];C.setAttribute("visibility","hidden");ka=E(ha.x,P.y);oa=E(ha.x+(xa.x-ha.x),P.y);var eb=E(ha.x,P.y+P.height);ha=E(ha.x+(xa.x-ha.x),P.y+P.height);ma(D,{d:"M"+ka.x+","+ka.y+" L"+oa.x+","+oa.y+" "+ha.x+","+ha.y+" "+eb.x+","+eb.y+"z",display:"inline"})}}function k(ha,
ka){var oa=e.createSVGPoint();oa.x=ha;oa.y=ka;if(H.length==1)return 0;oa=A.getCharNumAtPosition(oa);if(oa<0){oa=H.length-2;if(ha<=H[0].x)oa=0}else if(oa>=H.length-2)oa=H.length-2;var xa=H[oa];ha>xa.x+xa.width/2&&oa++;return oa}function v(ha,ka,oa){var xa=F.selectionStart;ha=k(ha,ka);h(Math.min(xa,ha),Math.max(xa,ha),!oa)}function t(ha,ka){var oa={x:ha,y:ka};oa.x/=o;oa.y/=o;if(R){var xa=O(oa.x,oa.y,R.inverse());oa.x=xa.x;oa.y=xa.y}return oa}function E(ha,ka){var oa={x:ha,y:ka};if(R){var xa=O(oa.x,
oa.y,R);oa.x=xa.x;oa.y=xa.y}oa.x*=o;oa.y*=o;return oa}function w(ha){h(0,A.textContent.length);$(this).unbind(ha)}function s(ha){if(wa&&A){var ka=O(ha.pageX,ha.pageY,Lb);ka=t(ka.x*o,ka.y*o);ka=k(ka.x,ka.y);var oa=A.textContent,xa=oa.substr(0,ka).replace(/[a-z0-9]+$/i,"").length;oa=oa.substr(ka).match(/^[a-z0-9]+/i);h(xa,(oa?oa[0].length:0)+ka);$(ha.target).click(w);setTimeout(function(){$(ha.target).unbind("click",w)},300)}}var A,F,C,D,G,H=[],P,R,aa,ua,wa;return{select:function(ha,ka,oa){A=ha;rb.toEditMode(ka,
oa)},start:function(ha){A=ha;rb.toEditMode()},mouseDown:function(ha,ka,oa,xa){ha=t(oa,xa);F.focus();g(k(ha.x,ha.y));aa=oa;ua=xa},mouseMove:function(ha,ka){var oa=t(ha,ka);v(oa.x,oa.y)},mouseUp:function(ha,ka,oa){var xa=t(ka,oa);v(xa.x,xa.y,true);ha.target!==A&&ka<aa+2&&ka>aa-2&&oa<ua+2&&oa>ua-2&&rb.toSelectMode(true)},setCursor:g,toEditMode:function(ha,ka){wa=false;Na="textedit";Oa.requestSelector(A).showGrips(false);Oa.requestSelector(A);rb.init();$(A).css("cursor","text");if(arguments.length){var oa=
t(ha,ka);g(k(oa.x,oa.y))}else g();setTimeout(function(){wa=true},300)},toSelectMode:function(ha){Na="select";clearInterval(G);G=null;D&&$(D).attr("display","none");C&&$(C).attr("visibility","hidden");$(A).css("cursor","move");if(ha){bb();$(A).css("cursor","move");I("selected",[A]);qb([A],true)}A&&!A.textContent.length&&b.deleteSelectedElements();$(F).blur();A=false},setInputElem:function(ha){F=ha},clear:function(){Na=="textedit"&&rb.toSelectMode()},init:function(){if(A){if(!A.parentNode){A=J[0];Oa.requestSelector(A).showGrips(false)}var ha=
A.textContent.length,ka=A.getAttribute("transform");P=svgedit.utilities.getBBox(A);R=ka?ea(A):null;H=Array(ha);F.focus();$(A).unbind("dblclick",s).dblclick(s);if(!ha)var oa={x:P.x+P.width/2,width:0};for(ka=0;ka<ha;ka++){var xa=A.getStartPositionOfChar(ka);oa=A.getEndPositionOfChar(ka);if(!svgedit.browser.supportsGoodTextCharPos()){var eb=b.contentW*o;xa.x-=eb;oa.x-=eb;xa.x/=o;oa.x/=o}H[ka]={x:xa.x,y:P.y,width:oa.x-xa.x,height:P.height}}H.push({x:oa.x,width:0});h(F.selectionStart,F.selectionEnd,true)}}}}(),
Va=b.pathActions=function(){var g=false,h,k,v;svgedit.path.Path.prototype.endChanges=function(w){if(svgedit.browser.isWebkit()){var s=this.elem;s.setAttribute("d",Va.convertPath(s))}w=new Wa(this.elem,{d:this.last_d},w);Ga(w);I("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(w){$.isArray(w)||(w=[w]);for(var s=0;s<w.length;s++){var A=w[s],F=this.segs[A];F.ptgrip&&this.selected_pts.indexOf(A)==-1&&A>=0&&this.selected_pts.push(A)}this.selected_pts.sort();s=this.selected_pts.length;
for(w=Array(s);s--;){F=this.segs[this.selected_pts[s]];F.select(true);w[s]=F.ptgrip}Va.canDeleteNodes=true;Va.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);I("selected",w)};var t=h=null,E=false;return{mouseDown:function(w,s,A,F){if(Na==="path"){mouse_x=A;mouse_y=F;F=mouse_x/o;s=mouse_y/o;A=la("path_stretch_line");k=[F,s];if(m.gridSnapping){F=Fa(F);s=Fa(s);mouse_x=Fa(mouse_x);mouse_y=Fa(mouse_y)}if(!A){A=document.createElementNS(c,"path");ma(A,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",
fill:"none"});A=la("selectorParentGroup").appendChild(A)}A.setAttribute("display","inline");var C=null;if(t){C=t.pathSegList;for(var D=C.numberOfItems,G=6/o,H=false;D;){D--;var P=C.getItem(D),R=P.x;P=P.y;if(F>=R-G&&F<=R+G&&s>=P-G&&s<=P+G){H=true;break}}G=ta();svgedit.path.removePath_(G);G=la(G);R=C.numberOfItems;if(H){if(D<=1&&R>=2){F=C.getItem(0).x;s=C.getItem(0).y;w=A.pathSegList.getItem(1);w=w.pathSegType===4?t.createSVGPathSegLinetoAbs(F,s):t.createSVGPathSegCurvetoCubicAbs(F,s,w.x1/o,w.y1/o,
F,s);F=t.createSVGPathSegClosePath();C.appendItem(w);C.appendItem(F)}else if(R<3)return C=false;$(A).remove();element=G;t=null;Ra=false;if(g){svgedit.path.path.matrix&&xb(G,{},svgedit.path.path.matrix.inverse());A=G.getAttribute("d");w=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",w+A);$(G).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Va.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,
$b(w))){console.log("Clicked outside canvas");return false}C=t.pathSegList.numberOfItems;D=t.pathSegList.getItem(C-1);G=D.x;D=D.y;if(w.shiftKey){w=ca(G,D,F,s);F=w.x;s=w.y}w=A.pathSegList.getItem(1);w=w.pathSegType===4?t.createSVGPathSegLinetoAbs(Cb(F),Cb(s)):t.createSVGPathSegCurvetoCubicAbs(Cb(F),Cb(s),w.x1/o,w.y1/o,w.x2/o,w.y2/o);t.pathSegList.appendItem(w);F*=o;s*=o;A.setAttribute("d",["M",F,s,F,s].join(" "));A=C;if(g)A+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(A,F,s)}}else{d_attr=
"M"+F+","+s+" ";t=da({element:"path",curStyles:true,attr:{d:d_attr,id:M(),opacity:N.opacity/2}});A.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));A=g?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(A,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();G=w.target.id;if(G.substr(0,14)=="pathpointgrip_"){s=svgedit.path.path.cur_pt=parseInt(G.substr(14));svgedit.path.path.dragging=[A,F];C=svgedit.path.path.segs[s];if(w.shiftKey)C.selected?svgedit.path.path.removePtFromSelection(s):
svgedit.path.path.addPtsToSelection(s);else{if(svgedit.path.path.selected_pts.length<=1||!C.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(s)}}else if(G.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[A,F];w=G.split("_")[1].split("c");s=w[0]-0;svgedit.path.path.selectPt(s,w[1]-0)}if(!svgedit.path.path.dragging){if(Ca==null)Ca=Oa.getRubberBandBox();ma(Ca,{x:A*o,y:F*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(w,s,A){E=true;if(Na==="path"){if(t){var F=
t.pathSegList;w=F.numberOfItems-1;if(k){var C=svgedit.path.addCtrlGrip("1c1"),D=svgedit.path.addCtrlGrip("0c2");D.getAttribute("cx");D.getAttribute("cy");C.setAttribute("cx",s);C.setAttribute("cy",A);C.setAttribute("display","inline");C=k[0];var G=k[1];F.getItem(w);var H=C+(C-s/o),P=G+(G-A/o);D.setAttribute("cx",H*o);D.setAttribute("cy",P*o);D.setAttribute("display","inline");D=svgedit.path.getCtrlLine(1);var R=svgedit.path.getCtrlLine(2);ma(D,{x1:s,y1:A,x2:C*o,y2:G*o,display:"inline"});ma(R,{x1:H*
o,y1:P*o,x2:C*o,y2:G*o,display:"inline"});if(w===0)v=[s,A];else{F=F.getItem(w-1);s=F.x;A=F.y;if(F.pathSegType===6){s+=s-F.x2;A+=A-F.y2}else if(v){s=v[0]/o;A=v[1]/o}svgedit.path.replacePathSeg(6,w,[C,G,s,A,H,P],t)}}else if(C=la("path_stretch_line")){w=F.getItem(w);if(w.pathSegType===6)svgedit.path.replacePathSeg(6,1,[s,A,(w.x+(w.x-w.x2))*o,(w.y+(w.y-w.y2))*o,s,A],C);else v?svgedit.path.replacePathSeg(6,1,[s,A,v[0],v[1],s,A],C):svgedit.path.replacePathSeg(4,1,[s,A],C)}}}else if(svgedit.path.path.dragging){C=
svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);G=svgedit.path.getPointFromGrip({x:s,y:A},svgedit.path.path);w=G.x-C.x;C=G.y-C.y;svgedit.path.path.dragging=[s,A];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(w,C):svgedit.path.path.movePts(w,C)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var aa=Ca.getBBox(),ua=svgedit.path.getGripPt(this);aa=svgedit.math.rectsIntersect(aa,
{x:ua.x,y:ua.y,width:0,height:0});this.select(aa);aa&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(w,s){if(Na==="path"){k=null;if(!t){s=la(ta());Ra=false;v=null}return{keep:true,element:s}}if(svgedit.path.path.dragging){var A=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)");!w.shiftKey&&!E&&svgedit.path.path.selectPt(A)}else if(Ca&&Ca.getAttribute("display")!=
"none"){Ca.setAttribute("display","none");Ca.getAttribute("width")<=2&&Ca.getAttribute("height")<=2&&Va.toSelectMode(w.target)}else Va.toSelectMode(w.target);E=false},toEditMode:function(w){svgedit.path.path=svgedit.path.getPath_(w);Na="pathedit";bb();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);g=false},toSelectMode:function(w){var s=w==svgedit.path.path.elem;Na="select";svgedit.path.path.show(false);h=false;bb();svgedit.path.path.matrix&&
svgedit.path.recalcRotatedPath();if(s){I("selected",[w]);qb([w],true)}},addSubPath:function(w){if(w){Na="path";g=true}else{Va.clear(true);Va.toEditMode(svgedit.path.path.elem)}},select:function(w){if(h===w){Va.toEditMode(w);Na="pathedit"}else h=w},reorient:function(){var w=J[0];if(w)if(ra(w)!=0){var s=new La("Reorient path"),A={d:w.getAttribute("d"),transform:w.getAttribute("transform")};s.addSubCommand(new Wa(w,A));bb();this.resetOrientation(w);Ga(s);svgedit.path.getPath_(w).show(false).matrix=null;
this.clear();qb([w],true);I("changed",J)}},clear:function(){h=null;if(t){var w=la(ta());$(la("path_stretch_line")).remove();$(w).remove();$(la("pathpointgrip_container")).find("*").attr("display","none");t=v=null;Ra=false}else Na=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(w){if(w==null||w.nodeName!="path")return false;var s=V(w),A=ja(s).matrix;s.clear();w.removeAttribute("transform");s=w.pathSegList;for(var F=s.numberOfItems,
C=0;C<F;++C){var D=s.getItem(C),G=D.pathSegType;if(G!=1){var H=[];$.each(["",1,2],function(P,R){var aa=D["x"+R],ua=D["y"+R];if(aa!==undefined&&ua!==undefined){aa=O(aa,ua,A);H.splice(H.length,0,aa.x,aa.y)}});svgedit.path.replacePathSeg(G,C,H,w)}}f(w,A)},zoomChange:function(){Na=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var w=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:w.item.x,y:w.item.y,type:w.type}},linkControlPoints:function(w){svgedit.path.setLinkControlPoints(w)},
clonePathNode:function(){svgedit.path.path.storeD();for(var w=svgedit.path.path.selected_pts,s=w.length,A=[];s--;){var F=w[s];svgedit.path.path.addSeg(F);A.push(F+s);A.push(F+s+1)}svgedit.path.path.init().addPtsToSelection(A);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var w=svgedit.path.path.selected_pts;if(w.length===1){var s=svgedit.path.path.elem,A=s.pathSegList,F=w[0],C=null,D=null;svgedit.path.path.eachSeg(function(R){if(this.type===2&&R<=F)D=this.item;if(R<=
F)return true;if(this.type===2){C=R;return false}else if(this.type===1)return C=false});if(C==null)C=svgedit.path.path.segs.length-1;if(C!==false){var G=s.createSVGPathSegLinetoAbs(D.x,D.y),H=s.createSVGPathSegClosePath();if(C==svgedit.path.path.segs.length-1){A.appendItem(G);A.appendItem(H)}else{svgedit.path.insertItemBefore(s,H,C);svgedit.path.insertItemBefore(s,G,C)}svgedit.path.path.init().selectPt(C+1)}else if(svgedit.path.path.segs[F].mate){A.removeItem(F);A.removeItem(F);svgedit.path.path.init().selectPt(F-
1)}else{for(w=0;w<A.numberOfItems;w++){var P=A.getItem(w);if(P.pathSegType===2)G=w;else if(w===F)A.removeItem(G);else if(P.pathSegType===1&&F<w){H=w-1;A.removeItem(w);break}}for(w=F-G-1;w--;)svgedit.path.insertItemBefore(s,A.getItem(G),H);s=A.getItem(G);svgedit.path.replacePathSeg(2,G,[s.x,s.y]);w=F;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Va.canDeleteNodes){svgedit.path.path.storeD();for(var w=svgedit.path.path.selected_pts,s=w.length;s--;)svgedit.path.path.deleteSeg(w[s]);
var A=function(){var F=svgedit.path.path.elem.pathSegList,C=F.numberOfItems,D=function(P,R){for(;R--;)F.removeItem(P)};if(C<=1)return true;for(;C--;){var G=F.getItem(C);if(G.pathSegType===1){G=F.getItem(C-1);var H=F.getItem(C-2);if(G.pathSegType===2){D(C-1,2);A();break}else if(H.pathSegType===2){D(C-2,3);A();break}}else if(G.pathSegType===2)if(C>0){G=F.getItem(C-1).pathSegType;if(G===2){D(C-1,1);A();break}else if(G===1&&F.numberOfItems-1===C){D(C,1);A();break}}}return false};A();if(svgedit.path.path.elem.pathSegList.numberOfItems<=
1){Va.toSelectMode(svgedit.path.path.elem);b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){w=$(svgedit.path.path.elem);w.attr("d",w.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(w){var s=w.points,A=s.numberOfItems;if(A>=4){var F=s.getItem(0),C=null;w=[];w.push(["M",F.x,",",F.y," C"].join(""));for(var D=1;D<=A-4;D+=3){var G=s.getItem(D),H=s.getItem(D+1),P=s.getItem(D+2);if(C)if((F=svgedit.path.smoothControlPoints(C,
G,F))&&F.length==2){G=w[w.length-1].split(",");G[2]=F[0].x;G[3]=F[0].y;w[w.length-1]=G.join(",");G=F[1]}w.push([G.x,G.y,H.x,H.y,P.x,P.y].join(","));F=P;C=H}for(w.push("L");D<A;++D){H=s.getItem(D);w.push([H.x,H.y].join(","))}w=w.join(" ");w=da({element:"path",curStyles:true,attr:{id:ta(),d:w,fill:"none"}})}return w},setSegType:function(w){svgedit.path.path.setSegType(w)},moveNode:function(w,s){var A=svgedit.path.path.selected_pts;if(A.length){svgedit.path.path.storeD();A=svgedit.path.path.segs[A[0]];
var F={x:0,y:0};F[w]=s-A.item[w];A.move(F.x,F.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(w){for(var s=w.pathSegList,A=s.numberOfItems,F,C=0;C<A;++C){var D=s.getItem(C);if(D.pathSegType===2)F=D;if(D.pathSegType===1){D=s.getItem(C-1);if(D.x!=F.x||D.y!=F.y){s=w.createSVGPathSegLinetoAbs(F.x,F.y);svgedit.path.insertItemBefore(w,s,C);Va.fixEnd(w);break}}}svgedit.browser.isWebkit()&&w.setAttribute("d",Va.convertPath(w))},convertPath:function(w,s){for(var A=w.pathSegList,F=A.numberOfItems,
C=0,D=0,G="",H=null,P=0;P<F;++P){var R=A.getItem(P),aa=R.x||0,ua=R.y||0,wa=R.x1||0,ha=R.y1||0,ka=R.x2||0,oa=R.y2||0,xa=R.pathSegType,eb=db[xa]["to"+(s?"Lower":"Upper")+"Case"](),Db=function(Pb,Jb,Ob){Jb=Jb?" "+Jb.join(" "):"";Ob=Ob?" "+svgedit.units.shortFloat(Ob):"";$.each(Pb,function(bc,kc){Pb[bc]=svgedit.units.shortFloat(kc)});G+=eb+Pb.join(" ")+Jb+Ob};switch(xa){case 1:G+="z";break;case 12:aa-=C;case 13:if(s){C+=aa;eb="l"}else{aa+=C;C=aa;eb="L"}Db([[aa,D]]);break;case 14:ua-=D;case 15:if(s){D+=
ua;eb="l"}else{ua+=D;D=ua;eb="L"}Db([[C,ua]]);break;case 2:case 4:case 18:aa-=C;ua-=D;case 5:case 3:if(H&&A.getItem(P-1).pathSegType===1&&!s){C=H[0];D=H[1]}case 19:if(s){C+=aa;D+=ua}else{aa+=C;ua+=D;C=aa;D=ua}if(xa===3)H=[C,D];Db([[aa,ua]]);break;case 6:aa-=C;wa-=C;ka-=C;ua-=D;ha-=D;oa-=D;case 7:if(s){C+=aa;D+=ua}else{aa+=C;wa+=C;ka+=C;ua+=D;ha+=D;oa+=D;C=aa;D=ua}Db([[wa,ha],[ka,oa],[aa,ua]]);break;case 8:aa-=C;wa-=C;ua-=D;ha-=D;case 9:if(s){C+=aa;D+=ua}else{aa+=C;wa+=C;ua+=D;ha+=D;C=aa;D=ua}Db([[wa,
ha],[aa,ua]]);break;case 10:aa-=C;ua-=D;case 11:if(s){C+=aa;D+=ua}else{aa+=C;ua+=D;C=aa;D=ua}Db([[R.r1,R.r2]],[R.angle,R.largeArcFlag?1:0,R.sweepFlag?1:0],[aa,ua]);break;case 16:aa-=C;ka-=C;ua-=D;oa-=D;case 17:if(s){C+=aa;D+=ua}else{aa+=C;ka+=C;ua+=D;oa+=D;C=aa;D=ua}Db([[ka,oa],[aa,ua]])}}return G}}}(),gc=this.removeUnusedDefElems=function(){var g=l.getElementsByTagNameNS(c,"defs");if(!g||!g.length)return 0;for(var h=[],k=0,v=["fill","stroke","filter","marker-start","marker-mid","marker-end"],t=v.length,
E=l.getElementsByTagNameNS(c,"*"),w=E.length,s=0;s<w;s++){for(var A=E[s],F=0;F<t;F++){var C=pa(A.getAttribute(v[F]));C&&h.push(C.substr(1))}(A=ba(A))&&A.indexOf("#")===0&&h.push(A.substr(1))}g=$(g).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(s=g.length;s--;){v=g[s];t=v.id;if(h.indexOf(t)<0){Bb[t]=v;v.parentNode.removeChild(v);k++}}return k};this.svgCanvasToString=function(){for(;gc()>0;);Va.clear(true);$.each(l.childNodes,function(k,v){k&&v.nodeType===8&&
v.data.indexOf("Created with")>=0&&l.insertBefore(v,l.firstChild)});if(L){ac();Qb([L])}var g=[];$(l).find("g:data(gsvg)").each(function(){for(var k=this.attributes,v=k.length,t=0;t<v;t++)if(k[t].nodeName=="id"||k[t].nodeName=="style")v--;if(v<=0){k=this.firstChild;g.push(k);$(this).replaceWith(k)}});var h=this.svgToString(l,0);g.length&&$(g).each(function(){na(this)});return h};this.svgToString=function(g,h){var k=[],v=svgedit.utilities.toXml,t=m.baseUnit,E=RegExp("^-?[\\d\\.]+"+t+"$");if(g){Y(g);
var w=g.attributes,s,A,F=g.childNodes;for(A=0;A<h;A++)k.push(" ");k.push("<");k.push(g.nodeName);if(g.id==="svgcontent"){A=Vb();if(t!=="px"){A.w=svgedit.units.convertUnit(A.w,t)+t;A.h=svgedit.units.convertUnit(A.h,t)+t}k.push(' width="'+A.w+'" height="'+A.h+'" xmlns="'+c+'"');var C={};$(g).find("*").andSelf().each(function(){$.each(this.attributes,function(P,R){var aa=R.namespaceURI;if(aa&&!C[aa]&&za[aa]!=="xmlns"&&za[aa]!=="xml"){C[aa]=true;k.push(" xmlns:"+za[aa]+'="'+aa+'"')}})});A=w.length;for(t=
["width","height","xmlns","x","y","viewBox","id","overflow"];A--;){s=w.item(A);var D=v(s.nodeValue);if(s.nodeName.indexOf("xmlns:")!==0)if(D!=""&&t.indexOf(s.localName)==-1)if(!s.namespaceURI||za[s.namespaceURI]){k.push(" ");k.push(s.nodeName);k.push('="');k.push(D);k.push('"')}}}else{if(g.nodeName==="defs"&&!g.firstChild)return;var G=["-moz-math-font-style","_moz-math-font-style"];for(A=w.length-1;A>=0;A--){s=w.item(A);D=v(s.nodeValue);if(!(G.indexOf(s.localName)>=0))if(D!="")if(D.indexOf("pointer-events")!==
0)if(!(s.localName==="class"&&D.indexOf("se_")===0)){k.push(" ");if(s.localName==="d")D=Va.convertPath(g,true);if(isNaN(D)){if(E.test(D))D=svgedit.units.shortFloat(D)+t}else D=svgedit.units.shortFloat(D);if(Za.apply&&g.nodeName==="image"&&s.localName==="href"&&Za.images&&Za.images==="embed"){var H=Sa[D];if(H)D=H}if(!s.namespaceURI||s.namespaceURI==c||za[s.namespaceURI]){k.push(s.nodeName);k.push('="');k.push(D);k.push('"')}}}}if(g.hasChildNodes()){k.push(">");h++;w=false;for(A=0;A<F.length;A++){t=
F.item(A);switch(t.nodeType){case 1:k.push("\n");k.push(this.svgToString(F.item(A),h));break;case 3:t=t.nodeValue.replace(/^\s+|\s+$/g,"");if(t!=""){w=true;k.push(v(t)+"")}break;case 4:k.push("\n");k.push(Array(h+1).join(" "));k.push("<![CDATA[");k.push(t.nodeValue);k.push("]]\>");break;case 8:k.push("\n");k.push(Array(h+1).join(" "));k.push("<!--");k.push(t.data);k.push("--\>")}}h--;if(!w){k.push("\n");for(A=0;A<h;A++)k.push(" ")}k.push("</");k.push(g.nodeName);k.push(">")}else k.push("/>")}return k.join("")};
this.embedImage=function(g,h){$(new Image).load(function(){var k=document.createElement("canvas");k.width=this.width;k.height=this.height;k.getContext("2d").drawImage(this,0,0);try{var v=";svgedit_url="+encodeURIComponent(g);v=k.toDataURL().replace(";base64",v+";base64");Sa[g]=v}catch(t){Sa[g]=false}Ja=g;h&&h(Sa[g])}).attr("src",g)};this.setGoodImage=function(g){Ja=g};this.open=function(){};this.save=function(g){bb();g&&$.extend(Za,g);Za.apply=true;g=this.svgCanvasToString();I("saved",g)};this.rasterExport=
function(){bb();var g=[],h={feGaussianBlur:Gb.exportNoBlur,foreignObject:Gb.exportNoforeignObject,"[stroke-dasharray]":Gb.exportNoDashArray},k=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=Gb.exportNoText;$.each(h,function(v,t){k.find(v).length&&g.push(t)});h=this.svgCanvasToString();I("exported",{svg:h,issues:g})};this.getSvgString=function(){Za.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,
z()):svgedit.draw.randomizeIds(true,z())};var cc=this.uniquifyElems=function(g){var h={},k=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(g,function(s){if(s.nodeType==1){if(s.id){s.id in h||(h[s.id]={elem:null,attrs:[],hrefs:[]});h[s.id].elem=s}$.each(Nb,function(F,C){var D=s.getAttributeNode(C);if(D){var G=svgedit.utilities.getUrlFromAttr(D.value);if(G=G?G.substr(1):null){G in h||(h[G]={elem:null,attrs:[],hrefs:[]});h[G].attrs.push(D)}}});
var A=svgedit.utilities.getHref(s);if(A&&k.indexOf(s.nodeName)>=0)if(A=A.substr(1)){A in h||(h[A]={elem:null,attrs:[],hrefs:[]});h[A].hrefs.push(s)}}});for(var v in h)if(v){var t=h[v].elem;if(t){g=M();t.id=g;t=h[v].attrs;for(var E=t.length;E--;){var w=t[E];w.ownerElement.setAttribute(w.name,"url(#"+g+")")}t=h[v].hrefs;for(E=t.length;E--;)svgedit.utilities.setHref(t[E],"#"+g)}}},Ub=this.setUseData=function(g){var h=$(g);if(g.tagName!=="use")h=h.find("use");h.each(function(){var k=ba(this).substr(1);
if(k=la(k)){$(this).data("ref",k);if(k.tagName=="symbol"||k.tagName=="svg")$(this).data("symbol",k).data("ref",k)}})},hc=this.convertGradients=function(g){var h=$(g).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(g).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var k=$(l).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(k.length)if(k=svgedit.utilities.getBBox(k[0]))if(this.tagName===
"linearGradient"){var v=$(this).attr(["x1","y1","x2","y2"]),t=this.gradientTransform.baseVal;if(t&&t.numberOfItems>0){var E=ja(t).matrix;t=O(v.x1,v.y1,E);E=O(v.x2,v.y2,E);v.x1=t.x;v.y1=t.y;v.x2=E.x;v.y2=E.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(v.x1-k.x)/k.width,y1:(v.y1-k.y)/k.height,x2:(v.x2-k.x)/k.width,y2:(v.y2-k.y)/k.height});this.removeAttribute("gradientUnits")}}})},lc=this.convertToGroup=function(g){g||(g=J[0]);var h=$(g),k=new La,v;if(h.data("gsvg")){k=$(g.firstChild).attr(["x",
"y"]);$(g.firstChild.firstChild).unwrap();$(g).removeData("gsvg");v=V(g);var t=e.createSVGTransform();t.setTranslate(k.x,k.y);v.appendItem(t);pb(g);I("selected",[g])}else if(h.data("symbol")){g=h.data("symbol");v=h.attr("transform");t=h.attr(["x","y"]);var E=g.getAttribute("viewBox");if(E){E=E.split(" ");t.x-=+E[0];t.y-=+E[1]}v+=" translate("+(t.x||0)+","+(t.y||0)+")";t=h.prev();k.addSubCommand(new Ua(h[0],h[0].nextSibling,h[0].parentNode));h.remove();E=$(l).find("use:data(symbol)").length;h=d.createElementNS(c,
"g");for(var w=g.childNodes,s=0;s<w.length;s++)h.appendChild(w[s].cloneNode(true));if(svgedit.browser.isGecko()){w=$(ub()).children("linearGradient,radialGradient,pattern").clone();$(h).append(w)}v&&h.setAttribute("transform",v);v=g.parentNode;cc(h);svgedit.browser.isGecko()&&$(ub()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=M();t.after(h);if(v){if(!E){t=g.nextSibling;v.removeChild(g);k.addSubCommand(new Ua(g,t,v))}k.addSubCommand(new Ka(h))}Ub(h);svgedit.browser.isGecko()?hc(ub()):
hc(h);svgedit.utilities.walkTreePost(h,function(A){try{pb(A)}catch(F){console.log(F)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=M()});Qb([h]);(g=fc(h,true))&&k.addSubCommand(g);Ga(k)}else console.log("Unexpected element to ungroup:",g)};this.setSvgString=function(g){try{var h=svgedit.utilities.text2xml(g);this.prepareSvg(h);var k=new La("Change Source"),v=l.nextSibling,t=e.removeChild(l);k.addSubCommand(new Ua(t,
v,e));l=d.adoptNode?d.adoptNode(h.documentElement):d.importNode(h.documentElement,true);e.appendChild(l);var E=$(l);b.current_drawing_=new svgedit.draw.Drawing(l,u);var w=z().getNonce();w?I("setnonce",w):I("unsetnonce");E.find("image").each(function(){var H=this;Zb(H);var P=ba(this);if(P.indexOf("data:")===0){var R=P.match(/svgedit_url=(.*?);/);if(R){var aa=decodeURIComponent(R[1]);$(new Image).load(function(){H.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",aa)}).attr("src",aa)}}b.embedImage(P)});
E.find("svg").each(function(){if(!$(this).closest("defs").length){cc(this);var H=this.parentNode;if(H.childNodes.length===1&&H.nodeName==="g"){$(H).data("gsvg",this);H.id=H.id||M()}else na(this)}});svgedit.browser.isGecko()&&E.find("linearGradient, radialGradient, pattern").appendTo(ub());Ub(E);hc(E[0]);svgedit.utilities.walkTreePost(l,function(H){try{pb(H)}catch(P){console.log(P)}});var s={id:"svgcontent",overflow:m.show_outside_canvas?"visible":"hidden"},A=false;if(E.attr("viewBox")){var F=E.attr("viewBox").split(" ");
s.width=F[2];s.height=F[3]}else $.each(["width","height"],function(H,P){var R=E.attr(P);R||(R="100%");if((R+"").substr(-1)==="%")A=true;else s[P]=qa(P,R)});Wb();E.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=M()});if(A){var C=getStrokedBBox();s.width=C.width+C.x;s.height=C.height+C.y}if(s.width<=0)s.width=100;if(s.height<=0)s.height=100;E.attr(s);this.contentW=s.width;this.contentH=s.height;k.addSubCommand(new Ka(l));
var D=E.attr(["width","height"]);k.addSubCommand(new Wa(e,D));o=1;svgedit.transformlist.resetListMap();bb();svgedit.path.clearData();e.appendChild(Oa.selectorParentGroup);Ga(k);I("changed",[l])}catch(G){console.log(G);return false}return true};this.importSvgString=function(g){try{var h=svgedit.utilities.encode64(g.length+g).substr(0,32),k=false;if(Ab[h])if($(Ab[h].symbol).parents("#svgroot").length)k=true;var v=new La("Import SVG");if(k)var t=Ab[h].symbol,E=Ab[h].xform;else{var w=svgedit.utilities.text2xml(g);
this.prepareSvg(w);var s;s=d.adoptNode?d.adoptNode(w.documentElement):d.importNode(w.documentElement,true);cc(s);var A=qa("width",s.getAttribute("width")),F=qa("height",s.getAttribute("height")),C=s.getAttribute("viewBox"),D=C?C.split(" "):[0,0,A,F];for(g=0;g<4;++g)D[g]=+D[g];l.getAttribute("width");var G=+l.getAttribute("height");E=F>A?"scale("+G/3/D[3]+")":"scale("+G/3/D[2]+")";E="translate(0) "+E+" translate(0)";t=d.createElementNS(c,"symbol");var H=ub();for(svgedit.browser.isGecko()&&$(s).find("linearGradient, radialGradient, pattern").appendTo(H);s.firstChild;)t.appendChild(s.firstChild);
var P=s.attributes;for(s=0;s<P.length;s++){var R=P[s];t.setAttribute(R.nodeName,R.nodeValue)}t.id=M();Ab[h]={symbol:t,xform:E};ub().appendChild(t);v.addSubCommand(new Ka(t))}var aa=d.createElementNS(c,"use");aa.id=M();S(aa,"#"+t.id);(L||z().getCurrentLayer()).appendChild(aa);v.addSubCommand(new Ka(aa));bb();aa.setAttribute("transform",E);pb(aa);$(aa).data("symbol",t).data("ref",t);qb([aa]);Ga(v);I("changed",[l])}catch(ua){console.log(ua);return false}return true};var Wb=b.identifyLayers=function(){ac();
z().identifyLayers()};this.createLayer=function(g){var h=new La("Create Layer");g=z().createLayer(g);h.addSubCommand(new Ka(g));Ga(h);bb();I("changed",[g])};this.cloneLayer=function(g){var h=new La("Duplicate Layer"),k=d.createElementNS(c,"g"),v=d.createElementNS(c,"title");v.textContent=g;k.appendChild(v);v=z().getCurrentLayer();$(v).after(k);v=v.childNodes;for(var t=0;t<v.length;t++){var E=v[t];E.localName!="title"&&k.appendChild(Z(E))}bb();Wb();h.addSubCommand(new Ka(k));Ga(h);b.setCurrentLayer(g);
I("changed",[k])};this.deleteCurrentLayer=function(){var g=z().getCurrentLayer(),h=g.nextSibling,k=g.parentNode;if(g=z().deleteCurrentLayer()){var v=new La("Delete Layer");v.addSubCommand(new Ua(g,h,k));Ga(v);bb();I("changed",[k]);return true}return false};this.setCurrentLayer=function(g){(g=z().setCurrentLayer(svgedit.utilities.toXml(g)))&&bb();return g};this.renameCurrentLayer=function(g){var h=z();if(h.current_layer){var k=h.current_layer;if(!b.setCurrentLayer(g)){for(var v=new La("Rename Layer"),
t=0;t<h.getNumLayers();++t)if(h.all_layers[t][1]==k)break;var E=h.getLayerName(t);h.all_layers[t][0]=svgedit.utilities.toXml(g);var w=k.childNodes.length;for(t=0;t<w;++t){var s=k.childNodes.item(t);if(s&&s.tagName=="title"){for(;s.firstChild;)s.removeChild(s.firstChild);s.textContent=g;v.addSubCommand(new Wa(s,{"#text":E}));Ga(v);I("changed",[k]);return true}}}h.current_layer=k}return false};this.setCurrentLayerPosition=function(g){var h=z();if(h.current_layer&&g>=0&&g<h.getNumLayers()){for(var k=
0;k<h.getNumLayers();++k)if(h.all_layers[k][1]==h.current_layer)break;if(k==h.getNumLayers())return false;if(k!=g){var v=null,t=h.current_layer.nextSibling;if(g>k){if(g<h.getNumLayers()-1)v=h.all_layers[g+1][1]}else v=h.all_layers[g][1];l.insertBefore(h.current_layer,v);Ga(new Qa(h.current_layer,t,l));Wb();b.setCurrentLayer(h.getLayerName(g));return true}}return false};this.setLayerVisibility=function(g,h){var k=z(),v=k.getLayerVisibility(g),t=k.setLayerVisibility(g,h);if(t)Ga(new Wa(t,{display:v?
"inline":"none"},"Layer Visibility"));else return false;if(t==k.getCurrentLayer()){bb();Va.clear()}return true};this.moveSelectedToLayer=function(g){for(var h=null,k=z(),v=0;v<k.getNumLayers();++v)if(k.getLayerName(v)==g){h=k.all_layers[v][1];break}if(!h)return false;g=new La("Move Elements to Layer");k=J;for(v=k.length;v--;){var t=k[v];if(t){var E=t.nextSibling,w=t.parentNode;h.appendChild(t);g.addSubCommand(new Qa(t,E,w))}}Ga(g);return true};this.mergeLayer=function(g){var h=new La("Merge Layer"),
k=z(),v=$(k.current_layer).prev()[0];if(v){for(h.addSubCommand(new Ua(k.current_layer,k.current_layer.nextSibling,l));k.current_layer.firstChild;){var t=k.current_layer.firstChild;if(t.localName=="title"){h.addSubCommand(new Ua(t,t.nextSibling,k.current_layer));k.current_layer.removeChild(t)}else{var E=t.nextSibling;v.appendChild(t);h.addSubCommand(new Qa(t,E,k.current_layer))}}l.removeChild(k.current_layer);if(!g){bb();Wb();I("changed",[l]);Ga(h)}k.current_layer=v;return h}};this.mergeAllLayers=
function(){var g=new La("Merge all Layers"),h=z();for(h.current_layer=h.all_layers[h.getNumLayers()-1][1];$(l).children("g").length>1;)g.addSubCommand(b.mergeLayer(true));bb();Wb();I("changed",[l]);Ga(g)};var ac=this.leaveContext=function(){var g=Ea.length;if(g){for(var h=0;h<g;h++){var k=Ea[h],v=lb(k,"orig_opac");v!==1?k.setAttribute("opacity",v):k.removeAttribute("opacity");k.setAttribute("style","pointer-events: inherit")}Ea=[];bb(true);I("contextset",null)}L=null},nc=this.setContext=function(g){ac();
if(typeof g==="string")g=la(g);L=g;$(g).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var h=this.getAttribute("opacity")||1;lb(this,"orig_opac",h);this.setAttribute("opacity",h*0.33);this.setAttribute("style","pointer-events: none");Ea.push(this)});bb();I("contextset",L)};this.clear=function(){Va.clear();bb();b.clearSvgContentElement();b.current_drawing_=new svgedit.draw.Drawing(l);b.createLayer("Layer 1");b.undoMgr.resetUndoStack();Oa.initGroup();Ca=Oa.getRubberBandBox();I("cleared")};
this.linkControlPoints=Va.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=function(){return e};this.getSelectedElems=function(){return J};var Vb=this.getResolution=function(){var g=l.getAttribute("width")/o,h=l.getAttribute("height")/o;return{w:g,h:h,zoom:o}};this.getZoom=function(){return o};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(g){$.extend(Gb,g.notification)};this.setConfig=function(g){$.extend(m,g)};this.getTitle=
function(g){if(g=g||J[0]){g=$(g).data("gsvg")||$(g).data("symbol")||g;g=g.childNodes;for(var h=0;h<g.length;h++)if(g[h].nodeName=="title")return g[h].textContent;return""}};this.setGroupTitle=function(g){var h=J[0];h=$(h).data("gsvg")||h;var k=$(h).children("title"),v=new La("Set Label");if(g.length)if(k.length){k=k[0];v.addSubCommand(new Wa(k,{"#text":k.textContent}));k.textContent=g}else{k=d.createElementNS(c,"title");k.textContent=g;$(h).prepend(k);v.addSubCommand(new Ka(k))}else{v.addSubCommand(new Ua(k[0],
k.nextSibling,h));k.remove()}Ga(v)};this.getDocumentTitle=function(){return b.getTitle(l)};this.setDocumentTitle=function(g){for(var h=l.childNodes,k=false,v="",t=new La("Change Image Title"),E=0;E<h.length;E++)if(h[E].nodeName=="title"){k=h[E];v=k.textContent;break}if(!k){k=d.createElementNS(c,"title");l.insertBefore(k,l.firstChild)}if(g.length)k.textContent=g;else k.parentNode.removeChild(k);t.addSubCommand(new Wa(k,{"#text":v}));Ga(t)};this.getEditorNS=function(g){g&&l.setAttribute("xmlns:se",
"http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(g,h){var k=Vb(),v=k.w;k=k.h;var t;if(g=="fit"){var E=getStrokedBBox();if(E){t=new La("Fit Canvas to Content");var w=Ib();qb(w);var s=[],A=[];$.each(w,function(){s.push(E.x*-1);A.push(E.y*-1)});w=b.moveSelectedElements(s,A,true);t.addSubCommand(w);bb();g=Math.round(E.width);h=Math.round(E.height)}else return false}if(g!=v||h!=k){w=e.suspendRedraw(1E3);t||(t=new La("Change Image Dimensions"));g=qa("width",
g);h=qa("height",h);l.setAttribute("width",g);l.setAttribute("height",h);this.contentW=g;this.contentH=h;t.addSubCommand(new Wa(l,{width:v,height:k}));l.setAttribute("viewBox",[0,0,g/o,h/o].join(" "));t.addSubCommand(new Wa(l,{viewBox:["0 0",v,k].join(" ")}));Ga(t);e.unsuspendRedraw(w);I("changed",[l])}return true};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(g,h,k){var v=0.85,t=function(E){if(!E)return false;var w=Math.min(Math.round(h/E.width*100*v)/100,Math.round(k/
E.height*100*v)/100);b.setZoom(w);return{zoom:w,bbox:E}};if(typeof g=="object"){g=g;if(g.width==0||g.height==0){b.setZoom(g.zoom?g.zoom:o*g.factor);return{zoom:o,bbox:g}}return t(g)}switch(g){case "selection":if(!J[0])return;g=$.map(J,function(E){if(E)return E});g=getStrokedBBox(g);break;case "canvas":g=Vb();v=0.95;g={width:g.w,height:g.h,x:0,y:0};break;case "content":g=getStrokedBBox();break;case "layer":g=getStrokedBBox(Ib(z().getCurrentLayer()));break;default:return}return t(g)};this.setZoom=function(g){var h=
Vb();l.setAttribute("viewBox","0 0 "+h.w/g+" "+h.h/g);o=g;$.each(J,function(k,v){v&&Oa.requestSelector(v).resize()});Va.zoomChange();ob("zoomChanged",g)};this.getMode=function(){return Na};this.setMode=function(g){Va.clear(true);rb.clear();$("#workarea").attr("class",g);jb=J[0]&&J[0].nodeName=="text"?cb:N;Na=g};this.getColor=function(g){return jb[g]};this.setColor=function(g,h,k){N[g]=h;jb[g+"_paint"]={type:"solidColor"};for(var v=[],t=J.length;t--;){var E=J[t];if(E)if(E.tagName=="g")svgedit.utilities.walkTree(E,
function(w){w.nodeName!="g"&&v.push(w)});else if(g=="fill")E.tagName!="polyline"&&E.tagName!="line"&&v.push(E);else v.push(E)}if(v.length>0)if(k)Sb(g,h,v);else{vb(g,h,v);I("changed",v)}};var ub=function(){var g=l.getElementsByTagNameNS(c,"defs");if(g.length>0)g=g[0];else{g=d.createElementNS(c,"defs");l.firstChild?l.insertBefore(g,l.firstChild.nextSibling):l.appendChild(g)}return g},ic=this.setGradient=function(g){if(!(!jb[g+"_paint"]||jb[g+"_paint"].type=="solidColor")){var h=b[g+"Grad"],k=dc(h),
v=ub();if(k)h=k;else{h=v.appendChild(d.importNode(h,true));h.id=M()}b.setColor(g,"url(#"+h.id+")")}},dc=function(g){var h=ub();h=$(h).find("linearGradient, radialGradient");for(var k=h.length,v=["r","cx","cy","fx","fy"];k--;){var t=h[k];if(g.tagName=="linearGradient"){if(g.getAttribute("x1")!=t.getAttribute("x1")||g.getAttribute("y1")!=t.getAttribute("y1")||g.getAttribute("x2")!=t.getAttribute("x2")||g.getAttribute("y2")!=t.getAttribute("y2"))continue}else{var E=$(g).attr(v),w=$(t).attr(v),s=false;
$.each(v,function(H,P){if(E[P]!=w[P])s=true});if(s)continue}var A=g.getElementsByTagNameNS(c,"stop"),F=t.getElementsByTagNameNS(c,"stop");if(A.length==F.length){for(var C=A.length;C--;){var D=A[C],G=F[C];if(D.getAttribute("offset")!=G.getAttribute("offset")||D.getAttribute("stop-opacity")!=G.getAttribute("stop-opacity")||D.getAttribute("stop-color")!=G.getAttribute("stop-color"))break}if(C==-1)return t}}return null};this.setPaint=function(g,h){var k=new $.jGraduate.Paint(h);this.setPaintOpacity(g,
k.alpha/100,true);jb[g+"_paint"]=k;switch(k.type){case "solidColor":if(k.solidColor!="none")this.setColor(g,"#"+k.solidColor);else{this.setColor(g,"none");document.querySelector(g=="fill"?"#fill_color rect":"#stroke_color rect").setAttribute("fill","transparent")}break;case "linearGradient":case "radialGradient":b[g+"Grad"]=k[k.type];ic(g)}};this.getStrokeWidth=function(){return jb.stroke_width};this.setStrokeWidth=function(g){if(g==0&&["line","path"].indexOf(Na)>=0)b.setStrokeWidth(1);else{jb.stroke_width=
g;for(var h=[],k=J.length;k--;){var v=J[k];if(v)v.tagName=="g"?svgedit.utilities.walkTree(v,function(t){t.nodeName!="g"&&h.push(t)}):h.push(v)}if(h.length>0){vb("stroke-width",g,h);I("changed",J)}}};this.setStrokeAttr=function(g,h){N[g.replace("-","_")]=h;for(var k=[],v=J.length;v--;){var t=J[v];if(t)t.tagName=="g"?svgedit.utilities.walkTree(t,function(E){E.nodeName!="g"&&k.push(E)}):k.push(t)}if(k.length>0){vb(g,h,k);I("changed",J)}};this.getStyle=function(){return N};this.getOpacity=function(){return N.opacity};
this.setOpacity=function(g){N.opacity=g;vb("opacity",g)};this.getFillOpacity=function(){return N.fill_opacity};this.getStrokeOpacity=function(){return N.stroke_opacity};this.setPaintOpacity=function(g,h,k){N[g+"_opacity"]=h;k?Sb(g+"-opacity",h):vb(g+"-opacity",h)};this.getBlur=function(g){var h=0;if(g)if(g.getAttribute("filter"))if(g=la(g.id+"_blur"))h=g.firstChild.getAttribute("stdDeviation");return h};(function(){function g(){var t=b.undoMgr.finishUndoableChange();h.addSubCommand(t);Ga(h);k=h=null}
var h=null,k=null,v=false;b.setBlurNoUndo=function(t){if(k)if(t===0){Sb("filter","");v=true}else{var E=J[0];v&&Sb("filter","url(#"+E.id+"_blur)");if(svgedit.browser.isWebkit()){E.removeAttribute("filter");E.setAttribute("filter","url(#"+E.id+"_blur)")}Sb("stdDeviation",t,[k.firstChild]);b.setBlurOffsets(k,t)}else b.setBlur(t)};b.setBlurOffsets=function(t,E){if(E>3)ma(t,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100);else if(!svgedit.browser.isWebkit()){t.removeAttribute("x");t.removeAttribute("y");
t.removeAttribute("width");t.removeAttribute("height")}};b.setBlur=function(t,E){if(h)g();else{var w=J[0],s=w.id;k=la(s+"_blur");t-=0;var A=new La;if(k){if(t===0)k=null}else{var F=da({element:"feGaussianBlur",attr:{"in":"SourceGraphic",stdDeviation:t}});k=da({element:"filter",attr:{id:s+"_blur"}});k.appendChild(F);ub().appendChild(k);A.addSubCommand(new Ka(k))}F={filter:w.getAttribute("filter")};if(t===0){w.removeAttribute("filter");A.addSubCommand(new Wa(w,F))}else{vb("filter","url(#"+s+"_blur)");
A.addSubCommand(new Wa(w,F));b.setBlurOffsets(k,t);h=A;b.undoMgr.beginUndoableChange("stdDeviation",[k?k.firstChild:null]);if(E){b.setBlurNoUndo(t);g()}}}}})();this.getBold=function(){var g=J[0];if(g!=null&&g.tagName=="text"&&J[1]==null)return g.getAttribute("font-weight")=="bold";return false};this.setBold=function(g){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)vb("font-weight",g?"bold":"normal");J[0].textContent||rb.setCursor()};this.getItalic=function(){var g=J[0];if(g!=null&&g.tagName==
"text"&&J[1]==null)return g.getAttribute("font-style")=="italic";return false};this.setItalic=function(g){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)vb("font-style",g?"italic":"normal");J[0].textContent||rb.setCursor()};this.getFontFamily=function(){return cb.font_family};this.setFontFamily=function(g){cb.font_family=g;vb("font-family",g);J[0]&&!J[0].textContent&&rb.setCursor()};this.setFontColor=function(g){cb.fill=g;vb("fill",g)};this.getFontSize=function(){return cb.fill};this.getFontSize=
function(){return cb.font_size};this.setFontSize=function(g){cb.font_size=g;vb("font-size",g);J[0].textContent||rb.setCursor()};this.getText=function(){var g=J[0];if(g==null)return"";return g.textContent};this.setTextContent=function(g){vb("#text",g);rb.init(g);rb.setCursor()};this.setImageURL=function(g){var h=J[0];if(h){var k=$(h).attr(["width","height"]);k=!k.width||!k.height;var v=ba(h);if(v!==g)k=true;else if(!k)return;var t=new La("Change Image URL");S(h,g);t.addSubCommand(new Wa(h,{"#href":v}));
k?$(new Image).load(function(){var E=$(h).attr(["width","height"]);$(h).attr({width:this.width,height:this.height});Oa.requestSelector(h).resize();t.addSubCommand(new Wa(h,E));Ga(t);I("changed",[h])}).attr("src",g):Ga(t)}};this.setLinkURL=function(g){var h=J[0];if(h){if(h.tagName!=="a"){h=$(h).parents("a");if(h.length)h=h[0];else return}var k=ba(h);if(k!==g){var v=new La("Change Link URL");S(h,g);v.addSubCommand(new Wa(h,{"#href":k}));Ga(v)}}};this.setRectRadius=function(g){var h=J[0];if(h!=null&&
h.tagName=="rect"){var k=h.getAttribute("rx");if(k!=g){h.setAttribute("rx",g);h.setAttribute("ry",g);Ga(new Wa(h,{rx:k,ry:k},"Radius"));I("changed",[h])}}};this.makeHyperlink=function(g){b.groupSelectedElements("a",g)};this.removeHyperlink=function(){b.ungroupSelectedElement()};this.setSegType=function(g){Va.setSegType(g)};this.convertToPath=function(g,h){if(g==null)$.each(J,function(wa,ha){ha&&b.convertToPath(ha)});else{if(!h)var k=new La("Convert element to Path");var v=h?{}:{fill:N.fill,"fill-opacity":N.fill_opacity,
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,opacity:N.opacity,visibility:"hidden"};$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(g.getAttribute(this))v[this]=g.getAttribute(this)});var t=da({element:"path",attr:v}),E=g.getAttribute("transform");E&&t.setAttribute("transform",E);var w=g.id,s=g.parentNode;g.nextSibling?
s.insertBefore(t,g):s.appendChild(t);var A="",F=function(wa){$.each(wa,function(ha,ka){var oa=ka[1];A+=ka[0];for(var xa=0;xa<oa.length;xa+=2)A+=oa[xa]+","+oa[xa+1]+" "})},C=1.81;switch(g.tagName){case "ellipse":case "circle":var D=$(g).attr(["rx","ry","cx","cy"]),G=D.cx,H=D.cy,P=D.rx;D=D.ry;if(g.tagName=="circle")P=D=$(g).attr("r");F([["M",[G-P,H]],["C",[G-P,H-D/C,G-P/C,H-D,G,H-D]],["C",[G+P/C,H-D,G+P,H-D/C,G+P,H]],["C",[G+P,H+D/C,G+P/C,H+D,G,H+D]],["C",[G-P/C,H+D,G-P,H+D/C,G-P,H]],["Z",[]]]);break;
case "path":A=g.getAttribute("d");break;case "line":D=$(g).attr(["x1","y1","x2","y2"]);A="M"+D.x1+","+D.y1+"L"+D.x2+","+D.y2;break;case "polyline":case "polygon":A="M"+g.getAttribute("points");break;case "rect":D=$(g).attr(["rx","ry"]);P=D.rx;D=D.ry;var R=g.getBBox();G=R.x;H=R.y;var aa=R.width;R=R.height;C=4-C;!P&&!D?F([["M",[G,H]],["L",[G+aa,H]],["L",[G+aa,H+R]],["L",[G,H+R]],["L",[G,H]],["Z",[]]]):F([["M",[G,H+D]],["C",[G,H+D/C,G+P/C,H,G+P,H]],["L",[G+aa-P,H]],["C",[G+aa-P/C,H,G+aa,H+D/C,G+aa,H+
D]],["L",[G+aa,H+R-D]],["C",[G+aa,H+R-D/C,G+aa-P/C,H+R,G+aa-P,H+R]],["L",[G+P,H+R]],["C",[G+P/C,H+R,G,H+R-D/C,G,H+R-D]],["L",[G,H+D]],["Z",[]]]);break;default:t.parentNode.removeChild(t)}A&&t.setAttribute("d",A);if(h){Va.resetOrientation(t);k=false;try{k=t.getBBox()}catch(ua){}t.parentNode.removeChild(t);return k}else{if(E){E=V(t);sa(E)&&Va.resetOrientation(t)}k.addSubCommand(new Ua(g,g.nextSibling,s));k.addSubCommand(new Ka(t));bb();g.parentNode.removeChild(g);t.setAttribute("id",w);t.removeAttribute("visibility");
qb([t],true);Ga(k)}}};var Sb=function(g,h,k){var v=e.suspendRedraw(1E3);Na=="pathedit"&&Va.moveNode(g,h);k=k||J;for(var t=k.length,E=["g","polyline","path"];t--;){var w=k[t];if(w!=null){Na==="textedit"&&g!=="#text"&&w.textContent.length&&rb.toSelectMode(w);if((g==="x"||g==="y")&&E.indexOf(w.tagName)>=0){var s=getStrokedBBox([w]);b.moveSelectedElements((g==="x"?h-s.x:0)*o,(g==="y"?h-s.y:0)*o,true)}else{s=g==="#text"?w.textContent:w.getAttribute(g);if(s==null)s="";if(s!==String(h)){if(g=="#text"){svgedit.utilities.getBBox(w);
w.textContent=h;if(/rotate/.test(w.getAttribute("transform")))w=Ma(w)}else g=="#href"?S(w,h):w.setAttribute(g,h);if(svgedit.browser.isGecko()&&w.nodeName==="text"&&/rotate/.test(w.getAttribute("transform")))if((h+"").indexOf("url")===0||["font-size","font-family","x","y"].indexOf(g)>=0&&w.textContent)w=Ma(w);J.indexOf(w)>=0&&setTimeout(function(){w.parentNode&&Oa.requestSelector(w).resize()},0);s=ra(w);if(s!=0&&g!="transform")for(var A=V(w),F=A.numberOfItems;F--;)if(A.getItem(F).type==4){A.removeItem(F);
var C=svgedit.utilities.getBBox(w),D=O(C.x+C.width/2,C.y+C.height/2,ja(A).matrix);C=D.x;D=D.y;var G=e.createSVGTransform();G.setRotate(s,C,D);A.insertItemBefore(G,F);break}}}}}e.unsuspendRedraw(v)},vb=this.changeSelectedAttribute=function(g,h,k){k=k||J;b.undoMgr.beginUndoableChange(g,k);Sb(g,h,k);g=b.undoMgr.finishUndoableChange();g.isEmpty()||Ga(g)};this.deleteSelectedElements=function(){for(var g=new La("Delete Elements"),h=J.length,k=[],v=0;v<h;++v){var t=J[v];if(t==null)break;var E=t.parentNode,
w=t;Oa.releaseSelector(w);svgedit.path.removePath_(w.id);if(E.tagName==="a"&&E.childNodes.length===1){w=E;E=E.parentNode}var s=w.nextSibling;w=E.removeChild(w);k.push(t);J[v]=null;g.addSubCommand(new Ua(w,s,E))}g.isEmpty()||Ga(g);I("changed",k);bb()};this.cutSelectedElements=function(){for(var g=new La("Cut Elements"),h=J.length,k=[],v=0;v<h;++v){var t=J[v];if(t==null)break;var E=t.parentNode,w=t;Oa.releaseSelector(w);svgedit.path.removePath_(w.id);var s=w.nextSibling;w=E.removeChild(w);k.push(t);
J[v]=null;g.addSubCommand(new Ua(w,s,E))}g.isEmpty()||Ga(g);I("changed",k);bb();b.clipBoard=k};this.copySelectedElements=function(){b.clipBoard=$.merge([],J)};this.pasteElements=function(g,h,k){var v=b.clipBoard,t=v.length;if(t){for(var E=[],w=new La("Paste elements");t--;){var s=v[t];if(s){var A=Z(s);if(!la(s.id))A.id=s.id;E.push(A);(L||z().getCurrentLayer()).appendChild(A);w.addSubCommand(new Ka(A))}}Qb(E);if(g!="in_place"){if(yb==null){yb.x=0;yb.y=0}var F,C;if(g){if(g==="point"){F=h;C=k}}else{F=
yb.x;C=yb.y}g=getStrokedBBox(E);var D=F-(g.x+g.width/2),G=C-(g.y+g.height/2),H=[],P=[];$.each(E,function(){H.push(D);P.push(G)});F=b.moveSelectedElements(H,P,false);w.addSubCommand(F)}Ga(w);I("changed",E)}};this.groupSelectedElements=function(g){g||(g="g");var h="";switch(g){case "a":h="Make hyperlink";var k="";if(arguments.length>1)k=arguments[1];break;default:g="g";h="Group Elements"}h=new La(h);var v=da({element:g,attr:{id:M()}});g==="a"&&S(v,k);h.addSubCommand(new Ka(v));for(k=J.length;k--;){var t=
J[k];if(t!=null){if(t.parentNode.tagName==="a"&&t.parentNode.childNodes.length===1)t=t.parentNode;var E=t.nextSibling,w=t.parentNode;v.appendChild(t);h.addSubCommand(new Qa(t,E,w))}}h.isEmpty()||Ga(h);Qb([v],true)};var fc=this.pushGroupProperties=function(g,h){var k=g.childNodes,v=k.length,t=g.getAttribute("transform"),E=V(g),w=ja(E).matrix,s=new La("Push group properties"),A=0,F=ra(g),C=$(g).attr(["filter","opacity"]),D,G;for(A=0;A<v;A++){var H=k[A];if(H.nodeType===1){if(C.opacity!==null&&C.opacity!==
1){H.getAttribute("opacity");var P=Math.round((H.getAttribute("opacity")||1)*C.opacity*100)/100;vb("opacity",P,[H])}if(C.filter){var R=P=this.getBlur(H);G||(G=this.getBlur(g));if(P)P=G-0+(P-0);else if(P===0)P=G;if(R)D=X(H.getAttribute("filter"));else if(D){D=Z(D);ub().appendChild(D)}else D=X(C.filter);D.id=H.id+"_"+(D.firstChild.tagName==="feGaussianBlur"?"blur":"filter");vb("filter","url(#"+D.id+")",[H]);if(P){vb("stdDeviation",P,[D.firstChild]);b.setBlurOffsets(D,P)}}P=V(H);if(~H.tagName.indexOf("Gradient"))P=
null;if(P)if(H.tagName!=="defs")if(E.numberOfItems){if(F&&E.numberOfItems==1){var aa=E.getItem(0).matrix,ua=e.createSVGMatrix();if(R=ra(H))ua=P.getItem(0).matrix;var wa=svgedit.utilities.getBBox(H),ha=ja(P).matrix,ka=O(wa.x+wa.width/2,wa.y+wa.height/2,ha);wa=F+R;ha=e.createSVGTransform();ha.setRotate(wa,ka.x,ka.y);aa=fa(aa,ua,ha.matrix.inverse());R&&P.removeItem(0);if(wa)P.numberOfItems?P.insertItemBefore(ha,0):P.appendItem(ha);if(aa.e||aa.f){R=e.createSVGTransform();R.setTranslate(aa.e,aa.f);P.numberOfItems?
P.insertItemBefore(R,0):P.appendItem(R)}}else{R=H.getAttribute("transform");aa={};aa.transform=R?R:"";R=e.createSVGTransform();aa=ja(P).matrix;ua=aa.inverse();aa=fa(ua,w,aa);R.setMatrix(aa);P.appendItem(R)}(H=pb(H))&&s.addSubCommand(H)}}}if(t){aa={};aa.transform=t;g.setAttribute("transform","");g.removeAttribute("transform");s.addSubCommand(new Wa(g,aa))}if(h&&!s.isEmpty())return s};this.ungroupSelectedElement=function(){var g=J[0];if($(g).data("gsvg")||$(g).data("symbol"))lc(g);else if(g.tagName===
"use"){var h=la(ba(g).substr(1));$(g).data("symbol",h).data("ref",h);lc(g)}else{h=$(g).parents("a");if(h.length)g=h[0];if(g.tagName==="g"||g.tagName==="a"){h=new La("Ungroup Elements");var k=fc(g,true);k&&h.addSubCommand(k);k=g.parentNode;for(var v=g.nextSibling,t=Array(g.childNodes.length),E=0;g.firstChild;){var w=g.firstChild,s=w.nextSibling,A=w.parentNode;if(w.tagName==="title"){h.addSubCommand(new Ua(w,w.nextSibling,A));A.removeChild(w)}else{t[E++]=w=k.insertBefore(w,v);h.addSubCommand(new Qa(w,
s,A))}}bb();v=g.nextSibling;g=k.removeChild(g);h.addSubCommand(new Ua(g,v,k));h.isEmpty()||Ga(h);qb(t)}}};this.moveToTopSelectedElement=function(){var g=J[0];if(g!=null){g=g;var h=g.parentNode,k=g.nextSibling;g=g.parentNode.appendChild(g);if(k!=g.nextSibling){Ga(new Qa(g,k,h,"top"));I("changed",[g])}}};this.moveToBottomSelectedElement=function(){var g=J[0];if(g!=null){g=g;var h=g.parentNode,k=g.nextSibling,v=g.parentNode.firstChild;if(v.tagName=="title")v=v.nextSibling;if(v.tagName=="defs")v=v.nextSibling;
g=g.parentNode.insertBefore(g,v);if(k!=g.nextSibling){Ga(new Qa(g,k,h,"bottom"));I("changed",[g])}}};this.moveUpDownSelected=function(g){var h=J[0];if(h){wb=[];var k,v,t=$(Kb(getStrokedBBox([h]))).toArray();g=="Down"&&t.reverse();$.each(t,function(){if(v){k=this;return false}else if(this==h)v=true});if(k){t=h.parentNode;var E=h.nextSibling;$(k)[g=="Down"?"before":"after"](h);if(E!=h.nextSibling){Ga(new Qa(h,E,t,"Move "+g));I("changed",[h])}}}};this.moveSelectedElements=function(g,h,k){if(g.constructor!=
Array){g/=o;h/=o}k=k||true;for(var v=new La("position"),t=J.length;t--;){var E=J[t];if(E!=null){var w=e.createSVGTransform(),s=V(E);g.constructor==Array?w.setTranslate(g[t],h[t]):w.setTranslate(g,h);s.numberOfItems?s.insertItemBefore(w,0):s.appendItem(w);(w=pb(E))&&v.addSubCommand(w);Oa.requestSelector(E).resize()}}if(!v.isEmpty()){k&&Ga(v);I("changed",J);return v}};this.cloneSelectedElements=function(g,h){for(var k=new La("Clone Elements"),v=J.length,t=0;t<v;++t){var E=J[t];if(E==null)break}v=J.slice(0,
t);this.clearSelection(true);for(t=v.length;t--;){E=v[t]=Z(v[t]);(L||z().getCurrentLayer()).appendChild(E);k.addSubCommand(new Ka(E))}if(!k.isEmpty()){qb(v.reverse());this.moveSelectedElements(g,h,false);Ga(k)}};this.alignSelectedElements=function(g,h){var k=[],v=Number.MAX_VALUE,t=Number.MIN_VALUE,E=Number.MAX_VALUE,w=Number.MIN_VALUE,s=Number.MIN_VALUE,A=Number.MIN_VALUE,F=J.length;if(F){for(var C=0;C<F;++C){if(J[C]==null)break;k[C]=getStrokedBBox([J[C]]);switch(h){case "smallest":if((g=="l"||g==
"c"||g=="r")&&(s==Number.MIN_VALUE||s>k[C].width)||(g=="t"||g=="m"||g=="b")&&(A==Number.MIN_VALUE||A>k[C].height)){v=k[C].x;E=k[C].y;t=k[C].x+k[C].width;w=k[C].y+k[C].height;s=k[C].width;A=k[C].height}break;case "largest":if((g=="l"||g=="c"||g=="r")&&(s==Number.MIN_VALUE||s<k[C].width)||(g=="t"||g=="m"||g=="b")&&(A==Number.MIN_VALUE||A<k[C].height)){v=k[C].x;E=k[C].y;t=k[C].x+k[C].width;w=k[C].y+k[C].height;s=k[C].width;A=k[C].height}break;default:if(k[C].x<v)v=k[C].x;if(k[C].y<E)E=k[C].y;if(k[C].x+
k[C].width>t)t=k[C].x+k[C].width;if(k[C].y+k[C].height>w)w=k[C].y+k[C].height}}if(h=="page"){E=v=0;t=b.contentW;w=b.contentH}s=Array(F);A=Array(F);for(C=0;C<F;++C){if(J[C]==null)break;var D=k[C];s[C]=0;A[C]=0;switch(g){case "l":s[C]=v-D.x;break;case "c":s[C]=(v+t)/2-(D.x+D.width/2);break;case "r":s[C]=t-(D.x+D.width);break;case "t":A[C]=E-D.y;break;case "m":A[C]=(E+w)/2-(D.y+D.height/2);break;case "b":A[C]=w-(D.y+D.height)}}this.moveSelectedElements(s,A)}};this.contentW=Vb().w;this.contentH=Vb().h;
this.updateCanvas=function(g,h){e.setAttribute("width",g);e.setAttribute("height",h);var k=$("#canvasBackground")[0],v=l.getAttribute("x"),t=l.getAttribute("y"),E=g/2-this.contentW*o/2,w=h/2-this.contentH*o/2;ma(l,{width:this.contentW*o,height:this.contentH*o,x:E,y:w,viewBox:"0 0 "+this.contentW+" "+this.contentH});ma(k,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:E,y:w});(k=la("background_image"))&&ma(k,{width:"100%",height:"100%"});Oa.selectorParentGroup.setAttribute("transform",
"translate("+E+","+w+")");return{x:E,y:w,old_x:v,old_y:t,d_x:E-v,d_y:w-t}};this.setBackground=function(g,h){var k=la("canvasBackground"),v=$(k).find("rect")[0],t=la("background_image");v.setAttribute("fill",g);if(h){if(!t){t=d.createElementNS(c,"image");ma(t,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}S(t,h);k.appendChild(t)}else t&&t.parentNode.removeChild(t)};this.cycleElement=function(g){var h=J[0],k=false,v=Ib(L||z().getCurrentLayer());
if(v.length){if(h==null){g=g?v.length-1:0;k=v[g]}else for(var t=v.length;t--;)if(v[t]==h){g=g?t-1:t+1;if(g>=v.length)g=0;else if(g<0)g=v.length-1;k=v[g];break}Qb([k],true);I("selected",J)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:Ga,setGradient:ic,addSvgElementFromJson:da,assignAttributes:ma,BatchCommand:La,call:I,ChangeElementCommand:Wa,copyElem:Z,ffClone:Ma,findDefs:ub,findDuplicateGradient:dc,getElem:la,getId:ta,getIntersectionList:Kb,getMouseTarget:$b,getNextId:M,
getPathBBox:U,getUrlFromAttr:pa,hasMatrixTransform:sa,identifyLayers:Wb,InsertElementCommand:Ka,isIdentity:svgedit.math.isIdentity,logMatrix:tb,matrixMultiply:fa,MoveElementCommand:Qa,preventClickDefault:Zb,recalculateAllSelectedDimensions:Xa,recalculateDimensions:pb,remapElement:xb,RemoveElementCommand:Ua,removeUnusedDefElems:gc,round:Cb,runExtensions:ob,sanitizeSvg:Ia,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:ja,
transformPoint:O,walkTree:svgedit.utilities.walkTree}}};(function(){document.addEventListener("touchstart",touchHandler,true);document.addEventListener("touchmove",touchHandler,true);document.addEventListener("touchend",touchHandler,true);document.addEventListener("touchcancel",touchHandler,true);if(!window.svgEditor)window.svgEditor=function(a){function n(z,o){var L=f.setSvgString(z)!==false;o=o||a.noop;L?o(true):a.alert(e.notification.errorLoadingSVG,function(){o(false)})}var f,c={},m=false,p={lang:"en",iconsize:"m",bkgd_color:"FFF",bkgd_url:"",img_save:"embed"},
null,s=null,E={},w={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(t){if(!(b.spaceKey||t.button===1)){var A=t.button===2;t.altKey&&svgCanvas.cloneSelectedElements(0,0);Lb=l.getScreenCTM().inverse();var F=O(t.pageX,t.pageY,Lb),C=F.x*o,D=F.y*o;t.preventDefault();if(A){Ka="select";yb=F}F=C/o;D=D/o;var G=$b(t);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;C=v=h=F;var H=s=k=D;if(m.gridSnapping){F=Fa(F);D=Fa(D);h=Fa(h);k=Fa(k)}if(G==Oa.selectorParentGroup&&J[0]!=null){G=t.target;
var P=lb(G,"type");if(P=="rotate"){Ka="rotate";current_rotate_mode=lb(G,"dir")}else if(P=="resize"){Ka="resize";mb=lb(G,"dir")}G=J[0]}$a=G.getAttribute("transform");P=V(G);switch(Ka){case "select":Ra=true;mb="none";if(A)Ra=false;if(G!=e){if(J.indexOf(G)==-1){t.shiftKey||bb(true);qb([G]);kb=G;Va.clear()}if(!A)for(A=0;A<J.length;++A)if(J[A]!=null){var Q=V(J[A]);Q.numberOfItems?Q.insertItemBefore(e.createSVGTransform(),0):Q.appendItem(e.createSVGTransform())}}else if(!A){bb();Ka="multiselect";if(Ca==
null)Ca=Oa.getRubberBandBox();v*=o;s*=o;ma(Ca,{x:v,y:s,width:0,height:0,display:"inline"},100)}break;case "zoom":Ra=true;if(Ca==null)Ca=Oa.getRubberBandBox();ma(Ca,{x:C*o,y:C*o,width:0,height:0,display:"inline"},100);break;case "resize":Ra=true;h=F;k=D;E=svgedit.utilities.getBBox($("#selectedBox0")[0]);var aa={};$.each(E,function(ua,wa){aa[ua]=wa/o});E=aa;A=ra(G)?1:0;if(sa(P)){P.insertItemBefore(e.createSVGTransform(),A);P.insertItemBefore(e.createSVGTransform(),A);P.insertItemBefore(e.createSVGTransform(),
A)}else{P.appendItem(e.createSVGTransform());P.appendItem(e.createSVGTransform());P.appendItem(e.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(F=svgedit.browser.isChrome())Q=function(ua){var wa=ua.getAttributeNS(null,"stroke");ua.removeAttributeNS(null,"stroke");setTimeout(function(){ua.setAttributeNS(null,"stroke",wa)},1)};G.style.vectorEffect="non-scaling-stroke";F&&Q(G);D=G.getElementsByTagName("*");C=D.length;for(A=0;A<C;A++){D[A].style.vectorEffect="non-scaling-stroke";
F&&Q(D[A])}}}break;case "fhellipse":case "fhrect":case "fhpath":Ra=true;g=C+","+H+" ";Q=N.stroke_width==0?1:N.stroke_width;da({element:"polyline",curStyles:true,attr:{points:g,id:M(),fill:"none",opacity:N.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});w.minx=C;w.maxx=C;w.miny=H;w.maxy=H;break;case "image":Ra=true;Q=da({element:"image",attr:{x:F,y:D,width:0,height:0,id:M(),opacity:N.opacity/2,style:"pointer-events:inherit"}});S(Q,Ja);Zb(Q);break;case "square":case "rect":Ra=true;
h=F;k=D;da({element:"rect",curStyles:true,attr:{x:F,y:D,width:0,height:0,id:M(),opacity:N.opacity/2}});break;case "line":Ra=true;Q=N.stroke_width==0?1:N.stroke_width;da({element:"line",curStyles:true,attr:{x1:F,y1:D,x2:F,y2:D,id:M(),stroke:N.stroke,"stroke-width":Q,"stroke-dasharray":N.stroke_dasharray,"stroke-linejoin":N.stroke_linejoin,"stroke-linecap":N.stroke_linecap,"stroke-opacity":N.stroke_opacity,fill:"none",opacity:N.opacity/2,style:"pointer-events:none"}});break;case "circle":Ra=true;da({element:"circle",
curStyles:true,attr:{cx:F,cy:D,r:0,id:M(),opacity:N.opacity/2}});break;case "ellipse":Ra=true;da({element:"ellipse",curStyles:true,attr:{cx:F,cy:D,rx:0,ry:0,id:M(),opacity:N.opacity/2}});break;case "text":Ra=true;da({element:"text",curStyles:true,attr:{x:F,y:D,id:M(),fill:cb.fill,"stroke-width":cb.stroke_width,"font-size":cb.font_size,"font-family":cb.font_family,"text-anchor":"left","xml:space":"preserve",opacity:N.opacity}});break;case "path":case "pathedit":h*=o;k*=o;Va.mouseDown(t,G,h,k);Ra=true;
break;case "textedit":h*=o;k*=o;rb.mouseDown(t,G,h,k);Ra=true;break;case "rotate":Ra=true;b.undoMgr.beginUndoableChange("transform",J);document.getElementById("workarea").className="rotate"}Q=ob("mouseDown",{event:t,start_x:h,start_y:k,selectedElements:J},true);$.each(Q,function(ua,wa){if(wa&&wa.started)Ra=true});if(Ka)document.getElementById("workarea").className=Ka=="resize"?t.target.style.cursor:Ka}}).mousemove(function(t){if(Ra)if(!(t.button===1||b.spaceKey)){var A=J[0],F=O(t.pageX,t.pageY,Lb),
C=F.x*o;F=F.y*o;var D=la(ta()),G=x=C/o,H=y=F/o;if(m.gridSnapping){x=Fa(x);y=Fa(y)}t.preventDefault();switch(Ka){case "select":if(J[0]!==null){G=x-h;var P=y-k;if(m.gridSnapping){G=Fa(G);P=Fa(P)}if(t.shiftKey){var Q=ca(h,k,x,y);x=Q.x;y=Q.y}if(G!=0||P!=0){Q=J.length;for(H=0;H<Q;++H){A=J[H];if(A==null)break;var aa=e.createSVGTransform();D=V(A);aa.setTranslate(G,P);D.numberOfItems?D.replaceItem(aa,0):D.appendItem(aa);Oa.requestSelector(A).resize()}I("transition",J)}}break;case "multiselect":G*=o;H*=o;
ma(Ca,{x:Math.min(v,G),y:Math.min(s,H),width:Math.abs(G-v),height:Math.abs(H-s)},100);D=[];G=[];aa=Kb();Q=J.length;for(H=0;H<Q;++H){P=aa.indexOf(J[H]);if(P==-1)D.push(J[H]);else aa[P]=null}Q=aa.length;for(H=0;H<Q;++H)aa[H]&&G.push(aa[H]);D.length>0&&b.removeFromSelection(D);G.length>0&&qb(G);break;case "resize":D=V(A);G=(Q=sa(D))?E:svgedit.utilities.getBBox(A);H=G.x;aa=G.y;var ua=G.width,wa=G.height;G=x-h;P=y-k;if(m.gridSnapping){G=Fa(G);P=Fa(P);wa=Fa(wa);ua=Fa(ua)}var ha=ra(A);if(ha){var ka=Math.sqrt(G*
G+P*P);P=Math.atan2(P,G)-ha*Math.PI/180;G=ka*Math.cos(P);P=ka*Math.sin(P)}if(mb.indexOf("n")==-1&&mb.indexOf("s")==-1)P=0;if(mb.indexOf("e")==-1&&mb.indexOf("w")==-1)G=0;var oa=ka=0,xa=wa?(wa+P)/wa:1,eb=ua?(ua+G)/ua:1;if(mb.indexOf("n")>=0){xa=wa?(wa-P)/wa:1;oa=wa}if(mb.indexOf("w")>=0){eb=ua?(ua-G)/ua:1;ka=ua}G=e.createSVGTransform();P=e.createSVGTransform();ua=e.createSVGTransform();if(m.gridSnapping){H=Fa(H);ka=Fa(ka);aa=Fa(aa);oa=Fa(oa)}G.setTranslate(-(H+ka),-(aa+oa));if(t.shiftKey)if(eb==1)eb=
xa;else xa=eb;P.setScale(eb,xa);ua.setTranslate(H+ka,aa+oa);if(Q){Q=ha?1:0;D.replaceItem(G,2+Q);D.replaceItem(P,1+Q);D.replaceItem(ua,0+Q)}else{Q=D.numberOfItems;D.replaceItem(ua,Q-3);D.replaceItem(P,Q-2);D.replaceItem(G,Q-1)}Oa.requestSelector(A).resize();I("transition",J);break;case "zoom":G*=o;H*=o;ma(Ca,{x:Math.min(v*o,G),y:Math.min(s*o,H),width:Math.abs(G-v*o),height:Math.abs(H-s*o)},100);break;case "text":ma(D,{x:x,y:y},1E3);break;case "line":G=null;window.opera||e.suspendRedraw(1E3);if(m.gridSnapping){x=
Fa(x);y=Fa(y)}H=x;Q=y;if(t.shiftKey){Q=ca(h,k,H,Q);H=Q.x;Q=Q.y}D.setAttributeNS(null,"x2",H);D.setAttributeNS(null,"y2",Q);window.opera||e.unsuspendRedraw(G);break;case "foreignObject":case "square":case "rect":case "image":G=Math.abs(x-h);Q=Math.abs(y-k);if(Ka=="square"||t.shiftKey){G=Q=Math.max(G,Q);H=h<x?h:h-G;aa=k<y?k:k-Q}else{H=Math.min(h,x);aa=Math.min(k,y)}if(m.gridSnapping){G=Fa(G);Q=Fa(Q);H=Fa(H);aa=Fa(aa)}ma(D,{width:G,height:Q,x:H,y:aa},1E3);break;case "circle":G=$(D).attr(["cx","cy"]);
Q=G.cx;H=G.cy;G=Math.sqrt((x-Q)*(x-Q)+(y-H)*(y-H));if(m.gridSnapping)G=Fa(G);D.setAttributeNS(null,"r",G);break;case "ellipse":G=$(D).attr(["cx","cy"]);Q=G.cx;H=G.cy;G=null;window.opera||e.suspendRedraw(1E3);if(m.gridSnapping){x=Fa(x);Q=Fa(Q);y=Fa(y);H=Fa(H)}D.setAttributeNS(null,"rx",Math.abs(x-Q));D.setAttributeNS(null,"ry",Math.abs(t.shiftKey?x-Q:y-H));window.opera||e.unsuspendRedraw(G);break;case "fhellipse":case "fhrect":w.minx=Math.min(G,w.minx);w.maxx=Math.max(G,w.maxx);w.miny=Math.min(H,w.miny);
w.maxy=Math.max(H,w.maxy);case "fhpath":g+=+G+","+H+" ";D.setAttributeNS(null,"points",g);break;case "path":case "pathedit":x*=o;y*=o;if(m.gridSnapping){x=Fa(x);y=Fa(y);h=Fa(h);k=Fa(k)}if(t.shiftKey){if(Q=svgedit.path.path){D=Q.dragging?Q.dragging[0]:h;Q=Q.dragging?Q.dragging[1]:k}else{D=h;Q=k}Q=ca(D,Q,x,y);x=Q.x;y=Q.y}if(Ca&&Ca.getAttribute("display")!=="none"){G*=o;H*=o;ma(Ca,{x:Math.min(v*o,G),y:Math.min(s*o,H),width:Math.abs(G-v*o),height:Math.abs(H-s*o)},100)}Va.mouseMove(t,x,y);break;case "textedit":x*=
o;y*=o;rb.mouseMove(C,F);break;case "rotate":G=svgedit.utilities.getBBox(A);Q=G.x+G.width/2;H=G.y+G.height/2;D=ea(A);D=O(Q,H,D);Q=D.x;H=D.y;D=G.x;aa=G.y;if(current_rotate_mode=="nw")D=G.x+G.width;if(current_rotate_mode=="se")aa=G.y+G.height;if(current_rotate_mode=="sw"){D=G.x+G.width;aa=G.y+G.height}compensation_angle=(Math.atan2(H-aa,Q-D)*(180/Math.PI)-90)%360;ha=(Math.atan2(H-y,Q-x)*(180/Math.PI)-90)%360;ha+=compensation_angle;if(m.gridSnapping)ha=Fa(ha);if(t.shiftKey)ha=Math.round(ha/45)*45;b.setRotationAngle(ha<
-180?360+ha:ha,true);I("transition",J)}ob("mouseMove",{event:t,mouse_x:C,mouse_y:F,selected:A})}}).click(function(t){t.preventDefault();return false}).dblclick(function(t){var A=t.target.parentNode;if(A!==L){var F=$b(t),C=F.tagName;if(C==="text"&&Ka!=="textedit"){t=O(t.pageX,t.pageY,Lb);rb.select(F,t.x,t.y)}if((C==="g"||C==="a")&&ra(F)){fc(F);F=J[0];bb(true)}L&&ac();A.tagName!=="g"&&A.tagName!=="a"||A===z().getCurrentLayer()||F===Oa.selectorParentGroup||nc(F)}}).mouseup(function(t){if(t.button!==
2){var A=kb;kb=null;if(Ra){var F=O(t.pageX,t.pageY,Lb),C=F.x*o;F=F.y*o;var D=C/o,G=F/o,H=la(ta()),P=false;Ra=false;switch(Ka){case "resize":case "multiselect":if(Ca!=null){Ca.setAttribute("display","none");wb=[]}Ka="select";case "select":if(J[0]!=null){if(J[1]==null){C=J[0];switch(C.tagName){case "g":case "use":case "image":case "foreignObject":break;default:jb.fill=C.getAttribute("fill");jb.fill_opacity=C.getAttribute("fill-opacity");jb.stroke=C.getAttribute("stroke");jb.stroke_opacity=C.getAttribute("stroke-opacity");
jb.stroke_width=C.getAttribute("stroke-width");jb.stroke_dasharray=C.getAttribute("stroke-dasharray");jb.stroke_linejoin=C.getAttribute("stroke-linejoin");jb.stroke_linecap=C.getAttribute("stroke-linecap")}if(C.tagName=="text"){cb.font_size=C.getAttribute("font-size");cb.font_family=C.getAttribute("font-family")}Oa.requestSelector(C).showGrips(true)}Xa();if(D!=v||G!=s){t=J.length;for(C=0;C<t;++C){if(J[C]==null)break;J[C].firstChild||Oa.requestSelector(J[C]).resize()}}else{C=t.target;if(J[0].nodeName===
"path"&&J[1]==null)Va.select(J[0]);else t.shiftKey&&A!=C&&b.removeFromSelection([C])}if(svgedit.browser.supportsNonScalingStroke())if(t=J[0]){t.removeAttribute("style");svgedit.utilities.walkTree(t,function(ua){ua.removeAttribute("style")})}}return;case "zoom":Ca!=null&&Ca.setAttribute("display","none");I("zoomed",{x:Math.min(v,D),y:Math.min(s,G),width:Math.abs(D-v),height:Math.abs(G-s),factor:t.altKey?0.5:2});return;case "fhpath":A=H.getAttribute("points");D=A.indexOf(",");if(P=D>=0?A.indexOf(",",
D+1)>=0:A.indexOf(" ",A.indexOf(" ")+1)>=0)H=Va.smoothPolylineIntoPath(H);break;case "line":A=$(H).attr(["x1","x2","y1","y2"]);P=A.x1!=A.x2||A.y1!=A.y2;break;case "foreignObject":case "square":case "rect":case "image":A=$(H).attr(["width","height"]);P=A.width!=0||A.height!=0||Ka==="image";break;case "circle":P=H.getAttribute("r")!=0;break;case "ellipse":A=$(H).attr(["rx","ry"]);P=A.rx!=null||A.ry!=null;break;case "fhellipse":if(w.maxx-w.minx>0&&w.maxy-w.miny>0){H=da({element:"ellipse",curStyles:true,
attr:{cx:(w.minx+w.maxx)/2,cy:(w.miny+w.maxy)/2,rx:(w.maxx-w.minx)/2,ry:(w.maxy-w.miny)/2,id:ta()}});I("changed",[H]);P=true}break;case "fhrect":if(w.maxx-w.minx>0&&w.maxy-w.miny>0){H=da({element:"rect",curStyles:true,attr:{x:w.minx,y:w.miny,width:w.maxx-w.minx,height:w.maxy-w.miny,id:ta()}});I("changed",[H]);P=true}break;case "text":P=true;Qb([H]);rb.start(H);break;case "path":H=null;Ra=true;A=Va.mouseUp(t,H,C,F);H=A.element;P=A.keep;break;case "pathedit":P=true;H=null;Va.mouseUp(t);break;case "textedit":P=
false;H=null;rb.mouseUp(t,C,F);break;case "rotate":P=true;H=null;Ka="select";A=b.undoMgr.finishUndoableChange();A.isEmpty()||Ga(A);Xa();I("changed",J)}C=ob("mouseUp",{event:t,mouse_x:C,mouse_y:F},true);$.each(C,function(ua,wa){if(wa){P=wa.keep||P;H=wa.element;Ra=wa.started||Ra}});if(!P&&H!=null){z().releaseId(ta());H.parentNode.removeChild(H);H=null;for(C=t.target;C.parentNode.parentNode.tagName=="g";)C=C.parentNode;if((Ka!="path"||!drawn_path)&&C.parentNode.id!="selectorParentGroup"&&C.id!="svgcanvas"&&
C.id!="svgroot"){b.setMode("select");Qb([C],true)}}else if(H!=null){b.addedNew=true;t=0.2;var Q;if(false.beginElement&&H.getAttribute("opacity")!=N.opacity){Q=$(false).clone().attr({to:N.opacity,dur:t}).appendTo(H);try{Q[0].beginElement()}catch(aa){}}else t=0;setTimeout(function(){Q&&Q.remove();H.setAttribute("opacity",N.opacity);H.setAttribute("style","pointer-events:inherit");Y(H);if(Ka==="path")Va.toEditMode(H);else m.selectNew&&Qb([H],true);Ga(new La(H));I("changed",[H])},t*1E3)}$a=null}}});$(a).bind("mousewheel DOMMouseScroll",
function(t){if(t.shiftKey){t.preventDefault();Lb=l.getScreenCTM().inverse();var A=O(t.pageX,t.pageY,Lb);A={x:A.x,y:A.y,width:0,height:0};if(t.wheelDelta)if(t.wheelDelta>=120)A.factor=2;else{if(t.wheelDelta<=-120)A.factor=0.5}else if(t.detail)if(t.detail>0)A.factor=0.5;else if(t.detail<0)A.factor=2;A.factor&&I("zoomed",A)}})})();var Zb=function(g){$(g).click(function(h){h.preventDefault()})},rb=b.textActions=function(){function g(ha){var ka=F.value==="";$(F).focus();if(!arguments.length)if(ka)ha=0;
else{if(F.selectionEnd!==F.selectionStart)return;ha=F.selectionEnd}var oa;oa=H[ha];ka||F.setSelectionRange(ha,ha);C=la("text_cursor");if(!C){C=document.createElementNS(c,"line");ma(C,{id:"text_cursor",stroke:"#333","stroke-width":1});C=la("selectorParentGroup").appendChild(C)}G||(G=setInterval(function(){var xa=C.getAttribute("display")==="none";C.setAttribute("display",xa?"inline":"none")},600));ka=E(oa.x,P.y);oa=E(oa.x,P.y+P.height);ma(C,{x1:ka.x,y1:ka.y,x2:oa.x,y2:oa.y,visibility:"visible",display:"inline"});
D&&D.setAttribute("d","")}function h(ha,ka,oa){if(ha===ka)g(ka);else{oa||F.setSelectionRange(ha,ka);D=la("text_selectblock");if(!D){D=document.createElementNS(c,"path");ma(D,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});la("selectorParentGroup").appendChild(D)}ha=H[ha];var xa=H[ka];C.setAttribute("visibility","hidden");ka=E(ha.x,P.y);oa=E(ha.x+(xa.x-ha.x),P.y);var eb=E(ha.x,P.y+P.height);ha=E(ha.x+(xa.x-ha.x),P.y+P.height);ma(D,{d:"M"+ka.x+","+ka.y+" L"+oa.x+","+oa.y+
" "+ha.x+","+ha.y+" "+eb.x+","+eb.y+"z",display:"inline"})}}function k(ha,ka){var oa=e.createSVGPoint();oa.x=ha;oa.y=ka;if(H.length==1)return 0;oa=A.getCharNumAtPosition(oa);if(oa<0){oa=H.length-2;if(ha<=H[0].x)oa=0}else if(oa>=H.length-2)oa=H.length-2;var xa=H[oa];ha>xa.x+xa.width/2&&oa++;return oa}function v(ha,ka,oa){var xa=F.selectionStart;ha=k(ha,ka);h(Math.min(xa,ha),Math.max(xa,ha),!oa)}function s(ha,ka){var oa={x:ha,y:ka};oa.x/=o;oa.y/=o;if(Q){var xa=O(oa.x,oa.y,Q.inverse());oa.x=xa.x;oa.y=
xa.y}return oa}function E(ha,ka){var oa={x:ha,y:ka};if(Q){var xa=O(oa.x,oa.y,Q);oa.x=xa.x;oa.y=xa.y}oa.x*=o;oa.y*=o;return oa}function w(ha){h(0,A.textContent.length);$(this).unbind(ha)}function t(ha){if(wa&&A){var ka=O(ha.pageX,ha.pageY,Lb);ka=s(ka.x*o,ka.y*o);ka=k(ka.x,ka.y);var oa=A.textContent,xa=oa.substr(0,ka).replace(/[a-z0-9]+$/i,"").length;oa=oa.substr(ka).match(/^[a-z0-9]+/i);h(xa,(oa?oa[0].length:0)+ka);$(ha.target).click(w);setTimeout(function(){$(ha.target).unbind("click",w)},300)}}var A,
F,C,D,G,H=[],P,Q,aa,ua,wa;return{select:function(ha,ka,oa){A=ha;rb.toEditMode(ka,oa)},start:function(ha){A=ha;rb.toEditMode()},mouseDown:function(ha,ka,oa,xa){ha=s(oa,xa);F.focus();g(k(ha.x,ha.y));aa=oa;ua=xa},mouseMove:function(ha,ka){var oa=s(ha,ka);v(oa.x,oa.y)},mouseUp:function(ha,ka,oa){var xa=s(ka,oa);v(xa.x,xa.y,true);ha.target!==A&&ka<aa+2&&ka>aa-2&&oa<ua+2&&oa>ua-2&&rb.toSelectMode(true)},setCursor:g,toEditMode:function(ha,ka){wa=false;Ka="textedit";Oa.requestSelector(A).showGrips(false);
Oa.requestSelector(A);rb.init();$(A).css("cursor","text");if(arguments.length){var oa=s(ha,ka);g(k(oa.x,oa.y))}else g();setTimeout(function(){wa=true},300)},toSelectMode:function(ha){Ka="select";clearInterval(G);G=null;D&&$(D).attr("display","none");C&&$(C).attr("visibility","hidden");$(A).css("cursor","move");if(ha){bb();$(A).css("cursor","move");I("selected",[A]);qb([A],true)}A&&!A.textContent.length&&b.deleteSelectedElements();$(F).blur();A=false},setInputElem:function(ha){F=ha},clear:function(){Ka==
"textedit"&&rb.toSelectMode()},init:function(){if(A){if(!A.parentNode){A=J[0];Oa.requestSelector(A).showGrips(false)}var ha=A.textContent.length,ka=A.getAttribute("transform");P=svgedit.utilities.getBBox(A);Q=ka?ea(A):null;H=Array(ha);F.focus();$(A).unbind("dblclick",t).dblclick(t);if(!ha)var oa={x:P.x+P.width/2,width:0};for(ka=0;ka<ha;ka++){var xa=A.getStartPositionOfChar(ka);oa=A.getEndPositionOfChar(ka);if(!svgedit.browser.supportsGoodTextCharPos()){var eb=b.contentW*o;xa.x-=eb;oa.x-=eb;xa.x/=
o;oa.x/=o}H[ka]={x:xa.x,y:P.y,width:oa.x-xa.x,height:P.height}}H.push({x:oa.x,width:0});h(F.selectionStart,F.selectionEnd,true)}}}}(),Va=b.pathActions=function(){var g=false,h,k,v;svgedit.path.Path.prototype.endChanges=function(w){if(svgedit.browser.isWebkit()){var t=this.elem;t.setAttribute("d",Va.convertPath(t))}w=new Wa(this.elem,{d:this.last_d},w);Ga(w);I("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(w){$.isArray(w)||(w=[w]);for(var t=0;t<w.length;t++){var A=w[t],
F=this.segs[A];F.ptgrip&&this.selected_pts.indexOf(A)==-1&&A>=0&&this.selected_pts.push(A)}this.selected_pts.sort();t=this.selected_pts.length;for(w=Array(t);t--;){F=this.segs[this.selected_pts[t]];F.select(true);w[t]=F.ptgrip}Va.canDeleteNodes=true;Va.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);I("selected",w)};var s=h=null,E=false;return{mouseDown:function(w,t,A,F){if(Ka==="path"){mouse_x=A;mouse_y=F;F=mouse_x/o;t=mouse_y/o;A=la("path_stretch_line");k=[F,t];if(m.gridSnapping){F=Fa(F);
t=Fa(t);mouse_x=Fa(mouse_x);mouse_y=Fa(mouse_y)}if(!A){A=document.createElementNS(c,"path");ma(A,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});A=la("selectorParentGroup").appendChild(A)}A.setAttribute("display","inline");var C=null;if(s){C=s.pathSegList;for(var D=C.numberOfItems,G=6/o,H=false;D;){D--;var P=C.getItem(D),Q=P.x;P=P.y;if(F>=Q-G&&F<=Q+G&&t>=P-G&&t<=P+G){H=true;break}}G=ta();svgedit.path.removePath_(G);G=la(G);Q=C.numberOfItems;if(H){if(D<=1&&Q>=2){F=C.getItem(0).x;
t=C.getItem(0).y;w=A.pathSegList.getItem(1);w=w.pathSegType===4?s.createSVGPathSegLinetoAbs(F,t):s.createSVGPathSegCurvetoCubicAbs(F,t,w.x1/o,w.y1/o,F,t);F=s.createSVGPathSegClosePath();C.appendItem(w);C.appendItem(F)}else if(Q<3)return C=false;$(A).remove();element=G;s=null;Ra=false;if(g){svgedit.path.path.matrix&&xb(G,{},svgedit.path.path.matrix.inverse());A=G.getAttribute("d");w=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",w+A);$(G).remove();svgedit.path.path.matrix&&
svgedit.path.recalcRotatedPath();svgedit.path.path.init();Va.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,$b(w))){console.log("Clicked outside canvas");return false}C=s.pathSegList.numberOfItems;D=s.pathSegList.getItem(C-1);G=D.x;D=D.y;if(w.shiftKey){w=ca(G,D,F,t);F=w.x;t=w.y}w=A.pathSegList.getItem(1);w=w.pathSegType===4?s.createSVGPathSegLinetoAbs(Cb(F),Cb(t)):s.createSVGPathSegCurvetoCubicAbs(Cb(F),Cb(t),w.x1/o,w.y1/o,w.x2/o,w.y2/o);s.pathSegList.appendItem(w);
F*=o;t*=o;A.setAttribute("d",["M",F,t,F,t].join(" "));A=C;if(g)A+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(A,F,t)}}else{d_attr="M"+F+","+t+" ";s=da({element:"path",curStyles:true,attr:{d:d_attr,id:M(),opacity:N.opacity/2}});A.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));A=g?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(A,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();G=w.target.id;if(G.substr(0,14)=="pathpointgrip_"){t=svgedit.path.path.cur_pt=
parseInt(G.substr(14));svgedit.path.path.dragging=[A,F];C=svgedit.path.path.segs[t];if(w.shiftKey)C.selected?svgedit.path.path.removePtFromSelection(t):svgedit.path.path.addPtsToSelection(t);else{if(svgedit.path.path.selected_pts.length<=1||!C.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(t)}}else if(G.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[A,F];w=G.split("_")[1].split("c");t=w[0]-0;svgedit.path.path.selectPt(t,w[1]-0)}if(!svgedit.path.path.dragging){if(Ca==
null)Ca=Oa.getRubberBandBox();ma(Ca,{x:A*o,y:F*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(w,t,A){E=true;if(Ka==="path"){if(s){var F=s.pathSegList;w=F.numberOfItems-1;if(k){var C=svgedit.path.addCtrlGrip("1c1"),D=svgedit.path.addCtrlGrip("0c2");D.getAttribute("cx");D.getAttribute("cy");C.setAttribute("cx",t);C.setAttribute("cy",A);C.setAttribute("display","inline");C=k[0];var G=k[1];F.getItem(w);var H=C+(C-t/o),P=G+(G-A/o);D.setAttribute("cx",H*o);D.setAttribute("cy",P*o);D.setAttribute("display",
"inline");D=svgedit.path.getCtrlLine(1);var Q=svgedit.path.getCtrlLine(2);ma(D,{x1:t,y1:A,x2:C*o,y2:G*o,display:"inline"});ma(Q,{x1:H*o,y1:P*o,x2:C*o,y2:G*o,display:"inline"});if(w===0)v=[t,A];else{F=F.getItem(w-1);t=F.x;A=F.y;if(F.pathSegType===6){t+=t-F.x2;A+=A-F.y2}else if(v){t=v[0]/o;A=v[1]/o}svgedit.path.replacePathSeg(6,w,[C,G,t,A,H,P],s)}}else if(C=la("path_stretch_line")){w=F.getItem(w);if(w.pathSegType===6)svgedit.path.replacePathSeg(6,1,[t,A,(w.x+(w.x-w.x2))*o,(w.y+(w.y-w.y2))*o,t,A],C);
else v?svgedit.path.replacePathSeg(6,1,[t,A,v[0],v[1],t,A],C):svgedit.path.replacePathSeg(4,1,[t,A],C)}}}else if(svgedit.path.path.dragging){C=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);G=svgedit.path.getPointFromGrip({x:t,y:A},svgedit.path.path);w=G.x-C.x;C=G.y-C.y;svgedit.path.path.dragging=[t,A];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(w,C):svgedit.path.path.movePts(w,C)}else{svgedit.path.path.selected_pts=[];
svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var aa=Ca.getBBox(),ua=svgedit.path.getGripPt(this);aa=svgedit.math.rectsIntersect(aa,{x:ua.x,y:ua.y,width:0,height:0});this.select(aa);aa&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(w,t){if(Ka==="path"){k=null;if(!s){t=la(ta());Ra=false;v=null}return{keep:true,element:t}}if(svgedit.path.path.dragging){var A=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)");!w.shiftKey&&!E&&svgedit.path.path.selectPt(A)}else if(Ca&&Ca.getAttribute("display")!="none"){Ca.setAttribute("display","none");Ca.getAttribute("width")<=2&&Ca.getAttribute("height")<=2&&Va.toSelectMode(w.target)}else Va.toSelectMode(w.target);E=false},toEditMode:function(w){svgedit.path.path=svgedit.path.getPath_(w);Ka="pathedit";bb();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);
g=false},toSelectMode:function(w){var t=w==svgedit.path.path.elem;Ka="select";svgedit.path.path.show(false);h=false;bb();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(t){I("selected",[w]);qb([w],true)}},addSubPath:function(w){if(w){Ka="path";g=true}else{Va.clear(true);Va.toEditMode(svgedit.path.path.elem)}},select:function(w){if(h===w){Va.toEditMode(w);Ka="pathedit"}else h=w},reorient:function(){var w=J[0];if(w)if(ra(w)!=0){var t=new Ma("Reorient path"),A={d:w.getAttribute("d"),transform:w.getAttribute("transform")};
t.addSubCommand(new Wa(w,A));bb();this.resetOrientation(w);Ga(t);svgedit.path.getPath_(w).show(false).matrix=null;this.clear();qb([w],true);I("changed",J)}},clear:function(){h=null;if(s){var w=la(ta());$(la("path_stretch_line")).remove();$(w).remove();$(la("pathpointgrip_container")).find("*").attr("display","none");s=v=null;Ra=false}else Ka=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(w){if(w==null||w.nodeName!="path")return false;
var t=V(w),A=ja(t).matrix;t.clear();w.removeAttribute("transform");t=w.pathSegList;for(var F=t.numberOfItems,C=0;C<F;++C){var D=t.getItem(C),G=D.pathSegType;if(G!=1){var H=[];$.each(["",1,2],function(P,Q){var aa=D["x"+Q],ua=D["y"+Q];if(aa!==undefined&&ua!==undefined){aa=O(aa,ua,A);H.splice(H.length,0,aa.x,aa.y)}});svgedit.path.replacePathSeg(G,C,H,w)}}f(w,A)},zoomChange:function(){Ka=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var w=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?
svgedit.path.path.selected_pts[0]:1];return{x:w.item.x,y:w.item.y,type:w.type}},linkControlPoints:function(w){svgedit.path.setLinkControlPoints(w)},clonePathNode:function(){svgedit.path.path.storeD();for(var w=svgedit.path.path.selected_pts,t=w.length,A=[];t--;){var F=w[t];svgedit.path.path.addSeg(F);A.push(F+t);A.push(F+t+1)}svgedit.path.path.init().addPtsToSelection(A);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var w=svgedit.path.path.selected_pts;if(w.length===
1){var t=svgedit.path.path.elem,A=t.pathSegList,F=w[0],C=null,D=null;svgedit.path.path.eachSeg(function(Q){if(this.type===2&&Q<=F)D=this.item;if(Q<=F)return true;if(this.type===2){C=Q;return false}else if(this.type===1)return C=false});if(C==null)C=svgedit.path.path.segs.length-1;if(C!==false){var G=t.createSVGPathSegLinetoAbs(D.x,D.y),H=t.createSVGPathSegClosePath();if(C==svgedit.path.path.segs.length-1){A.appendItem(G);A.appendItem(H)}else{svgedit.path.insertItemBefore(t,H,C);svgedit.path.insertItemBefore(t,
G,C)}svgedit.path.path.init().selectPt(C+1)}else if(svgedit.path.path.segs[F].mate){A.removeItem(F);A.removeItem(F);svgedit.path.path.init().selectPt(F-1)}else{for(w=0;w<A.numberOfItems;w++){var P=A.getItem(w);if(P.pathSegType===2)G=w;else if(w===F)A.removeItem(G);else if(P.pathSegType===1&&F<w){H=w-1;A.removeItem(w);break}}for(w=F-G-1;w--;)svgedit.path.insertItemBefore(t,A.getItem(G),H);t=A.getItem(G);svgedit.path.replacePathSeg(2,G,[t.x,t.y]);w=F;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Va.canDeleteNodes){svgedit.path.path.storeD();
for(var w=svgedit.path.path.selected_pts,t=w.length;t--;)svgedit.path.path.deleteSeg(w[t]);var A=function(){var F=svgedit.path.path.elem.pathSegList,C=F.numberOfItems,D=function(P,Q){for(;Q--;)F.removeItem(P)};if(C<=1)return true;for(;C--;){var G=F.getItem(C);if(G.pathSegType===1){G=F.getItem(C-1);var H=F.getItem(C-2);if(G.pathSegType===2){D(C-1,2);A();break}else if(H.pathSegType===2){D(C-2,3);A();break}}else if(G.pathSegType===2)if(C>0){G=F.getItem(C-1).pathSegType;if(G===2){D(C-1,1);A();break}else if(G===
1&&F.numberOfItems-1===C){D(C,1);A();break}}}return false};A();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Va.toSelectMode(svgedit.path.path.elem);b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){w=$(svgedit.path.path.elem);w.attr("d",w.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(w){var t=w.points,A=t.numberOfItems;if(A>=4){var F=t.getItem(0),C=null;w=[];w.push(["M",F.x,",",
F.y," C"].join(""));for(var D=1;D<=A-4;D+=3){var G=t.getItem(D),H=t.getItem(D+1),P=t.getItem(D+2);if(C)if((F=svgedit.path.smoothControlPoints(C,G,F))&&F.length==2){G=w[w.length-1].split(",");G[2]=F[0].x;G[3]=F[0].y;w[w.length-1]=G.join(",");G=F[1]}w.push([G.x,G.y,H.x,H.y,P.x,P.y].join(","));F=P;C=H}for(w.push("L");D<A;++D){H=t.getItem(D);w.push([H.x,H.y].join(","))}w=w.join(" ");w=da({element:"path",curStyles:true,attr:{id:ta(),d:w,fill:"none"}})}return w},setSegType:function(w){svgedit.path.path.setSegType(w)},
moveNode:function(w,t){var A=svgedit.path.path.selected_pts;if(A.length){svgedit.path.path.storeD();A=svgedit.path.path.segs[A[0]];var F={x:0,y:0};F[w]=t-A.item[w];A.move(F.x,F.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(w){for(var t=w.pathSegList,A=t.numberOfItems,F,C=0;C<A;++C){var D=t.getItem(C);if(D.pathSegType===2)F=D;if(D.pathSegType===1){D=t.getItem(C-1);if(D.x!=F.x||D.y!=F.y){t=w.createSVGPathSegLinetoAbs(F.x,F.y);svgedit.path.insertItemBefore(w,t,C);Va.fixEnd(w);
break}}}svgedit.browser.isWebkit()&&w.setAttribute("d",Va.convertPath(w))},convertPath:function(w,t){for(var A=w.pathSegList,F=A.numberOfItems,C=0,D=0,G="",H=null,P=0;P<F;++P){var Q=A.getItem(P),aa=Q.x||0,ua=Q.y||0,wa=Q.x1||0,ha=Q.y1||0,ka=Q.x2||0,oa=Q.y2||0,xa=Q.pathSegType,eb=db[xa]["to"+(t?"Lower":"Upper")+"Case"](),Db=function(Pb,Jb,Ob){Jb=Jb?" "+Jb.join(" "):"";Ob=Ob?" "+svgedit.units.shortFloat(Ob):"";$.each(Pb,function(bc,kc){Pb[bc]=svgedit.units.shortFloat(kc)});G+=eb+Pb.join(" ")+Jb+Ob};
switch(xa){case 1:G+="z";break;case 12:aa-=C;case 13:if(t){C+=aa;eb="l"}else{aa+=C;C=aa;eb="L"}Db([[aa,D]]);break;case 14:ua-=D;case 15:if(t){D+=ua;eb="l"}else{ua+=D;D=ua;eb="L"}Db([[C,ua]]);break;case 2:case 4:case 18:aa-=C;ua-=D;case 5:case 3:if(H&&A.getItem(P-1).pathSegType===1&&!t){C=H[0];D=H[1]}case 19:if(t){C+=aa;D+=ua}else{aa+=C;ua+=D;C=aa;D=ua}if(xa===3)H=[C,D];Db([[aa,ua]]);break;case 6:aa-=C;wa-=C;ka-=C;ua-=D;ha-=D;oa-=D;case 7:if(t){C+=aa;D+=ua}else{aa+=C;wa+=C;ka+=C;ua+=D;ha+=D;oa+=D;
C=aa;D=ua}Db([[wa,ha],[ka,oa],[aa,ua]]);break;case 8:aa-=C;wa-=C;ua-=D;ha-=D;case 9:if(t){C+=aa;D+=ua}else{aa+=C;wa+=C;ua+=D;ha+=D;C=aa;D=ua}Db([[wa,ha],[aa,ua]]);break;case 10:aa-=C;ua-=D;case 11:if(t){C+=aa;D+=ua}else{aa+=C;ua+=D;C=aa;D=ua}Db([[Q.r1,Q.r2]],[Q.angle,Q.largeArcFlag?1:0,Q.sweepFlag?1:0],[aa,ua]);break;case 16:aa-=C;ka-=C;ua-=D;oa-=D;case 17:if(t){C+=aa;D+=ua}else{aa+=C;ka+=C;ua+=D;oa+=D;C=aa;D=ua}Db([[ka,oa],[aa,ua]])}}return G}}}(),gc=this.removeUnusedDefElems=function(){var g=l.getElementsByTagNameNS(c,
"defs");if(!g||!g.length)return 0;for(var h=[],k=0,v=["fill","stroke","filter","marker-start","marker-mid","marker-end"],s=v.length,E=l.getElementsByTagNameNS(c,"*"),w=E.length,t=0;t<w;t++){for(var A=E[t],F=0;F<s;F++){var C=pa(A.getAttribute(v[F]));C&&h.push(C.substr(1))}(A=ba(A))&&A.indexOf("#")===0&&h.push(A.substr(1))}g=$(g).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(t=g.length;t--;){v=g[t];s=v.id;if(h.indexOf(s)<0){Bb[s]=v;v.parentNode.removeChild(v);
k++}}return k};this.svgCanvasToString=function(){for(;gc()>0;);Va.clear(true);$.each(l.childNodes,function(k,v){k&&v.nodeType===8&&v.data.indexOf("Created with")>=0&&l.insertBefore(v,l.firstChild)});if(L){ac();Qb([L])}var g=[];$(l).find("g:data(gsvg)").each(function(){for(var k=this.attributes,v=k.length,s=0;s<v;s++)if(k[s].nodeName=="id"||k[s].nodeName=="style")v--;if(v<=0){k=this.firstChild;g.push(k);$(this).replaceWith(k)}});var h=this.svgToString(l,0);g.length&&$(g).each(function(){na(this)});
return h};this.svgToString=function(g,h){var k=[],v=svgedit.utilities.toXml,s=m.baseUnit,E=RegExp("^-?[\\d\\.]+"+s+"$");if(g){Y(g);var w=g.attributes,t,A,F=g.childNodes;for(A=0;A<h;A++)k.push(" ");k.push("<");k.push(g.nodeName);if(g.id==="svgcontent"){A=Vb();if(s!=="px"){A.w=svgedit.units.convertUnit(A.w,s)+s;A.h=svgedit.units.convertUnit(A.h,s)+s}k.push(' width="'+A.w+'" height="'+A.h+'" xmlns="'+c+'"');var C={};$(g).find("*").andSelf().each(function(){$.each(this.attributes,function(P,Q){var aa=
Q.namespaceURI;if(aa&&!C[aa]&&za[aa]!=="xmlns"&&za[aa]!=="xml"){C[aa]=true;k.push(" xmlns:"+za[aa]+'="'+aa+'"')}})});A=w.length;for(s=["width","height","xmlns","x","y","viewBox","id","overflow"];A--;){t=w.item(A);var D=v(t.nodeValue);if(t.nodeName.indexOf("xmlns:")!==0)if(D!=""&&s.indexOf(t.localName)==-1)if(!t.namespaceURI||za[t.namespaceURI]){k.push(" ");k.push(t.nodeName);k.push('="');k.push(D);k.push('"')}}}else{if(g.nodeName==="defs"&&!g.firstChild)return;var G=["-moz-math-font-style","_moz-math-font-style"];
for(A=w.length-1;A>=0;A--){t=w.item(A);D=v(t.nodeValue);if(!(G.indexOf(t.localName)>=0))if(D!="")if(D.indexOf("pointer-events")!==0)if(!(t.localName==="class"&&D.indexOf("se_")===0)){k.push(" ");if(t.localName==="d")D=Va.convertPath(g,true);if(isNaN(D)){if(E.test(D))D=svgedit.units.shortFloat(D)+s}else D=svgedit.units.shortFloat(D);if(Za.apply&&g.nodeName==="image"&&t.localName==="href"&&Za.images&&Za.images==="embed"){var H=Sa[D];if(H)D=H}if(!t.namespaceURI||t.namespaceURI==c||za[t.namespaceURI]){k.push(t.nodeName);
k.push('="');k.push(D);k.push('"')}}}}if(g.hasChildNodes()){k.push(">");h++;w=false;for(A=0;A<F.length;A++){s=F.item(A);switch(s.nodeType){case 1:k.push("\n");k.push(this.svgToString(F.item(A),h));break;case 3:s=s.nodeValue.replace(/^\s+|\s+$/g,"");if(s!=""){w=true;k.push(v(s)+"")}break;case 4:k.push("\n");k.push(Array(h+1).join(" "));k.push("<![CDATA[");k.push(s.nodeValue);k.push("]]\>");break;case 8:k.push("\n");k.push(Array(h+1).join(" "));k.push("<!--");k.push(s.data);k.push("--\>")}}h--;if(!w){k.push("\n");
for(A=0;A<h;A++)k.push(" ")}k.push("</");k.push(g.nodeName);k.push(">")}else k.push("/>")}return k.join("")};this.embedImage=function(g,h){$(new Image).load(function(){var k=document.createElement("canvas");k.width=this.width;k.height=this.height;k.getContext("2d").drawImage(this,0,0);try{var v=";svgedit_url="+encodeURIComponent(g);v=k.toDataURL().replace(";base64",v+";base64");Sa[g]=v}catch(s){Sa[g]=false}Ja=g;h&&h(Sa[g])}).attr("src",g)};this.setGoodImage=function(g){Ja=g};this.open=function(){};
this.save=function(g){bb();g&&$.extend(Za,g);Za.apply=true;g=this.svgCanvasToString();I("saved",g)};this.rasterExport=function(){bb();var g=[],h={feGaussianBlur:Gb.exportNoBlur,foreignObject:Gb.exportNoforeignObject,"[stroke-dasharray]":Gb.exportNoDashArray},k=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=Gb.exportNoText;$.each(h,function(v,s){k.find(v).length&&g.push(s)});h=this.svgCanvasToString();I("exported",{svg:h,issues:g})};this.getSvgString=function(){Za.apply=false;return this.svgCanvasToString()};
this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,z()):svgedit.draw.randomizeIds(true,z())};var cc=this.uniquifyElems=function(g){var h={},k=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(g,function(t){if(t.nodeType==1){if(t.id){t.id in h||(h[t.id]={elem:null,attrs:[],hrefs:[]});h[t.id].elem=t}$.each(Nb,function(F,C){var D=t.getAttributeNode(C);if(D){var G=svgedit.utilities.getUrlFromAttr(D.value);
if(G=G?G.substr(1):null){G in h||(h[G]={elem:null,attrs:[],hrefs:[]});h[G].attrs.push(D)}}});var A=svgedit.utilities.getHref(t);if(A&&k.indexOf(t.nodeName)>=0)if(A=A.substr(1)){A in h||(h[A]={elem:null,attrs:[],hrefs:[]});h[A].hrefs.push(t)}}});for(var v in h)if(v){var s=h[v].elem;if(s){g=M();s.id=g;s=h[v].attrs;for(var E=s.length;E--;){var w=s[E];w.ownerElement.setAttribute(w.name,"url(#"+g+")")}s=h[v].hrefs;for(E=s.length;E--;)svgedit.utilities.setHref(s[E],"#"+g)}}},Ub=this.setUseData=function(g){var h=
$(g);if(g.tagName!=="use")h=h.find("use");h.each(function(){var k=ba(this).substr(1);if(k=la(k)){$(this).data("ref",k);if(k.tagName=="symbol"||k.tagName=="svg")$(this).data("symbol",k).data("ref",k)}})},hc=this.convertGradients=function(g){var h=$(g).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(g).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var k=$(l).find('[fill="url(#'+
this.id+')"],[stroke="url(#'+this.id+')"]');if(k.length)if(k=svgedit.utilities.getBBox(k[0]))if(this.tagName==="linearGradient"){var v=$(this).attr(["x1","y1","x2","y2"]),s=this.gradientTransform.baseVal;if(s&&s.numberOfItems>0){var E=ja(s).matrix;s=O(v.x1,v.y1,E);E=O(v.x2,v.y2,E);v.x1=s.x;v.y1=s.y;v.x2=E.x;v.y2=E.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(v.x1-k.x)/k.width,y1:(v.y1-k.y)/k.height,x2:(v.x2-k.x)/k.width,y2:(v.y2-k.y)/k.height});this.removeAttribute("gradientUnits")}}})},
lc=this.convertToGroup=function(g){g||(g=J[0]);var h=$(g),k=new Ma,v;if(h.data("gsvg")){k=$(g.firstChild).attr(["x","y"]);$(g.firstChild.firstChild).unwrap();$(g).removeData("gsvg");v=V(g);var s=e.createSVGTransform();s.setTranslate(k.x,k.y);v.appendItem(s);pb(g);I("selected",[g])}else if(h.data("symbol")){g=h.data("symbol");v=h.attr("transform");s=h.attr(["x","y"]);var E=g.getAttribute("viewBox");if(E){E=E.split(" ");s.x-=+E[0];s.y-=+E[1]}v+=" translate("+(s.x||0)+","+(s.y||0)+")";s=h.prev();k.addSubCommand(new Ua(h[0],
h[0].nextSibling,h[0].parentNode));h.remove();E=$(l).find("use:data(symbol)").length;h=d.createElementNS(c,"g");for(var w=g.childNodes,t=0;t<w.length;t++)h.appendChild(w[t].cloneNode(true));if(svgedit.browser.isGecko()){w=$(ub()).children("linearGradient,radialGradient,pattern").clone();$(h).append(w)}v&&h.setAttribute("transform",v);v=g.parentNode;cc(h);svgedit.browser.isGecko()&&$(ub()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=M();s.after(h);if(v){if(!E){s=g.nextSibling;v.removeChild(g);
k.addSubCommand(new Ua(g,s,v))}k.addSubCommand(new La(h))}Ub(h);svgedit.browser.isGecko()?hc(ub()):hc(h);svgedit.utilities.walkTreePost(h,function(A){try{pb(A)}catch(F){console.log(F)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=M()});Qb([h]);(g=fc(h,true))&&k.addSubCommand(g);Ga(k)}else console.log("Unexpected element to ungroup:",g)};this.setSvgString=function(g){try{var h=svgedit.utilities.text2xml(g);
this.prepareSvg(h);var k=new Ma("Change Source"),v=l.nextSibling,s=e.removeChild(l);k.addSubCommand(new Ua(s,v,e));l=d.adoptNode?d.adoptNode(h.documentElement):d.importNode(h.documentElement,true);e.appendChild(l);var E=$(l);b.current_drawing_=new svgedit.draw.Drawing(l,u);var w=z().getNonce();w?I("setnonce",w):I("unsetnonce");E.find("image").each(function(){var H=this;Zb(H);var P=ba(this);if(P.indexOf("data:")===0){var Q=P.match(/svgedit_url=(.*?);/);if(Q){var aa=decodeURIComponent(Q[1]);$(new Image).load(function(){H.setAttributeNS("http://www.w3.org/1999/xlink",
"xlink:href",aa)}).attr("src",aa)}}b.embedImage(P)});E.find("svg").each(function(){if(!$(this).closest("defs").length){cc(this);var H=this.parentNode;if(H.childNodes.length===1&&H.nodeName==="g"){$(H).data("gsvg",this);H.id=H.id||M()}else na(this)}});svgedit.browser.isGecko()&&E.find("linearGradient, radialGradient, pattern").appendTo(ub());Ub(E);hc(E[0]);svgedit.utilities.walkTreePost(l,function(H){try{pb(H)}catch(P){console.log(P)}});var t={id:"svgcontent",overflow:m.show_outside_canvas?"visible":
"hidden"},A=false;if(E.attr("viewBox")){var F=E.attr("viewBox").split(" ");t.width=F[2];t.height=F[3]}else $.each(["width","height"],function(H,P){var Q=E.attr(P);Q||(Q="100%");if((Q+"").substr(-1)==="%")A=true;else t[P]=qa(P,Q)});Wb();E.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=M()});if(A){var C=getStrokedBBox();t.width=C.width+C.x;t.height=C.height+C.y}if(t.width<=0)t.width=100;if(t.height<=0)t.height=
100;E.attr(t);this.contentW=t.width;this.contentH=t.height;k.addSubCommand(new La(l));var D=E.attr(["width","height"]);k.addSubCommand(new Wa(e,D));o=1;svgedit.transformlist.resetListMap();bb();svgedit.path.clearData();e.appendChild(Oa.selectorParentGroup);Ga(k);I("changed",[l])}catch(G){console.log(G);return false}return true};this.importSvgString=function(g){try{var h=svgedit.utilities.encode64(g.length+g).substr(0,32),k=false;if(Ab[h])if($(Ab[h].symbol).parents("#svgroot").length)k=true;var v=
new Ma("Import SVG");if(k)var s=Ab[h].symbol,E=Ab[h].xform;else{var w=svgedit.utilities.text2xml(g);this.prepareSvg(w);var t;t=d.adoptNode?d.adoptNode(w.documentElement):d.importNode(w.documentElement,true);cc(t);var A=qa("width",t.getAttribute("width")),F=qa("height",t.getAttribute("height")),C=t.getAttribute("viewBox"),D=C?C.split(" "):[0,0,A,F];for(g=0;g<4;++g)D[g]=+D[g];l.getAttribute("width");var G=+l.getAttribute("height");E=F>A?"scale("+G/3/D[3]+")":"scale("+G/3/D[2]+")";E="translate(0) "+
E+" translate(0)";s=d.createElementNS(c,"symbol");var H=ub();for(svgedit.browser.isGecko()&&$(t).find("linearGradient, radialGradient, pattern").appendTo(H);t.firstChild;)s.appendChild(t.firstChild);var P=t.attributes;for(t=0;t<P.length;t++){var Q=P[t];s.setAttribute(Q.nodeName,Q.nodeValue)}s.id=M();Ab[h]={symbol:s,xform:E};ub().appendChild(s);v.addSubCommand(new La(s))}var aa=d.createElementNS(c,"use");aa.id=M();S(aa,"#"+s.id);(L||z().getCurrentLayer()).appendChild(aa);v.addSubCommand(new La(aa));
bb();aa.setAttribute("transform",E);pb(aa);$(aa).data("symbol",s).data("ref",s);qb([aa]);Ga(v);I("changed",[l])}catch(ua){console.log(ua);return false}return true};var Wb=b.identifyLayers=function(){ac();z().identifyLayers()};this.createLayer=function(g){var h=new Ma("Create Layer");g=z().createLayer(g);h.addSubCommand(new La(g));Ga(h);bb();I("changed",[g])};this.cloneLayer=function(g){var h=new Ma("Duplicate Layer"),k=d.createElementNS(c,"g"),v=d.createElementNS(c,"title");v.textContent=g;k.appendChild(v);
v=z().getCurrentLayer();$(v).after(k);v=v.childNodes;for(var s=0;s<v.length;s++){var E=v[s];E.localName!="title"&&k.appendChild(Z(E))}bb();Wb();h.addSubCommand(new La(k));Ga(h);b.setCurrentLayer(g);I("changed",[k])};this.deleteCurrentLayer=function(){var g=z().getCurrentLayer(),h=g.nextSibling,k=g.parentNode;if(g=z().deleteCurrentLayer()){var v=new Ma("Delete Layer");v.addSubCommand(new Ua(g,h,k));Ga(v);bb();I("changed",[k]);return true}return false};this.setCurrentLayer=function(g){(g=z().setCurrentLayer(svgedit.utilities.toXml(g)))&&
bb();return g};this.renameCurrentLayer=function(g){var h=z();if(h.current_layer){var k=h.current_layer;if(!b.setCurrentLayer(g)){for(var v=new Ma("Rename Layer"),s=0;s<h.getNumLayers();++s)if(h.all_layers[s][1]==k)break;var E=h.getLayerName(s);h.all_layers[s][0]=svgedit.utilities.toXml(g);var w=k.childNodes.length;for(s=0;s<w;++s){var t=k.childNodes.item(s);if(t&&t.tagName=="title"){for(;t.firstChild;)t.removeChild(t.firstChild);t.textContent=g;v.addSubCommand(new Wa(t,{"#text":E}));Ga(v);I("changed",
[k]);return true}}}h.current_layer=k}return false};this.setCurrentLayerPosition=function(g){var h=z();if(h.current_layer&&g>=0&&g<h.getNumLayers()){for(var k=0;k<h.getNumLayers();++k)if(h.all_layers[k][1]==h.current_layer)break;if(k==h.getNumLayers())return false;if(k!=g){var v=null,s=h.current_layer.nextSibling;if(g>k){if(g<h.getNumLayers()-1)v=h.all_layers[g+1][1]}else v=h.all_layers[g][1];l.insertBefore(h.current_layer,v);Ga(new Qa(h.current_layer,s,l));Wb();b.setCurrentLayer(h.getLayerName(g));
return true}}return false};this.setLayerVisibility=function(g,h){var k=z(),v=k.getLayerVisibility(g),s=k.setLayerVisibility(g,h);if(s)Ga(new Wa(s,{display:v?"inline":"none"},"Layer Visibility"));else return false;if(s==k.getCurrentLayer()){bb();Va.clear()}return true};this.moveSelectedToLayer=function(g){for(var h=null,k=z(),v=0;v<k.getNumLayers();++v)if(k.getLayerName(v)==g){h=k.all_layers[v][1];break}if(!h)return false;g=new Ma("Move Elements to Layer");k=J;for(v=k.length;v--;){var s=k[v];if(s){var E=
s.nextSibling,w=s.parentNode;h.appendChild(s);g.addSubCommand(new Qa(s,E,w))}}Ga(g);return true};this.mergeLayer=function(g){var h=new Ma("Merge Layer"),k=z(),v=$(k.current_layer).prev()[0];if(v){for(h.addSubCommand(new Ua(k.current_layer,k.current_layer.nextSibling,l));k.current_layer.firstChild;){var s=k.current_layer.firstChild;if(s.localName=="title"){h.addSubCommand(new Ua(s,s.nextSibling,k.current_layer));k.current_layer.removeChild(s)}else{var E=s.nextSibling;v.appendChild(s);h.addSubCommand(new Qa(s,
E,k.current_layer))}}l.removeChild(k.current_layer);if(!g){bb();Wb();I("changed",[l]);Ga(h)}k.current_layer=v;return h}};this.mergeAllLayers=function(){var g=new Ma("Merge all Layers"),h=z();for(h.current_layer=h.all_layers[h.getNumLayers()-1][1];$(l).children("g").length>1;)g.addSubCommand(b.mergeLayer(true));bb();Wb();I("changed",[l]);Ga(g)};var ac=this.leaveContext=function(){var g=Ea.length;if(g){for(var h=0;h<g;h++){var k=Ea[h],v=lb(k,"orig_opac");v!==1?k.setAttribute("opacity",v):k.removeAttribute("opacity");
k.setAttribute("style","pointer-events: inherit")}Ea=[];bb(true);I("contextset",null)}L=null},nc=this.setContext=function(g){ac();if(typeof g==="string")g=la(g);L=g;$(g).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var h=this.getAttribute("opacity")||1;lb(this,"orig_opac",h);this.setAttribute("opacity",h*0.33);this.setAttribute("style","pointer-events: none");Ea.push(this)});bb();I("contextset",L)};this.clear=function(){Va.clear();bb();b.clearSvgContentElement();b.current_drawing_=
new svgedit.draw.Drawing(l);b.createLayer("Layer 1");b.undoMgr.resetUndoStack();Oa.initGroup();Ca=Oa.getRubberBandBox();I("cleared")};this.linkControlPoints=Va.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=function(){return e};this.getSelectedElems=function(){return J};var Vb=this.getResolution=function(){var g=l.getAttribute("width")/o,h=l.getAttribute("height")/o;return{w:g,h:h,zoom:o}};this.getZoom=function(){return o};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};
this.setUiStrings=function(g){$.extend(Gb,g.notification)};this.setConfig=function(g){$.extend(m,g)};this.getTitle=function(g){if(g=g||J[0]){g=$(g).data("gsvg")||$(g).data("symbol")||g;g=g.childNodes;for(var h=0;h<g.length;h++)if(g[h].nodeName=="title")return g[h].textContent;return""}};this.setGroupTitle=function(g){var h=J[0];h=$(h).data("gsvg")||h;var k=$(h).children("title"),v=new Ma("Set Label");if(g.length)if(k.length){k=k[0];v.addSubCommand(new Wa(k,{"#text":k.textContent}));k.textContent=
g}else{k=d.createElementNS(c,"title");k.textContent=g;$(h).prepend(k);v.addSubCommand(new La(k))}else{v.addSubCommand(new Ua(k[0],k.nextSibling,h));k.remove()}Ga(v)};this.getDocumentTitle=function(){return b.getTitle(l)};this.setDocumentTitle=function(g){for(var h=l.childNodes,k=false,v="",s=new Ma("Change Image Title"),E=0;E<h.length;E++)if(h[E].nodeName=="title"){k=h[E];v=k.textContent;break}if(!k){k=d.createElementNS(c,"title");l.insertBefore(k,l.firstChild)}if(g.length)k.textContent=g;else k.parentNode.removeChild(k);
s.addSubCommand(new Wa(k,{"#text":v}));Ga(s)};this.getEditorNS=function(g){g&&l.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(g,h){var k=Vb(),v=k.w;k=k.h;var s;if(g=="fit"){var E=getStrokedBBox();if(E){s=new Ma("Fit Canvas to Content");var w=Ib();qb(w);var t=[],A=[];$.each(w,function(){t.push(E.x*-1);A.push(E.y*-1)});w=b.moveSelectedElements(t,A,true);s.addSubCommand(w);bb();g=Math.round(E.width);h=Math.round(E.height)}else return false}if(g!=
v||h!=k){w=e.suspendRedraw(1E3);s||(s=new Ma("Change Image Dimensions"));g=qa("width",g);h=qa("height",h);l.setAttribute("width",g);l.setAttribute("height",h);this.contentW=g;this.contentH=h;s.addSubCommand(new Wa(l,{width:v,height:k}));l.setAttribute("viewBox",[0,0,g/o,h/o].join(" "));s.addSubCommand(new Wa(l,{viewBox:["0 0",v,k].join(" ")}));Ga(s);e.unsuspendRedraw(w);I("changed",[l])}return true};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(g,h,k){var v=0.85,
s=function(E){if(!E)return false;var w=Math.min(Math.round(h/E.width*100*v)/100,Math.round(k/E.height*100*v)/100);b.setZoom(w);return{zoom:w,bbox:E}};if(typeof g=="object"){g=g;if(g.width==0||g.height==0){b.setZoom(g.zoom?g.zoom:o*g.factor);return{zoom:o,bbox:g}}return s(g)}switch(g){case "selection":if(!J[0])return;g=$.map(J,function(E){if(E)return E});g=getStrokedBBox(g);break;case "canvas":g=Vb();v=0.95;g={width:g.w,height:g.h,x:0,y:0};break;case "content":g=getStrokedBBox();break;case "layer":g=
getStrokedBBox(Ib(z().getCurrentLayer()));break;default:return}return s(g)};this.setZoom=function(g){var h=Vb();l.setAttribute("viewBox","0 0 "+h.w/g+" "+h.h/g);o=g;$.each(J,function(k,v){v&&Oa.requestSelector(v).resize()});Va.zoomChange();ob("zoomChanged",g)};this.getMode=function(){return Ka};this.setMode=function(g){Va.clear(true);rb.clear();$("#workarea").attr("class",g);jb=J[0]&&J[0].nodeName=="text"?cb:N;Ka=g};this.getColor=function(g){return jb[g]};this.setColor=function(g,h,k){N[g]=h;jb[g+
"_paint"]={type:"solidColor"};for(var v=[],s=J.length;s--;){var E=J[s];if(E)if(E.tagName=="g")svgedit.utilities.walkTree(E,function(w){w.nodeName!="g"&&v.push(w)});else if(g=="fill")E.tagName!="polyline"&&E.tagName!="line"&&v.push(E);else v.push(E)}if(v.length>0)if(k)Sb(g,h,v);else{vb(g,h,v);I("changed",v)}};var ub=function(){var g=l.getElementsByTagNameNS(c,"defs");if(g.length>0)g=g[0];else{g=d.createElementNS(c,"defs");l.firstChild?l.insertBefore(g,l.firstChild.nextSibling):l.appendChild(g)}return g},
ic=this.setGradient=function(g){if(!(!jb[g+"_paint"]||jb[g+"_paint"].type=="solidColor")){var h=b[g+"Grad"],k=dc(h),v=ub();if(k)h=k;else{h=v.appendChild(d.importNode(h,true));h.id=M()}b.setColor(g,"url(#"+h.id+")")}},dc=function(g){var h=ub();h=$(h).find("linearGradient, radialGradient");for(var k=h.length,v=["r","cx","cy","fx","fy"];k--;){var s=h[k];if(g.tagName=="linearGradient"){if(g.getAttribute("x1")!=s.getAttribute("x1")||g.getAttribute("y1")!=s.getAttribute("y1")||g.getAttribute("x2")!=s.getAttribute("x2")||
g.getAttribute("y2")!=s.getAttribute("y2"))continue}else{var E=$(g).attr(v),w=$(s).attr(v),t=false;$.each(v,function(H,P){if(E[P]!=w[P])t=true});if(t)continue}var A=g.getElementsByTagNameNS(c,"stop"),F=s.getElementsByTagNameNS(c,"stop");if(A.length==F.length){for(var C=A.length;C--;){var D=A[C],G=F[C];if(D.getAttribute("offset")!=G.getAttribute("offset")||D.getAttribute("stop-opacity")!=G.getAttribute("stop-opacity")||D.getAttribute("stop-color")!=G.getAttribute("stop-color"))break}if(C==-1)return s}}return null};
this.setPaint=function(g,h){var k=new $.jGraduate.Paint(h);this.setPaintOpacity(g,k.alpha/100,true);jb[g+"_paint"]=k;switch(k.type){case "solidColor":if(k.solidColor!="none")this.setColor(g,"#"+k.solidColor);else{this.setColor(g,"none");document.querySelector(g=="fill"?"#fill_color rect":"#stroke_color rect").setAttribute("fill","transparent")}break;case "linearGradient":case "radialGradient":b[g+"Grad"]=k[k.type];ic(g)}};this.getStrokeWidth=function(){return jb.stroke_width};this.setStrokeWidth=
function(g){if(g==0&&["line","path"].indexOf(Ka)>=0)b.setStrokeWidth(1);else{jb.stroke_width=g;for(var h=[],k=J.length;k--;){var v=J[k];if(v)v.tagName=="g"?svgedit.utilities.walkTree(v,function(s){s.nodeName!="g"&&h.push(s)}):h.push(v)}if(h.length>0){vb("stroke-width",g,h);I("changed",J)}}};this.setStrokeAttr=function(g,h){N[g.replace("-","_")]=h;for(var k=[],v=J.length;v--;){var s=J[v];if(s)s.tagName=="g"?svgedit.utilities.walkTree(s,function(E){E.nodeName!="g"&&k.push(E)}):k.push(s)}if(k.length>
0){vb(g,h,k);I("changed",J)}};this.getStyle=function(){return N};this.getOpacity=function(){return N.opacity};this.setOpacity=function(g){N.opacity=g;vb("opacity",g)};this.getFillOpacity=function(){return N.fill_opacity};this.getStrokeOpacity=function(){return N.stroke_opacity};this.setPaintOpacity=function(g,h,k){N[g+"_opacity"]=h;k?Sb(g+"-opacity",h):vb(g+"-opacity",h)};this.getBlur=function(g){var h=0;if(g)if(g.getAttribute("filter"))if(g=la(g.id+"_blur"))h=g.firstChild.getAttribute("stdDeviation");
return h};(function(){function g(){var s=b.undoMgr.finishUndoableChange();h.addSubCommand(s);Ga(h);k=h=null}var h=null,k=null,v=false;b.setBlurNoUndo=function(s){if(k)if(s===0){Sb("filter","");v=true}else{var E=J[0];v&&Sb("filter","url(#"+E.id+"_blur)");if(svgedit.browser.isWebkit()){E.removeAttribute("filter");E.setAttribute("filter","url(#"+E.id+"_blur)")}Sb("stdDeviation",s,[k.firstChild]);b.setBlurOffsets(k,s)}else b.setBlur(s)};b.setBlurOffsets=function(s,E){if(E>3)ma(s,{x:"-50%",y:"-50%",width:"200%",
height:"200%"},100);else if(!svgedit.browser.isWebkit()){s.removeAttribute("x");s.removeAttribute("y");s.removeAttribute("width");s.removeAttribute("height")}};b.setBlur=function(s,E){if(h)g();else{var w=J[0],t=w.id;k=la(t+"_blur");s-=0;var A=new Ma;if(k){if(s===0)k=null}else{var F=da({element:"feGaussianBlur",attr:{"in":"SourceGraphic",stdDeviation:s}});k=da({element:"filter",attr:{id:t+"_blur"}});k.appendChild(F);ub().appendChild(k);A.addSubCommand(new La(k))}F={filter:w.getAttribute("filter")};
if(s===0){w.removeAttribute("filter");A.addSubCommand(new Wa(w,F))}else{vb("filter","url(#"+t+"_blur)");A.addSubCommand(new Wa(w,F));b.setBlurOffsets(k,s);h=A;b.undoMgr.beginUndoableChange("stdDeviation",[k?k.firstChild:null]);if(E){b.setBlurNoUndo(s);g()}}}}})();this.getBold=function(){var g=J[0];if(g!=null&&g.tagName=="text"&&J[1]==null)return g.getAttribute("font-weight")=="bold";return false};this.setBold=function(g){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)vb("font-weight",g?"bold":
"normal");J[0].textContent||rb.setCursor()};this.getItalic=function(){var g=J[0];if(g!=null&&g.tagName=="text"&&J[1]==null)return g.getAttribute("font-style")=="italic";return false};this.setItalic=function(g){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)vb("font-style",g?"italic":"normal");J[0].textContent||rb.setCursor()};this.getFontFamily=function(){return cb.font_family};this.setFontFamily=function(g){cb.font_family=g;vb("font-family",g);J[0]&&!J[0].textContent&&rb.setCursor()};this.setFontColor=
function(g){cb.fill=g;vb("fill",g)};this.getFontSize=function(){return cb.fill};this.getFontSize=function(){return cb.font_size};this.setFontSize=function(g){cb.font_size=g;vb("font-size",g);J[0].textContent||rb.setCursor()};this.getText=function(){var g=J[0];if(g==null)return"";return g.textContent};this.setTextContent=function(g){vb("#text",g);rb.init(g);rb.setCursor()};this.setImageURL=function(g){var h=J[0];if(h){var k=$(h).attr(["width","height"]);k=!k.width||!k.height;var v=ba(h);if(v!==g)k=
true;else if(!k)return;var s=new Ma("Change Image URL");S(h,g);s.addSubCommand(new Wa(h,{"#href":v}));k?$(new Image).load(function(){var E=$(h).attr(["width","height"]);$(h).attr({width:this.width,height:this.height});Oa.requestSelector(h).resize();s.addSubCommand(new Wa(h,E));Ga(s);I("changed",[h])}).attr("src",g):Ga(s)}};this.setLinkURL=function(g){var h=J[0];if(h){if(h.tagName!=="a"){h=$(h).parents("a");if(h.length)h=h[0];else return}var k=ba(h);if(k!==g){var v=new Ma("Change Link URL");S(h,g);
v.addSubCommand(new Wa(h,{"#href":k}));Ga(v)}}};this.setRectRadius=function(g){var h=J[0];if(h!=null&&h.tagName=="rect"){var k=h.getAttribute("rx");if(k!=g){h.setAttribute("rx",g);h.setAttribute("ry",g);Ga(new Wa(h,{rx:k,ry:k},"Radius"));I("changed",[h])}}};this.makeHyperlink=function(g){b.groupSelectedElements("a",g)};this.removeHyperlink=function(){b.ungroupSelectedElement()};this.setSegType=function(g){Va.setSegType(g)};this.convertToPath=function(g,h){if(g==null)$.each(J,function(wa,ha){ha&&b.convertToPath(ha)});
else{if(!h)var k=new Ma("Convert element to Path");var v=h?{}:{fill:N.fill,"fill-opacity":N.fill_opacity,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,opacity:N.opacity,visibility:"hidden"};$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(g.getAttribute(this))v[this]=g.getAttribute(this)});var s=da({element:"path",attr:v}),
E=g.getAttribute("transform");E&&s.setAttribute("transform",E);var w=g.id,t=g.parentNode;g.nextSibling?t.insertBefore(s,g):t.appendChild(s);var A="",F=function(wa){$.each(wa,function(ha,ka){var oa=ka[1];A+=ka[0];for(var xa=0;xa<oa.length;xa+=2)A+=oa[xa]+","+oa[xa+1]+" "})},C=1.81;switch(g.tagName){case "ellipse":case "circle":var D=$(g).attr(["rx","ry","cx","cy"]),G=D.cx,H=D.cy,P=D.rx;D=D.ry;if(g.tagName=="circle")P=D=$(g).attr("r");F([["M",[G-P,H]],["C",[G-P,H-D/C,G-P/C,H-D,G,H-D]],["C",[G+P/C,H-
D,G+P,H-D/C,G+P,H]],["C",[G+P,H+D/C,G+P/C,H+D,G,H+D]],["C",[G-P/C,H+D,G-P,H+D/C,G-P,H]],["Z",[]]]);break;case "path":A=g.getAttribute("d");break;case "line":D=$(g).attr(["x1","y1","x2","y2"]);A="M"+D.x1+","+D.y1+"L"+D.x2+","+D.y2;break;case "polyline":case "polygon":A="M"+g.getAttribute("points");break;case "rect":D=$(g).attr(["rx","ry"]);P=D.rx;D=D.ry;var Q=g.getBBox();G=Q.x;H=Q.y;var aa=Q.width;Q=Q.height;C=4-C;!P&&!D?F([["M",[G,H]],["L",[G+aa,H]],["L",[G+aa,H+Q]],["L",[G,H+Q]],["L",[G,H]],["Z",
[]]]):F([["M",[G,H+D]],["C",[G,H+D/C,G+P/C,H,G+P,H]],["L",[G+aa-P,H]],["C",[G+aa-P/C,H,G+aa,H+D/C,G+aa,H+D]],["L",[G+aa,H+Q-D]],["C",[G+aa,H+Q-D/C,G+aa-P/C,H+Q,G+aa-P,H+Q]],["L",[G+P,H+Q]],["C",[G+P/C,H+Q,G,H+Q-D/C,G,H+Q-D]],["L",[G,H+D]],["Z",[]]]);break;default:s.parentNode.removeChild(s)}A&&s.setAttribute("d",A);if(h){Va.resetOrientation(s);k=false;try{k=s.getBBox()}catch(ua){}s.parentNode.removeChild(s);return k}else{if(E){E=V(s);sa(E)&&Va.resetOrientation(s)}k.addSubCommand(new Ua(g,g.nextSibling,
t));k.addSubCommand(new La(s));bb();g.parentNode.removeChild(g);s.setAttribute("id",w);s.removeAttribute("visibility");qb([s],true);Ga(k)}}};var Sb=function(g,h,k){var v=e.suspendRedraw(1E3);Ka=="pathedit"&&Va.moveNode(g,h);k=k||J;for(var s=k.length,E=["g","polyline","path"];s--;){var w=k[s];if(w!=null){Ka==="textedit"&&g!=="#text"&&w.textContent.length&&rb.toSelectMode(w);if((g==="x"||g==="y")&&E.indexOf(w.tagName)>=0){var t=getStrokedBBox([w]);b.moveSelectedElements((g==="x"?h-t.x:0)*o,(g==="y"?
h-t.y:0)*o,true)}else{t=g==="#text"?w.textContent:w.getAttribute(g);if(t==null)t="";if(t!==String(h)){if(g=="#text"){svgedit.utilities.getBBox(w);w.textContent=h;if(/rotate/.test(w.getAttribute("transform")))w=Na(w)}else g=="#href"?S(w,h):w.setAttribute(g,h);if(svgedit.browser.isGecko()&&w.nodeName==="text"&&/rotate/.test(w.getAttribute("transform")))if((h+"").indexOf("url")===0||["font-size","font-family","x","y"].indexOf(g)>=0&&w.textContent)w=Na(w);J.indexOf(w)>=0&&setTimeout(function(){w.parentNode&&
Oa.requestSelector(w).resize()},0);t=ra(w);if(t!=0&&g!="transform")for(var A=V(w),F=A.numberOfItems;F--;)if(A.getItem(F).type==4){A.removeItem(F);var C=svgedit.utilities.getBBox(w),D=O(C.x+C.width/2,C.y+C.height/2,ja(A).matrix);C=D.x;D=D.y;var G=e.createSVGTransform();G.setRotate(t,C,D);A.insertItemBefore(G,F);break}}}}}e.unsuspendRedraw(v)},vb=this.changeSelectedAttribute=function(g,h,k){k=k||J;b.undoMgr.beginUndoableChange(g,k);Sb(g,h,k);g=b.undoMgr.finishUndoableChange();g.isEmpty()||Ga(g)};this.deleteSelectedElements=
function(){for(var g=new Ma("Delete Elements"),h=J.length,k=[],v=0;v<h;++v){var s=J[v];if(s==null)break;var E=s.parentNode,w=s;Oa.releaseSelector(w);svgedit.path.removePath_(w.id);if(E.tagName==="a"&&E.childNodes.length===1){w=E;E=E.parentNode}var t=w.nextSibling;w=E.removeChild(w);k.push(s);J[v]=null;g.addSubCommand(new Ua(w,t,E))}g.isEmpty()||Ga(g);I("changed",k);bb()};this.cutSelectedElements=function(){for(var g=new Ma("Cut Elements"),h=J.length,k=[],v=0;v<h;++v){var s=J[v];if(s==null)break;var E=
s.parentNode,w=s;Oa.releaseSelector(w);svgedit.path.removePath_(w.id);var t=w.nextSibling;w=E.removeChild(w);k.push(s);J[v]=null;g.addSubCommand(new Ua(w,t,E))}g.isEmpty()||Ga(g);I("changed",k);bb();b.clipBoard=k};this.copySelectedElements=function(){b.clipBoard=$.merge([],J)};this.pasteElements=function(g,h,k){var v=b.clipBoard,s=v.length;if(s){for(var E=[],w=new Ma("Paste elements");s--;){var t=v[s];if(t){var A=Z(t);if(!la(t.id))A.id=t.id;E.push(A);(L||z().getCurrentLayer()).appendChild(A);w.addSubCommand(new La(A))}}Qb(E);
if(g!="in_place"){if(yb==null){yb.x=0;yb.y=0}var F,C;if(g){if(g==="point"){F=h;C=k}}else{F=yb.x;C=yb.y}g=getStrokedBBox(E);var D=F-(g.x+g.width/2),G=C-(g.y+g.height/2),H=[],P=[];$.each(E,function(){H.push(D);P.push(G)});F=b.moveSelectedElements(H,P,false);w.addSubCommand(F)}Ga(w);I("changed",E)}};this.groupSelectedElements=function(g){g||(g="g");var h="";switch(g){case "a":h="Make hyperlink";var k="";if(arguments.length>1)k=arguments[1];break;default:g="g";h="Group Elements"}h=new Ma(h);var v=da({element:g,
attr:{id:M()}});g==="a"&&S(v,k);h.addSubCommand(new La(v));for(k=J.length;k--;){var s=J[k];if(s!=null){if(s.parentNode.tagName==="a"&&s.parentNode.childNodes.length===1)s=s.parentNode;var E=s.nextSibling,w=s.parentNode;v.appendChild(s);h.addSubCommand(new Qa(s,E,w))}}h.isEmpty()||Ga(h);Qb([v],true)};var fc=this.pushGroupProperties=function(g,h){var k=g.childNodes,v=k.length,s=g.getAttribute("transform"),E=V(g),w=ja(E).matrix,t=new Ma("Push group properties"),A=0,F=ra(g),C=$(g).attr(["filter","opacity"]),
D,G;for(A=0;A<v;A++){var H=k[A];if(H.nodeType===1){if(C.opacity!==null&&C.opacity!==1){H.getAttribute("opacity");var P=Math.round((H.getAttribute("opacity")||1)*C.opacity*100)/100;vb("opacity",P,[H])}if(C.filter){var Q=P=this.getBlur(H);G||(G=this.getBlur(g));if(P)P=G-0+(P-0);else if(P===0)P=G;if(Q)D=X(H.getAttribute("filter"));else if(D){D=Z(D);ub().appendChild(D)}else D=X(C.filter);D.id=H.id+"_"+(D.firstChild.tagName==="feGaussianBlur"?"blur":"filter");vb("filter","url(#"+D.id+")",[H]);if(P){vb("stdDeviation",
P,[D.firstChild]);b.setBlurOffsets(D,P)}}P=V(H);if(~H.tagName.indexOf("Gradient"))P=null;if(P)if(H.tagName!=="defs")if(E.numberOfItems){if(F&&E.numberOfItems==1){var aa=E.getItem(0).matrix,ua=e.createSVGMatrix();if(Q=ra(H))ua=P.getItem(0).matrix;var wa=svgedit.utilities.getBBox(H),ha=ja(P).matrix,ka=O(wa.x+wa.width/2,wa.y+wa.height/2,ha);wa=F+Q;ha=e.createSVGTransform();ha.setRotate(wa,ka.x,ka.y);aa=fa(aa,ua,ha.matrix.inverse());Q&&P.removeItem(0);if(wa)P.numberOfItems?P.insertItemBefore(ha,0):P.appendItem(ha);
if(aa.e||aa.f){Q=e.createSVGTransform();Q.setTranslate(aa.e,aa.f);P.numberOfItems?P.insertItemBefore(Q,0):P.appendItem(Q)}}else{Q=H.getAttribute("transform");aa={};aa.transform=Q?Q:"";Q=e.createSVGTransform();aa=ja(P).matrix;ua=aa.inverse();aa=fa(ua,w,aa);Q.setMatrix(aa);P.appendItem(Q)}(H=pb(H))&&t.addSubCommand(H)}}}if(s){aa={};aa.transform=s;g.setAttribute("transform","");g.removeAttribute("transform");t.addSubCommand(new Wa(g,aa))}if(h&&!t.isEmpty())return t};this.ungroupSelectedElement=function(){var g=
J[0];if($(g).data("gsvg")||$(g).data("symbol"))lc(g);else if(g.tagName==="use"){var h=la(ba(g).substr(1));$(g).data("symbol",h).data("ref",h);lc(g)}else{h=$(g).parents("a");if(h.length)g=h[0];if(g.tagName==="g"||g.tagName==="a"){h=new Ma("Ungroup Elements");var k=fc(g,true);k&&h.addSubCommand(k);k=g.parentNode;for(var v=g.nextSibling,s=Array(g.childNodes.length),E=0;g.firstChild;){var w=g.firstChild,t=w.nextSibling,A=w.parentNode;if(w.tagName==="title"){h.addSubCommand(new Ua(w,w.nextSibling,A));
A.removeChild(w)}else{s[E++]=w=k.insertBefore(w,v);h.addSubCommand(new Qa(w,t,A))}}bb();v=g.nextSibling;g=k.removeChild(g);h.addSubCommand(new Ua(g,v,k));h.isEmpty()||Ga(h);qb(s)}}};this.moveToTopSelectedElement=function(){var g=J[0];if(g!=null){g=g;var h=g.parentNode,k=g.nextSibling;g=g.parentNode.appendChild(g);if(k!=g.nextSibling){Ga(new Qa(g,k,h,"top"));I("changed",[g])}}};this.moveToBottomSelectedElement=function(){var g=J[0];if(g!=null){g=g;var h=g.parentNode,k=g.nextSibling,v=g.parentNode.firstChild;
if(v.tagName=="title")v=v.nextSibling;if(v.tagName=="defs")v=v.nextSibling;g=g.parentNode.insertBefore(g,v);if(k!=g.nextSibling){Ga(new Qa(g,k,h,"bottom"));I("changed",[g])}}};this.moveUpDownSelected=function(g){var h=J[0];if(h){wb=[];var k,v,s=$(Kb(getStrokedBBox([h]))).toArray();g=="Down"&&s.reverse();$.each(s,function(){if(v){k=this;return false}else if(this==h)v=true});if(k){s=h.parentNode;var E=h.nextSibling;$(k)[g=="Down"?"before":"after"](h);if(E!=h.nextSibling){Ga(new Qa(h,E,s,"Move "+g));
I("changed",[h])}}}};this.moveSelectedElements=function(g,h,k){if(g.constructor!=Array){g/=o;h/=o}k=k||true;for(var v=new Ma("position"),s=J.length;s--;){var E=J[s];if(E!=null){var w=e.createSVGTransform(),t=V(E);g.constructor==Array?w.setTranslate(g[s],h[s]):w.setTranslate(g,h);t.numberOfItems?t.insertItemBefore(w,0):t.appendItem(w);(w=pb(E))&&v.addSubCommand(w);Oa.requestSelector(E).resize()}}if(!v.isEmpty()){k&&Ga(v);I("changed",J);return v}};this.cloneSelectedElements=function(g,h){for(var k=
new Ma("Clone Elements"),v=J.length,s=0;s<v;++s){var E=J[s];if(E==null)break}v=J.slice(0,s);this.clearSelection(true);for(s=v.length;s--;){E=v[s]=Z(v[s]);(L||z().getCurrentLayer()).appendChild(E);k.addSubCommand(new La(E))}if(!k.isEmpty()){qb(v.reverse());this.moveSelectedElements(g,h,false);Ga(k)}};this.alignSelectedElements=function(g,h){var k=[],v=Number.MAX_VALUE,s=Number.MIN_VALUE,E=Number.MAX_VALUE,w=Number.MIN_VALUE,t=Number.MIN_VALUE,A=Number.MIN_VALUE,F=J.length;if(F){for(var C=0;C<F;++C){if(J[C]==
null)break;k[C]=getStrokedBBox([J[C]]);switch(h){case "smallest":if((g=="l"||g=="c"||g=="r")&&(t==Number.MIN_VALUE||t>k[C].width)||(g=="t"||g=="m"||g=="b")&&(A==Number.MIN_VALUE||A>k[C].height)){v=k[C].x;E=k[C].y;s=k[C].x+k[C].width;w=k[C].y+k[C].height;t=k[C].width;A=k[C].height}break;case "largest":if((g=="l"||g=="c"||g=="r")&&(t==Number.MIN_VALUE||t<k[C].width)||(g=="t"||g=="m"||g=="b")&&(A==Number.MIN_VALUE||A<k[C].height)){v=k[C].x;E=k[C].y;s=k[C].x+k[C].width;w=k[C].y+k[C].height;t=k[C].width;
A=k[C].height}break;default:if(k[C].x<v)v=k[C].x;if(k[C].y<E)E=k[C].y;if(k[C].x+k[C].width>s)s=k[C].x+k[C].width;if(k[C].y+k[C].height>w)w=k[C].y+k[C].height}}if(h=="page"){E=v=0;s=b.contentW;w=b.contentH}t=Array(F);A=Array(F);for(C=0;C<F;++C){if(J[C]==null)break;var D=k[C];t[C]=0;A[C]=0;switch(g){case "l":t[C]=v-D.x;break;case "c":t[C]=(v+s)/2-(D.x+D.width/2);break;case "r":t[C]=s-(D.x+D.width);break;case "t":A[C]=E-D.y;break;case "m":A[C]=(E+w)/2-(D.y+D.height/2);break;case "b":A[C]=w-(D.y+D.height)}}this.moveSelectedElements(t,
A)}};this.contentW=Vb().w;this.contentH=Vb().h;this.updateCanvas=function(g,h){e.setAttribute("width",g);e.setAttribute("height",h);var k=$("#canvasBackground")[0],v=l.getAttribute("x"),s=l.getAttribute("y"),E=g/2-this.contentW*o/2,w=h/2-this.contentH*o/2;ma(l,{width:this.contentW*o,height:this.contentH*o,x:E,y:w,viewBox:"0 0 "+this.contentW+" "+this.contentH});ma(k,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:E,y:w});(k=la("background_image"))&&ma(k,{width:"100%",height:"100%"});
Oa.selectorParentGroup.setAttribute("transform","translate("+E+","+w+")");return{x:E,y:w,old_x:v,old_y:s,d_x:E-v,d_y:w-s}};this.setBackground=function(g,h){var k=la("canvasBackground"),v=$(k).find("rect")[0],s=la("background_image");v.setAttribute("fill",g);if(h){if(!s){s=d.createElementNS(c,"image");ma(s,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}S(s,h);k.appendChild(s)}else s&&s.parentNode.removeChild(s)};this.cycleElement=function(g){var h=
J[0],k=false,v=Ib(L||z().getCurrentLayer());if(v.length){if(h==null){g=g?v.length-1:0;k=v[g]}else for(var s=v.length;s--;)if(v[s]==h){g=g?s-1:s+1;if(g>=v.length)g=0;else if(g<0)g=v.length-1;k=v[g];break}Qb([k],true);I("selected",J)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:Ga,setGradient:ic,addSvgElementFromJson:da,assignAttributes:ma,BatchCommand:Ma,call:I,ChangeElementCommand:Wa,copyElem:Z,ffClone:Na,findDefs:ub,findDuplicateGradient:dc,getElem:la,getId:ta,getIntersectionList:Kb,
getMouseTarget:$b,getNextId:M,getPathBBox:U,getUrlFromAttr:pa,hasMatrixTransform:sa,identifyLayers:Wb,InsertElementCommand:La,isIdentity:svgedit.math.isIdentity,logMatrix:tb,matrixMultiply:fa,MoveElementCommand:Qa,preventClickDefault:Zb,recalculateAllSelectedDimensions:Xa,recalculateDimensions:pb,remapElement:xb,RemoveElementCommand:Ua,removeUnusedDefElems:gc,round:Cb,runExtensions:ob,sanitizeSvg:Ia,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,
transformListToTransform:ja,transformPoint:O,walkTree:svgedit.utilities.walkTree}}};(function(){document.addEventListener("touchstart",touchHandler,true);document.addEventListener("touchmove",touchHandler,true);document.addEventListener("touchend",touchHandler,true);document.addEventListener("touchcancel",touchHandler,true);if(!window.svgEditor)window.svgEditor=function(a){function n(z,o){var L=f.setSvgString(z)!==false;o=o||a.noop;L?o(true):a.alert(e.notification.errorLoadingSVG,function(){o(false)})}var f,c={},m=false,p={lang:"en",iconsize:"m",bkgd_color:"FFF",bkgd_url:"",img_save:"embed"},
b={},d={canvas_expansion:1,dimensions:[640,480],initFill:{color:"fff",opacity:1},initStroke:{width:1.5,color:"000",opacity:1},initOpacity:1,imgPath:"images/",langPath:"locale/",extPath:"extensions/",jGraduatePath:"jgraduate/images/",extensions:["ext-markers.js","ext-eyedropper.js","ext-shapes.js","ext-grid.js"],initTool:"select",wireframe:false,colorPickerCSS:false,gridSnapping:false,gridColor:"#000",baseUnit:"px",snappingStep:10,showRulers:true,show_outside_canvas:false,no_save_warning:true},e=c.uiStrings=
{common:{ok:"OK",cancel:"Cancel",key_up:"Up",key_down:"Down",key_backspace:"Backspace",key_del:"Del"},layers:{layer:"Layer"},notification:{invalidAttrValGiven:"Invalid value given",noContentToFitTo:"No content to fit to",dupeLayerName:"There is already a layer named that!",enterUniqueLayerName:"Please enter a unique layer name",enterNewLayerName:"Please enter the new layer name",layerHasThatName:"Layer already has that name",QmoveElemsToLayer:'Move selected elements to layer "%s"?',QwantToClear:"Do you want to clear the drawing?\nThis will also erase your undo history!",
QwantToOpen:"Do you want to open a new file?\nThis will also erase your undo history!",QerrorsRevertToSource:"There were parsing errors in your SVG source.\nRevert back to original SVG source?",QignoreSourceChanges:"Ignore changes made to SVG source?",featNotSupported:"Feature not supported",enterNewImgURL:"Enter the new image URL",defsFailOnSave:"NOTE: Due to a bug in your browser, this image may appear wrong (missing gradients or elements). It will however appear correct once actually saved.",loadingImage:"Loading image, please wait...",
saveFromBrowser:'Select "Save As..." in your browser to save this image as a %s file.',noteTheseIssues:"Also note the following issues: ",unsavedChanges:"There are unsaved changes.",enterNewLinkURL:"Enter the new hyperlink URL",errorLoadingSVG:"Error: Unable to load SVG data",URLloadFail:"Unable to load from URL",retrieving:'Retrieving "%s" ...'}};b={};var l={};c.curConfig=d;c.tool_scale=1;a.pref=function(z,o){if(o)b[z]=o;z="svg-edit-"+z;var L=location.hostname,T=L&&L.indexOf(".")>=0,N=o!=undefined,
J=false;try{if(window.localStorage)J=localStorage}catch(da){}try{if(window.globalStorage&&T)J=globalStorage[L]}catch(V){}if(J)if(N)J.setItem(z,o);else{if(J.getItem(z))return J.getItem(z)+""}else if(window.widget)if(N)widget.setPreferenceForKey(o,z);else return widget.preferenceForKey(z);else if(N){L=new Date;L.setTime(L.getTime()+31536E6);o=encodeURIComponent(o);document.cookie=z+"="+o+"; expires="+L.toUTCString()}else return(L=document.cookie.match(RegExp(z+"=([^;]+)")))?decodeURIComponent(L[1]):
""};c.setConfig=function(z){a.each(z,function(o,L){o in p&&a.pref(o,L)});a.extend(true,d,z);if(z.extensions)d.extensions=z.extensions};c.setCustomHandlers=function(z){c.ready(function(){if(z.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();f.open=z.open}if(z.save){c.show_save_warning=false;f.bind("saved",z.save)}z.pngsave&&f.bind("exported",z.pngsave);l=z})};c.randomizeIds=function(){f.randomizeIds(arguments)};c.init=function(){function z(q,B){var K=q.id,Q=K.split("_"),W=
Q[0];Q=Q[1];B&&f.setStrokeAttr("stroke-"+W,Q);cb();H("#cur_"+W,K,20);a(q).addClass("current").siblings().removeClass("current")}function o(q,B){a.pref("bkgd_color",q);a.pref("bkgd_url",B);f.setBackground(q,B)}function L(){var q=f.getHref(Y);q=q.indexOf("data:")===0?"":q;a.prompt(e.notification.enterNewImgURL,q,function(B){B&&Ja(B)})}function T(){if(f.deleteCurrentLayer()){Za();Eb();a("#layerlist tr.layer").removeClass("layersel");a("#layerlist tr.layer:first").addClass("layersel")}}function N(){var q=
f.getCurrentDrawing().getCurrentLayerName()+" copy";a.prompt(e.notification.enterUniqueLayerName,q,function(B){if(B)if(f.getCurrentDrawing().hasLayer(B))a.alert(e.notification.dupeLayerName);else{f.cloneLayer(B);Za();Eb()}})}function J(q){var B=a("#layerlist tr.layersel").index(),K=f.getCurrentDrawing().getNumLayers();if(B>0||B<K-1){B+=q;f.setCurrentLayerPosition(K-B-1);Eb()}}function da(q,B){var K=document.getElementById("ruler_x_cursor"),Q=document.getElementById("ruler_y_cursor"),W=document.getElementById("workarea"),
ia=document.getElementById("title_show");a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(Xb){Xb.stopPropagation();K.style.left=Xb.pageX-66+W.scrollLeft+"px";Q.style.top=Xb.pageY-48+W.scrollTop+"px";Xb=Xb.target.getAttribute("title");typeof Xb!="undefined"&&Xb&&ia.innerHTML(Xb)});B||(B=f.getZoom());q||(q=a("#svgcanvas"));for(var va=f.getContentElem(),ya=svgedit.units.getTypeMap()[d.baseUnit],Da=0;Da<2;Da++){var Ha=Da===0,Aa=Ha?"x":"y",fb=Ha?"width":"height",gb=va.getAttribute(Aa)-
""};c.setConfig=function(z){a.each(z,function(o,L){o in p&&a.pref(o,L)});a.extend(true,d,z);if(z.extensions)d.extensions=z.extensions};c.setCustomHandlers=function(z){c.ready(function(){if(z.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();f.open=z.open}if(z.save){c.show_save_warning=false;f.bind("saved",z.save)}z.pngsave&&f.bind("exported",z.pngsave);l=z})};c.randomizeIds=function(){f.randomizeIds(arguments)};c.init=function(){function z(q,B){var K=q.id,R=K.split("_"),W=
R[0];R=R[1];B&&f.setStrokeAttr("stroke-"+W,R);cb();H("#cur_"+W,K,20);a(q).addClass("current").siblings().removeClass("current")}function o(q,B){a.pref("bkgd_color",q);a.pref("bkgd_url",B);f.setBackground(q,B)}function L(){var q=f.getHref(Y);q=q.indexOf("data:")===0?"":q;a.prompt(e.notification.enterNewImgURL,q,function(B){B&&Ja(B)})}function T(){if(f.deleteCurrentLayer()){Za();Eb();a("#layerlist tr.layer").removeClass("layersel");a("#layerlist tr.layer:first").addClass("layersel")}}function N(){var q=
f.getCurrentDrawing().getCurrentLayerName()+" copy";a.prompt(e.notification.enterUniqueLayerName,q,function(B){if(B)if(f.getCurrentDrawing().hasLayer(B))a.alert(e.notification.dupeLayerName);else{f.cloneLayer(B);Za();Eb()}})}function J(q){var B=a("#layerlist tr.layersel").index(),K=f.getCurrentDrawing().getNumLayers();if(B>0||B<K-1){B+=q;f.setCurrentLayerPosition(K-B-1);Eb()}}function da(q,B){var K=document.getElementById("ruler_x_cursor"),R=document.getElementById("ruler_y_cursor"),W=document.getElementById("workarea"),
ia=document.getElementById("title_show");a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(Xb){Xb.stopPropagation();K.style.left=Xb.pageX-66+W.scrollLeft+"px";R.style.top=Xb.pageY-48+W.scrollTop+"px";Xb=Xb.target.getAttribute("title");typeof Xb!="undefined"&&Xb&&ia.innerHTML(Xb)});B||(B=f.getZoom());q||(q=a("#svgcanvas"));for(var va=f.getContentElem(),ya=svgedit.units.getTypeMap()[d.baseUnit],Da=0;Da<2;Da++){var Ha=Da===0,Aa=Ha?"x":"y",fb=Ha?"width":"height",gb=va.getAttribute(Aa)-
0;Aa=a("#ruler_"+Aa+" canvas:first");$hcanv=Aa.clone();Aa.replaceWith($hcanv);var ga=$hcanv[0];var zb=Aa=q[fb]()*2;ga.parentNode.style[fb]=zb+"px";var hb=0,Ta,Pa=ga.getContext("2d");Pa.fillStyle="rgb(200,0,0)";Pa.fillRect(0,0,ga.width,ga.height);$hcanv.siblings().remove();if(Aa>=3E4){var Ya=parseInt(Aa/3E4)+1;Ta=Array(Ya);Ta[0]=Pa;for(var Ba=1;Ba<Ya;Ba++){ga[fb]=3E4;var ib=ga.cloneNode(true);ga.parentNode.appendChild(ib);Ta[Ba]=ib.getContext("2d")}ib[fb]=Aa%3E4;Aa=3E4}ga[fb]=Aa;fb=ya*B;var sb=50/
fb;ga=1;for(Ba=0;Ba<jc.length;Ba++){ga=Ya=jc[Ba];if(sb<=Ya)break}sb=ga*fb;Pa.font="normal 9px 'Lucida Grande', sans-serif";Pa.fillStyle="#777";for(var Fb=gb/fb%ga*fb,Yb=Fb-sb;Fb<zb;Fb+=sb){Yb+=sb;Ba=Math.round(Fb)+0.5;if(Ha){Pa.moveTo(Ba,15);Pa.lineTo(Ba,0)}else{Pa.moveTo(15,Ba);Pa.lineTo(0,Ba)}Ya=(Yb-gb)/fb;if(ga>=1)Ba=Math.round(Ya);else{Ba=(ga+"").split(".")[1].length;Ba=Ya.toFixed(Ba)-0}if(Ba!==0&&Ba!==1E3&&Ba%1E3===0)Ba=Ba/1E3+"K";if(Ha){Pa.fillText(Ba,Fb+2,8);Pa.fillStyle="#777"}else{Ya=(Ba+
"").split("");for(Ba=0;Ba<Ya.length;Ba++){Pa.fillText(Ya[Ba],1,Fb+9+Ba*9);Pa.fillStyle="#777"}}Ya=sb/10;for(Ba=1;Ba<10;Ba++){var Mb=Math.round(Fb+Ya*Ba)+0.5;if(Ta&&Mb>Aa){hb++;Pa.stroke();if(hb>=Ta.length){Ba=10;Fb=zb;continue}Pa=Ta[hb];Fb-=3E4;Mb=Math.round(Fb+Ya*Ba)+0.5}var qc=Ba%2?12:10;if(Ha){Pa.moveTo(Mb,15);Pa.lineTo(Mb,qc)}else{Pa.moveTo(15,Mb);Pa.lineTo(qc,Mb)}}}Pa.strokeStyle="#666";Pa.stroke()}}(function(){var q=window.opener;if(q)try{var B=q.document.createEvent("Event");B.initEvent("svgEditorReady",
@ -397,31 +397,31 @@ arrow_right:"flyouth.png",arrow_down:"dropdown.gif"},placement:{"#tool_docprops
"#blurLabel":"blur",".flyout_arrow_horiz":"arrow_right","#palette .palette_item:first, #fill_bg, #stroke_bg":"no_color"},resize:{"#logo .svg_icon":32,".flyout_arrow_horiz .svg_icon":5,".layer_button .svg_icon, #layerlist td.layervis .svg_icon":14,"#main_button .dropdown .svg_icon":9,"#fill_bg .svg_icon, #stroke_bg .svg_icon":24,".palette_item:first .svg_icon":16,".toolbar_button button .svg_icon":16,".stroke_tool div div .svg_icon":20,"#tools_bottom label .svg_icon":18,"#zoom_dropdown .svg_icon":7},
callback:function(){a(".toolbar_button button > svg, .toolbar_button button > img").each(function(){a(this).parent().prepend(this)});var q=a("#tools_left");if(q.length!=0){q.offset();q.outerHeight()}a(".tools_flyout").each(function(){var B=a("#"+this.id+"_show"),K=B.attr("data-curopt");if(!B.children("svg, img").length){K=a(K).children().clone();if(K.length){K[0].removeAttribute("style");B.append(K)}}});svgEditor.runCallbacks();setTimeout(function(){a(".flyout_arrow_horiz:empty").each(function(){a(this).append(a.getSvgIcon("arrow_right").width(5).height(5))})},
1)}});c.canvas=f=new a.SvgCanvas(document.getElementById("svgcanvas"),d);c.show_save_warning=false;V=navigator.platform.indexOf("Mac")>=0;var O=navigator.userAgent.indexOf("AppleWebKit")>=0,fa=V?"meta+":"ctrl+",sa=f.pathActions,ja=f.undoMgr,ca=svgedit.utilities,ea=d.imgPath+"placeholder.svg",qa=a("#workarea"),pa=a("#cmenu_canvas");a("#cmenu_layers");var ba=null,S=1,U="toolbars",ra="",la={fill:null,stroke:null};(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",
containment:"window"});var q=a("#dialog_box"),B=a("#dialog_buttons"),K=function(Q,W,ia,va){a("#dialog_content").html("<p>"+W.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",Q=="prompt");B.empty();var ya=a('<input type="button" value="'+e.common.ok+'">').appendTo(B);Q!="alert"&&a('<input type="button" value="'+e.common.cancel+'">').appendTo(B).click(function(){q.hide();ia(false)});if(Q=="prompt"){var Da=a('<input type="text">').prependTo(B);Da.val(va||"");Da.bind("keydown","return",function(){ya.click()})}Q==
"process"&&ya.hide();q.show();ya.click(function(){q.hide();var Ha=Q=="prompt"?Da.val():true;ia&&ia(Ha)}).focus();Q=="prompt"&&Da.focus()};a.alert=function(Q,W){K("alert",Q,W)};a.confirm=function(Q,W){K("confirm",Q,W)};a.process_cancel=function(Q,W){K("process",Q,W)};a.prompt=function(Q,W,ia){K("prompt",Q,ia,W)}})();var ma=function(){var q=a(".tool_button_current");if(q.length&&q[0].id!=="tool_select"){q.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");
a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all} #svgcanvas svg{cursor:default}")}f.setMode("select")},Y=null,za=false,Ia=false,Qa=false,Ka=false,Ua="",Wa=a("title:first").text(),La=function(q,B,K){f.getResolution();a("#svgcanvas").position();if(B=f.setBBoxZoom(B,qa.width()-15,qa.height()-15)){q=B.zoom;B=B.bbox;if(q<0.0010)Na({value:0.1});else{a("#zoom").val(q*100);K?Tb():Tb(false,{x:B.x*q+B.width*q/2,y:B.y*q+B.height*q/2});f.getMode()=="zoom"&&B.width&&ma();t()}}};a("#cur_context_panel").delegate("a",
"click",function(){var q=a(this);q.attr("data-root")?f.leaveContext():f.setContext(q.text());return false});var Ga={},Oa=function(q){a.each(q,function(B,K){var Q=a(B).children(),W=B+"_show",ia=a(W),va=false;Q.addClass("tool_button").unbind("click mousedown mouseup").each(function(Ha){var Aa=K[Ha];Ga[Aa.sel]=Aa.fn;if(Aa.isDefault)va=Ha;Ha=function(fb){var gb=Aa;if(fb.type==="keydown"){var ga=a(gb.parent+"_show").hasClass("tool_button_current"),zb=a(gb.parent+"_show").attr("data-curopt");a.each(q[Aa.parent],
containment:"window"});var q=a("#dialog_box"),B=a("#dialog_buttons"),K=function(R,W,ia,va){a("#dialog_content").html("<p>"+W.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",R=="prompt");B.empty();var ya=a('<input type="button" value="'+e.common.ok+'">').appendTo(B);R!="alert"&&a('<input type="button" value="'+e.common.cancel+'">').appendTo(B).click(function(){q.hide();ia(false)});if(R=="prompt"){var Da=a('<input type="text">').prependTo(B);Da.val(va||"");Da.bind("keydown","return",function(){ya.click()})}R==
"process"&&ya.hide();q.show();ya.click(function(){q.hide();var Ha=R=="prompt"?Da.val():true;ia&&ia(Ha)}).focus();R=="prompt"&&Da.focus()};a.alert=function(R,W){K("alert",R,W)};a.confirm=function(R,W){K("confirm",R,W)};a.process_cancel=function(R,W){K("process",R,W)};a.prompt=function(R,W,ia){K("prompt",R,ia,W)}})();var ma=function(){var q=a(".tool_button_current");if(q.length&&q[0].id!=="tool_select"){q.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");
a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all} #svgcanvas svg{cursor:default}")}f.setMode("select")},Y=null,za=false,Ia=false,Qa=false,La=false,Ua="",Wa=a("title:first").text(),Ma=function(q,B,K){f.getResolution();a("#svgcanvas").position();if(B=f.setBBoxZoom(B,qa.width()-15,qa.height()-15)){q=B.zoom;B=B.bbox;if(q<0.0010)Ka({value:0.1});else{a("#zoom").val(q*100);K?Tb():Tb(false,{x:B.x*q+B.width*q/2,y:B.y*q+B.height*q/2});f.getMode()=="zoom"&&B.width&&ma();s()}}};a("#cur_context_panel").delegate("a",
"click",function(){var q=a(this);q.attr("data-root")?f.leaveContext():f.setContext(q.text());return false});var Ga={},Oa=function(q){a.each(q,function(B,K){var R=a(B).children(),W=B+"_show",ia=a(W),va=false;R.addClass("tool_button").unbind("click mousedown mouseup").each(function(Ha){var Aa=K[Ha];Ga[Aa.sel]=Aa.fn;if(Aa.isDefault)va=Ha;Ha=function(fb){var gb=Aa;if(fb.type==="keydown"){var ga=a(gb.parent+"_show").hasClass("tool_button_current"),zb=a(gb.parent+"_show").attr("data-curopt");a.each(q[Aa.parent],
function(Ta,Pa){if(Pa.sel==zb)gb=!fb.shiftKey||!ga?Pa:q[Aa.parent][Ta+1]||q[Aa.parent][0]})}if(a(this).hasClass("disabled"))return false;kb(W)&&gb.fn();var hb=gb.icon?a.getSvgIcon(gb.icon,true):a(gb.sel).children().eq(0).clone();hb[0].setAttribute("width",ia.width());hb[0].setAttribute("height",ia.height());ia.children(":not(.flyout_arrow_horiz)").remove();ia.append(hb).attr("data-curopt",gb.sel)};a(this).mouseup(Ha);Aa.key&&a(document).bind("keydown",Aa.key[0]+" shift+"+Aa.key[0],Ha)});if(va)ia.attr("data-curopt",
K[va].sel);else ia.attr("data-curopt")||ia.attr("data-curopt",K[0].sel);var ya,Da=a(W).position();a(B).css({left:Da.left+34,top:Da.top+77});ia.mousedown(function(Ha){a("#tools_shapelib").is(":visible")&&kb(W,false);if(ia.hasClass("disabled"))return false;var Aa=a(B),fb=Da.left+34,gb=Aa.width()*-1,ga=Aa.data("shown_popop")?200:0;ya=setTimeout(function(){ia.data("isLibrary")?Aa.css("left",fb).show():Aa.css("left",gb).show().animate({left:fb},150);Aa.data("shown_popop",true)},ga);Ha.preventDefault()}).mouseup(function(){clearTimeout(ya);
var Ha=a(this).attr("data-curopt");if(ia.data("isLibrary")&&a(W.replace("_show","")).is(":visible"))kb(W,true);else kb(W)&&Ha in Ga&&Ga[Ha]()})});Nb()},Fa=function(q,B){return a("<div>",{"class":"tools_flyout",id:q}).appendTo("#svg_editor").append(B)},Gb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show"),B=q.offset();q=q.outerWidth();a(this).css({left:(B.left+q)*S,top:B.top})})},Nb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show");if(!q.data("isLibrary")){var B=
[];a(this).children().each(function(){B.push(this.title)});q[0].title=B.join(" / ")}})},lb,ab=function(q,B,K){var Q=null;if(q.indexOf("url(#")===0){q=(q=f.getRefElem(q))?q.cloneNode(true):a("#"+K+"_color defs *")[0];Q={alpha:B};Q[q.tagName]=q}else Q=q.indexOf("#")===0?{alpha:B,solidColor:q.substr(1)}:{alpha:B,solidColor:"none"};return new a.jGraduate.Paint(Q)},Sa=f.getResolution();if(d.baseUnit!=="px"){Sa.w=svgedit.units.convertUnit(Sa.w)+d.baseUnit;Sa.h=svgedit.units.convertUnit(Sa.h)+d.baseUnit}a(".canvas_width").val(Sa.w);
[];a(this).children().each(function(){B.push(this.title)});q[0].title=B.join(" / ")}})},lb,ab=function(q,B,K){var R=null;if(q.indexOf("url(#")===0){q=(q=f.getRefElem(q))?q.cloneNode(true):a("#"+K+"_color defs *")[0];R={alpha:B};R[q.tagName]=q}else R=q.indexOf("#")===0?{alpha:B,solidColor:q.substr(1)}:{alpha:B,solidColor:"none"};return new a.jGraduate.Paint(R)},Sa=f.getResolution();if(d.baseUnit!=="px"){Sa.w=svgedit.units.convertUnit(Sa.w)+d.baseUnit;Sa.h=svgedit.units.convertUnit(Sa.h)+d.baseUnit}a(".canvas_width").val(Sa.w);
a(".canvas_height").val(Sa.h);a("#docprops_button").on("click",function(){w()});var Ja=c.setImageURL=function(q){q||(q=ea);f.setImageURL(q);a("#image_url").val(q);if(q.indexOf("data:")===0){a("#image_url").hide();a("#change_image_url").show()}else{f.embedImage(q,function(B){B?a("#url_notice").hide():a("#url_notice").show();ea=q});a("#image_url").show();a("#change_image_url").hide()}},Ea=function(q){var B=Math.min(Math.max(12+q.value.length*6,50),300);a(q).width(B)},Za=function(){var q=Y;if(q!=null&&
!q.parentNode)q=null;var B=f.getCurrentDrawing().getCurrentLayerName(),K=f.getMode(),Q=d.baseUnit!=="px"?d.baseUnit:null,W=K=="pathedit",ia=a("#cmenu_canvas li");a("#selected_panel, #multiselected_panel, #g_panel, #path_panel, #rect_panel, #canvas_panel, #circle_panel,\t\t\t\t\t#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");!q&&!za&&a("#canvas_panel").show();
!q.parentNode)q=null;var B=f.getCurrentDrawing().getCurrentLayerName(),K=f.getMode(),R=d.baseUnit!=="px"?d.baseUnit:null,W=K=="pathedit",ia=a("#cmenu_canvas li");a("#selected_panel, #multiselected_panel, #g_panel, #path_panel, #rect_panel, #canvas_panel, #circle_panel,\t\t\t\t\t#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");!q&&!za&&a("#canvas_panel").show();
if(q!=null){var va=q.nodeName,ya=f.getRotationAngle(q);a("#angle").val(Math.round(ya));ya=f.getBlur(q);a("#blur").val(ya);a("#blur_slider").slider("option","value",ya);f.addedNew&&va==="image"&&f.getHref(q).indexOf("data:")!==0&&L();if(!W&&K!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(va)>=0)a("#xy_panel").hide();else{var Da,Ha;if(["g","polyline","path"].indexOf(va)>=0){if(K=f.getStrokedBBox([q])){Da=K.x;Ha=K.y}}else{Da=
q.getAttribute("x");Ha=q.getAttribute("y")}if(Q){Da=svgedit.units.convertUnit(Da);Ha=svgedit.units.convertUnit(Ha)}a("#selected_x").val(Math.round(Ha)||0);a("#selected_y").val(Math.round(Da)||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(va)==-1&&a(".action_path_convert_selected").removeClass("disabled");va==="path"&&a(".action_path_selected").removeClass("disabled")}else{B=sa.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",
!sa.canDeleteNodes);H("#tool_openclose_path",sa.closed_subpath?"open_path":"close_path");if(B){W=a("#seg_type");if(Q){B.x=svgedit.units.convertUnit(B.x);B.y=svgedit.units.convertUnit(B.y)}a("#path_node_x").val(Math.round(B.x));a("#path_node_y").val(Math.round(B.y));B.type?W.val(B.type).removeAttr("disabled"):W.val(4).attr("disabled","disabled")}return}Q={g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],
text:[],use:[]};var Aa=q.tagName;a(q).data("gsvg")&&a("#g_panel").show();Aa=="path"&&a("#path_panel").show();if(Q[Aa]){Q=Q[Aa];a("#"+Aa+"_panel").show();a.each(Q,function(fb,gb){var ga=q.getAttribute(gb);if(d.baseUnit!=="px"&&q[gb])ga=svgedit.units.convertUnit(q[gb].baseVal.value);a("#"+Aa+"_"+gb).val(Math.round(ga)||0)});if(Aa=="text"){a("#text_panel").css("display","inline");f.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");
q.getAttribute("x");Ha=q.getAttribute("y")}if(R){Da=svgedit.units.convertUnit(Da);Ha=svgedit.units.convertUnit(Ha)}a("#selected_x").val(Math.round(Ha)||0);a("#selected_y").val(Math.round(Da)||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(va)==-1&&a(".action_path_convert_selected").removeClass("disabled");va==="path"&&a(".action_path_selected").removeClass("disabled")}else{B=sa.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",
!sa.canDeleteNodes);H("#tool_openclose_path",sa.closed_subpath?"open_path":"close_path");if(B){W=a("#seg_type");if(R){B.x=svgedit.units.convertUnit(B.x);B.y=svgedit.units.convertUnit(B.y)}a("#path_node_x").val(Math.round(B.x));a("#path_node_y").val(Math.round(B.y));B.type?W.val(B.type).removeAttr("disabled"):W.val(4).attr("disabled","disabled")}return}R={g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],
text:[],use:[]};var Aa=q.tagName;a(q).data("gsvg")&&a("#g_panel").show();Aa=="path"&&a("#path_panel").show();if(R[Aa]){R=R[Aa];a("#"+Aa+"_panel").show();a.each(R,function(fb,gb){var ga=q.getAttribute(gb);if(d.baseUnit!=="px"&&q[gb])ga=svgedit.units.convertUnit(q[gb].baseVal.value);a("#"+Aa+"_"+gb).val(Math.round(ga)||0)});if(Aa=="text"){a("#text_panel").css("display","inline");f.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");
f.getBold()?a("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_bold").removeClass("push_button_pressed").addClass("tool_button");a("#font_family").val(q.getAttribute("font-family"));a("#font_size").val(q.getAttribute("font-size"));a("#text").val(q.textContent);f.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(Aa=="image")Ja(f.getHref(q));else if(Aa==="g"||Aa==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");
Q=f.getTitle();va=a("#g_title")[0];va.value=Q;Ea(va);Aa=="use"?va.setAttribute("disabled","disabled"):va.removeAttribute("disabled")}}ia[(Aa==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");ia[(Aa==="g"||!za?"dis":"en")+"ableContextMenuItems"]("#group")}else if(za){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");ia.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else ia.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");
R=f.getTitle();va=a("#g_title")[0];va.value=R;Ea(va);Aa=="use"?va.setAttribute("disabled","disabled"):va.removeAttribute("disabled")}}ia[(Aa==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");ia[(Aa==="g"||!za?"dis":"en")+"ableContextMenuItems"]("#group")}else if(za){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");ia.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else ia.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");
ja.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");ja.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");f.addedNew=false;if(q&&!W||za){a("#selLayerNames").removeAttr("disabled").val(B);pa.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}else a("#selLayerNames").attr("disabled","disabled")};a("#text").focus(function(){});a("#text").blur(function(){});f.bind("selected",
function(q,B){var K=f.getMode();K==="select"&&ma();K=K=="pathedit";Y=B.length==1||B[1]==null?B[0]:null;za=B.length>=2&&B[1]!=null;if(Y!=null)if(!K){if(Y!=null)switch(Y.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var Q=null,W=Y.getElementsByTagName("*"),ia=0,va=W.length;ia<va;ia++){var ya=W[ia].getAttribute("stroke-width");if(ia===0)Q=ya;else if(Q!==ya)Q=null}a("#stroke_width").val(Q===null?"":Q);la.fill.update(true);la.stroke.update(true);break;default:la.fill.update(true);
la.stroke.update(true);a("#stroke_width").val(Y.getAttribute("stroke-width")||1);a("#stroke_style").val(Y.getAttribute("stroke-dasharray")||"none");Q=Y.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+Q).length!=0&&z(a("#linejoin_"+Q)[0]);Q=Y.getAttribute("stroke-linecap")||"butt";a("#linecap_"+Q).length!=0&&z(a("#linecap_"+Q)[0])}if(Y!=null){Q=(Y.getAttribute("opacity")||1)*100;a("#group_opacity").val(Q);a("#opac_slider").slider("option","value",Q);a("#elem_id").val(Y.id)}bc()}a("#path_node_panel").toggle(K);
a("#tools_bottom_2,#tools_bottom_3").toggle(!K);if(K){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");H("#tool_select","select_node");za=false;if(B.length)Y=B[0]}else H("#tool_select","select");Za();f.runExtensions("selectedChanged",{elems:B,selectedElement:Y,multiselected:za})});f.bind("transition",function(q,B){var K=f.getMode(),Q=B[0];if(Q){za=B.length>=2&&B[1]!=null;if(!za)switch(K){case "rotate":K=
f.getRotationAngle(Q);a("#angle").val(Math.round(K));a("#tool_reorient").toggleClass("disabled",K==0)}f.runExtensions("elementTransition",{elems:B})}});f.bind("changed",function(q,B){var K=f.getMode();K==="select"&&ma();for(var Q=0;Q<B.length;++Q){var W=B[Q];if(W&&W.tagName==="svg"){Eb();Tb()}else if(W&&Y&&Y.parentNode==null)Y=W}c.show_save_warning=true;Za();if(Y&&K==="select"){la.fill.update();la.stroke.update()}f.runExtensions("elementChanged",{elems:B})});f.bind("saved",function(q,B){c.show_save_warning=
false;B='<?xml version="1.0"?>\n'+B;var K=navigator.userAgent;if(~K.indexOf("Chrome")&&a.browser.version>=533||~K.indexOf("MSIE"))E(0,true);else{var Q=q.open("data:image/svg+xml;base64,"+ca.encode64(B)),W=a.pref("save_notice_done");if(W!=="all"){var ia=e.notification.saveFromBrowser.replace("%s","SVG");if(K.indexOf("Gecko/")!==-1)if(B.indexOf("<defs")!==-1){ia+="\n\n"+e.notification.defsFailOnSave;a.pref("save_notice_done","all");W="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done",
"all");W!=="part"&&Q.alert(ia)}}});f.bind("exported",function(q,B){var K=B.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var Q=a("#export_canvas")[0];Q.width=f.contentW;Q.height=f.contentH;canvg(Q,B.svg,{renderCallback:function(){var W=Q.toDataURL("image/png");ba.location.href=W;if(a.pref("export_notice_done")!=="all"){W=e.notification.saveFromBrowser.replace("%s","PNG");if(K.length)W+="\n\n"+e.notification.noteTheseIssues+"\n \u2022 "+K.join("\n \u2022 ");
a.pref("export_notice_done","all");ba.alert(W)}}})});f.bind("zoomed",La);f.bind("contextset",function(q,B){var K="";if(B){var Q="";K='<a href="#" data-root="y">'+f.getCurrentDrawing().getCurrentLayerName()+"</a>";a(B).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){Q+=" > "+this.id;K+=this!==B?' > <a href="#">'+this.id+"</a>":" > "+this.id}});Ua=Q}else Ua=null;a("#cur_context_panel").toggle(!!B).html(K);C()});f.bind("extension_added",function(q,B){function K(){if(lb){clearTimeout(lb);
lb=null}W||(lb=setTimeout(function(){W=true;aa(b.iconsize)},50))}var Q=false,W=false,ia=true,va=function(){if(B.callback&&!Q&&ia){Q=true;B.callback()}},ya=[];B.context_tools&&a.each(B.context_tools,function(gb,ga){var zb=ga.container_id?' id="'+ga.container_id+'"':"",hb=a("#"+ga.panel);hb.length||(hb=a("<div>",{id:ga.panel}).appendTo("#tools_top"));switch(ga.type){case "tool_button":var Ta='<div class="tool_button">'+ga.id+"</div>",Pa=a(Ta).appendTo(hb);ga.events&&a.each(ga.events,function(ib,sb){a(Pa).bind(ib,
function(q,B){var K=f.getMode();K==="select"&&ma();K=K=="pathedit";Y=B.length==1||B[1]==null?B[0]:null;za=B.length>=2&&B[1]!=null;if(Y!=null)if(!K){if(Y!=null)switch(Y.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var R=null,W=Y.getElementsByTagName("*"),ia=0,va=W.length;ia<va;ia++){var ya=W[ia].getAttribute("stroke-width");if(ia===0)R=ya;else if(R!==ya)R=null}a("#stroke_width").val(R===null?"":R);la.fill.update(true);la.stroke.update(true);break;default:la.fill.update(true);
la.stroke.update(true);a("#stroke_width").val(Y.getAttribute("stroke-width")||1);a("#stroke_style").val(Y.getAttribute("stroke-dasharray")||"none");R=Y.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+R).length!=0&&z(a("#linejoin_"+R)[0]);R=Y.getAttribute("stroke-linecap")||"butt";a("#linecap_"+R).length!=0&&z(a("#linecap_"+R)[0])}if(Y!=null){R=(Y.getAttribute("opacity")||1)*100;a("#group_opacity").val(R);a("#opac_slider").slider("option","value",R);a("#elem_id").val(Y.id)}bc()}a("#path_node_panel").toggle(K);
a("#tools_bottom_2,#tools_bottom_3").toggle(!K);if(K){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");H("#tool_select","select_node");za=false;if(B.length)Y=B[0]}else H("#tool_select","select");Za();f.runExtensions("selectedChanged",{elems:B,selectedElement:Y,multiselected:za})});f.bind("transition",function(q,B){var K=f.getMode(),R=B[0];if(R){za=B.length>=2&&B[1]!=null;if(!za)switch(K){case "rotate":K=
f.getRotationAngle(R);a("#angle").val(Math.round(K));a("#tool_reorient").toggleClass("disabled",K==0)}f.runExtensions("elementTransition",{elems:B})}});f.bind("changed",function(q,B){var K=f.getMode();K==="select"&&ma();for(var R=0;R<B.length;++R){var W=B[R];if(W&&W.tagName==="svg"){Eb();Tb()}else if(W&&Y&&Y.parentNode==null)Y=W}c.show_save_warning=true;Za();if(Y&&K==="select"){la.fill.update();la.stroke.update()}f.runExtensions("elementChanged",{elems:B})});f.bind("saved",function(q,B){c.show_save_warning=
false;B='<?xml version="1.0"?>\n'+B;var K=navigator.userAgent;if(~K.indexOf("Chrome")&&a.browser.version>=533||~K.indexOf("MSIE"))E(0,true);else{var R=q.open("data:image/svg+xml;base64,"+ca.encode64(B)),W=a.pref("save_notice_done");if(W!=="all"){var ia=e.notification.saveFromBrowser.replace("%s","SVG");if(K.indexOf("Gecko/")!==-1)if(B.indexOf("<defs")!==-1){ia+="\n\n"+e.notification.defsFailOnSave;a.pref("save_notice_done","all");W="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done",
"all");W!=="part"&&R.alert(ia)}}});f.bind("exported",function(q,B){var K=B.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var R=a("#export_canvas")[0];R.width=f.contentW;R.height=f.contentH;canvg(R,B.svg,{renderCallback:function(){var W=R.toDataURL("image/png");ba.location.href=W;if(a.pref("export_notice_done")!=="all"){W=e.notification.saveFromBrowser.replace("%s","PNG");if(K.length)W+="\n\n"+e.notification.noteTheseIssues+"\n \u2022 "+K.join("\n \u2022 ");
a.pref("export_notice_done","all");ba.alert(W)}}})});f.bind("zoomed",Ma);f.bind("contextset",function(q,B){var K="";if(B){var R="";K='<a href="#" data-root="y">'+f.getCurrentDrawing().getCurrentLayerName()+"</a>";a(B).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){R+=" > "+this.id;K+=this!==B?' > <a href="#">'+this.id+"</a>":" > "+this.id}});Ua=R}else Ua=null;a("#cur_context_panel").toggle(!!B).html(K);C()});f.bind("extension_added",function(q,B){function K(){if(lb){clearTimeout(lb);
lb=null}W||(lb=setTimeout(function(){W=true;aa(b.iconsize)},50))}var R=false,W=false,ia=true,va=function(){if(B.callback&&!R&&ia){R=true;B.callback()}},ya=[];B.context_tools&&a.each(B.context_tools,function(gb,ga){var zb=ga.container_id?' id="'+ga.container_id+'"':"",hb=a("#"+ga.panel);hb.length||(hb=a("<div>",{id:ga.panel}).appendTo("#tools_top"));switch(ga.type){case "tool_button":var Ta='<div class="tool_button">'+ga.id+"</div>",Pa=a(Ta).appendTo(hb);ga.events&&a.each(ga.events,function(ib,sb){a(Pa).bind(ib,
sb)});break;case "select":Ta="<label"+zb+'><select id="'+ga.id+'">';a.each(ga.options,function(ib,sb){Ta+='<option value="'+ib+'"'+(ib==ga.defval?" selected":"")+">"+sb+"</option>"});Ta+="</select></label>";var Ya=a(Ta).appendTo(hb).find("select");a.each(ga.events,function(ib,sb){a(Ya).bind(ib,sb)});break;case "button-select":Ta='<div id="'+ga.id+'" class="dropdown toolset" title="'+ga.title+'"><div id="cur_'+ga.id+'" class="icon_label"></div><button></button></div>';zb=a('<ul id="'+ga.id+'_opts"></ul>').appendTo("#option_lists");
ga.colnum&&zb.addClass("optcols"+ga.colnum);a(Ta).appendTo(hb).children();ya.push({elem:"#"+ga.id,list:"#"+ga.id+"_opts",title:ga.title,callback:ga.events.change,cur:"#cur_"+ga.id});break;case "input":Ta="<label"+zb+'><span id="'+ga.id+'_label">'+ga.label+':</span><input id="'+ga.id+'" title="'+ga.title+'" size="'+(ga.size||"4")+'" value="'+(ga.defval||"")+'" type="text"/></label>';var Ba=a(Ta).appendTo(hb).find("input");ga.spindata&&Ba.SpinButton(ga.spindata);ga.events&&a.each(ga.events,function(ib,
sb){Ba.bind(ib,sb)})}});if(B.buttons){var Da={},Ha={},Aa=B.svgicons,fb={};a.each(B.buttons,function(gb,ga){for(var zb,hb=ga.id,Ta=gb;a("#"+hb).length;)hb=ga.id+"_"+ ++Ta;if(Aa){Da[hb]=ga.icon;Ta=ga.svgicon?ga.svgicon:ga.id;if(ga.type=="app_menu")Ha["#"+hb+" > div"]=Ta;else Ha["#"+hb]=Ta}else zb=ga.type=="menu"?"":a('<img src="'+ga.icon+'">');var Pa,Ya;switch(ga.type){case "mode_flyout":case "mode":Pa="tool_button";if(ga.cls)Pa+=" "+ga.cls;Ya="#tools_left";break;case "context":Pa="tool_button";Ya=
@ -431,48 +431,48 @@ a("#"+ga.list+"_opts").append(Ba);if(ga.isDefault){a("#cur_"+ga.list).append(Ba.
Pa[0].id]=[{sel:"#"+hb,fn:ga.events.click,icon:ga.id,key:ga.key,isDefault:ga.includeWith?ga.includeWith.isDefault:0},Fb];ib="position"in Ya?Ya.position:"last";Fb=Pa.children().length;if(!isNaN(ib)&&ib>=0&&ib<Fb)Pa.children().eq(ib).before(Ba);else{Pa.append(Ba);hb.reverse()}}Aa||Ba.append(zb);ga.list||a.each(ga.events,function(Yb,Mb){if(Yb=="click")if(ga.type=="mode"){ga.includeWith?Ba.bind(Yb,Mb):Ba.bind(Yb,function(){kb(Ba)&&Mb()});if(ga.key){a(document).bind("keydown",ga.key,Mb);ga.title&&Ba.attr("title",
ga.title+" ["+ga.key+"]")}}else Ba.bind(Yb,Mb);else Ba.bind(Yb,Mb)});Oa(fb)});a.each(ya,function(){nb(this.elem,this.list,this.callback,{seticon:true})});if(Aa)ia=false;a.svgIcons(Aa,{w:24,h:24,id_match:false,no_img:!O,fallback:Da,placement:Ha,callback:function(){b.iconsize&&b.iconsize!="m"&&K();ia=true;va()}})}va()});f.textActions.setInputElem(a("#text")[0]);var Ra='<div class="palette_item" data-rgb="#none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00",
"#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff","#aad4ff"],function(q,B){Ra+='<div class="palette_item" style="background-color: '+B+';" data-rgb="'+B+'"></div>'});a("#palette").append(Ra);Ra="";a.each(["#FFF","#888","#000"],function(){Ra+='<div class="color_block" style="background-color:'+
this+';"></div>'});a("#bg_blocks").append(Ra);var $a=a("#bg_blocks div");$a.each(function(){a(this).click(function(){$a.removeClass("cur_background");a(this).addClass("cur_background")})});if(a.pref("bkgd_color"))o(a.pref("bkgd_color"),a.pref("bkgd_url"));else a.pref("bkgd_url")&&o(p.bkgd_color,a.pref("bkgd_url"));if(a.pref("img_save")){b.img_save=a.pref("img_save");a("#image_save_opts input").val([b.img_save])}var Na=function(q){var B=q.value/100;if(B<0.0010)q.value=0.1;else{q=f.getZoom();La(window,
{width:0,height:0,x:(qa[0].scrollLeft+qa.width()/2)/q,y:(qa[0].scrollTop+qa.height()/2)/q,zoom:B},true)}},mb=function(q,B){if(B==null)B=q.value;a("#group_opacity").val(B);if(!q||!q.handle)a("#opac_slider").slider("option","value",B);f.setOpacity(B/100)},Ab=function(q,B,K){if(B==null)B=q.value;a("#blur").val(B);var Q=false;if(!q||!q.handle){a("#blur_slider").slider("option","value",B);Q=true}K?f.setBlurNoUndo(B):f.setBlur(B,Q)},cb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};
a("#stroke_style").change(function(){f.setStrokeAttr("stroke-dasharray",a(this).val());cb()});a("#stroke_linejoin").change(function(){f.setStrokeAttr("stroke-linejoin",a(this).val());cb()});a("select").change(function(){a(this).blur()});var jb=false;a("#selLayerNames").change(function(){var q=this.options[this.selectedIndex].value,B=e.notification.QmoveElemsToLayer.replace("%s",q),K=function(Q){if(Q){jb=true;f.moveSelectedToLayer(q);f.clearSelection();Eb()}};if(q)jb?K(true):a.confirm(B,K)});a("#font_family").change(function(){f.setFontFamily(this.value)});
this+';"></div>'});a("#bg_blocks").append(Ra);var $a=a("#bg_blocks div");$a.each(function(){a(this).click(function(){$a.removeClass("cur_background");a(this).addClass("cur_background")})});if(a.pref("bkgd_color"))o(a.pref("bkgd_color"),a.pref("bkgd_url"));else a.pref("bkgd_url")&&o(p.bkgd_color,a.pref("bkgd_url"));if(a.pref("img_save")){b.img_save=a.pref("img_save");a("#image_save_opts input").val([b.img_save])}var Ka=function(q){var B=q.value/100;if(B<0.0010)q.value=0.1;else{q=f.getZoom();Ma(window,
{width:0,height:0,x:(qa[0].scrollLeft+qa.width()/2)/q,y:(qa[0].scrollTop+qa.height()/2)/q,zoom:B},true)}},mb=function(q,B){if(B==null)B=q.value;a("#group_opacity").val(B);if(!q||!q.handle)a("#opac_slider").slider("option","value",B);f.setOpacity(B/100)},Ab=function(q,B,K){if(B==null)B=q.value;a("#blur").val(B);var R=false;if(!q||!q.handle){a("#blur_slider").slider("option","value",B);R=true}K?f.setBlurNoUndo(B):f.setBlur(B,R)},cb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};
a("#stroke_style").change(function(){f.setStrokeAttr("stroke-dasharray",a(this).val());cb()});a("#stroke_linejoin").change(function(){f.setStrokeAttr("stroke-linejoin",a(this).val());cb()});a("select").change(function(){a(this).blur()});var jb=false;a("#selLayerNames").change(function(){var q=this.options[this.selectedIndex].value,B=e.notification.QmoveElemsToLayer.replace("%s",q),K=function(R){if(R){jb=true;f.moveSelectedToLayer(q);f.clearSelection();Eb()}};if(q)jb?K(true):a.confirm(B,K)});a("#font_family").change(function(){f.setFontFamily(this.value)});
a("#seg_type").change(function(){f.setSegType(a(this).val())});a("#text").keyup(function(){f.setTextContent(this.value)});a("#image_url").change(function(){Ja(this.value)});a("#link_url").change(function(){this.value.length?f.setLinkURL(this.value):f.removeHyperlink()});a("#g_title").change(function(){f.setGroupTitle(this.value)});a(".attr_changer").change(function(){var q=this.getAttribute("data-attr"),B=this.value;if(svgedit.units.isValidUnit(q,B,Y))this.blur();else{a.alert(e.notification.invalidAttrValGiven);
this.value=Y.getAttribute(q);return false}if(q!=="id")if(isNaN(B))B=f.convertToNum(q,B);else if(d.baseUnit!=="px"){var K=svgedit.units.getTypeMap();if(Y[q]||f.getMode()==="pathedit"||q==="x"||q==="y")B*=K[d.baseUnit]}if(q==="id"){q=Y;f.clearSelection();q.id=B;f.addToSelection([q],true)}else f.changeSelectedAttribute(q,B);this.blur()});a("#palette").mouseover(function(){var q=a('<input type="hidden">');a(this).append(q);q.focus().remove()});a(".palette_item").mousedown(function(){var q=a("#tool_stroke").hasClass("active"),
B=q?"stroke":"fill",K=a(this).attr("data-rgb"),Q=null;console.log(K);if(K==="transparent"||K==="initial"||K==="#none"){K="none";Q=new a.jGraduate.Paint}else Q=new a.jGraduate.Paint({alpha:100,solidColor:K.substr(1)});la[B].setPaint(Q);if(q){f.setColor("stroke",K);K!="none"&&f.getStrokeOpacity()!=1&&f.setPaintOpacity("stroke",1)}else{f.setColor("fill",K);K!="none"&&f.getFillOpacity()!=1&&f.setPaintOpacity("fill",1)}bc()}).bind("contextmenu",function(q){q.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display",
B=q?"stroke":"fill",K=a(this).attr("data-rgb"),R=null;console.log(K);if(K==="transparent"||K==="initial"||K==="#none"){K="none";R=new a.jGraduate.Paint}else R=new a.jGraduate.Paint({alpha:100,solidColor:K.substr(1)});la[B].setPaint(R);if(q){f.setColor("stroke",K);K!="none"&&f.getStrokeOpacity()!=1&&f.setPaintOpacity("stroke",1)}else{f.setColor("fill",K);K!="none"&&f.getFillOpacity()!=1&&f.setPaintOpacity("fill",1)}bc()}).bind("contextmenu",function(q){q.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display",
"table-cell");a(this).addClass("expanded");xa()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");xa()});var kb=function(q,B){if(a(q).hasClass("disabled"))return false;if(a(q).parent().hasClass("tools_flyout"))return true;var K=K||"normal";B||a(".tools_flyout").fadeOut(K);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(q).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var q=
null,B=null,K=qa[0],Q=false,W=false;a("#svgcanvas").bind("mousemove mouseup",function(ia){if(Q!==false){K.scrollLeft-=ia.clientX-q;K.scrollTop-=ia.clientY-B;q=ia.clientX;B=ia.clientY;if(ia.type==="mouseup")Q=false;return false}}).mousedown(function(ia){if(ia.button===1||W===true){Q=true;q=ia.clientX;B=ia.clientY;return false}});a(window).mouseup(function(){Q=false});a(document).bind("keydown","space",function(ia){f.spaceKey=W=true;ia.preventDefault()}).bind("keyup","space",function(ia){ia.preventDefault();
null,B=null,K=qa[0],R=false,W=false;a("#svgcanvas").bind("mousemove mouseup",function(ia){if(R!==false){K.scrollLeft-=ia.clientX-q;K.scrollTop-=ia.clientY-B;q=ia.clientX;B=ia.clientY;if(ia.type==="mouseup")R=false;return false}}).mousedown(function(ia){if(ia.button===1||W===true){R=true;q=ia.clientX;B=ia.clientY;return false}});a(window).mouseup(function(){R=false});a(document).bind("keydown","space",function(ia){f.spaceKey=W=true;ia.preventDefault()}).bind("keyup","space",function(ia){ia.preventDefault();
f.spaceKey=W=false}).bind("keydown","alt",function(){f.getMode()==="zoom"&&qa.addClass("out")}).bind("keyup","alt",function(){f.getMode()==="zoom"&&qa.removeClass("out")})})();var Ca=a(".menu"),wb=function(q){q.target.style.background="#fff";setTimeout(function(){q.target.style.background="#ddd"},50);setTimeout(function(){q.target.style.background="#fff"},150);setTimeout(function(){q.target.style.background="#ddd"},200);setTimeout(function(){q.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},
220);return false};a(".menu_item").live("click",function(q){wb(q)});a("svg, body").on("click",function(q){top!=self&&!q.isTrigger&&typeof top.exports.setEditorFocus=="function"&&top.exports.setEditorFocus();if(!a(q.target).hasClass("menu_title")&&a("#menu_bar").hasClass("active"))if(!a(q.target).hasClass("disabled")&&a(q.target).hasClass("menu_item"))wb(q);else{a("#menu_bar").removeClass("active");a(".tools_flyout").hide();a("input").blur()}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});
a(".menu_title").on("mouseover",function(){Ca.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(q,B,K){if(a(q).length!=0){var Q=a(q).find("button"),W=a(q).find("ul").attr("id",a(q)[0].id+"-list");K||a("#option_lists").append(W);var ia=false;K&&a(q).addClass("dropup");W.find("li").bind("mouseup",B);a(window).mouseup(function(){if(!ia){Q.removeClass("down");W.hide()}ia=false});Q.bind("mousedown",function(){if(Q.hasClass("down")){Q.removeClass("down");W.hide()}else{Q.addClass("down");
if(!K){var va=a(q).offset();W.css({top:va.top,left:va.left-110})}W.show();ia=true}}).hover(function(){ia=true}).mouseout(function(){ia=false})}};var nb=function(q,B,K,Q){var W=a(q);B=a(B);var ia=false,va=Q.dropUp;va&&a(q).addClass("dropup");B.find("li").bind("mouseup",function(){if(Q.seticon){H("#cur_"+W[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}K.apply(this,arguments)});a(window).mouseup(function(){if(!ia){W.removeClass("down");B.hide();B.css({top:0,
left:0})}ia=false});B.height();a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=B.height();ya.left+=8}else ya.top+=a(q).height();a(B).offset(ya);if(W.hasClass("down")){W.removeClass("down");B.hide();B.css({top:0,left:0})}else{W.addClass("down");B.show();ia=true;return false}}).hover(function(){ia=true}).mouseout(function(){ia=false});Q.multiclick&&B.mousedown(function(){ia=true})};c.addDropDown("#font_family_dropdown",function(){a(this).text();a("#font_family").val(a(this).text()).change()});
a(".menu_title").on("mouseover",function(){Ca.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(q,B,K){if(a(q).length!=0){var R=a(q).find("button"),W=a(q).find("ul").attr("id",a(q)[0].id+"-list");K||a("#option_lists").append(W);var ia=false;K&&a(q).addClass("dropup");W.find("li").bind("mouseup",B);a(window).mouseup(function(){if(!ia){R.removeClass("down");W.hide()}ia=false});R.bind("mousedown",function(){if(R.hasClass("down")){R.removeClass("down");W.hide()}else{R.addClass("down");
if(!K){var va=a(q).offset();W.css({top:va.top,left:va.left-110})}W.show();ia=true}}).hover(function(){ia=true}).mouseout(function(){ia=false})}};var nb=function(q,B,K,R){var W=a(q);B=a(B);var ia=false,va=R.dropUp;va&&a(q).addClass("dropup");B.find("li").bind("mouseup",function(){if(R.seticon){H("#cur_"+W[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}K.apply(this,arguments)});a(window).mouseup(function(){if(!ia){W.removeClass("down");B.hide();B.css({top:0,
left:0})}ia=false});B.height();a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=B.height();ya.left+=8}else ya.top+=a(q).height();a(B).offset(ya);if(W.hasClass("down")){W.removeClass("down");B.hide();B.css({top:0,left:0})}else{W.addClass("down");B.show();ia=true;return false}}).hover(function(){ia=true}).mouseout(function(){ia=false});R.multiclick&&B.mousedown(function(){ia=true})};c.addDropDown("#font_family_dropdown",function(){a(this).text();a("#font_family").val(a(this).text()).change()});
c.addDropDown("#opacity_dropdown",function(){if(!a(this).find("div").length){var q=parseInt(a(this).text().split("%")[0]);mb(false,q)}},false);a("#opac_slider").slider({start:function(){a("#opacity_dropdown li:not(.special)").hide()},stop:function(){a("#opacity_dropdown li").show();a(window).mouseup()},slide:function(q,B){mb(B)}});c.addDropDown("#blur_dropdown",a.noop);var yb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(q,B){yb=false;Ab(B);a("#blur_dropdown li").show();a(window).mouseup()},
start:function(){yb=true},slide:function(q,B){Ab(B,null,yb)}});c.addDropDown("#zoom_dropdown",function(){var q=a(this),B=q.attr("data-val");B?La(window,B):Na({value:parseInt(q.text())})},true);nb("#stroke_linecap","#linecap_opts",function(){z(this,true)},{dropUp:true});nb("#stroke_linejoin","#linejoin_opts",function(){z(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,
start:function(){yb=true},slide:function(q,B){Ab(B,null,yb)}});c.addDropDown("#zoom_dropdown",function(){var q=a(this),B=q.attr("data-val");B?Ma(window,B):Ka({value:parseInt(q.text())})},true);nb("#stroke_linecap","#linecap_opts",function(){z(this,true)},{dropUp:true});nb("#stroke_linejoin","#linejoin_opts",function(){z(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,
"page")})});(function(){var q,B=function(){a(q).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){q=this;U="toolbars";qa.mousedown(B)}).blur(function(){U="canvas";qa.unbind("mousedown",B);f.getMode()=="textedit"&&a("#text").focus()})})();var Bb=function(){if(kb("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},ob=function(){kb("#tool_fhpath")&&f.setMode("fhpath")},Cb=
function(){kb("#tool_line")&&f.setMode("line")},Kb=function(){kb("#tool_rect")&&f.setMode("rect")},Ib=function(){kb("#tool_ellipse")&&f.setMode("ellipse")},Rb=function(){kb("#tool_image")&&f.setMode("image")},na=function(){kb("#tool_zoom")&&f.setMode("zoom")},Z=function(){if(kb("#tool_zoom")){h();ma()}},ta=function(){kb("#tool_text")&&f.setMode("text")},M=function(){kb("#tool_path")&&f.setMode("path")},I=function(){if(Y!=null||za)f.deleteSelectedElements()},X=function(){if(Y!=null||za)f.cutSelectedElements()},
Ma=function(){if(Y!=null||za)f.copySelectedElements()},Xa=function(){var q=f.getZoom(),B=(qa[0].scrollLeft+qa.width()/2)/q-f.contentW;q=(qa[0].scrollTop+qa.height()/2)/q-f.contentH;f.pasteElements("point",B,q)},db=function(){Y!=null&&f.moveToTopSelectedElement()},tb=function(){Y!=null&&f.moveToBottomSelectedElement()},xb=function(){Y!=null&&f.moveUpDownSelected("Up")},Hb=function(){Y!=null&&f.moveUpDownSelected("Down")},pb=function(){Y!=null&&f.convertToPath()},Lb=function(){Y!=null&&sa.reorient()},
Na=function(){if(Y!=null||za)f.copySelectedElements()},Xa=function(){var q=f.getZoom(),B=(qa[0].scrollLeft+qa.width()/2)/q-f.contentW;q=(qa[0].scrollTop+qa.height()/2)/q-f.contentH;f.pasteElements("point",B,q)},db=function(){Y!=null&&f.moveToTopSelectedElement()},tb=function(){Y!=null&&f.moveToBottomSelectedElement()},xb=function(){Y!=null&&f.moveUpDownSelected("Up")},Hb=function(){Y!=null&&f.moveUpDownSelected("Down")},pb=function(){Y!=null&&f.convertToPath()},Lb=function(){Y!=null&&sa.reorient()},
bb=function(){if(Y!=null||za)a.prompt(e.notification.enterNewLinkURL,"http://",function(q){q&&f.makeHyperlink(q)})},qb=function(q,B){if(Y!=null||za){if(d.gridSnapping){var K=f.getZoom()*d.snappingStep;q*=K;B*=K}f.moveSelectedElements(q,B)}},Qb=function(){var q=!a("#tool_node_link").hasClass("push_button_pressed");q?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button").find("input").attr("checked",true):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button").find("input").attr("checked",
false);sa.linkControlPoints(q)},$b=function(){sa.getNodePoint()&&sa.clonePathNode()},Zb=function(){sa.getNodePoint()&&sa.deletePathNode()},rb=function(){var q=a("#tool_add_subpath"),B=!q.hasClass("push_button_pressed");B?q.addClass("push_button_pressed").removeClass("tool_button"):q.removeClass("push_button_pressed").addClass("tool_button");sa.addSubPath(B)},Va=function(){sa.opencloseSubPath()},gc=function(){f.cycleElement(1)},cc=function(){f.cycleElement(0)},Ub=function(q,B){if(!(Y==null||za)){q||
(B*=-1);var K=a("#angle").val()*1+B;f.setRotationAngle(K);Za()}},hc=function(){var q=d.dimensions;a.confirm(e.notification.QwantToClear,function(B){if(B){ma();f.clear();f.setResolution(q[0],q[1]);Tb(true);h();Eb();Za();la.fill.prep();la.stroke.prep();f.runExtensions("onNewDocument")}})},lc=function(){f.setBold(!f.getBold());Za();return false},Wb=function(){f.setItalic(!f.getItalic());Za();return false},ac=function(){if(!l.pngsave){var q=e.notification.loadingImage;ba=window.open("data:text/html;charset=utf-8,<title>"+
q+"</title><h1>"+q+"</h1>")}window.canvg?f.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},nc=function(){f.open()},Vb=function(){},ub=function(q){var B=q.prev();B.css("background","#09f");setTimeout(function(){B.css("background","")},200)},ic=function(){if(ja.getUndoStackSize()>0){window.event.type==="keydown"&&ub(a("#edit_menu"));ja.undo();Eb()}},dc=function(){if(ja.getRedoStackSize()>0){window.event.type==="keydown"&&ub(a("#edit_menu"));
ja.redo();Eb()}},Sb=function(){if(za)f.groupSelectedElements();else Y&&f.ungroupSelectedElement()},vb=function(){window.event.type==="keydown"&&ub(a("#edit_menu"));f.cloneSelectedElements(20,20)},fc=function(){var q=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(q,a("#align_relative_to").val())},g=function(){var q=document.querySelector("#tool_stroke rect"),B=document.querySelector("#tool_fill rect"),K=B.getAttribute("fill"),Q=q.getAttribute("fill");q=parseFloat(q.getAttribute("stroke-opacity"));
if(isNaN(q))q=100;B=parseFloat(B.getAttribute("fill-opacity"));if(isNaN(B))B=100;Q=ab(Q,q,"stroke");K=ab(K,B,"fill");la.fill.setPaint(Q,true);la.stroke.setPaint(K,true)},h=function(q){var B=f.getResolution();q=q?B.zoom*q:1;a("#zoom").val(q*100);f.setZoom(q);t();Tb(true)},k=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");qa.toggleClass("wireframe");if(!kc){var q=a("#wireframe_rules");
q.length?q.empty():a('<style id="wireframe_rules"></style>').appendTo("head");t()}},v=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);d.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);d.showRulers=true}a("#rulers").toggle(!!d.showRulers)},t=function(){if(!kc){var q="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+
ja.redo();Eb()}},Sb=function(){if(za)f.groupSelectedElements();else Y&&f.ungroupSelectedElement()},vb=function(){window.event.type==="keydown"&&ub(a("#edit_menu"));f.cloneSelectedElements(20,20)},fc=function(){var q=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(q,a("#align_relative_to").val())},g=function(){var q=document.querySelector("#tool_stroke rect"),B=document.querySelector("#tool_fill rect"),K=B.getAttribute("fill"),R=q.getAttribute("fill");q=parseFloat(q.getAttribute("stroke-opacity"));
if(isNaN(q))q=100;B=parseFloat(B.getAttribute("fill-opacity"));if(isNaN(B))B=100;R=ab(R,q,"stroke");K=ab(K,B,"fill");la.fill.setPaint(R,true);la.stroke.setPaint(K,true)},h=function(q){var B=f.getResolution();q=q?B.zoom*q:1;a("#zoom").val(q*100);f.setZoom(q);s();Tb(true)},k=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");qa.toggleClass("wireframe");if(!kc){var q=a("#wireframe_rules");
q.length?q.empty():a('<style id="wireframe_rules"></style>').appendTo("head");s()}},v=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);d.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);d.showRulers=true}a("#rulers").toggle(!!d.showRulers)},s=function(){if(!kc){var q="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+
"px; }";a("#wireframe_rules").text(qa.hasClass("wireframe")?q:"")}},E=function(q,B){if(!Ia){Ia=true;a("#save_output_btns").toggle(!!B);a("#tool_source_back").toggle(!B);var K=ra=f.getSvgString();a("#svg_source_textarea").val(K);a("#svg_source_editor").fadeIn();A();a("#svg_source_textarea").focus()}},w=function(){if(!Qa){Qa=true;a("#image_save_opts input").val([b.img_save]);var q=f.getResolution();if(d.baseUnit!=="px"){q.w=svgedit.units.convertUnit(q.w)+d.baseUnit;q.h=svgedit.units.convertUnit(q.h)+
d.baseUnit}a(".canvas_width").val(q.w);a(".canvas_height").val(q.h);a("#canvas_title").val(f.getDocumentTitle());a("#svg_docprops").show()}},s=function(){if(!Ka){Ka=true;var q=a("#bg_blocks div"),B=a.pref("bkgd_color"),K=a.pref("bkgd_url");q.each(function(){var Q=a(this),W=Q.css("background-color")==B;Q.toggleClass("cur_background",W);W&&a("#canvas_bg_url").removeClass("cur_background")});B||q.eq(0).addClass("cur_background");K&&a("#canvas_bg_url").val(K);a("grid_snapping_step").attr("value",d.snappingStep);
d.baseUnit}a(".canvas_width").val(q.w);a(".canvas_height").val(q.h);a("#canvas_title").val(f.getDocumentTitle());a("#svg_docprops").show()}},t=function(){if(!La){La=true;var q=a("#bg_blocks div"),B=a.pref("bkgd_color"),K=a.pref("bkgd_url");q.each(function(){var R=a(this),W=R.css("background-color")==B;R.toggleClass("cur_background",W);W&&a("#canvas_bg_url").removeClass("cur_background")});B||q.eq(0).addClass("cur_background");K&&a("#canvas_bg_url").val(K);a("grid_snapping_step").attr("value",d.snappingStep);
d.gridSnapping==true?a("#grid_snapping_on").attr("checked","checked"):a("#grid_snapping_on").removeAttr("checked");a("#svg_prefs").show()}},A=function(){var q=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",q)},F=function(){if(Ia){var q=function(){f.clearSelection();wa();h();Eb();C();la.fill.prep();la.stroke.prep()};f.setSvgString(a("#svg_source_textarea").val())?q():a.confirm(e.notification.QerrorsRevertToSource,function(B){if(!B)return false;q()});ma()}},C=function(q){q=
q||f.getDocumentTitle();q=Wa+(q?": "+q:"");a("title:first").text(q)},D=function(){var q=a("#canvas_width"),B=q.val(),K=a("#canvas_height"),Q=K.val();if(B!="fit"&&!svgedit.units.isValidUnit("width",B)){a.alert(e.notification.invalidAttrValGiven);q.parent().addClass("error");return false}q.parent().removeClass("error");if(Q!="fit"&&!svgedit.units.isValidUnit("height",Q)){a.alert(e.notification.invalidAttrValGiven);K.parent().addClass("error");return false}K.parent().removeClass("error");if(!f.setResolution(B,
Q)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();a.pref("img_save",b.img_save);Tb();ha()},G=function(){var q=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";o(q,a("#canvas_bg_url").val());q=a("#lang_select").val();q!=b.lang&&c.putLocale(q);aa(a("#iconsize").val());d.gridSnapping=a("#grid_snapping_on")[0].checked;d.snappingStep=a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);
d.showRulers&&da();d.baseUnit=a("#base_unit").val();f.setConfig(d);Tb();ka()},H=c.setIcon=function(q,B){var K=typeof B==="string"?a.getSvgIcon(B,true):B.clone();K?a(q).find("img").replaceWith(K):console.log("NOTE: Icon image missing: "+B)},P;P=function(){var q=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,B=document.getElementsByTagName("script")[0],K;for(K in B.style)if(q.test(K))return K.match(q)[0];if("WebkitOpacity"in B.style)return"Webkit";if("KhtmlOpacity"in B.style)return"Khtml";return""}();var R=
function(q,B){P.toLowerCase();var K=["top","left","bottom","right"];q.each(function(){for(var Q=a(this),W=Q.outerWidth()*(B-1),ia=Q.outerHeight()*(B-1),va=0;va<4;va++){var ya=K[va],Da=Q.data("orig_margin-"+ya);if(Da==null){Da=parseInt(Q.css("margin-"+ya));Q.data("orig_margin-"+ya,Da)}Da=Da*B;if(ya==="right")Da+=W;else if(ya==="bottom")Da+=ia;Q.css("margin-"+ya,Da)}})},aa=c.setIconSize=function(q,B){if(!(q==b.size&&!B)){console.log("size",q);var K=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),
Q=1;Q=typeof q=="number"?q:{s:0.75,m:1,l:1.25,xl:1.5}[q];c.tool_scale=S=Q;Gb();var W=K.parents(":hidden");W.css("visibility","hidden").show();R(K,Q);W.css("visibility","visible").hide();a.pref("iconsize",q);a("#iconsize").val(q);W={"#tools_top":{left:50,height:72},"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};K=a("#tool_size_rules");if(K.length)K.empty();else K=a('<style id="tool_size_rules"></style>').appendTo("head");if(q!="m"){var ia="";a.each(W,function(va,ya){va="#svg_editor "+
va.replace(/,/g,", #svg_editor");ia+=va+"{";a.each(ya,function(Da,Ha){if(typeof Ha==="number")var Aa=Ha*Q+"px";else if(Ha[q]||Ha.all)Aa=Ha[q]||Ha.all;ia+=Da+":"+Aa+";"});ia+="}"});W="-"+P.toLowerCase()+"-";ia+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+W+"transform: scale("+Q+");} #svg_editor div.toolset .toolset {"+W+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+
W+"transform: scale("+1/Q+");}";K.text(ia)}Gb()}},ua=function(){a("#dialog_box").hide();if(!Ia&&!Qa&&!Ka)Ua&&f.leaveContext();else{if(Ia)ra!==a("#svg_source_textarea").val()?a.confirm(e.notification.QignoreSourceChanges,function(q){q&&wa()}):wa();else if(Qa)ha();else Ka&&ka();xa()}},wa=function(){a("#svg_source_editor").hide();Ia=false;a("#svg_source_textarea").blur()},ha=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=
0;a("#image_save_opts input").val([b.img_save]);Qa=false},ka=function(){a("#svg_prefs").hide();Ka=false},oa={width:a(window).width(),height:a(window).height()},xa=a.noop,eb;svgedit.browser.isIE()&&function(){xa=function(){if(qa[0].scrollLeft===0&&qa[0].scrollTop===0){qa[0].scrollLeft=eb.left;qa[0].scrollTop=eb.top}};eb={left:qa[0].scrollLeft,top:qa[0].scrollTop};a(window).resize(xa);svgEditor.ready(function(){setTimeout(function(){xa()},500)});qa.scroll(function(){eb={left:qa[0].scrollLeft,top:qa[0].scrollTop}})}();
q||f.getDocumentTitle();q=Wa+(q?": "+q:"");a("title:first").text(q)},D=function(){var q=a("#canvas_width"),B=q.val(),K=a("#canvas_height"),R=K.val();if(B!="fit"&&!svgedit.units.isValidUnit("width",B)){a.alert(e.notification.invalidAttrValGiven);q.parent().addClass("error");return false}q.parent().removeClass("error");if(R!="fit"&&!svgedit.units.isValidUnit("height",R)){a.alert(e.notification.invalidAttrValGiven);K.parent().addClass("error");return false}K.parent().removeClass("error");if(!f.setResolution(B,
R)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();a.pref("img_save",b.img_save);Tb();ha()},G=function(){var q=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";o(q,a("#canvas_bg_url").val());q=a("#lang_select").val();q!=b.lang&&c.putLocale(q);aa(a("#iconsize").val());d.gridSnapping=a("#grid_snapping_on")[0].checked;d.snappingStep=a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);
d.showRulers&&da();d.baseUnit=a("#base_unit").val();f.setConfig(d);Tb();ka()},H=c.setIcon=function(q,B){var K=typeof B==="string"?a.getSvgIcon(B,true):B.clone();K?a(q).find("img").replaceWith(K):console.log("NOTE: Icon image missing: "+B)},P;P=function(){var q=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,B=document.getElementsByTagName("script")[0],K;for(K in B.style)if(q.test(K))return K.match(q)[0];if("WebkitOpacity"in B.style)return"Webkit";if("KhtmlOpacity"in B.style)return"Khtml";return""}();var Q=
function(q,B){P.toLowerCase();var K=["top","left","bottom","right"];q.each(function(){for(var R=a(this),W=R.outerWidth()*(B-1),ia=R.outerHeight()*(B-1),va=0;va<4;va++){var ya=K[va],Da=R.data("orig_margin-"+ya);if(Da==null){Da=parseInt(R.css("margin-"+ya));R.data("orig_margin-"+ya,Da)}Da=Da*B;if(ya==="right")Da+=W;else if(ya==="bottom")Da+=ia;R.css("margin-"+ya,Da)}})},aa=c.setIconSize=function(q,B){if(!(q==b.size&&!B)){console.log("size",q);var K=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),
R=1;R=typeof q=="number"?q:{s:0.75,m:1,l:1.25,xl:1.5}[q];c.tool_scale=S=R;Gb();var W=K.parents(":hidden");W.css("visibility","hidden").show();Q(K,R);W.css("visibility","visible").hide();a.pref("iconsize",q);a("#iconsize").val(q);W={"#tools_top":{left:50,height:72},"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};K=a("#tool_size_rules");if(K.length)K.empty();else K=a('<style id="tool_size_rules"></style>').appendTo("head");if(q!="m"){var ia="";a.each(W,function(va,ya){va="#svg_editor "+
va.replace(/,/g,", #svg_editor");ia+=va+"{";a.each(ya,function(Da,Ha){if(typeof Ha==="number")var Aa=Ha*R+"px";else if(Ha[q]||Ha.all)Aa=Ha[q]||Ha.all;ia+=Da+":"+Aa+";"});ia+="}"});W="-"+P.toLowerCase()+"-";ia+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+W+"transform: scale("+R+");} #svg_editor div.toolset .toolset {"+W+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+
W+"transform: scale("+1/R+");}";K.text(ia)}Gb()}},ua=function(){a("#dialog_box").hide();if(!Ia&&!Qa&&!La)Ua&&f.leaveContext();else{if(Ia)ra!==a("#svg_source_textarea").val()?a.confirm(e.notification.QignoreSourceChanges,function(q){q&&wa()}):wa();else if(Qa)ha();else La&&ka();xa()}},wa=function(){a("#svg_source_editor").hide();Ia=false;a("#svg_source_textarea").blur()},ha=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=
0;a("#image_save_opts input").val([b.img_save]);Qa=false},ka=function(){a("#svg_prefs").hide();La=false},oa={width:a(window).width(),height:a(window).height()},xa=a.noop,eb;svgedit.browser.isIE()&&function(){xa=function(){if(qa[0].scrollLeft===0&&qa[0].scrollTop===0){qa[0].scrollLeft=eb.left;qa[0].scrollTop=eb.top}};eb={left:qa[0].scrollLeft,top:qa[0].scrollTop};a(window).resize(xa);svgEditor.ready(function(){setTimeout(function(){xa()},500)});qa.scroll(function(){eb={left:qa[0].scrollLeft,top:qa[0].scrollTop}})}();
a(window).resize(function(){Ia&&A();a.each(oa,function(q,B){var K=a(window)[q]();qa[0]["scroll"+(q==="width"?"Left":"Top")]-=(K-B)/2;oa[q]=K})});(function(){qa.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=qa[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=qa[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(L);(function(){var q=["clear","open","save","source","delete","delete_multi","paste","clone",
"clone_multi","move_top","move_bottom"],B="";a.each(q,function(K,Q){B+="#tool_"+Q+(K==q.length-1?",":"")});a(B).mousedown(function(){a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")});a("#tool_undo, #tool_redo").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")})})();if(V&&!window.opera){V=["tool_clear",
"tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(Sa=V.length;Sa--;){var Db=document.getElementById(V[Sa]);if(Db!=null){var Pb=Db.title,Jb=Pb.indexOf("Ctrl+");Db.title=[Pb.substr(0,Jb),"Cmd+",Pb.substr(Jb+5)].join("")}}}var Ob=function(q){var B=q.attr("id")=="stroke_color"?"stroke":"fill",K=la[B].paint,Q=B=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";q=q.position();a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",
containment:"window"}).css(d.colorPickerCSS||{left:q.left,bottom:50-q.top}).jGraduate({paint:K,window:{pickerTitle:Q},images:{clientPath:d.jGraduatePath},newstop:"inverse"},function(W){K=new a.jGraduate.Paint(W);la[B].setPaint(K);f.setPaint(B,K);a("#color_picker").hide()},function(){a("#color_picker").hide()})},bc=function(){var q=f.getColor("fill")=="none",B=f.getColor("stroke")=="none",K=["#tool_fhpath","#tool_line"],Q=["#tools_rect .tool_button","#tools_ellipse .tool_button","#tool_text","#tool_path"];
if(B)for(var W in K){var ia=K[W];a(ia).hasClass("tool_button_current")&&Bb();a(ia).addClass("disabled")}else for(W in K){ia=K[W];a(ia).removeClass("disabled")}if(B&&q)for(W in Q){ia=Q[W];a(ia).hasClass("tool_button_current")&&Bb();a(ia).addClass("disabled")}else for(W in Q){ia=Q[W];a(ia).removeClass("disabled")}f.runExtensions("toolButtonStateUpdate",{nofill:q,nostroke:B});a(".tools_flyout").each(function(){var va=a("#"+this.id+"_show"),ya=false;a(this).children().each(function(){a(this).hasClass("disabled")||
(ya=true)});va.toggleClass("disabled",!ya)});cb()};V=function(q,B){var K=d[B==="fill"?"initFill":"initStroke"],Q=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+K.color+'" opacity="'+K.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;Q=a(q)[0].appendChild(document.importNode(Q,true));Q.setAttribute("width",24.5);this.rect=Q.firstChild;this.defs=Q.getElementsByTagName("defs")[0];
"clone_multi","move_top","move_bottom"],B="";a.each(q,function(K,R){B+="#tool_"+R+(K==q.length-1?",":"")});a(B).mousedown(function(){a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")});a("#tool_undo, #tool_redo").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")})})();if(V&&!window.opera){V=["tool_clear",
"tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(Sa=V.length;Sa--;){var Db=document.getElementById(V[Sa]);if(Db!=null){var Pb=Db.title,Jb=Pb.indexOf("Ctrl+");Db.title=[Pb.substr(0,Jb),"Cmd+",Pb.substr(Jb+5)].join("")}}}var Ob=function(q){var B=q.attr("id")=="stroke_color"?"stroke":"fill",K=la[B].paint,R=B=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";q=q.position();a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",
containment:"window"}).css(d.colorPickerCSS||{left:q.left,bottom:50-q.top}).jGraduate({paint:K,window:{pickerTitle:R},images:{clientPath:d.jGraduatePath},newstop:"inverse"},function(W){K=new a.jGraduate.Paint(W);la[B].setPaint(K);f.setPaint(B,K);a("#color_picker").hide()},function(){a("#color_picker").hide()})},bc=function(){var q=f.getColor("fill")=="none",B=f.getColor("stroke")=="none",K=["#tool_fhpath","#tool_line"],R=["#tools_rect .tool_button","#tools_ellipse .tool_button","#tool_text","#tool_path"];
if(B)for(var W in K){var ia=K[W];a(ia).hasClass("tool_button_current")&&Bb();a(ia).addClass("disabled")}else for(W in K){ia=K[W];a(ia).removeClass("disabled")}if(B&&q)for(W in R){ia=R[W];a(ia).hasClass("tool_button_current")&&Bb();a(ia).addClass("disabled")}else for(W in R){ia=R[W];a(ia).removeClass("disabled")}f.runExtensions("toolButtonStateUpdate",{nofill:q,nostroke:B});a(".tools_flyout").each(function(){var va=a("#"+this.id+"_show"),ya=false;a(this).children().each(function(){a(this).hasClass("disabled")||
(ya=true)});va.toggleClass("disabled",!ya)});cb()};V=function(q,B){var K=d[B==="fill"?"initFill":"initStroke"],R=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+K.color+'" opacity="'+K.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;R=a(q)[0].appendChild(document.importNode(R,true));R.setAttribute("width",24.5);this.rect=R.firstChild;this.defs=R.getElementsByTagName("defs")[0];
this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:K.color});this.type=B;this.setPaint=function(W,ia){this.paint=W;var va="none",ya=W.type,Da=W.alpha/100;switch(ya){case "solidColor":va="#"+W[ya];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(W[ya]);va="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",va);this.rect.setAttribute("opacity",Da);if(ia){f.setColor(this.type,va,true);
f.setPaintOpacity(this.type,Da,true)}};this.update=function(W){if(Y){var ia=this.type;switch(Y.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var va=null,ya=Y.getElementsByTagName("*"),Da=0,Ha=ya.length;Da<Ha;Da++){var Aa=ya[Da].getAttribute(ia);if(Da===0)va=Aa;else if(va!==Aa){va=null;break}}if(va===null){ya=null;return}ya=va;va=1;break;default:va=parseFloat(Y.getAttribute(ia+"-opacity"));if(isNaN(va))va=1;ya=ia==="fill"?"black":"none";ya=Y.getAttribute(ia)||ya}if(W){f.setColor(ia,
ya,true);f.setPaintOpacity(ia,va,true)}va*=100;this.setPaint(ab(ya,va,ia))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var W=new a.jGraduate.Paint({copy:this.paint});f.setPaint(B,W)}}};la.fill=new V("#fill_color","fill");la.stroke=new V("#stroke_color","stroke");a("#stroke_width").val(d.initStroke.width);a("#group_opacity").val(d.initOpacity*100);V=la.fill.rect.cloneNode(false);V.setAttribute("style","vector-effect:non-scaling-stroke");var kc=V.style.vectorEffect===
@ -482,34 +482,34 @@ a("#zoomLabel").click(function(){a("#zoom_dropdown button").mousedown();a(window
a("#layer_new").click(function(){var q=f.getCurrentDrawing().getNumLayers();do var B=e.layers.layer+" "+ ++q;while(f.getCurrentDrawing().hasLayer(B));a.prompt(e.notification.enterUniqueLayerName,B,function(K){if(K)if(f.getCurrentDrawing().hasLayer(K))a.alert(e.notification.dupeLayerName);else{f.createLayer(K);Za();Eb()}})});a("#layer_delete").click(T);a("#layer_up").click(function(){J(-1)});a("#layer_down").click(function(){J(1)});a("#layer_rename").click(function(){a("#layerlist tr.layersel").prevAll();
var q=a("#layerlist tr.layersel td.layername").text();a.prompt(e.notification.enterNewLayerName,"",function(B){if(B)if(q==B||f.getCurrentDrawing().hasLayer(B))a.alert(e.notification.layerHasThatName);else{f.renameCurrentLayer(B);Eb()}})});var ec=-1,mc=false,pc=false,rc=function(q){if(pc)if(ec!=-1){mc=true;q=ec-q.pageX;var B=a("#sidepanels"),K=parseInt(B.css("width"));if(K+q>300)q=300-K;else if(K+q<2)q=2-K;if(q!=0){ec-=q;K=a("#layerpanel");qa.css("right",parseInt(qa.css("right"))+q);B.css("width",
parseInt(B.css("width"))+q);K.css("width",parseInt(K.css("width"))+q);B=a("#ruler_x");B.css("right",parseInt(B.css("right"))+q)}}};a("#sidepanel_handle").mousedown(function(q){ec=q.pageX;a(window).mousemove(rc);pc=false;setTimeout(function(){pc=true},20)}).mouseup(function(){mc||sc();ec=-1;mc=false});a(window).mouseup(function(){ec=-1;mc=false;a("#svg_editor").unbind("mousemove",rc)});var sc=function(q){var B=parseInt(a("#sidepanels").css("width"));q=(B>2||q?2:150)-B;B=a("#sidepanels");var K=a("#layerpanel"),
Q=a("#ruler_x");qa.css("right",parseInt(qa.css("right"))+q);B.css("width",parseInt(B.css("width"))+q);K.css("width",parseInt(K.css("width"))+q);Q.css("right",parseInt(Q.css("right"))+q)},tc=function(q){for(var B=Array(f.getCurrentDrawing().getNumLayers()),K=0;K<B.length;++K)B[K]=f.getCurrentDrawing().getLayerName(K);if(q)for(K=0;K<B.length;++K)B[K]!=q&&f.getCurrentDrawing().setLayerOpacity(B[K],0.5);else for(K=0;K<B.length;++K)f.getCurrentDrawing().setLayerOpacity(B[K],1)},Eb=function(){var q=a("#layerlist tbody"),
B=a("#selLayerNames");q.empty();B.empty();for(var K=f.getCurrentDrawing().getCurrentLayerName(),Q=f.getCurrentDrawing().getNumLayers(),W=a.getSvgIcon("eye");Q--;){var ia=f.getCurrentDrawing().getLayerName(Q),va='<tr class="layer';if(ia==K)va+=" layersel";va+='">';va+=f.getCurrentDrawing().getLayerVisibility(ia)?'<td class="layervis"/><td class="layername" >'+ia+"</td></tr>":'<td class="layervis layerinvis"/><td class="layername" >'+ia+"</td></tr>";q.append(va);B.append('<option value="'+ia+'">'+ia+
R=a("#ruler_x");qa.css("right",parseInt(qa.css("right"))+q);B.css("width",parseInt(B.css("width"))+q);K.css("width",parseInt(K.css("width"))+q);R.css("right",parseInt(R.css("right"))+q)},tc=function(q){for(var B=Array(f.getCurrentDrawing().getNumLayers()),K=0;K<B.length;++K)B[K]=f.getCurrentDrawing().getLayerName(K);if(q)for(K=0;K<B.length;++K)B[K]!=q&&f.getCurrentDrawing().setLayerOpacity(B[K],0.5);else for(K=0;K<B.length;++K)f.getCurrentDrawing().setLayerOpacity(B[K],1)},Eb=function(){var q=a("#layerlist tbody"),
B=a("#selLayerNames");q.empty();B.empty();for(var K=f.getCurrentDrawing().getCurrentLayerName(),R=f.getCurrentDrawing().getNumLayers(),W=a.getSvgIcon("eye");R--;){var ia=f.getCurrentDrawing().getLayerName(R),va='<tr class="layer';if(ia==K)va+=" layersel";va+='">';va+=f.getCurrentDrawing().getLayerVisibility(ia)?'<td class="layervis"/><td class="layername" >'+ia+"</td></tr>":'<td class="layervis layerinvis"/><td class="layername" >'+ia+"</td></tr>";q.append(va);B.append('<option value="'+ia+'">'+ia+
"</option>")}if(W!==undefined){W.clone();a("td.layervis",q).append(W.clone());a.resizeSvgIcons({"td.layervis .svg_icon":14})}a("#layerlist td.layername").mouseup(function(ya){a("#layerlist tr.layer").removeClass("layersel");a(this.parentNode).addClass("layersel");f.setCurrentLayer(this.textContent);ya.preventDefault()}).mouseover(function(){a(this).css({"font-style":"italic",color:"blue"});tc(this.textContent)}).mouseout(function(){a(this).css({"font-style":"normal",color:"black"});tc()});a("#layerlist td.layervis").click(function(){var ya=
a(this.parentNode).prevAll().length;ya=a("#layerlist tr.layer:eq("+ya+") td.layername").text();var Da=a(this).hasClass("layerinvis");f.setLayerVisibility(ya,Da);Da?a(this).removeClass("layerinvis"):a(this).addClass("layerinvis")});for(B=5-a("#layerlist tr.layer").size();B-- >0;)q.append('<tr><td style="color:white">_</td><td/></tr>')};Eb();a(window).bind("load resize",function(){qa.css("line-height",qa.height()+"px")});a("#resolution").change(function(){var q=a("#canvas_width,#canvas_height");if(this.selectedIndex)if(this.value==
"content")q.val("fit").attr("disabled","disabled");else{var B=this.value.split("x");a("#canvas_width").val(B[0]);a("#canvas_height").val(B[1]);q.removeAttr("disabled")}else a("#canvas_width").val()=="fit"&&q.removeAttr("disabled").val(100)});a("input,select").attr("autocomplete","off");var oc=function(){var q=[{sel:"#tool_select",fn:Bb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:ob,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Cb,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Kb,evt:"click",
key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ib,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:M,evt:"click",key:["P",true]},{sel:"#tool_text",fn:ta,evt:"click",key:["T",true]},{sel:"#tool_image",fn:Rb,evt:"mouseup"},{sel:"#tool_zoom",fn:na,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:hc,evt:"mouseup",key:[fa+"N",true]},{sel:"#tool_save",fn:function(){Ia?F():f.save({images:b.img_save,round_digits:6})},evt:"mouseup",key:[fa+"S",true]},{sel:"#tool_export",fn:ac,evt:"mouseup"},
{sel:"#tool_open",fn:nc,evt:"mouseup"},{sel:"#tool_import",fn:Vb,evt:"mouseup"},{sel:"#tool_source",fn:E,evt:"click",key:[fa+"U",true]},{sel:"#tool_wireframe",fn:k,evt:"click"},{sel:"#tool_rulers",fn:v,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:ua,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:F,evt:"click"},{sel:"#tool_docprops_save",fn:D,evt:"click"},{sel:"#tool_docprops",fn:w,evt:"mouseup"},{sel:"#tool_prefs_save",
fn:G,evt:"click"},{sel:"#tool_prefs_option",fn:function(){s();return false},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:I,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:Lb,evt:"click"},{sel:"#tool_node_link",fn:Qb,evt:"click"},{sel:"#tool_node_clone",fn:$b,evt:"click"},{sel:"#tool_node_delete",fn:Zb,evt:"click"},{sel:"#tool_openclose_path",fn:Va,evt:"click"},{sel:"#tool_add_subpath",fn:rb,evt:"click"},{sel:"#tool_move_top",fn:db,evt:"click",key:fa+"shift+up"},{sel:"#tool_move_bottom",
fn:G,evt:"click"},{sel:"#tool_prefs_option",fn:function(){t();return false},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:I,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:Lb,evt:"click"},{sel:"#tool_node_link",fn:Qb,evt:"click"},{sel:"#tool_node_clone",fn:$b,evt:"click"},{sel:"#tool_node_delete",fn:Zb,evt:"click"},{sel:"#tool_openclose_path",fn:Va,evt:"click"},{sel:"#tool_add_subpath",fn:rb,evt:"click"},{sel:"#tool_move_top",fn:db,evt:"click",key:fa+"shift+up"},{sel:"#tool_move_bottom",
fn:tb,evt:"click",key:fa+"shift+down"},{sel:"#tool_move_up",fn:xb,evt:"click",key:[fa+"up",true]},{sel:"#tool_move_down",fn:Hb,evt:"click",key:[fa+"down",true]},{sel:"#tool_topath",fn:pb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:bb,evt:"click"},{sel:"#tool_undo",fn:ic,evt:"click",key:[fa+"Z",true]},{sel:"#tool_redo",fn:dc,evt:"click",key:["Y",true]},{sel:"#tool_clone,#tool_clone_multi",fn:vb,evt:"click",key:[fa+"D",true]},{sel:"#tool_group",fn:Sb,evt:"click",key:[fa+"G",true]},
{sel:"#tool_ungroup",fn:Sb,evt:"click",key:fa+"shift+G"},{sel:"#tool_unlink_use",fn:Sb,evt:"click"},{sel:"[id^=tool_align]",fn:fc,evt:"click"},{sel:"#tool_switch",fn:g,evt:"click",key:["X",true]},{sel:"#tool_bold",fn:lc,evt:"mousedown",key:[fa+"B",true]},{sel:"#tool_italic",fn:Wb,evt:"mousedown",key:[fa+"I",true]},{sel:"#copy_save_done",fn:ua,evt:"click"},{key:"ctrl+left",fn:function(){Ub(0,1)}},{key:"ctrl+right",fn:function(){Ub(1,1)}},{key:"ctrl+shift+left",fn:function(){Ub(0,5)}},{key:"ctrl+shift+right",
fn:function(){Ub(1,5)}},{key:"shift+O",fn:cc},{key:"shift+P",fn:gc},{key:[fa+"+",true],fn:function(){h(2)}},{key:[fa+"-",true],fn:function(){h(0.5)}},{key:["up",true],fn:function(){qb(0,-1)}},{key:["down",true],fn:function(){qb(0,1)}},{key:["left",true],fn:function(){qb(-1,0)}},{key:["right",true],fn:function(){qb(1,0)}},{key:"shift+up",fn:function(){qb(0,-10)}},{key:"shift+down",fn:function(){qb(0,10)}},{key:"shift+left",fn:function(){qb(-10,0)}},{key:"shift+right",fn:function(){qb(10,0)}},{key:["alt+up",
true],fn:function(){f.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){f.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){f.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){f.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){f.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){f.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){f.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",
true],fn:function(){f.cloneSelectedElements(10,0)}},{key:fa+"A",fn:function(){f.selectAllInCurrentLayer()}},{key:fa+"z",fn:ic},{key:fa+"shift+z",fn:dc},{key:fa+"y",fn:dc},{key:fa+"x",fn:X},{key:fa+"c",fn:Ma},{key:fa+"v",fn:Xa}],B={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var K={};a.each(q,function(Q,W){if(W.sel){var ia=a(W.sel);if(ia.length==0)return true;if(W.evt){if(svgedit.browser.isTouch()&&W.evt==="click")W.evt="mousedown";ia[W.evt](W.fn)}if(W.parent&&
true],fn:function(){f.cloneSelectedElements(10,0)}},{key:fa+"A",fn:function(){f.selectAllInCurrentLayer()}},{key:fa+"z",fn:ic},{key:fa+"shift+z",fn:dc},{key:fa+"y",fn:dc},{key:fa+"x",fn:X},{key:fa+"c",fn:Na},{key:fa+"v",fn:Xa}],B={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var K={};a.each(q,function(R,W){if(W.sel){var ia=a(W.sel);if(ia.length==0)return true;if(W.evt){if(svgedit.browser.isTouch()&&W.evt==="click")W.evt="mousedown";ia[W.evt](W.fn)}if(W.parent&&
a(W.parent+"_show").length!=0){var va=a(W.parent);va.length||(va=Fa(W.parent.substr(1)));va.append(ia);a.isArray(K[W.parent])||(K[W.parent]=[]);K[W.parent].push(W)}}if(W.key){var ya=W.fn,Da=false;if(a.isArray(W.key)){va=W.key[0];if(W.key.length>1)Da=W.key[1]}else va=W.key;va+="";svgedit.browser.isMac&&va.indexOf("+")!=-1&&va.split("+")[0]=="ctrl"&&va.replace("ctrl","cmd");a.each(va.split("/"),function(Aa,fb){a(document).bind("keydown",fb,function(gb){ya();Da&&gb.preventDefault();return false})});
if(W.sel&&!W.hidekey&&ia.attr("title")){var Ha=ia.attr("title").split("[")[0]+" ("+va+")";B[va]=W.sel;ia.parents("#main_menu").length||ia.attr("title",Ha)}}});Oa(K);a(".attr_changer, #image_url").bind("keydown","return",function(Q){a(this).change();Q.preventDefault()});a(window).bind("keydown","tab",function(Q){if(U==="canvas"){Q.preventDefault();gc()}}).bind("keydown","shift+tab",function(Q){if(U==="canvas"){Q.preventDefault();cc()}});a("#tool_zoom").dblclick(Z)},setTitles:function(){a.each(B,function(K,
Q){var W=a(Q).parents("#main_menu").length;a(Q).each(function(){var ia=W?a(this).text().split(" [")[0]:this.title.split(" [")[0],va="";a.each(K.split("/"),function(ya,Da){var Ha=Da.split("+"),Aa="";if(Ha.length>1){Aa=Ha[0]+"+";Da=Ha[1]}va+=(ya?"/":"")+Aa+(e["key_"+Da]||Da)});if(W)this.lastChild.textContent=ia+" ["+va+"]";else this.title=ia+" ["+va+"]"})})},getButtonData:function(K){var Q;a.each(q,function(W,ia){if(ia.sel===K)Q=ia});return Q}}}();oc.setAll();c.ready(function(){var q=d.initTool,B=a("#tools_left, #svg_editor .tools_flyout"),
if(W.sel&&!W.hidekey&&ia.attr("title")){var Ha=ia.attr("title").split("[")[0]+" ("+va+")";B[va]=W.sel;ia.parents("#main_menu").length||ia.attr("title",Ha)}}});Oa(K);a(".attr_changer, #image_url").bind("keydown","return",function(R){a(this).change();R.preventDefault()});a(window).bind("keydown","tab",function(R){if(U==="canvas"){R.preventDefault();gc()}}).bind("keydown","shift+tab",function(R){if(U==="canvas"){R.preventDefault();cc()}});a("#tool_zoom").dblclick(Z)},setTitles:function(){a.each(B,function(K,
R){var W=a(R).parents("#main_menu").length;a(R).each(function(){var ia=W?a(this).text().split(" [")[0]:this.title.split(" [")[0],va="";a.each(K.split("/"),function(ya,Da){var Ha=Da.split("+"),Aa="";if(Ha.length>1){Aa=Ha[0]+"+";Da=Ha[1]}va+=(ya?"/":"")+Aa+(e["key_"+Da]||Da)});if(W)this.lastChild.textContent=ia+" ["+va+"]";else this.title=ia+" ["+va+"]"})})},getButtonData:function(K){var R;a.each(q,function(W,ia){if(ia.sel===K)R=ia});return R}}}();oc.setAll();c.ready(function(){var q=d.initTool,B=a("#tools_left, #svg_editor .tools_flyout"),
K=B.find("#tool_"+q);q=B.find("#"+q);(K.length?K:q.length?q:a("#tool_select")).click().mouseup();d.wireframe&&a("#tool_wireframe").click();d.showlayers&&sc();a("#rulers").toggle(!!d.showRulers);if(d.showRulers)a("#show_rulers")[0].checked=true;if(d.gridSnapping)a("#grid_snapping_on")[0].checked=true;d.baseUnit&&a("#base_unit").val(d.baseUnit);d.snappingStep&&a("#grid_snapping_step").val(d.snappingStep)});a("#rect_rx").SpinButton({min:0,max:1E3,step:1,callback:function(q){f.setRectRadius(q.value)}});
a("#stroke_width").SpinButton({min:0,max:99,step:1,smallStep:0.1,callback:function(q){var B=q.value;if(B==0&&Y&&["line","polyline"].indexOf(Y.nodeName)>=0)B=q.value=1;f.setStrokeWidth(B)}});a("#angle").SpinButton({min:-180,max:180,step:5,callback:function(q){f.setRotationAngle(q.value);a("#tool_reorient").toggleClass("disabled",q.value==0)}});a("#font_size").SpinButton({step:1,min:0.0010,stepfunc:function(q,B){var K=q.value-0,Q=K+B,W=Q>=K;if(B===0)return K;return K>=24?W?Math.round(K*1.1):Math.round(K/
1.1):K<=1?W?K*2:K/2:Q},callback:function(q){f.setFontSize(q.value)}});a("#group_opacity").SpinButton({step:5,min:0,max:100,callback:mb});a("#blur").SpinButton({step:0.1,min:0,max:10,callback:Ab});a("#zoom").SpinButton({min:0.0010,max:1E4,step:50,stepfunc:function(q,B){var K=q.value-0;if(K===0)return 100;var Q=K+B;if(B===0)return K;return K>=100?Q:Q>=K?K*2:K/2},callback:Na}).val(f.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(q){switch(q){case "delete":I();break;
case "cut":X();break;case "copy":Ma();break;case "paste":f.pasteElements();break;case "paste_in_place":f.pasteElements("in_place");break;case "group":f.groupSelectedElements();break;case "ungroup":f.ungroupSelectedElement();break;case "move_front":db();break;case "move_up":Y!=null&&f.moveUpDownSelected("Up");break;case "move_down":Y!=null&&f.moveUpDownSelected("Down");break;case "move_back":tb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(q)&&svgedit.contextmenu.getCustomHandler(q).call()}f.clipBoard.length&&
a("#stroke_width").SpinButton({min:0,max:99,step:1,smallStep:0.1,callback:function(q){var B=q.value;if(B==0&&Y&&["line","polyline"].indexOf(Y.nodeName)>=0)B=q.value=1;f.setStrokeWidth(B)}});a("#angle").SpinButton({min:-180,max:180,step:5,callback:function(q){f.setRotationAngle(q.value);a("#tool_reorient").toggleClass("disabled",q.value==0)}});a("#font_size").SpinButton({step:1,min:0.0010,stepfunc:function(q,B){var K=q.value-0,R=K+B,W=R>=K;if(B===0)return K;return K>=24?W?Math.round(K*1.1):Math.round(K/
1.1):K<=1?W?K*2:K/2:R},callback:function(q){f.setFontSize(q.value)}});a("#group_opacity").SpinButton({step:5,min:0,max:100,callback:mb});a("#blur").SpinButton({step:0.1,min:0,max:10,callback:Ab});a("#zoom").SpinButton({min:0.0010,max:1E4,step:50,stepfunc:function(q,B){var K=q.value-0;if(K===0)return 100;var R=K+B;if(B===0)return K;return K>=100?R:R>=K?K*2:K/2},callback:Ka}).val(f.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(q){switch(q){case "delete":I();break;
case "cut":X();break;case "copy":Na();break;case "paste":f.pasteElements();break;case "paste_in_place":f.pasteElements("in_place");break;case "group":f.groupSelectedElements();break;case "ungroup":f.ungroupSelectedElement();break;case "move_front":db();break;case "move_up":Y!=null&&f.moveUpDownSelected("Up");break;case "move_down":Y!=null&&f.moveUpDownSelected("Down");break;case "move_back":tb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(q)&&svgedit.contextmenu.getCustomHandler(q).call()}f.clipBoard.length&&
pa.enableContextMenuItems("#paste,#paste_in_place")});V=function(q){switch(q){case "dupe":N();break;case "delete":T();break;case "merge_down":if(a("#layerlist tr.layersel").index()!=f.getCurrentDrawing().getNumLayers()-1){f.mergeLayer();Za();Eb()}break;case "merge_all":f.mergeAllLayers();Za();Eb()}};a("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},V);a("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:true},V);a(".contextMenu li").mousedown(function(q){q.preventDefault()});
a("#cmenu_canvas li").disableContextMenu();pa.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(ja.getUndoStackSize()===0)c.show_save_warning=false;if(!d.no_save_warning&&c.show_save_warning)return e.notification.unsavedChanges};c.openPrep=function(q){a("#main_menu").hide();ja.getUndoStackSize()===0?q(true):a.confirm(e.notification.QwantToOpen,q)};if(window.FileReader){V=a('<input type="file">').change(function(){var q=this;c.openPrep(function(B){if(B){f.clear();if(q.files.length==
1){B=new FileReader;B.onloadend=function(K){n(K.target.result);Tb()};B.readAsText(q.files[0])}}})});a("#tool_open").show().prepend(V);V=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var q=new FileReader;q.onloadend=function(B){f.importSvgString(B.target.result,true);Tb()};q.readAsText(this.files[0])}});a("#tool_import").show().prepend(V)}var Tb=c.updateCanvas=function(q,B){var K=qa.width(),Q=qa.height(),W=K,ia=Q,va=f.getZoom(),ya=a("#svgcanvas"),Da={x:qa[0].scrollLeft+
W/2,y:qa[0].scrollTop+ia/2},Ha=d.canvas_expansion;K=Math.max(W,f.contentW*va*Ha);Q=Math.max(ia,f.contentH*va*Ha);K==W&&Q==ia?qa.css("overflow","hidden"):qa.css("overflow","scroll");Ha=ya.height()/2;var Aa=ya.width()/2;ya.width(K).height(Q);var fb=Q/2,gb=K/2,ga=f.updateCanvas(K,Q),zb=gb/Aa;K=K/2-W/2;Q=Q/2-ia/2;if(B){B.x+=ga.x;B.y+=ga.y}else B={x:gb+(Da.x-Aa)*zb,y:fb+(Da.y-Ha)*zb};if(q)if(f.contentW>qa.width()){qa[0].scrollLeft=ga.x-10;qa[0].scrollTop=ga.y-10}else{qa[0].scrollLeft=K;qa[0].scrollTop=
Q}else{qa[0].scrollLeft=B.x-W/2;qa[0].scrollTop=B.y-ia/2}if(d.showRulers){da(ya,va);qa.scroll()}},jc=[];for(Sa=0.1;Sa<1E5;Sa*=10){jc.push(1*Sa);jc.push(2*Sa);jc.push(5*Sa)}Tb(true);try{var uc=function(q){if(window.JSON&&JSON.stringify)return JSON.stringify(q);var B=arguments.callee;if(typeof q=="boolean"||typeof q=="number")return q+"";else if(typeof q=="string")return'"'+q.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
function(W){return"\\u"+("0000"+W.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(q.length){for(var K=0;K<q.length;K++)q[K]=B(q[K]);return"["+q.join(",")+"]"}else{K=[];for(var Q in q)K.push(B(Q)+":"+B(q[Q]));return"{"+K.join(",")+"}"}};window.addEventListener("message",function(q){var B=parseInt(q.data.substr(0,q.data.indexOf(";")));try{q.source.postMessage("SVGe"+B+";"+uc(eval(q.data)),"*")}catch(K){q.source.postMessage("SVGe"+B+";error:"+K.message,"*")}},false)}catch(vc){window.embed_error=
1){B=new FileReader;B.onloadend=function(K){n(K.target.result);Tb()};B.readAsText(q.files[0])}}})});a("#tool_open").show().prepend(V);V=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var q=new FileReader;q.onloadend=function(B){f.importSvgString(B.target.result,true);Tb()};q.readAsText(this.files[0])}});a("#tool_import").show().prepend(V)}var Tb=c.updateCanvas=function(q,B){var K=qa.width(),R=qa.height(),W=K,ia=R,va=f.getZoom(),ya=a("#svgcanvas"),Da={x:qa[0].scrollLeft+
W/2,y:qa[0].scrollTop+ia/2},Ha=d.canvas_expansion;K=Math.max(W,f.contentW*va*Ha);R=Math.max(ia,f.contentH*va*Ha);K==W&&R==ia?qa.css("overflow","hidden"):qa.css("overflow","scroll");Ha=ya.height()/2;var Aa=ya.width()/2;ya.width(K).height(R);var fb=R/2,gb=K/2,ga=f.updateCanvas(K,R),zb=gb/Aa;K=K/2-W/2;R=R/2-ia/2;if(B){B.x+=ga.x;B.y+=ga.y}else B={x:gb+(Da.x-Aa)*zb,y:fb+(Da.y-Ha)*zb};if(q)if(f.contentW>qa.width()){qa[0].scrollLeft=ga.x-10;qa[0].scrollTop=ga.y-10}else{qa[0].scrollLeft=K;qa[0].scrollTop=
R}else{qa[0].scrollLeft=B.x-W/2;qa[0].scrollTop=B.y-ia/2}if(d.showRulers){da(ya,va);qa.scroll()}},jc=[];for(Sa=0.1;Sa<1E5;Sa*=10){jc.push(1*Sa);jc.push(2*Sa);jc.push(5*Sa)}Tb(true);try{var uc=function(q){if(window.JSON&&JSON.stringify)return JSON.stringify(q);var B=arguments.callee;if(typeof q=="boolean"||typeof q=="number")return q+"";else if(typeof q=="string")return'"'+q.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
function(W){return"\\u"+("0000"+W.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(q.length){for(var K=0;K<q.length;K++)q[K]=B(q[K]);return"["+q.join(",")+"]"}else{K=[];for(var R in q)K.push(B(R)+":"+B(q[R]));return"{"+K.join(",")+"}"}};window.addEventListener("message",function(q){var B=parseInt(q.data.substr(0,q.data.indexOf(";")));try{q.source.postMessage("SVGe"+B+";"+uc(eval(q.data)),"*")}catch(K){q.source.postMessage("SVGe"+B+";error:"+K.message,"*")}},false)}catch(vc){window.embed_error=
vc}a(function(){window.svgCanvas=f;f.ready=svgEditor.ready});c.setLang=function(q,B){a.pref("lang",q);a("#lang_select").val(q);if(B){var K=a("#layerlist tr.layersel td.layername").text()==e.common.layer+" 1";a.extend(e,B);f.setUiStrings(B);oc.setTitles();if(K){f.renameCurrentLayer(e.common.layer+" 1");Eb()}f.runExtensions("langChanged",q);Nb();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin",
"#linecap_butt":"#cur_linecap"},function(Q,W){a(W).attr("title",a(Q)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var u=[];c.ready=function(z){m?z():u.push(z)};c.runCallbacks=function(){a.each(u,function(){this()});m=true};c.loadFromString=function(z){c.ready(function(){n(z)})};c.disableUI=function(){};c.loadFromURL=function(z,o){o||(o={});var L=o.cache,T=o.callback;c.ready(function(){a.ajax({url:z,dataType:"text",
"#linecap_butt":"#cur_linecap"},function(R,W){a(W).attr("title",a(R)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var u=[];c.ready=function(z){m?z():u.push(z)};c.runCallbacks=function(){a.each(u,function(){this()});m=true};c.loadFromString=function(z){c.ready(function(){n(z)})};c.disableUI=function(){};c.loadFromURL=function(z,o){o||(o={});var L=o.cache,T=o.callback;c.ready(function(){a.ajax({url:z,dataType:"text",
cache:!!L,success:function(N){n(N,T)},error:function(N,J,da){N.status!=404&&N.responseText?n(N.responseText,T):a.alert(e.notification.URLloadFail+": \n"+da+"",T)}})})};c.loadFromDataURI=function(z){c.ready(function(){var o=z.substring(26);n(svgedit.utilities.decode64(o))})};c.addExtension=function(){var z=arguments;a(function(){f&&f.addExtension.apply(this,z)})};return c}(jQuery);$(svgEditor.init)})();svgedit=svgedit||{};
(function(){var a=this;if(!svgedit.contextmenu)svgedit.contextmenu={};a.contextMenuExtensions={};svgEditor.ready(function(){for(menuItem in contextMenuExtensions){var n=contextMenuExtensions[menuItem];Object.keys(a.contextMenuExtensions).length==0&&$("#cmenu_canvas").append("<li class='separator'>");var f=n.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+n.id+"'>"+n.label+"<span class='shortcut'>"+f+"</span></a></li>")}});svgedit.contextmenu.resetCustomMenus=function(){a.contextMenuExtensions=
{}};svgedit.contextmenu.add=function(n){if(n&&n.id&&n.label&&n.action&&typeof n.action=="function")if(n.id in a.contextMenuExtensions)console.error('Cannot add extension "'+n.id+'", an extension by that name already exists"');else{console.log("Registed contextmenu item: {id:"+n.id+", label:"+n.label+"}");a.contextMenuExtensions[n.id]=n}else console.error("Menu items must be defined and have at least properties: id, label, action, where action must be a function")};svgedit.contextmenu.hasCustomHandler=
@ -626,28 +626,28 @@ g:this.hexToInt(e),b:this.hexToInt(l),a:this.hexToInt(u)}},validateHex:function(
s:0,v:0},u=0,z=0;if(d>=e&&d>=b){z=d;u=e>b?b:e}else if(e>=b&&e>=d){z=e;u=d>b?b:d}else{z=b;u=e>d?d:e}l.v=z;l.s=z?(z-u)/z:0;if(l.s){u=z-u;l.h=d==z?(e-b)/u:e==z?2+(b-d)/u:4+(d-e)/u;l.h=parseInt(l.h*60);if(l.h<0)l.h+=360}else l.h=0;l.s=l.s*100|0;l.v=l.v*100|0;return l},hsvToRgb:function(b){var d={r:0,g:0,b:0,a:100},e=b.h,l=b.s;b=b.v;if(l==0)d.r=b==0?d.g=d.b=0:d.g=d.b=b*255/100|0;else{if(e==360)e=0;e/=60;l/=100;b/=100;var u=e|0,z=e-u;e=b*(1-l);var o=b*(1-l*z);l=b*(1-l*(1-z));switch(u){case 0:d.r=b;d.g=
l;d.b=e;break;case 1:d.r=o;d.g=b;d.b=e;break;case 2:d.r=e;d.g=b;d.b=l;break;case 3:d.r=e;d.g=o;d.b=b;break;case 4:d.r=l;d.g=e;d.b=b;break;case 5:d.r=b;d.g=e;d.b=o}d.r=d.r*255|0;d.g=d.g*255|0;d.b=d.b*255|0}return d}}};var c=a.jPicker.Color,m=a.jPicker.List,p=a.jPicker.ColorMethods;a.fn.jPicker=function(b){var d=arguments;return this.each(function(){var e=this,l=a.extend(true,{},a.fn.jPicker.defaults,b);if(a(e).get(0).nodeName.toLowerCase()=="input"){a.extend(true,l,{window:{bindToInput:true,expandable:true,
input:a(e)}});if(a(e).val()==""){l.color.active=new c({hex:null});l.color.current=new c({hex:null})}else if(p.validateHex(a(e).val())){l.color.active=new c({hex:a(e).val(),a:l.color.active.val("a")});l.color.current=new c({hex:a(e).val(),a:l.color.active.val("a")})}}if(l.window.expandable)a(e).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>');
else l.window.liveUpdate=false;var u=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,z=null,o=null,L=null,T=null,N=null,J=null,da=null,V=null,O=null,fa=null,sa=null,ja=null,ca=null,ea=null,qa=null,pa=null,ba=null,S=null,U=null,ra=null,la=null,ma=null,Y=null,za=null,Ia=null,Qa=null,Ka=null,Ua=null,Wa=function(M){var I=ta.active,X=I.val("hex"),Ma,Xa;l.color.mode=M;switch(M){case "h":setTimeout(function(){ab.call(e,o,"transparent");Ja.call(e,T,0);Ea.call(e,T,100);Ja.call(e,
else l.window.liveUpdate=false;var u=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,z=null,o=null,L=null,T=null,N=null,J=null,da=null,V=null,O=null,fa=null,sa=null,ja=null,ca=null,ea=null,qa=null,pa=null,ba=null,S=null,U=null,ra=null,la=null,ma=null,Y=null,za=null,Ia=null,Qa=null,La=null,Ua=null,Wa=function(M){var I=ta.active,X=I.val("hex"),Na,Xa;l.color.mode=M;switch(M){case "h":setTimeout(function(){ab.call(e,o,"transparent");Ja.call(e,T,0);Ea.call(e,T,100);Ja.call(e,
N,260);Ea.call(e,N,100);ab.call(e,L,"transparent");Ja.call(e,da,0);Ea.call(e,da,100);Ja.call(e,V,260);Ea.call(e,V,100);Ja.call(e,O,260);Ea.call(e,O,100);Ja.call(e,fa,260);Ea.call(e,fa,100);Ja.call(e,ja,260);Ea.call(e,ja,100)},0);ca.range("all",{minX:0,maxX:100,minY:0,maxY:100});ea.range("rangeY",{minY:0,maxY:360});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("s"),y:100-I.val("v")},ca);ea.val("y",360-I.val("h"),ea);break;case "s":setTimeout(function(){ab.call(e,o,"transparent");Ja.call(e,T,-260);
Ja.call(e,N,-520);Ja.call(e,da,-260);Ja.call(e,V,-520);Ja.call(e,ja,260);Ea.call(e,ja,100)},0);ca.range("all",{minX:0,maxX:360,minY:0,maxY:100});ea.range("rangeY",{minY:0,maxY:100});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("h"),y:100-I.val("v")},ca);ea.val("y",100-I.val("s"),ea);break;case "v":setTimeout(function(){ab.call(e,o,"000000");Ja.call(e,T,-780);Ja.call(e,N,260);ab.call(e,L,X);Ja.call(e,da,-520);Ja.call(e,V,260);Ea.call(e,V,100);Ja.call(e,ja,260);Ea.call(e,ja,100)},0);ca.range("all",
{minX:0,maxX:360,minY:0,maxY:100});ea.range("rangeY",{minY:0,maxY:100});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("h"),y:100-I.val("s")},ca);ea.val("y",100-I.val("v"),ea);break;case "r":Ma=-1040;Xa=-780;ca.range("all",{minX:0,maxX:255,minY:0,maxY:255});ea.range("rangeY",{minY:0,maxY:255});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("b"),y:255-I.val("g")},ca);ea.val("y",255-I.val("r"),ea);break;case "g":Ma=-1560;Xa=-1820;ca.range("all",{minX:0,maxX:255,minY:0,maxY:255});ea.range("rangeY",
{minY:0,maxY:255});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("b"),y:255-I.val("r")},ca);ea.val("y",255-I.val("g"),ea);break;case "b":Ma=-2080;Xa=-2860;ca.range("all",{minX:0,maxX:255,minY:0,maxY:255});ea.range("rangeY",{minY:0,maxY:255});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("r"),y:255-I.val("g")},ca);ea.val("y",255-I.val("b"),ea);break;case "a":setTimeout(function(){ab.call(e,o,"transparent");Ja.call(e,T,-260);Ja.call(e,N,-520);Ja.call(e,da,260);Ja.call(e,V,260);Ea.call(e,V,100);
{minX:0,maxX:360,minY:0,maxY:100});ea.range("rangeY",{minY:0,maxY:100});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("h"),y:100-I.val("s")},ca);ea.val("y",100-I.val("v"),ea);break;case "r":Na=-1040;Xa=-780;ca.range("all",{minX:0,maxX:255,minY:0,maxY:255});ea.range("rangeY",{minY:0,maxY:255});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("b"),y:255-I.val("g")},ca);ea.val("y",255-I.val("r"),ea);break;case "g":Na=-1560;Xa=-1820;ca.range("all",{minX:0,maxX:255,minY:0,maxY:255});ea.range("rangeY",
{minY:0,maxY:255});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("b"),y:255-I.val("r")},ca);ea.val("y",255-I.val("g"),ea);break;case "b":Na=-2080;Xa=-2860;ca.range("all",{minX:0,maxX:255,minY:0,maxY:255});ea.range("rangeY",{minY:0,maxY:255});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("r"),y:255-I.val("g")},ca);ea.val("y",255-I.val("b"),ea);break;case "a":setTimeout(function(){ab.call(e,o,"transparent");Ja.call(e,T,-260);Ja.call(e,N,-520);Ja.call(e,da,260);Ja.call(e,V,260);Ea.call(e,V,100);
Ja.call(e,ja,0);Ea.call(e,ja,100)},0);ca.range("all",{minX:0,maxX:360,minY:0,maxY:100});ea.range("rangeY",{minY:0,maxY:255});if(I.val("ahex")==null)break;ca.val("xy",{x:I.val("h"),y:100-I.val("v")},ca);ea.val("y",255-I.val("a"),ea);break;default:throw"Invalid Mode";}switch(M){case "s":case "v":case "a":setTimeout(function(){Ea.call(e,T,100);Ea.call(e,da,100);Ja.call(e,O,260);Ea.call(e,O,100);Ja.call(e,fa,260);Ea.call(e,fa,100)},0);break;case "r":case "g":case "b":setTimeout(function(){ab.call(e,o,
"transparent");ab.call(e,L,"transparent");Ea.call(e,da,100);Ea.call(e,T,100);Ja.call(e,T,Ma);Ja.call(e,N,Ma-260);Ja.call(e,da,Xa-780);Ja.call(e,V,Xa-520);Ja.call(e,O,Xa);Ja.call(e,fa,Xa-260);Ja.call(e,ja,260);Ea.call(e,ja,100)},0)}I.val("ahex")!=null&&La.call(e,I)},La=function(M,I){if(I==null||I!=ea&&I!=ca)Fa.call(e,M,I);setTimeout(function(){Gb.call(e,M);Nb.call(e,M);lb.call(e,M)},0)},Ga=function(M,I){var X=ta.active;if(!(I!=ca&&X.val()==null)){var Ma=M.val("all");switch(l.color.mode){case "h":X.val("sv",
{s:Ma.x,v:100-Ma.y},I);break;case "s":case "a":X.val("hv",{h:Ma.x,v:100-Ma.y},I);break;case "v":X.val("hs",{h:Ma.x,s:100-Ma.y},I);break;case "r":X.val("gb",{g:255-Ma.y,b:Ma.x},I);break;case "g":X.val("rb",{r:255-Ma.y,b:Ma.x},I);break;case "b":X.val("rg",{r:Ma.x,g:255-Ma.y},I)}}},Oa=function(M,I){var X=ta.active;if(!(I!=ea&&X.val()==null))switch(l.color.mode){case "h":X.val("h",{h:360-M.val("y")},I);break;case "s":X.val("s",{s:100-M.val("y")},I);break;case "v":X.val("v",{v:100-M.val("y")},I);break;
"transparent");ab.call(e,L,"transparent");Ea.call(e,da,100);Ea.call(e,T,100);Ja.call(e,T,Na);Ja.call(e,N,Na-260);Ja.call(e,da,Xa-780);Ja.call(e,V,Xa-520);Ja.call(e,O,Xa);Ja.call(e,fa,Xa-260);Ja.call(e,ja,260);Ea.call(e,ja,100)},0)}I.val("ahex")!=null&&Ma.call(e,I)},Ma=function(M,I){if(I==null||I!=ea&&I!=ca)Fa.call(e,M,I);setTimeout(function(){Gb.call(e,M);Nb.call(e,M);lb.call(e,M)},0)},Ga=function(M,I){var X=ta.active;if(!(I!=ca&&X.val()==null)){var Na=M.val("all");switch(l.color.mode){case "h":X.val("sv",
{s:Na.x,v:100-Na.y},I);break;case "s":case "a":X.val("hv",{h:Na.x,v:100-Na.y},I);break;case "v":X.val("hs",{h:Na.x,s:100-Na.y},I);break;case "r":X.val("gb",{g:255-Na.y,b:Na.x},I);break;case "g":X.val("rb",{r:255-Na.y,b:Na.x},I);break;case "b":X.val("rg",{r:Na.x,g:255-Na.y},I)}}},Oa=function(M,I){var X=ta.active;if(!(I!=ea&&X.val()==null))switch(l.color.mode){case "h":X.val("h",{h:360-M.val("y")},I);break;case "s":X.val("s",{s:100-M.val("y")},I);break;case "v":X.val("v",{v:100-M.val("y")},I);break;
case "r":X.val("r",{r:255-M.val("y")},I);break;case "g":X.val("g",{g:255-M.val("y")},I);break;case "b":X.val("b",{b:255-M.val("y")},I);break;case "a":X.val("a",255-M.val("y"),I)}},Fa=function(M,I){if(I!=ca)switch(l.color.mode){case "h":var X=M.val("sv");ca.val("xy",{x:X!=null?X.s:100,y:100-(X!=null?X.v:100)},I);break;case "s":case "a":X=M.val("hv");ca.val("xy",{x:X&&X.h||0,y:100-(X!=null?X.v:100)},I);break;case "v":X=M.val("hs");ca.val("xy",{x:X&&X.h||0,y:100-(X!=null?X.s:100)},I);break;case "r":X=
M.val("bg");ca.val("xy",{x:X&&X.b||0,y:255-(X&&X.g||0)},I);break;case "g":X=M.val("br");ca.val("xy",{x:X&&X.b||0,y:255-(X&&X.r||0)},I);break;case "b":X=M.val("rg");ca.val("xy",{x:X&&X.r||0,y:255-(X&&X.g||0)},I)}if(I!=ea)switch(l.color.mode){case "h":ea.val("y",360-(M.val("h")||0),I);break;case "s":X=M.val("s");ea.val("y",100-(X!=null?X:100),I);break;case "v":X=M.val("v");ea.val("y",100-(X!=null?X:100),I);break;case "r":ea.val("y",255-(M.val("r")||0),I);break;case "g":ea.val("y",255-(M.val("g")||0),
I);break;case "b":ea.val("y",255-(M.val("b")||0),I);break;case "a":X=M.val("a");ea.val("y",255-(X!=null?X:255),I)}},Gb=function(M){try{var I=M.val("all");ra.css({backgroundColor:I&&"#"+I.hex||"transparent"});Ea.call(e,ra,I&&Math.precision(I.a*100/255,4)||0)}catch(X){}},Nb=function(M){switch(l.color.mode){case "h":ab.call(e,o,(new c({h:M.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var I=M.val("s");Ea.call(e,N,100-(I!=null?I:100));break;case "v":I=M.val("v");Ea.call(e,T,I!=null?I:
100);break;case "r":Ea.call(e,N,Math.precision((M.val("r")||0)/255*100,4));break;case "g":Ea.call(e,N,Math.precision((M.val("g")||0)/255*100,4));break;case "b":Ea.call(e,N,Math.precision((M.val("b")||0)/255*100))}M=M.val("a");Ea.call(e,J,Math.precision((255-(M||0))*100/255,4))},lb=function(M){switch(l.color.mode){case "h":var I=M.val("a");Ea.call(e,sa,Math.precision((255-(I||0))*100/255,4));break;case "s":I=M.val("hva");var X=new c({h:I&&I.h||0,s:100,v:I!=null?I.v:100});ab.call(e,L,X.val("hex"));
Ea.call(e,V,100-(I!=null?I.v:100));Ea.call(e,sa,Math.precision((255-(I&&I.a||0))*100/255,4));break;case "v":I=M.val("hsa");X=new c({h:I&&I.h||0,s:I!=null?I.s:100,v:100});ab.call(e,L,X.val("hex"));Ea.call(e,sa,Math.precision((255-(I&&I.a||0))*100/255,4));break;case "r":case "g":case "b":X=I=0;M=M.val("rgba");if(l.color.mode=="r"){I=M&&M.b||0;X=M&&M.g||0}else if(l.color.mode=="g"){I=M&&M.b||0;X=M&&M.r||0}else if(l.color.mode=="b"){I=M&&M.r||0;X=M&&M.g||0}var Ma=X>I?I:X;Ea.call(e,V,I>X?Math.precision((I-
X)/(255-X)*100,4):0);Ea.call(e,O,X>I?Math.precision((X-I)/(255-I)*100,4):0);Ea.call(e,fa,Math.precision(Ma/255*100,4));Ea.call(e,sa,Math.precision((255-(M&&M.a||0))*100/255,4));break;case "a":I=M.val("a");ab.call(e,L,M.val("hex")||"000000");Ea.call(e,sa,I!=null?0:100);Ea.call(e,ja,I!=null?100:0)}},ab=function(M,I){M.css({backgroundColor:I&&I.length==6&&"#"+I||"transparent"})},Sa=function(M,I){if(u&&(I.indexOf("AlphaBar.png")!=-1||I.indexOf("Bars.png")!=-1||I.indexOf("Maps.png")!=-1)){M.attr("pngSrc",
Ea.call(e,V,100-(I!=null?I.v:100));Ea.call(e,sa,Math.precision((255-(I&&I.a||0))*100/255,4));break;case "v":I=M.val("hsa");X=new c({h:I&&I.h||0,s:I!=null?I.s:100,v:100});ab.call(e,L,X.val("hex"));Ea.call(e,sa,Math.precision((255-(I&&I.a||0))*100/255,4));break;case "r":case "g":case "b":X=I=0;M=M.val("rgba");if(l.color.mode=="r"){I=M&&M.b||0;X=M&&M.g||0}else if(l.color.mode=="g"){I=M&&M.b||0;X=M&&M.r||0}else if(l.color.mode=="b"){I=M&&M.r||0;X=M&&M.g||0}var Na=X>I?I:X;Ea.call(e,V,I>X?Math.precision((I-
X)/(255-X)*100,4):0);Ea.call(e,O,X>I?Math.precision((X-I)/(255-I)*100,4):0);Ea.call(e,fa,Math.precision(Na/255*100,4));Ea.call(e,sa,Math.precision((255-(M&&M.a||0))*100/255,4));break;case "a":I=M.val("a");ab.call(e,L,M.val("hex")||"000000");Ea.call(e,sa,I!=null?0:100);Ea.call(e,ja,I!=null?100:0)}},ab=function(M,I){M.css({backgroundColor:I&&I.length==6&&"#"+I||"transparent"})},Sa=function(M,I){if(u&&(I.indexOf("AlphaBar.png")!=-1||I.indexOf("Bars.png")!=-1||I.indexOf("Maps.png")!=-1)){M.attr("pngSrc",
I);M.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+I+"', sizingMethod='scale')"})}else M.css({backgroundImage:"url('"+I+"')"})},Ja=function(M,I){M.css({top:I+"px"})},Ea=function(M,I){M.css({visibility:I>0?"visible":"hidden"});if(I>0&&I<100)if(u){var X=M.attr("pngSrc");X!=null&&(X.indexOf("AlphaBar.png")!=-1||X.indexOf("Bars.png")!=-1||X.indexOf("Maps.png")!=-1)?M.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+X+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+
I+")"}):M.css({opacity:Math.precision(I/100,4)})}else M.css({opacity:Math.precision(I/100,4)});else if(I==0||I==100)if(u){X=M.attr("pngSrc");X!=null&&(X.indexOf("AlphaBar.png")!=-1||X.indexOf("Bars.png")!=-1||X.indexOf("Maps.png")!=-1)?M.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+X+"', sizingMethod='scale')"}):M.css({opacity:""})}else M.css({opacity:""})},Za=function(){ta.active.val("ahex",ta.current.val("ahex"))},Ra=function(){ta.current.val("ahex",ta.active.val("ahex"))},
$a=function(M){a(this).parents("tbody:first").find('input:radio[value!="'+M.target.value+'"]').removeAttr("checked");Wa.call(e,M.target.value)},Na=function(){Za.call(e)},mb=function(){Za.call(e);l.window.expandable&&Ib.call(e);a.isFunction(Cb)&&Cb.call(e,ta.active,Y)},Ab=function(){Ra.call(e);l.window.expandable&&Ib.call(e);a.isFunction(Bb)&&Bb.call(e,ta.active,ma)},cb=function(){Kb.call(e)},jb=function(M){var I=M.val("hex");la.css({backgroundColor:I&&"#"+I||"transparent"});Ea.call(e,la,Math.precision((M.val("a")||
$a=function(M){a(this).parents("tbody:first").find('input:radio[value!="'+M.target.value+'"]').removeAttr("checked");Wa.call(e,M.target.value)},Ka=function(){Za.call(e)},mb=function(){Za.call(e);l.window.expandable&&Ib.call(e);a.isFunction(Cb)&&Cb.call(e,ta.active,Y)},Ab=function(){Ra.call(e);l.window.expandable&&Ib.call(e);a.isFunction(Bb)&&Bb.call(e,ta.active,ma)},cb=function(){Kb.call(e)},jb=function(M){var I=M.val("hex");la.css({backgroundColor:I&&"#"+I||"transparent"});Ea.call(e,la,Math.precision((M.val("a")||
0)*100/255,4))},kb=function(M){var I=M.val("hex");M=M.val("va");Ia.css({backgroundColor:I&&"#"+I||"transparent"});Ea.call(e,Qa,Math.precision((255-(M&&M.a||0))*100/255,4));if(l.window.bindToInput&&l.window.updateInputColor)l.window.input.css({backgroundColor:I&&"#"+I||"transparent",color:M==null||M.v>75?"#000000":"#ffffff"})},Ca=function(M){pa=parseInt(z.css("left"));ba=parseInt(z.css("top"));S=M.pageX;U=M.pageY;a(document).bind("mousemove",wb).bind("mouseup",nb);M.preventDefault()},wb=function(M){z.css({left:pa-
(S-M.pageX)+"px",top:ba-(U-M.pageY)+"px"});l.window.expandable&&!a.support.boxModel&&z.prev().css({left:z.css("left"),top:z.css("top")});M.stopPropagation();M.preventDefault();return false},nb=function(M){a(document).unbind("mousemove",wb).unbind("mouseup",nb);M.stopPropagation();M.preventDefault();return false},yb=function(M){M.preventDefault();M.stopPropagation();ta.active.val("ahex",a(this).attr("title")||null,M.target);return false},Bb=a.isFunction(d[1])&&d[1]||null,ob=a.isFunction(d[2])&&d[2]||
null,Cb=a.isFunction(d[3])&&d[3]||null,Kb=function(){ta.current.val("ahex",ta.active.val("ahex"));var M=function(){if(!(!l.window.expandable||a.support.boxModel)){var I=z.find("table:first");z.before("<iframe/>");z.prev().css({width:I.width(),height:z.height(),opacity:0,position:"absolute",left:z.css("left"),top:z.css("top")})}};if(l.window.expandable){a(document.body).children("div.jPicker.Container").css({zIndex:10});z.css({zIndex:20})}switch(l.window.effects.type){case "fade":z.fadeIn(l.window.effects.speed.show,
M);break;case "slide":z.slideDown(l.window.effects.speed.show,M);break;default:z.show(l.window.effects.speed.show,M)}},Ib=function(){var M=function(){l.window.expandable&&z.css({zIndex:10});!l.window.expandable||a.support.boxModel||z.prev().remove()};switch(l.window.effects.type){case "fade":z.fadeOut(l.window.effects.speed.hide,M);break;case "slide":z.slideUp(l.window.effects.speed.hide,M);break;default:z.hide(l.window.effects.speed.hide,M)}},Rb=function(){var M=l.window,I=M.expandable?a(e).next().find(".Container:first"):
null;z=M.expandable?a("<div/>"):a(e);z.addClass("jPicker Container");M.expandable&&z.hide();z.get(0).onselectstart=function(Lb){if(Lb.target.nodeName.toLowerCase()!=="input")return false};var X=ta.active.val("all");if(M.alphaPrecision<0)M.alphaPrecision=0;else if(M.alphaPrecision>2)M.alphaPrecision=2;var Ma='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(M.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(M.title||Z.text.title)+
null;z=M.expandable?a("<div/>"):a(e);z.addClass("jPicker Container");M.expandable&&z.hide();z.get(0).onselectstart=function(Lb){if(Lb.target.nodeName.toLowerCase()!=="input")return false};var X=ta.active.val("all");if(M.alphaPrecision<0)M.alphaPrecision=0;else if(M.alphaPrecision>2)M.alphaPrecision=2;var Na='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(M.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(M.title||Z.text.title)+
'</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="'+na.clientPath+na.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9"><div class="Bar"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><span class="Map4">&nbsp;</span><span class="Map5">&nbsp;</span><span class="Map6">&nbsp;</span><img src="'+na.clientPath+na.colorBar.arrow.file+'" class="Arrow"/></div></td><td colspan="2" class="Preview"><div class="prev_div">'+
Z.text.newColor+'<div class="color_preview"><span class="Active" title="'+Z.tooltips.colors.newColor+'">&nbsp;</span><span class="Current" title="'+Z.tooltips.colors.currentColor+'">&nbsp;</span></div></div>'+Z.text.currentColor+'</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="'+Z.text.ok+'" title="'+Z.tooltips.buttons.ok+'"/><input type="button" class="Cancel" value="'+Z.text.cancel+'" title="'+Z.tooltips.buttons.cancel+'"/><div class="Grid">&nbsp;</div></td></tr><tr class="Hue"><td class="Radio"><label title="'+
Z.tooltips.hue.radio+'"><input type="radio" value="h"'+(l.color.mode=="h"?' checked="checked"':"")+'/>H:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(X!=null?X.h:"")+'" title="'+Z.tooltips.hue.textbox+'"/>&nbsp;\u00ba</td></tr><tr class="Saturation"><td class="Radio"><label title="'+Z.tooltips.saturation.radio+'"><input type="radio" value="s"'+(l.color.mode=="s"?' checked="checked"':"")+'/>S:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(X!=null?
@ -655,16 +655,16 @@ X.s:"")+'" title="'+Z.tooltips.saturation.textbox+'"/>&nbsp;%</td></tr><tr class
"r"?' checked="checked"':"")+'/>R:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(X!=null?X.r:"")+'" title="'+Z.tooltips.red.textbox+'"/></td></tr><tr class="Green"><td class="Radio"><label title="'+Z.tooltips.green.radio+'"><input type="radio" value="g"'+(l.color.mode=="g"?' checked="checked"':"")+'/>G:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(X!=null?X.g:"")+'" title="'+Z.tooltips.green.textbox+'"/></td></tr><tr class="Blue"><td class="Radio"><label title="'+
Z.tooltips.blue.radio+'"><input type="radio" value="b"'+(l.color.mode=="b"?' checked="checked"':"")+'/>B:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(X!=null?X.b:"")+'" title="'+Z.tooltips.blue.textbox+'"/></td></tr><tr class="Alpha"><td class="Radio">'+(M.alphaSupport?'<label title="'+Z.tooltips.alpha.radio+'"><input type="radio" value="a"'+(l.color.mode=="a"?' checked="checked"':"")+"/>A:</label>":"&nbsp;")+'</td><td class="Text">'+(M.alphaSupport?'<input type="text" maxlength="'+
(3+M.alphaPrecision)+'" value="'+(X!=null?Math.precision(X.a*100/255,M.alphaPrecision):"")+'" title="'+Z.tooltips.alpha.textbox+'"/>&nbsp;%':"&nbsp;")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+Z.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(X!=null?X.hex:"")+'"/></label>'+(M.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(X!=null?X.ahex.substring(6):"")+'" title="'+Z.tooltips.hex.alpha+'"/></td>':"&nbsp;")+"</tr></tbody></table>";
if(M.expandable){z.html(Ma);a(document.body).children("div.jPicker.Container").length==0?a(document.body).prepend(z):a(document.body).children("div.jPicker.Container:last").after(z);z.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});z.css({zIndex:20})});z.css({left:M.position.x=="left"?I.offset().left-530-(M.position.y=="center"?25:0)+"px":M.position.x=="center"?I.offset().left-260+"px":M.position.x=="right"?I.offset().left-10+(M.position.y=="center"?25:0)+
"px":M.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":I.offset().left+parseInt(M.position.x)+"px",position:"absolute",top:M.position.y=="top"?I.offset().top-312+"px":M.position.y=="center"?I.offset().top-156+"px":M.position.y=="bottom"?I.offset().top+25+"px":I.offset().top+parseInt(M.position.y)+"px"})}else{z=a(e);z.html(Ma)}Ma=z.find("tbody:first");o=Ma.find("div.Map:first");L=Ma.find("div.Bar:first");var Xa=o.find("span"),db=L.find("span");T=Xa.filter(".Map1:first");N=Xa.filter(".Map2:first");
if(M.expandable){z.html(Na);a(document.body).children("div.jPicker.Container").length==0?a(document.body).prepend(z):a(document.body).children("div.jPicker.Container:last").after(z);z.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});z.css({zIndex:20})});z.css({left:M.position.x=="left"?I.offset().left-530-(M.position.y=="center"?25:0)+"px":M.position.x=="center"?I.offset().left-260+"px":M.position.x=="right"?I.offset().left-10+(M.position.y=="center"?25:0)+
"px":M.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":I.offset().left+parseInt(M.position.x)+"px",position:"absolute",top:M.position.y=="top"?I.offset().top-312+"px":M.position.y=="center"?I.offset().top-156+"px":M.position.y=="bottom"?I.offset().top+25+"px":I.offset().top+parseInt(M.position.y)+"px"})}else{z=a(e);z.html(Na)}Na=z.find("tbody:first");o=Na.find("div.Map:first");L=Na.find("div.Bar:first");var Xa=o.find("span"),db=L.find("span");T=Xa.filter(".Map1:first");N=Xa.filter(".Map2:first");
J=Xa.filter(".Map3:first");da=db.filter(".Map1:first");V=db.filter(".Map2:first");O=db.filter(".Map3:first");fa=db.filter(".Map4:first");sa=db.filter(".Map5:first");ja=db.filter(".Map6:first");ca=new n(o,{map:{width:na.colorMap.width,height:na.colorMap.height},arrow:{image:na.clientPath+na.colorMap.arrow.file,width:na.colorMap.arrow.width,height:na.colorMap.arrow.height}});ca.bind(Ga);ea=new n(L,{map:{width:na.colorBar.width,height:na.colorBar.height},arrow:{image:na.clientPath+na.colorBar.arrow.file,
width:na.colorBar.arrow.width,height:na.colorBar.arrow.height}});ea.bind(Oa);qa=new f(Ma,ta.active,M.expandable&&M.bindToInput?M.input:null,M.alphaPrecision);Xa=X!=null?X.hex:null;var tb=Ma.find(".Preview");db=Ma.find(".Button");ra=tb.find(".Active:first").css({backgroundColor:Xa&&"#"+Xa||"transparent"});la=tb.find(".Current:first").css({backgroundColor:Xa&&"#"+Xa||"transparent"}).bind("click",Na);Ea.call(e,la,Math.precision(ta.current.val("a")*100)/255,4);ma=db.find(".Ok:first").bind("click",Ab);
width:na.colorBar.arrow.width,height:na.colorBar.arrow.height}});ea.bind(Oa);qa=new f(Na,ta.active,M.expandable&&M.bindToInput?M.input:null,M.alphaPrecision);Xa=X!=null?X.hex:null;var tb=Na.find(".Preview");db=Na.find(".Button");ra=tb.find(".Active:first").css({backgroundColor:Xa&&"#"+Xa||"transparent"});la=tb.find(".Current:first").css({backgroundColor:Xa&&"#"+Xa||"transparent"}).bind("click",Ka);Ea.call(e,la,Math.precision(ta.current.val("a")*100)/255,4);ma=db.find(".Ok:first").bind("click",Ab);
Y=db.find(".Cancel:first").bind("click",mb);za=db.find(".Grid:first");setTimeout(function(){Sa.call(e,T,na.clientPath+"Maps.png");Sa.call(e,N,na.clientPath+"Maps.png");Sa.call(e,J,na.clientPath+"map-opacity.png");Sa.call(e,da,na.clientPath+"Bars.png");Sa.call(e,V,na.clientPath+"Bars.png");Sa.call(e,O,na.clientPath+"Bars.png");Sa.call(e,fa,na.clientPath+"Bars.png");Sa.call(e,sa,na.clientPath+"bar-opacity.png");Sa.call(e,ja,na.clientPath+"AlphaBar.png");Sa.call(e,tb.find("div:last"),na.clientPath+"preview-opacity.png")},
0);Ma.find("td.Radio input").bind("click",$a);if(ta.quickList&&ta.quickList.length>0){db="";for(i=0;i<ta.quickList.length;i++){if((typeof ta.quickList[i]).toString().toLowerCase()=="string")ta.quickList[i]=new c({hex:ta.quickList[i]});var xb=ta.quickList[i].val("a"),Hb=ta.quickList[i].val("ahex");if(!M.alphaSupport&&Hb)Hb=Hb.substring(0,6)+"ff";var pb=ta.quickList[i].val("hex");db+='<span class="QuickColor"'+(Hb&&' title="#'+Hb+'"'||"")+' style="background-color:'+(pb&&"#"+pb||"")+";"+(pb?"":"background-image:url("+
na.clientPath+"NoColor.png)")+(M.alphaSupport&&xb&&xb<255?";opacity:"+Math.precision(xb/255,4)+";filter:Alpha(opacity="+Math.precision(xb/2.55,4)+")":"")+'">&nbsp;</span>'}Sa.call(e,za,na.clientPath+"bar-opacity.png");za.html(db);za.find(".QuickColor").click(yb)}Wa.call(e,l.color.mode);ta.active.bind(La);a.isFunction(ob)&&ta.active.bind(ob);ta.current.bind(jb);if(M.expandable){e.icon=I.parents(".Icon:first");Ia=e.icon.find(".Color:first").css({backgroundColor:Xa&&"#"+Xa||"transparent"});Qa=e.icon.find(".Alpha:first");
Sa.call(e,Qa,na.clientPath+"bar-opacity.png");Ea.call(e,Qa,Math.precision((255-(X!=null?X.a:0))*100/255,4));Ka=e.icon.find(".Image:first").css({backgroundImage:"url('"+na.clientPath+na.picker.file+"')"}).bind("click",cb);if(M.bindToInput&&M.updateInputColor)M.input.css({backgroundColor:Xa&&"#"+Xa||"transparent",color:X==null||X.v>75?"#000000":"#ffffff"});Ua=Ma.find(".Move:first").bind("mousedown",Ca);ta.active.bind(kb)}else Kb.call(e)},na=l.images,Z=l.localization,ta={active:(typeof l.color.active).toString().toLowerCase()==
0);Na.find("td.Radio input").bind("click",$a);if(ta.quickList&&ta.quickList.length>0){db="";for(i=0;i<ta.quickList.length;i++){if((typeof ta.quickList[i]).toString().toLowerCase()=="string")ta.quickList[i]=new c({hex:ta.quickList[i]});var xb=ta.quickList[i].val("a"),Hb=ta.quickList[i].val("ahex");if(!M.alphaSupport&&Hb)Hb=Hb.substring(0,6)+"ff";var pb=ta.quickList[i].val("hex");db+='<span class="QuickColor"'+(Hb&&' title="#'+Hb+'"'||"")+' style="background-color:'+(pb&&"#"+pb||"")+";"+(pb?"":"background-image:url("+
na.clientPath+"NoColor.png)")+(M.alphaSupport&&xb&&xb<255?";opacity:"+Math.precision(xb/255,4)+";filter:Alpha(opacity="+Math.precision(xb/2.55,4)+")":"")+'">&nbsp;</span>'}Sa.call(e,za,na.clientPath+"bar-opacity.png");za.html(db);za.find(".QuickColor").click(yb)}Wa.call(e,l.color.mode);ta.active.bind(Ma);a.isFunction(ob)&&ta.active.bind(ob);ta.current.bind(jb);if(M.expandable){e.icon=I.parents(".Icon:first");Ia=e.icon.find(".Color:first").css({backgroundColor:Xa&&"#"+Xa||"transparent"});Qa=e.icon.find(".Alpha:first");
Sa.call(e,Qa,na.clientPath+"bar-opacity.png");Ea.call(e,Qa,Math.precision((255-(X!=null?X.a:0))*100/255,4));La=e.icon.find(".Image:first").css({backgroundImage:"url('"+na.clientPath+na.picker.file+"')"}).bind("click",cb);if(M.bindToInput&&M.updateInputColor)M.input.css({backgroundColor:Xa&&"#"+Xa||"transparent",color:X==null||X.v>75?"#000000":"#ffffff"});Ua=Na.find(".Move:first").bind("mousedown",Ca);ta.active.bind(kb)}else Kb.call(e)},na=l.images,Z=l.localization,ta={active:(typeof l.color.active).toString().toLowerCase()==
"string"?new c({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new c({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),current:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new c({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,
6)+"ff":l.color.active.val("ahex")}),quickList:l.color.quickList};a.extend(true,e,{commitCallback:Bb,liveCallback:ob,cancelCallback:Cb,color:ta,show:Kb,hide:Ib,destroy:function(){z.find("td.Radio input").unbind("click",$a);la.unbind("click",Na);Y.unbind("click",mb);ma.unbind("click",Ab);if(l.window.expandable){Ka.unbind("click",cb);Ua.unbind("mousedown",Ca);e.icon=null}z.find(".QuickColor").unbind("click",yb);ja=sa=fa=O=V=da=J=N=T=L=o=null;ca.destroy();ca=null;ea.destroy();ea=null;qa.destroy();ob=
6)+"ff":l.color.active.val("ahex")}),quickList:l.color.quickList};a.extend(true,e,{commitCallback:Bb,liveCallback:ob,cancelCallback:Cb,color:ta,show:Kb,hide:Ib,destroy:function(){z.find("td.Radio input").unbind("click",$a);la.unbind("click",Ka);Y.unbind("click",mb);ma.unbind("click",Ab);if(l.window.expandable){La.unbind("click",cb);Ua.unbind("mousedown",Ca);e.icon=null}z.find(".QuickColor").unbind("click",yb);ja=sa=fa=O=V=da=J=N=T=L=o=null;ca.destroy();ca=null;ea.destroy();ea=null;qa.destroy();ob=
Cb=Bb=za=Y=ma=la=ra=qa=null;z.html("");for(i=0;i<m.length;i++)m[i]==e&&m.splice(i,1)}});m.push(e);setTimeout(function(){Rb.call(e)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new c({ahex:"#ffcc00ff"}),quickList:[new c({h:360,s:33,v:100}),new c({h:360,s:66,v:100}),new c({h:360,s:100,v:100}),
new c({h:360,s:100,v:75}),new c({h:360,s:100,v:50}),new c({h:180,s:0,v:100}),new c({h:30,s:33,v:100}),new c({h:30,s:66,v:100}),new c({h:30,s:100,v:100}),new c({h:30,s:100,v:75}),new c({h:30,s:100,v:50}),new c({h:180,s:0,v:90}),new c({h:60,s:33,v:100}),new c({h:60,s:66,v:100}),new c({h:60,s:100,v:100}),new c({h:60,s:100,v:75}),new c({h:60,s:100,v:50}),new c({h:180,s:0,v:80}),new c({h:90,s:33,v:100}),new c({h:90,s:66,v:100}),new c({h:90,s:100,v:100}),new c({h:90,s:100,v:75}),new c({h:90,s:100,v:50}),
new c({h:180,s:0,v:70}),new c({h:120,s:33,v:100}),new c({h:120,s:66,v:100}),new c({h:120,s:100,v:100}),new c({h:120,s:100,v:75}),new c({h:120,s:100,v:50}),new c({h:180,s:0,v:60}),new c({h:150,s:33,v:100}),new c({h:150,s:66,v:100}),new c({h:150,s:100,v:100}),new c({h:150,s:100,v:75}),new c({h:150,s:100,v:50}),new c({h:180,s:0,v:50}),new c({h:180,s:33,v:100}),new c({h:180,s:66,v:100}),new c({h:180,s:100,v:100}),new c({h:180,s:100,v:75}),new c({h:180,s:100,v:50}),new c({h:180,s:0,v:40}),new c({h:210,