-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvgedit.compiled.js
451 lines (451 loc) · 225 KB
/
svgedit.compiled.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
var svgedit=svgedit||{};
(function(){if(!svgedit.browser)svgedit.browser={};var a=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect;svgedit.browser.supportsSvg=function(){return a};if(svgedit.browser.supportsSvg()){var L=navigator.userAgent,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),o=!!window.opera,A=L.indexOf("AppleWebKit")>=0,G=L.indexOf("Gecko/")>=0,e=L.indexOf("MSIE")>=0,f=!!m.querySelector,h=!!document.evaluate,p=function(){var Z=document.createElementNS("http://www.w3.org/2000/svg",
"path");Z.setAttribute("d","M0,0 10,10");var W=Z.pathSegList;Z=Z.createSVGPathSegLinetoAbs(5,5);try{W.replaceItem(Z,0);return true}catch(ka){}return false}(),C=function(){var Z=document.createElementNS("http://www.w3.org/2000/svg","path");Z.setAttribute("d","M0,0 10,10");var W=Z.pathSegList;Z=Z.createSVGPathSegLinetoAbs(5,5);try{W.insertItemBefore(Z,0);return true}catch(ka){}return false}(),F=function(){var Z=document.createElementNS("http://www.w3.org/2000/svg","svg"),W=document.createElementNS("http://www.w3.org/2000/svg",
"svg");document.documentElement.appendChild(Z);W.setAttribute("x",5);Z.appendChild(W);var ka=document.createElementNS("http://www.w3.org/2000/svg","text");ka.textContent="a";W.appendChild(ka);W=ka.getStartPositionOfChar(0).x;document.documentElement.removeChild(Z);return W===0}(),z=function(){var Z=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(Z);var W=document.createElementNS("http://www.w3.org/2000/svg","path");W.setAttribute("d","M0,0 C0,0 10,10 10,0");
Z.appendChild(W);W=W.getBBox();document.documentElement.removeChild(Z);return W.height>4&&W.height<5}(),N=function(){var Z=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(Z);var W=document.createElementNS("http://www.w3.org/2000/svg","path");W.setAttribute("d","M0,0 10,0");var ka=document.createElementNS("http://www.w3.org/2000/svg","path");ka.setAttribute("d","M5,0 15,0");var oa=document.createElementNS("http://www.w3.org/2000/svg","g");oa.appendChild(W);
oa.appendChild(ka);Z.appendChild(oa);W=oa.getBBox();document.documentElement.removeChild(Z);return W.width==15}(),aa=function(){var Z=document.createElementNS("http://www.w3.org/2000/svg","rect");Z.setAttribute("x",0.1);(Z=Z.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");return Z}(),O=function(){var Z=document.createElementNS("http://www.w3.org/2000/svg",
"rect");Z.setAttribute("style","vector-effect:non-scaling-stroke");return Z.style.vectorEffect==="non-scaling-stroke"}(),J=function(){var Z=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,W=m.createSVGTransform();Z.appendItem(W);return Z.getItem(0)==W}();svgedit.browser.isOpera=function(){return o};svgedit.browser.isWebkit=function(){return A};svgedit.browser.isGecko=function(){return G};svgedit.browser.isIE=function(){return e};svgedit.browser.supportsSelectors=function(){return f};
svgedit.browser.supportsXpath=function(){return h};svgedit.browser.supportsPathReplaceItem=function(){return p};svgedit.browser.supportsPathInsertItemBefore=function(){return C};svgedit.browser.supportsPathBBox=function(){return z};svgedit.browser.supportsHVLineContainerBBox=function(){return N};svgedit.browser.supportsGoodTextCharPos=function(){return F};svgedit.browser.supportsEditableText=function(){return o};svgedit.browser.supportsGoodDecimals=function(){return aa};svgedit.browser.supportsNonScalingStroke=
function(){return O};svgedit.browser.supportsNativeTransformLists=function(){return J}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
(function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),L={};svgedit.transformlist.SVGTransformList=function(m){this._elem=m||null;this._xforms=[];this._update=function(){var o="";a.createSVGMatrix();for(var A=0;A<this.numberOfItems;++A){var G=this._list.getItem(A);o=o;G=G;var e=G.matrix,f="";switch(G.type){case 1:f="matrix("+[e.a,e.b,e.c,e.d,e.e,e.f].join(",")+")";break;case 2:f="translate("+e.e+","+e.f+")";break;case 3:f=
e.a==e.d?"scale("+e.a+")":"scale("+e.a+","+e.d+")";break;case 4:var h=0;f=0;if(G.angle!=0){h=1-e.a;f=(h*e.f+e.b*e.e)/(h*h+e.b*e.b);h=(e.e-e.b*f)/h}f="rotate("+G.angle+" "+h+","+f+")"}o=o+(f+" ")}this._elem.setAttribute("transform",o)};this._list=this;this._init=function(){var o=this._elem.getAttribute("transform");if(o)for(var A=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,G=true;G;){G=o.match(A);o=o.replace(A,"");if(G&&G[1]){var e=G[1].split(/\s*\(/),f=e[0];e=e[1].match(/\s*(.*?)\s*\)/);
e[1]=e[1].replace(/(\d)-/g,"$1 -");var h=e[1].split(/[, ]+/),p="abcdef".split(""),C=a.createSVGMatrix();$.each(h,function(N,aa){h[N]=parseFloat(aa);if(f=="matrix")C[p[N]]=h[N]});e=a.createSVGTransform();var F="set"+f.charAt(0).toUpperCase()+f.slice(1),z=f=="matrix"?[C]:h;if(f=="scale"&&z.length==1)z.push(z[0]);else if(f=="translate"&&z.length==1)z.push(0);else if(f=="rotate"&&z.length==1){z.push(0);z.push(0)}e[F].apply(e,z);this._list.appendItem(e)}}};this._removeFromOtherLists=function(o){if(o){var A=
false,G;for(G in L){for(var e=L[G],f=0,h=e._xforms.length;f<h;++f)if(e._xforms[f]==o){A=true;e.removeItem(f);break}if(A)break}}};this.numberOfItems=0;this.clear=function(){this.numberOfItems=0;this._xforms=[]};this.initialize=function(o){this.numberOfItems=1;this._removeFromOtherLists(o);this._xforms=[o]};this.getItem=function(o){if(o<this.numberOfItems&&o>=0)return this._xforms[o];throw{code:1};};this.insertItemBefore=function(o,A){var G=null;if(A>=0)if(A<this.numberOfItems){this._removeFromOtherLists(o);
G=Array(this.numberOfItems+1);for(var e=0;e<A;++e)G[e]=this._xforms[e];G[e]=o;for(var f=e+1;e<this.numberOfItems;++f,++e)G[f]=this._xforms[e];this.numberOfItems++;this._xforms=G;G=o;this._list._update()}else G=this._list.appendItem(o);return G};this.replaceItem=function(o,A){var G=null;if(A<this.numberOfItems&&A>=0){this._removeFromOtherLists(o);G=this._xforms[A]=o;this._list._update()}return G};this.removeItem=function(o){if(o<this.numberOfItems&&o>=0){for(var A=this._xforms[o],G=Array(this.numberOfItems-
1),e=0;e<o;++e)G[e]=this._xforms[e];for(o=e;o<this.numberOfItems-1;++o,++e)G[o]=this._xforms[e+1];this.numberOfItems--;this._xforms=G;this._list._update();return A}else throw{code:1};};this.appendItem=function(o){this._removeFromOtherLists(o);this._xforms.push(o);this.numberOfItems++;this._list._update();return o}};svgedit.transformlist.resetListMap=function(){L={}};svgedit.transformlist.removeElementFromListMap=function(m){m.id&&L[m.id]&&delete L[m.id]};svgedit.transformlist.getTransformList=function(m){if(svgedit.browser.supportsNativeTransformLists())if(m.transform)return m.transform.baseVal;
else if(m.gradientTransform)return m.gradientTransform.baseVal;else{if(m.patternTransform)return m.patternTransform.baseVal}else{var o=m.id;o||(o="temp");var A=L[o];if(!A||o=="temp"){L[o]=new svgedit.transformlist.SVGTransformList(m);L[o]._init();A=L[o]}return A}return null}})();svgedit=svgedit||{};
(function(){if(!svgedit.math)svgedit.math={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg");svgedit.math.transformPoint=function(L,m,o){return{x:o.a*L+o.c*m+o.e,y:o.b*L+o.d*m+o.f}};svgedit.math.isIdentity=function(L){return L.a===1&&L.b===0&&L.c===0&&L.d===1&&L.e===0&&L.f===0};svgedit.math.matrixMultiply=function(){for(var L=arguments,m=L.length,o=L[m-1];m-- >1;)o=L[m-1].multiply(o);if(Math.abs(o.a)<1.0E-14)o.a=0;if(Math.abs(o.b)<1.0E-14)o.b=0;if(Math.abs(o.c)<1.0E-14)o.c=0;if(Math.abs(o.d)<
1.0E-14)o.d=0;if(Math.abs(o.e)<1.0E-14)o.e=0;if(Math.abs(o.f)<1.0E-14)o.f=0;return o};svgedit.math.hasMatrixTransform=function(L){if(!L)return false;for(var m=L.numberOfItems;m--;){var o=L.getItem(m);if(o.type==1&&!svgedit.math.isIdentity(o.matrix))return true}return false};svgedit.math.transformBox=function(L,m,o,A,G){var e={x:L,y:m},f={x:L+o,y:m};o={x:L+o,y:m+A};L={x:L,y:m+A};m=svgedit.math.transformPoint;e=m(e.x,e.y,G);var h=A=e.x,p=e.y,C=e.y;f=m(f.x,f.y,G);A=Math.min(A,f.x);h=Math.max(h,f.x);
p=Math.min(p,f.y);C=Math.max(C,f.y);L=m(L.x,L.y,G);A=Math.min(A,L.x);h=Math.max(h,L.x);p=Math.min(p,L.y);C=Math.max(C,L.y);o=m(o.x,o.y,G);A=Math.min(A,o.x);h=Math.max(h,o.x);p=Math.min(p,o.y);C=Math.max(C,o.y);return{tl:e,tr:f,bl:L,br:o,aabox:{x:A,y:p,width:h-A,height:C-p}}};svgedit.math.transformListToTransform=function(L,m,o){if(L==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());m=m==undefined?0:m;o=o==undefined?L.numberOfItems-1:o;m=parseInt(m);o=parseInt(o);if(m>o){var A=o;o=m;
m=A}A=a.createSVGMatrix();for(m=m;m<=o;++m){var G=m>=0&&m<L.numberOfItems?L.getItem(m).matrix:a.createSVGMatrix();A=svgedit.math.matrixMultiply(A,G)}return a.createSVGTransformFromMatrix(A)};svgedit.math.getMatrix=function(L){L=svgedit.transformlist.getTransformList(L);return svgedit.math.transformListToTransform(L).matrix};svgedit.math.snapToAngle=function(L,m,o,A){var G=Math.PI/4;o=o-L;var e=A-m;A=Math.sqrt(o*o+e*e);G=Math.round(Math.atan2(e,o)/G)*G;return{x:L+A*Math.cos(G),y:m+A*Math.sin(G),a:G}};
svgedit.math.rectsIntersect=function(L,m){return m.x<L.x+L.width&&m.x+m.width>L.x&&m.y<L.y+L.height&&m.y+m.height>L.y}})();svgedit=svgedit||{};
(function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],L=["y","y1","cy","ry","height"],m=$.merge(["r","radius"],a);$.merge(m,L);var o,A={px:1};svgedit.units.init=function(e){o=e;e=document.createElementNS("http://www.w3.org/2000/svg","svg");document.body.appendChild(e);var f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("width","1em");f.setAttribute("height","1ex");f.setAttribute("x","1in");e.appendChild(f);f=f.getBBox();document.body.removeChild(e);
e=f.x;A.em=f.width;A.ex=f.height;A["in"]=e;A.cm=e/2.54;A.mm=e/25.4;A.pt=e/72;A.pc=e/6;A["%"]=0};svgedit.units.getTypeMap=function(){return A};svgedit.units.shortFloat=function(e){var f=o.getRoundDigits();if(isNaN(e)){if($.isArray(e))return svgedit.units.shortFloat(e[0])+","+svgedit.units.shortFloat(e[1])}else return+(+e).toFixed(f);return parseFloat(e).toFixed(f)-0};svgedit.units.convertUnit=function(e,f){f=f||o.getBaseUnit();return svgedit.unit.shortFloat(e/A[f])};svgedit.units.setUnitAttr=function(e,
f,h){isNaN(h)||e.getAttribute(f);e.setAttribute(f,h)};var G={line:["x1","x2","y1","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],foreignObject:["x","y","width","height"],rect:["x","y","width","height"],image:["x","y","width","height"],use:["x","y","width","height"],text:["x","y"]};svgedit.units.convertAttrs=function(e){var f=e.tagName,h=o.getBaseUnit();if(f=G[f])for(var p=f.length,C=0;C<p;C++){var F=f[C],z=e.getAttribute(F);if(z)isNaN(z)||e.setAttribute(F,z/A[h]+h)}};svgedit.units.convertToNum=
function(e,f){if(!isNaN(f))return f-0;if(f.substr(-1)==="%"){var h=f.substr(0,f.length-1)/100,p=o.getWidth(),C=o.getHeight();return a.indexOf(e)>=0?h*p:L.indexOf(e)>=0?h*C:h*Math.sqrt(p*p+C*C)/Math.sqrt(2)}else{p=f.substr(-2);h=f.substr(0,f.length-2);return h*A[p]}};svgedit.units.isValidUnit=function(e,f){var h=false;if(m.indexOf(e)>=0)if(isNaN(f)){f=f.toLowerCase();$.each(A,function(F){if(!h)if(RegExp("^-?[\\d\\.]+"+F+"$").test(f))h=true})}else h=true;else if(e=="id"){var p=false;try{p=o.getElement(f)==
null}catch(C){}return p}else h=true;return h}})();svgedit=svgedit||{};
(function(){function a(e){if(svgedit.browser.supportsHVLineContainerBBox())try{return e.getBBox()}catch(f){}var h=$.data(e,"ref"),p=null;if(h){var C=$(h).children().clone().attr("visibility","hidden");$(G).append(C);p=C.filter("line, path")}else p=$(e).find("line, path");var F=false;if(p.length){p.each(function(){var z=this.getBBox();if(!z.width||!z.height)F=true});if(F){e=h?C:$(e).children();ret=getStrokedBBox(e)}else ret=e.getBBox()}else ret=e.getBBox();h&&C.remove();return ret}if(!svgedit.utilities)svgedit.utilities=
{};var L="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),m=null,o=null,A=null,G=null;svgedit.utilities.init=function(e){m=e;o=e.getDOMDocument();A=e.getDOMContainer();G=e.getSVGRoot()};svgedit.utilities.toXml=function(e){return $("<p/>").text(e).html()};svgedit.utilities.fromXml=function(e){return $("<p/>").html(e).text()};svgedit.utilities.encode64=function(e){e=svgedit.utilities.convertToXMLReferences(e);if(window.btoa)return window.btoa(e);
var f=Array(Math.floor((e.length+2)/3)*4),h,p,C,F,z,N,aa=0,O=0;do{h=e.charCodeAt(aa++);p=e.charCodeAt(aa++);C=e.charCodeAt(aa++);F=h>>2;h=(h&3)<<4|p>>4;z=(p&15)<<2|C>>6;N=C&63;if(isNaN(p))z=N=64;else if(isNaN(C))N=64;f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(F);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(h);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(z);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(N)}while(aa<
e.length);return f.join("")};svgedit.utilities.decode64=function(e){if(window.atob)return window.atob(e);var f="",h,p,C="",F,z="",N=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(N++));p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(N++));F="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(N++));z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e.charAt(N++));
h=h<<2|p>>4;p=(p&15)<<4|F>>2;C=(F&3)<<6|z;f+=String.fromCharCode(h);if(F!=64)f+=String.fromCharCode(p);if(z!=64)f+=String.fromCharCode(C)}while(N<e.length);return unescape(f)};svgedit.utilities.convertToXMLReferences=function(e){for(var f="",h=0;h<e.length;h++){var p=e.charCodeAt(h);if(p<128)f+=e[h];else if(p>127)f+="&#"+p+";"}return f};svgedit.utilities.text2xml=function(e){if(e.indexOf("<svg:svg")>=0)e=e.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var f;try{var h=window.DOMParser?
new DOMParser:new ActiveXObject("Microsoft.XMLDOM");h.async=false}catch(p){throw Error("XML Parser could not be instantiated");}try{f=h.loadXML?h.loadXML(e)?h:false:h.parseFromString(e,"text/xml")}catch(C){throw Error("Error parsing XML string");}return f};svgedit.utilities.bboxToObj=function(e){return{x:e.x,y:e.y,width:e.width,height:e.height}};svgedit.utilities.walkTree=function(e,f){if(e&&e.nodeType==1){f(e);for(var h=e.childNodes.length;h--;)svgedit.utilities.walkTree(e.childNodes.item(h),f)}};
svgedit.utilities.walkTreePost=function(e,f){if(e&&e.nodeType==1){for(var h=e.childNodes.length;h--;)svgedit.utilities.walkTree(e.childNodes.item(h),f);f(e)}};svgedit.utilities.getUrlFromAttr=function(e){if(e)if(e.indexOf('url("')===0)return e.substring(5,e.indexOf('"',6));else if(e.indexOf("url('")===0)return e.substring(5,e.indexOf("'",6));else if(e.indexOf("url(")===0)return e.substring(4,e.indexOf(")"));return null};svgedit.utilities.getHref=function(e){return e.getAttributeNS("http://www.w3.org/1999/xlink",
"href")};svgedit.utilities.setHref=function(e,f){e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f)};svgedit.utilities.findDefs=function(e){e=m.getSVGContent().documentElement;var f=e.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return f=f.length>0?f[0]:e.insertBefore(e.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),e.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(e){var f=e.pathSegList,h=f.numberOfItems;e=[[],[]];var p=f.getItem(0),
C=[p.x,p.y];for(p=0;p<h;p++){var F=f.getItem(p);if(F.x){e[0].push(C[0]);e[1].push(C[1]);if(F.x1){for(var z=[F.x1,F.y1],N=[F.x2,F.y2],aa=[F.x,F.y],O=0;O<2;O++){F=function(oa){return Math.pow(1-oa,3)*C[O]+3*Math.pow(1-oa,2)*oa*z[O]+3*(1-oa)*Math.pow(oa,2)*N[O]+Math.pow(oa,3)*aa[O]};var J=6*C[O]-12*z[O]+6*N[O],Z=-3*C[O]+9*z[O]-9*N[O]+3*aa[O],W=3*z[O]-3*C[O];if(Z==0){if(J!=0){J=-W/J;0<J&&J<1&&e[O].push(F(J))}}else{W=Math.pow(J,2)-4*W*Z;if(!(W<0)){var ka=(-J+Math.sqrt(W))/(2*Z);0<ka&&ka<1&&e[O].push(F(ka));
J=(-J-Math.sqrt(W))/(2*Z);0<J&&J<1&&e[O].push(F(J))}}}C=aa}else{e[0].push(F.x);e[1].push(F.y)}}}f=Math.min.apply(null,e[0]);h=Math.max.apply(null,e[0])-f;p=Math.min.apply(null,e[1]);e=Math.max.apply(null,e[1])-p;return{x:f,y:p,width:h,height:e}};svgedit.utilities.getBBox=function(e){var f=e||m.geSelectedElements()[0];if(e.nodeType!=1)return null;e=null;var h=f.nodeName;switch(h){case "text":if(f.textContent===""){f.textContent="a";e=f.getBBox();f.textContent=""}else try{e=f.getBBox()}catch(p){}break;
case "path":if(svgedit.browser.supportsPathBBox())try{e=f.getBBox()}catch(C){}else e=svgedit.utilities.getPathBBox(f);break;case "g":case "a":e=a(f);break;default:if(h==="use")e=a(f,true);if(h==="use"||h==="foreignObject"){e||(e=f.getBBox());if(!svgedit.browser.isWebkit()){h={};h.width=e.width;h.height=e.height;h.x=e.x+parseFloat(f.getAttribute("x")||0);h.y=e.y+parseFloat(f.getAttribute("y")||0);e=h}}else if(~L.indexOf(h))try{e=f.getBBox()}catch(F){f=$(f).closest("foreignObject");if(f.length)try{e=
f[0].getBBox()}catch(z){e=null}else e=null}}if(e)e=svgedit.utilities.bboxToObj(e);return e};svgedit.utilities.getRotationAngle=function(e,f){var h=e||m.getSelectedElements()[0];h=svgedit.transformlist.getTransformList(h);if(!h)return 0;for(var p=h.numberOfItems,C=0;C<p;++C){var F=h.getItem(C);if(F.type==4)return f?F.angle*Math.PI/180:F.angle}return 0};svgedit.utilities.getElem=svgedit.browser.supportsSelectors()?function(e){return G.querySelector("#"+e)}:svgedit.browser.supportsXpath()?function(e){return o.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+
e+'"]',A,function(){return"http://www.w3.org/2000/svg"},9,null).singleNodeValue}:function(e){return $(G).find("[id="+e+"]")[0]};svgedit.utilities.assignAttributes=function(e,f,h,p){h||(h=0);svgedit.browser.isOpera()||G.suspendRedraw(h);for(var C in f)if(h=C.substr(0,4)==="xml:"?"http://www.w3.org/XML/1998/namespace":C.substr(0,6)==="xlink:"?"http://www.w3.org/1999/xlink":null)e.setAttributeNS(h,C,f[C]);else p?svgedit.units.setUnitAttr(e,C,f[C]):e.setAttribute(C,f[C]);svgedit.browser.isOpera()||G.unsuspendRedraw(null)};
svgedit.utilities.cleanupElement=function(e){var f=G.suspendRedraw(60),h={"fill-opacity":1,"stop-opacity":1,opacity:1,stroke:"none","stroke-dasharray":"none","stroke-linejoin":"miter","stroke-linecap":"butt","stroke-opacity":1,"stroke-width":1,rx:0,ry:0},p;for(p in h){var C=h[p];e.getAttribute(p)==C&&e.removeAttribute(p)}G.unsuspendRedraw(f)}})();svgedit=svgedit||{};
(function(){if(!svgedit.sanitize)svgedit.sanitize={};var a={};a["http://www.w3.org/1999/xlink"]="xlink";a["http://www.w3.org/XML/1998/namespace"]="xml";a["http://www.w3.org/2000/xmlns/"]="xmlns";a["http://svg-edit.googlecode.com"]="se";a["http://www.w3.org/1999/xhtml"]="xhtml";a["http://www.w3.org/1998/Math/MathML"]="mathml";var L={};$.each(a,function(A,G){L[G]=A});var m={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray",
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class",
"clipPathUnits","id"],defs:[],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters","filterRes",
"filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display","fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform",
"font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit",
"stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id","class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class","clip-path",
"clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class",
"clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points",
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id","r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray",
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class","clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],"switch":["class","id","requiredFeatures","systemLanguage"],
symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity",
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures","spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight",
"id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width",
"style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[],mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth",
"height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},o={};$.each(m,function(A,G){var e={};$.each(G,function(f,h){if(h.indexOf(":")>=
0){var p=h.split(":");e[p[1]]=L[p[0]]}else e[h]=h=="xmlns"?"http://www.w3.org/2000/xmlns/":null});o[A]=e});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(A){if(A.nodeType==3){A.nodeValue=A.nodeValue.replace(/^\s+|\s+$/g,"");A.nodeValue.length||A.parentNode.removeChild(A)}if(A.nodeType==1){var G=A.parentNode;if(A.ownerDocument&&G){var e=m[A.nodeName],f=o[A.nodeName];if(e!=undefined){for(var h=[],p=A.attributes.length;p--;){var C=A.attributes.item(p),F=C.nodeName,
z=C.localName,N=C.namespaceURI;if(!(f.hasOwnProperty(z)&&N==f[z]&&N!="http://www.w3.org/2000/xmlns/")&&!(N=="http://www.w3.org/2000/xmlns/"&&a[C.nodeValue])){F.indexOf("se:")==0&&h.push([F,C.nodeValue]);A.removeAttributeNS(N,z)}if(svgedit.browser.isGecko())switch(F){case "transform":case "gradientTransform":case "patternTransform":z=C.nodeValue.replace(/(\d)-/g,"$1 -");A.setAttribute(F,z)}if(F=="style"){C=C.nodeValue.split(";");for(F=C.length;F--;){z=C[F].split(":");e.indexOf(z[0])>=0&&A.setAttribute(z[0],
z[1])}A.removeAttribute("style")}}$.each(h,function(aa,O){A.setAttributeNS("http://svg-edit.googlecode.com",O[0],O[1])});if((p=svgedit.utilities.getHref(A))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(A.nodeName)>=0)if(p[0]!="#"){svgedit.utilities.setHref(A,"");A.removeAttributeNS("http://www.w3.org/1999/xlink","href")}if(A.nodeName=="use"&&!svgedit.utilities.getHref(A))G.removeChild(A);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start",
"mask","stroke"],function(aa,O){var J=A.getAttribute(O);if(J)if((J=svgedit.utilities.getUrlFromAttr(J))&&J[0]!=="#"){A.setAttribute(O,"");A.removeAttribute(O)}});for(p=A.childNodes.length;p--;)svgedit.sanitize.sanitizeSvg(A.childNodes.item(p))}}else{for(e=[];A.hasChildNodes();)e.push(G.insertBefore(A.firstChild,A));G.removeChild(A);for(p=e.length;p--;)svgedit.sanitize.sanitizeSvg(e[p])}}}}})();svgedit=svgedit||{};
(function(){if(!svgedit.history)svgedit.history={};svgedit.history.HistoryEventTypes={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"};svgedit.history.MoveElementCommand=function(a,L,m,o){this.elem=a;this.text=o?"Move "+a.tagName+" to "+o:"Move "+a.tagName;this.oldNextSibling=L;this.oldParent=m;this.newNextSibling=a.nextSibling;this.newParent=a.parentNode};svgedit.history.MoveElementCommand.type=function(){return"svgedit.history.MoveElementCommand"};svgedit.history.MoveElementCommand.prototype.type=
svgedit.history.MoveElementCommand.type;svgedit.history.MoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.MoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.MoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,
this);this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.InsertElementCommand=function(a,L){this.elem=a;this.text=L||"Create "+a.tagName;this.parent=a.parentNode;this.nextSibling=this.elem.nextSibling};svgedit.history.InsertElementCommand.type=function(){return"svgedit.history.InsertElementCommand"};svgedit.history.InsertElementCommand.prototype.type=
svgedit.history.InsertElementCommand.type;svgedit.history.InsertElementCommand.prototype.getText=function(){return this.text};svgedit.history.InsertElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.InsertElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,
this);this.parent=this.elem.parentNode;this.elem=this.elem.parentNode.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.InsertElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.RemoveElementCommand=function(a,L,m,o){this.elem=a;this.text=o||"Delete "+a.tagName;this.nextSibling=L;this.parent=m;svgedit.transformlist.removeElementFromListMap(a)};svgedit.history.RemoveElementCommand.type=function(){return"svgedit.history.RemoveElementCommand"};
svgedit.history.RemoveElementCommand.prototype.type=svgedit.history.RemoveElementCommand.type;svgedit.history.RemoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.RemoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.parent=this.elem.parentNode;this.elem=this.parent.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,
this)};svgedit.history.RemoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.nextSibling==null&&window.console&&console.log("Error: reference element was lost");this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]};
svgedit.history.ChangeElementCommand=function(a,L,m){this.elem=a;this.text=m?"Change "+a.tagName+" "+m:"Change "+a.tagName;this.newValues={};this.oldValues=L;for(var o in L)this.newValues[o]=o=="#text"?a.textContent:o=="#href"?svgedit.utilities.getHref(a):a.getAttribute(o)};svgedit.history.ChangeElementCommand.type=function(){return"svgedit.history.ChangeElementCommand"};svgedit.history.ChangeElementCommand.prototype.type=svgedit.history.ChangeElementCommand.type;svgedit.history.ChangeElementCommand.prototype.getText=
function(){return this.text};svgedit.history.ChangeElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var L=false,m;for(m in this.newValues){if(this.newValues[m])if(m=="#text")this.elem.textContent=this.newValues[m];else m=="#href"?svgedit.utilities.setHref(this.elem,this.newValues[m]):this.elem.setAttribute(m,this.newValues[m]);else if(m=="#text")this.elem.textContent="";else{this.elem.setAttribute(m,"");this.elem.removeAttribute(m)}if(m==
"transform")L=true}if(!L)if(L=svgedit.utilities.getRotationAngle(this.elem)){m=elem.getBBox();L=["rotate(",L," ",m.x+m.width/2,",",m.y+m.height/2,")"].join("");L!=elem.getAttribute("transform")&&elem.setAttribute("transform",L)}a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var L=false,m;for(m in this.oldValues){if(this.oldValues[m])if(m==
"#text")this.elem.textContent=this.oldValues[m];else m=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[m]):this.elem.setAttribute(m,this.oldValues[m]);else if(m=="#text")this.elem.textContent="";else this.elem.removeAttribute(m);if(m=="transform")L=true}if(!L)if(L=svgedit.utilities.getRotationAngle(this.elem)){m=elem.getBBox();L=["rotate(",L," ",m.x+m.width/2,",",m.y+m.height/2,")"].join("");L!=elem.getAttribute("transform")&&elem.setAttribute("transform",L)}svgedit.transformlist.removeElementFromListMap(this.elem);
a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.BatchCommand=function(a){this.text=a||"Batch Command";this.stack=[]};svgedit.history.BatchCommand.type=function(){return"svgedit.history.BatchCommand"};svgedit.history.BatchCommand.prototype.type=svgedit.history.BatchCommand.type;svgedit.history.BatchCommand.prototype.getText=function(){return this.text};svgedit.history.BatchCommand.prototype.apply=
function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);for(var L=this.stack.length,m=0;m<L;++m)this.stack[m].apply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.BatchCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);for(var L=this.stack.length-1;L>=0;L--)this.stack[L].unapply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,
this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],L=this.stack.length;L--;)for(var m=this.stack[L].elements(),o=m.length;o--;)a.indexOf(m[o])==-1&&a.push(m[o]);return a};svgedit.history.BatchCommand.prototype.addSubCommand=function(a){this.stack.push(a)};svgedit.history.BatchCommand.prototype.isEmpty=function(){return this.stack.length==0};svgedit.history.UndoManager=function(a){this.handler_=a||null;this.undoStackPointer=0;this.undoStack=[];this.undoChangeStackPointer=
-1;this.undoableChangeStack=[]};svgedit.history.UndoManager.prototype.resetUndoStack=function(){this.undoStack=[];this.undoStackPointer=0};svgedit.history.UndoManager.prototype.getUndoStackSize=function(){return this.undoStackPointer};svgedit.history.UndoManager.prototype.getRedoStackSize=function(){return this.undoStack.length-this.undoStackPointer};svgedit.history.UndoManager.prototype.getNextUndoCommandText=function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():
""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.undoStackPointer<this.undoStack.length?this.undoStack[this.undoStackPointer].getText():""};svgedit.history.UndoManager.prototype.undo=function(){this.undoStackPointer>0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)};svgedit.history.UndoManager.prototype.redo=function(){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)};
svgedit.history.UndoManager.prototype.addCommandToHistory=function(a){if(this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0)this.undoStack=this.undoStack.splice(0,this.undoStackPointer);this.undoStack.push(a);this.undoStackPointer=this.undoStack.length};svgedit.history.UndoManager.prototype.beginUndoableChange=function(a,L){for(var m=++this.undoChangeStackPointer,o=L.length,A=Array(o),G=Array(o);o--;){var e=L[o];if(e!=null){G[o]=e;A[o]=e.getAttribute(a)}}this.undoableChangeStack[m]=
{attrName:a,oldValues:A,elements:G}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,L=this.undoableChangeStack[a],m=L.elements.length,o=L.attrName,A=new svgedit.history.BatchCommand("Change "+o);m--;){var G=L.elements[m];if(G!=null){var e={};e[o]=L.oldValues[m];e[o]!=G.getAttribute(o)&&A.addSubCommand(new svgedit.history.ChangeElementCommand(G,e,o))}}this.undoableChangeStack[a]=null;return A}})();svgedit=svgedit||{};
(function(){if(!svgedit.select)svgedit.select={};var a,L,m;svgedit.select.Selector=function(o,A){this.id=o;this.selectedElement=A;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#22C","stroke-width":"1","stroke-dasharray":"5,5",style:"pointer-events:none"}}));this.gripCoords={nw:null,n:null,ne:null,e:null,se:null,
s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(o){this.locked=true;this.selectedElement=o;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(o){var A=[];o=Math.round(o/45);if(o<0)o+=8;for(var G in m.selectorGrips)A.push(G);for(;o>0;){A.push(A.shift());o--}o=0;for(G in m.selectorGrips){m.selectorGrips[G].setAttribute("style","cursor:"+A[o]+"-resize");o++}};svgedit.select.Selector.prototype.showGrips=
function(o){m.selectorGripsGroup.setAttribute("display",o?"inline":"none");var A=this.selectedElement;this.hasGrips=o;if(A&&o){this.selectorGroup.appendChild(m.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(A))}};svgedit.select.Selector.prototype.resize=function(){var o=this.selectorRect,A=m,G=A.selectorGrips,e=this.selectedElement,f=e.getAttribute("stroke-width"),h=a.currentZoom(),p=1/h;if(e.getAttribute("stroke")!=="none"&&!isNaN(f))p+=f/2;var C=e.tagName;if(C==="text")p+=
2/h;f=svgedit.transformlist.getTransformList(e);f=svgedit.math.transformListToTransform(f).matrix;f.e*=h;f.f*=h;var F=svgedit.utilities.getBBox(e);if(C==="g"&&!$.data(e,"gsvg"))if(C=a.getStrokedBBox(e.childNodes))F=C;C=F.x;var z=F.y,N=F.width;F=F.height;p*=h;h=svgedit.math.transformBox(C*h,z*h,N*h,F*h,f);f=h.aabox;C=f.x-p;z=f.y-p;N=f.width+p*2;var aa=f.height+p*2;f=C+N/2;F=z+aa/2;if(e=svgedit.utilities.getRotationAngle(e)){C=a.svgRoot().createSVGTransform();C.setRotate(-e,f,F);C=C.matrix;h.tl=svgedit.math.transformPoint(h.tl.x,
h.tl.y,C);h.tr=svgedit.math.transformPoint(h.tr.x,h.tr.y,C);h.bl=svgedit.math.transformPoint(h.bl.x,h.bl.y,C);h.br=svgedit.math.transformPoint(h.br.x,h.br.y,C);C=h.tl;N=C.x;aa=C.y;var O=C.x,J=C.y;C=Math.min;z=Math.max;N=C(N,C(h.tr.x,C(h.bl.x,h.br.x)))-p;aa=C(aa,C(h.tr.y,C(h.bl.y,h.br.y)))-p;O=z(O,z(h.tr.x,z(h.bl.x,h.br.x)))+p;J=z(J,z(h.tr.y,z(h.bl.y,h.br.y)))+p;C=N;z=aa;N=O-N;aa=J-aa}p=a.svgRoot().suspendRedraw(100);o.setAttribute("d","M"+C+","+z+" L"+(C+N)+","+z+" "+(C+N)+","+(z+aa)+" "+C+","+(z+
aa)+"z");this.selectorGroup.setAttribute("transform",e?"rotate("+[e,f,F].join(",")+")":"");this.gripCoords={nw:[C,z],ne:[C+N,z],sw:[C,z+aa],se:[C+N,z+aa],n:[C+N/2,z],w:[C,z+aa/2],e:[C+N,z+aa/2],s:[C+N/2,z+aa]};for(var Z in this.gripCoords){o=this.gripCoords[Z];G[Z].setAttribute("cx",o[0]);G[Z].setAttribute("cy",o[1])}A.rotateGripConnector.setAttribute("x1",C+N/2);A.rotateGripConnector.setAttribute("y1",z);A.rotateGripConnector.setAttribute("x2",C+N/2);A.rotateGripConnector.setAttribute("y2",z-20);
A.rotateGrip.setAttribute("cx",C+N/2);A.rotateGrip.setAttribute("cy",z-20);a.svgRoot().unsuspendRedraw(p)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.rotateGrip=this.rotateGripConnector=this.selectorGripsGroup=null;this.initGroup()};svgedit.select.SelectorManager.prototype.initGroup=function(){this.selectorParentGroup&&this.selectorParentGroup.parentNode&&
this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup);this.selectorParentGroup=a.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}});this.selectorGripsGroup=a.createSVGElement({element:"g",attr:{display:"none"}});this.selectorParentGroup.appendChild(this.selectorGripsGroup);a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var o in this.selectorGrips){var A=a.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+
o,fill:"#22C",r:4,style:"cursor:"+o+"-resize","stroke-width":2,"pointer-events":"all"}});$.data(A,"dir",o);$.data(A,"type","resize");this.selectorGrips[o]=this.selectorGripsGroup.appendChild(A)}this.rotateGripConnector=this.selectorGripsGroup.appendChild(a.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}}));this.rotateGrip=this.selectorGripsGroup.appendChild(a.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:4,
stroke:"#22C","stroke-width":2,style:"cursor:url("+L.imgPath+"rotate.png) 12 12, auto;"}}));$.data(this.rotateGrip,"type","rotate");if(!$("#canvasBackground").length){o=L.dimensions;o=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:o[0],height:o[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});A=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});
o.appendChild(A);a.svgRoot().insertBefore(o,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(o){if(o==null)return null;var A=this.selectors.length;if(typeof this.selectorMap[o.id]=="object"){this.selectorMap[o.id].locked=true;return this.selectorMap[o.id]}for(var G=0;G<A;++G)if(this.selectors[G]&&!this.selectors[G].locked){this.selectors[G].locked=true;this.selectors[G].reset(o);this.selectorMap[o.id]=this.selectors[G];return this.selectors[G]}this.selectors[A]=
new svgedit.select.Selector(A,o);this.selectorParentGroup.appendChild(this.selectors[A].selectorGroup);this.selectorMap[o.id]=this.selectors[A];return this.selectors[A]};svgedit.select.SelectorManager.prototype.releaseSelector=function(o){if(o!=null)for(var A=this.selectors.length,G=this.selectorMap[o.id],e=0;e<A;++e)if(this.selectors[e]&&this.selectors[e]==G){G.locked==false&&console.log("WARNING! selector was released but was already unlocked");delete this.selectorMap[o.id];G.locked=false;G.selectedElement=
null;G.showGrips(false);try{G.selectorGroup.setAttribute("display","none")}catch(f){}break}};svgedit.select.SelectorManager.prototype.getRubberBandBox=function(){if(!this.rubberBandBox)this.rubberBandBox=this.selectorParentGroup.appendChild(a.createSVGElement({element:"rect",attr:{id:"selectorRubberBand",fill:"#22C","fill-opacity":0.15,stroke:"#22C","stroke-width":0.5,display:"none",style:"pointer-events:none"}}));return this.rubberBandBox};svgedit.select.init=function(o,A){L=o;a=A;m=new svgedit.select.SelectorManager};
svgedit.select.getSelectorManager=function(){return m}})();svgedit=svgedit||{};
(function(){if(!svgedit.draw)svgedit.draw={};var a="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),L={LET_DOCUMENT_DECIDE:0,ALWAYS_RANDOMIZE:1,NEVER_RANDOMIZE:2},m=L.LET_DOCUMENT_DECIDE;svgedit.draw.Layer=function(o,A){this.name_=o;this.group_=A};svgedit.draw.Layer.prototype.getName=function(){return this.name_};svgedit.draw.Layer.prototype.getGroup=function(){return this.group_};svgedit.draw.randomizeIds=function(o,A){m=o==false?L.NEVER_RANDOMIZE:
L.ALWAYS_RANDOMIZE;if(m==L.ALWAYS_RANDOMIZE&&!A.getNonce())A.setNonce(Math.floor(Math.random()*100001));else m==L.NEVER_RANDOMIZE&&A.getNonce()&&A.clearNonce()};svgedit.draw.Drawing=function(o,A){if(!o||!o.tagName||!o.namespaceURI||o.tagName!="svg"||o.namespaceURI!="http://www.w3.org/2000/svg")throw"Error: svgedit.draw.Drawing instance initialized without a <svg> element";this.svgElem_=o;this.obj_num=0;this.idPrefix=A||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_=
"";var G=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(G&&m!=L.NEVER_RANDOMIZE)this.nonce_=G;else m==L.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(o){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+o):$(this.svgElem_).find("[id="+o+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_};
svgedit.draw.Drawing.prototype.setNonce=function(o){this.svgElem_.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:se","http://svg-edit.googlecode.com");this.svgElem_.setAttributeNS("http://svg-edit.googlecode.com","se:nonce",o);this.nonce_=o};svgedit.draw.Drawing.prototype.clearNonce=function(){this.nonce_=""};svgedit.draw.Drawing.prototype.getId=function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num};svgedit.draw.Drawing.prototype.getNextId=function(){var o=
this.obj_num,A=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();A=true}else this.obj_num++;for(var G=this.getId();this.getElem_(G);){if(A){this.obj_num=o;A=false}this.obj_num++;G=this.getId()}if(A)this.obj_num=o;return G};svgedit.draw.Drawing.prototype.releaseId=function(o){var A=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof o!="string"||o.indexOf(A)!=0)return false;o=parseInt(o.substr(A.length));if(typeof o!="number"||o<=0||this.releasedNums.indexOf(o)!=-1)return false;
this.releasedNums.push(o);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length};svgedit.draw.Drawing.prototype.hasLayer=function(o){for(var A=0;A<this.getNumLayers();A++)if(this.all_layers[A][0]==o)return true;return false};svgedit.draw.Drawing.prototype.getLayerName=function(o){if(o>=0&&o<this.getNumLayers())return this.all_layers[o][0];return""};svgedit.draw.Drawing.prototype.getCurrentLayer=function(){return this.current_layer};svgedit.draw.Drawing.prototype.getCurrentLayerName=
function(){for(var o=0;o<this.getNumLayers();++o)if(this.all_layers[o][1]==this.current_layer)return this.getLayerName(o);return""};svgedit.draw.Drawing.prototype.setCurrentLayer=function(o){for(var A=0;A<this.getNumLayers();++A)if(o==this.getLayerName(A)){if(this.current_layer!=this.all_layers[A][1]){this.current_layer.setAttribute("style","pointer-events:none");this.current_layer=this.all_layers[A][1];this.current_layer.setAttribute("style","pointer-events:all")}return true}return false};svgedit.draw.Drawing.prototype.deleteCurrentLayer=
function(){if(this.current_layer&&this.getNumLayers()>1){var o=this.current_layer.parentNode.removeChild(this.current_layer);this.identifyLayers();return o}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];for(var o=this.svgElem_.childNodes.length,A=[],G=[],e=null,f=false,h=0;h<o;++h){var p=this.svgElem_.childNodes.item(h);if(p&&p.nodeType==1)if(p.tagName=="g"){f=true;var C=$("title",p).text();if(!C&&svgedit.browser.isOpera()&&p.querySelectorAll)C=$(p.querySelectorAll("title")).text();
if(C){G.push(C);this.all_layers.push([C,p]);e=p;svgedit.utilities.walkTree(p,function(F){F.setAttribute("style","pointer-events:inherit")});e.setAttribute("style","pointer-events:none")}else A.push(p)}else if(~a.indexOf(p.nodeName)){svgedit.utilities.getBBox(p);A.push(p)}}o=this.svgElem_.ownerDocument;if(A.length>0||!f){for(h=1;G.indexOf("Layer "+h)>=0;)h++;G="Layer "+h;e=o.createElementNS("http://www.w3.org/2000/svg","g");f=o.createElementNS("http://www.w3.org/2000/svg","title");f.textContent=G;
e.appendChild(f);for(f=0;f<A.length;++f)e.appendChild(A[f]);this.svgElem_.appendChild(e);this.all_layers.push([G,e])}svgedit.utilities.walkTree(e,function(F){F.setAttribute("style","pointer-events:inherit")});this.current_layer=e;this.current_layer.setAttribute("style","pointer-events:all")};svgedit.draw.Drawing.prototype.createLayer=function(o){var A=this.svgElem_.ownerDocument,G=A.createElementNS("http://www.w3.org/2000/svg","g");A=A.createElementNS("http://www.w3.org/2000/svg","title");A.textContent=
o;G.appendChild(A);this.svgElem_.appendChild(G);this.identifyLayers();return G};svgedit.draw.Drawing.prototype.getLayerVisibility=function(o){for(var A=null,G=0;G<this.getNumLayers();++G)if(this.getLayerName(G)==o){A=this.all_layers[G][1];break}if(!A)return false;return A.getAttribute("display")!="none"};svgedit.draw.Drawing.prototype.setLayerVisibility=function(o,A){if(typeof A!="boolean")return null;for(var G=null,e=0;e<this.getNumLayers();++e)if(this.getLayerName(e)==o){G=this.all_layers[e][1];
break}if(!G)return null;G.getAttribute("display");G.setAttribute("display",A?"inline":"none");return G};svgedit.draw.Drawing.prototype.getLayerOpacity=function(o){for(var A=0;A<this.getNumLayers();++A)if(this.getLayerName(A)==o){(o=this.all_layers[A][1].getAttribute("opacity"))||(o="1.0");return parseFloat(o)}return null};svgedit.draw.Drawing.prototype.setLayerOpacity=function(o,A){if(!(typeof A!="number"||A<0||A>1))for(var G=0;G<this.getNumLayers();++G)if(this.getLayerName(G)==o){this.all_layers[G][1].setAttribute("opacity",
A);break}}})();svgedit=svgedit||{};
(function(){if(!svgedit.path)svgedit.path={};var a={pathNodeTooltip:"Drag node to move it. Double-click node to change segment type",pathCtrlPtTooltip:"Drag control point to adjust curve properties"},L={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},m=[],o=true,A={};svgedit.path.setLinkControlPoints=function(f){o=f};var G=svgedit.path.path=null;svgedit.path.init=
function(f){G=f;m=[0,"ClosePath"];$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(h,p){m.push(p+"Abs");m.push(p+"Rel")})};svgedit.path.insertItemBefore=function(f,h,p){f=f.pathSegList;if(svgedit.browser.supportsPathInsertItemBefore())f.insertItemBefore(h,p);else{for(var C=f.numberOfItems,F=[],z=0;z<C;z++){var N=f.getItem(z);F.push(N)}f.clear();for(z=0;z<C;z++){z==p&&f.appendItem(h);f.appendItem(F[z])}}};
svgedit.path.ptObjToArr=function(f,h){for(var p=L[f],C=p.length,F=Array(C),z=0;z<C;z++)F[z]=h[p[z]];return F};svgedit.path.getGripPt=function(f,h){var p={x:h?h.x:f.item.x,y:h?h.y:f.item.y},C=f.path;if(C.matrix)p=svgedit.math.transformPoint(p.x,p.y,C.matrix);p.x*=G.getCurrentZoom();p.y*=G.getCurrentZoom();return p};svgedit.path.getPointFromGrip=function(f,h){var p={x:f.x,y:f.y};if(h.matrix){f=svgedit.math.transformPoint(p.x,p.y,h.imatrix);p.x=f.x;p.y=f.y}p.x/=G.getCurrentZoom();p.y/=G.getCurrentZoom();
return p};svgedit.path.addPointGrip=function(f,h,p){var C=svgedit.path.getGripContainer(),F=svgedit.utilities.getElem("pathpointgrip_"+f);if(!F){F=document.createElementNS("http://www.w3.org/2000/svg","circle");svgedit.utilities.assignAttributes(F,{id:"pathpointgrip_"+f,display:"none",r:4,fill:"#0FF",stroke:"#00F","stroke-width":2,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});F=C.appendChild(F);$("#pathpointgrip_"+f).dblclick(function(){svgedit.path.path&&svgedit.path.path.setSegType()})}h&&
p&&svgedit.utilities.assignAttributes(F,{cx:h,cy:p,display:"inline"});return F};svgedit.path.getGripContainer=function(){var f=svgedit.utilities.getElem("pathpointgrip_container");if(!f){f=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS("http://www.w3.org/2000/svg","g"));f.id="pathpointgrip_container"}return f};svgedit.path.addCtrlGrip=function(f){var h=svgedit.utilities.getElem("ctrlpointgrip_"+f);if(h)return h;h=document.createElementNS("http://www.w3.org/2000/svg",
"circle");svgedit.utilities.assignAttributes(h,{id:"ctrlpointgrip_"+f,display:"none",r:4,fill:"#0FF",stroke:"#55F","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathCtrlPtTooltip});svgedit.path.getGripContainer().appendChild(h);return h};svgedit.path.getCtrlLine=function(f){var h=svgedit.utilities.getElem("ctrlLine_"+f);if(h)return h;h=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(h,{id:"ctrlLine_"+f,stroke:"#555","stroke-width":1,
style:"pointer-events:none"});svgedit.path.getGripContainer().appendChild(h);return h};svgedit.path.getPointGrip=function(f,h){var p=svgedit.path.addPointGrip(f.index);if(h){var C=svgedit.path.getGripPt(f);svgedit.utilities.assignAttributes(p,{cx:C.x,cy:C.y,display:"inline"})}return p};svgedit.path.getControlPoints=function(f){var h=f.item,p=f.index;if(!("x1"in h)||!("x2"in h))return null;var C={};svgedit.path.getGripContainer();for(var F=[svgedit.path.path.segs[p-1].item,h],z=1;z<3;z++){var N=p+
"c"+z,aa=C["c"+z+"_line"]=svgedit.path.getCtrlLine(N),O=svgedit.path.getGripPt(f,{x:h["x"+z],y:h["y"+z]}),J=svgedit.path.getGripPt(f,{x:F[z-1].x,y:F[z-1].y});svgedit.utilities.assignAttributes(aa,{x1:O.x,y1:O.y,x2:J.x,y2:J.y,display:"inline"});C["c"+z+"_line"]=aa;pointGrip=C["c"+z]=svgedit.path.addCtrlGrip(N);svgedit.utilities.assignAttributes(pointGrip,{cx:O.x,cy:O.y,display:"inline"});C["c"+z]=pointGrip}return C};svgedit.path.replacePathSeg=function(f,h,p,C){C=C||svgedit.path.path.elem;f=C["createSVGPathSeg"+
m[f]].apply(C,p);if(svgedit.browser.supportsPathReplaceItem())C.pathSegList.replaceItem(f,h);else{p=C.pathSegList;C=p.numberOfItems;for(var F=[],z=0;z<C;z++){var N=p.getItem(z);F.push(N)}p.clear();for(z=0;z<C;z++)z==h?p.appendItem(f):p.appendItem(F[z])}};svgedit.path.getSegSelector=function(f,h){var p=f.index,C=svgedit.utilities.getElem("segline_"+p);if(!C){var F=svgedit.path.getGripContainer();C=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(C,{id:"segline_"+
p,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});F.appendChild(C)}if(h){p=f.prev;if(!p){C.setAttribute("display","none");return C}p=svgedit.path.getGripPt(p);svgedit.path.replacePathSeg(2,0,[p.x,p.y],C);F=svgedit.path.ptObjToArr(f.type,f.item,true);for(var z=0;z<F.length;z+=2){p=svgedit.path.getGripPt(f,{x:F[z],y:F[z+1]});F[z]=p.x;F[z+1]=p.y}svgedit.path.replacePathSeg(f.type,1,F,C)}return C};svgedit.path.smoothControlPoints=this.smoothControlPoints=
function(f,h,p){var C=f.x-p.x,F=f.y-p.y,z=h.x-p.x,N=h.y-p.y;if((C!=0||F!=0)&&(z!=0||N!=0)){f=Math.atan2(F,C);h=Math.atan2(N,z);C=Math.sqrt(C*C+F*F);z=Math.sqrt(z*z+N*N);F=G.getSVGRoot().createSVGPoint();N=G.getSVGRoot().createSVGPoint();if(f<0)f+=2*Math.PI;if(h<0)h+=2*Math.PI;var aa=Math.abs(f-h),O=Math.abs(Math.PI-aa)/2;if(f-h>0){f=aa<Math.PI?f+O:f-O;h=aa<Math.PI?h-O:h+O}else{f=aa<Math.PI?f-O:f+O;h=aa<Math.PI?h+O:h-O}F.x=C*Math.cos(f)+p.x;F.y=C*Math.sin(f)+p.y;N.x=z*Math.cos(h)+p.x;N.y=z*Math.sin(h)+
p.y;return[F,N]}};svgedit.path.Segment=function(f,h){this.selected=false;this.index=f;this.item=h;this.type=h.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=function(f){for(var h in this.ctrlpts)this.ctrlpts[h].setAttribute("display",f?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(f){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill",f?"#0FF":"#EEE")};svgedit.path.Segment.prototype.show=function(f){if(this.ptgrip){this.ptgrip.setAttribute("display",
f?"inline":"none");this.segsel.setAttribute("display",f?"inline":"none");this.showCtrlPts(f)}};svgedit.path.Segment.prototype.select=function(f){if(this.ptgrip){this.ptgrip.setAttribute("stroke",f?"#0FF":"#00F");this.segsel.setAttribute("display",f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,
true)};svgedit.path.Segment.prototype.update=function(f){if(this.ptgrip){var h=svgedit.path.getGripPt(this);svgedit.utilities.assignAttributes(this.ptgrip,{cx:h.x,cy:h.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(f,h){var p=this.item;p=this.ctrlpts?[p.x+=f,p.y+=h,p.x1,p.y1,p.x2+=f,p.y2+=h]:[p.x+=f,
p.y+=h];svgedit.path.replacePathSeg(this.type,this.index,p);if(this.next&&this.next.ctrlpts){p=this.next.item;p=[p.x,p.y,p.x1+=f,p.y1+=h,p.x2,p.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,p)}if(this.mate){p=this.mate.item;p=[p.x+=f,p.y+=h];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,p)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var h,p,C;if(f==2){p=1;h=this.next;if(!h)return;C=this.item}else{p=2;h=this.prev;
if(!h)return;C=h.item}var F=h.item;F["x"+p]=C.x+(C.x-this.item["x"+f]);F["y"+p]=C.y+(C.y-this.item["y"+f]);svgedit.path.replacePathSeg(h.type,h.index,[F.x,F.y,F.x1,F.y1,F.x2,F.y2]);h.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(f,h,p){var C=this.item;C["x"+f]+=h;C["y"+f]+=p;svgedit.path.replacePathSeg(this.type,this.index,[C.x,C.y,C.x1,C.y1,C.x2,C.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,h){svgedit.path.replacePathSeg(f,this.index,h);this.type=f;
this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,h=f.numberOfItems;
this.segs=[];this.selected_pts=[];this.first_seg=null;for(var p=0;p<h;p++){var C=f.getItem(p);C=new svgedit.path.Segment(p,C);C.path=this;this.segs.push(C)}f=this.segs;C=null;for(p=0;p<h;p++){var F=f[p],z=p+1>=h?null:f[p+1],N=p-1<0?null:f[p-1];if(F.type===2){if(N&&N.type!==1){z=f[C];z.next=f[C+1];z.next.prev=z;z.addGrip()}C=p}else if(z&&z.type===1){F.next=f[C+1];F.next.prev=F;F.mate=f[C];F.addGrip();if(this.first_seg==null)this.first_seg=F}else if(z){if(F.type!==1){F.addGrip();if(z&&z.type!==2){F.next=
z;F.next.prev=F}}}else if(F.type!==1){z=f[C];z.next=f[C+1];z.next.prev=z;z.addGrip();F.addGrip();if(!this.first_seg)this.first_seg=f[C]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var h=this.segs.length,p=0;p<h;p++)if(f.call(this.segs[p],p)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var h=this.segs[f];if(h.prev){var p=h.prev,C;switch(h.item.pathSegType){case 4:var F=(h.item.x+p.item.x)/2,z=(h.item.y+p.item.y)/2;C=this.elem.createSVGPathSegLinetoAbs(F,z);break;
case 6:C=(p.item.x+h.item.x1)/2;var N=(h.item.x1+h.item.x2)/2,aa=(h.item.x2+h.item.x)/2,O=(C+N)/2;N=(N+aa)/2;F=(O+N)/2;var J=(p.item.y+h.item.y1)/2,Z=(h.item.y1+h.item.y2)/2;p=(h.item.y2+h.item.y)/2;var W=(J+Z)/2;Z=(Z+p)/2;z=(W+Z)/2;C=this.elem.createSVGPathSegCurvetoCubicAbs(F,z,C,J,O,W);svgedit.path.replacePathSeg(h.type,f,[h.item.x,h.item.y,N,Z,aa,p])}svgedit.path.insertItemBefore(this.elem,C,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var h=this.segs[f],p=this.elem.pathSegList;h.show(false);
var C=h.next;if(h.mate){var F=[C.item.x,C.item.y];svgedit.path.replacePathSeg(2,C.index,F);svgedit.path.replacePathSeg(4,h.index,F);p.removeItem(h.mate.index)}else{if(!h.prev){F=[C.item.x,C.item.y];svgedit.path.replacePathSeg(2,h.next.index,F)}p.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var h=false;svgedit.path.path.eachSeg(function(p){if(p<=f)return true;if(this.type===2)return false;else if(this.type===1){h=true;return false}});return h};svgedit.path.Path.prototype.removePtFromSelection=
function(f){var h=this.selected_pts.indexOf(f);if(h!=-1){this.segs[f].select(false);this.selected_pts.splice(h,1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,
h){for(var p=this.selected_pts.length;p--;)this.segs[this.selected_pts[p]].move(f,h)};svgedit.path.Path.prototype.moveCtrl=function(f,h){var p=this.segs[this.selected_pts[0]];p.moveCtrl(this.dragctrl,f,h);o&&p.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var h=this.selected_pts.length,p;h--;){var C=this.segs[this.selected_pts[h]],F=C.prev;if(F){if(!f){p="Toggle Path Segment Type";f=C.type==6?4:6}f-=0;var z=C.item.x,N=C.item.y,aa=F.item.x;F=F.item.y;
var O;switch(f){case 6:if(C.olditem){aa=C.olditem;O=[z,N,aa.x1,aa.y1,aa.x2,aa.y2]}else{O=z-aa;var J=N-F;O=[z,N,aa+O/3,F+J/3,z-O/3,N-J/3]}break;case 4:O=[z,N];C.olditem=C.item}C.setType(f,O)}}svgedit.path.path.endChanges(p)};svgedit.path.Path.prototype.selectPt=function(f,h){this.clearSelection();f==null&&this.eachSeg(function(p){if(this.prev)f=p});this.addPtsToSelection(f);if(h){this.dragctrl=h;o&&this.segs[f].setLinked(h)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=
svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=null;this.eachSeg(function(h){this.item=f.pathSegList.getItem(h);this.update()});return this};svgedit.path.getPath_=function(f){var h=A[f.id];h||(h=A[f.id]=new svgedit.path.Path(f));return h};svgedit.path.removePath_=function(f){f in A&&delete A[f]};var e=function(f,h){dx=f-oldcx;dy=h-oldcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+angle;dx=r*Math.cos(theta)+oldcx;dy=r*Math.sin(theta)+oldcy;dx-=newcx;
dy-=newcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-angle;return{x:(r*Math.cos(theta)+newcx)/1,y:(r*Math.sin(theta)+newcy)/1}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,h=svgedit.utilities.getRotationAngle(f,true);if(h){var p=svgedit.utilities.getBBox(f),C=svgedit.path.path.oldbbox,F=C.x+C.width/2,z=C.y+C.height/2;C=p.x+p.width/2;p=p.y+p.height/2;C=C-F;var N=p-z;p=Math.sqrt(C*C+N*N);N=Math.atan2(N,C)+h;C=p*Math.cos(N)+F;p=p*Math.sin(N)+z;F=f.pathSegList;for(z=F.numberOfItems;z;){z-=
1;N=F.getItem(z);var aa=N.pathSegType;if(aa!=1){var O=e(N.x,N.y);O=[O.x,O.y];if(N.x1!=null&&N.x2!=null){c_vals1=e(N.x1,N.y1);c_vals2=e(N.x2,N.y2);O.splice(O.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(aa,z,O)}}svgedit.utilities.getBBox(f);F=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);F.setRotate(h*180/Math.PI,C,p);f.replaceItem(F,0)}};svgedit.path.clearData=function(){A={}}})();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(L,m){var o=this.length;if(!o)return this;for(var A=0;A<o;A++){var G=this[A];if(G.namespaceURI==="http://www.w3.org/2000/svg")if(m!==undefined)G.setAttribute(L,m);else if($.isArray(L)){o=L.length;for(A={};o--;){var e=L[o],f=G.getAttribute(e);if(f||f==="0")f=isNaN(f)?f:f-0;A[e]=f}return A}else if(typeof L==="object")for(e in L)G.setAttribute(e,L[e]);else{if((f=G.getAttribute(L))||f==="0")f=isNaN(f)?f:f-0;return f}else return a.apply(this,arguments)}return this}})();
$.SvgCanvas=function(a,L){function m(b,c){for(var d=svgedit.utilities.getBBox(b),l=0;l<2;l++){var k=l===0?"fill":"stroke",w=b.getAttribute(k);if(w&&w.indexOf("url(")===0){w=pb(w);if(w.tagName==="linearGradient"){var n=w.getAttribute("x1")||0,g=w.getAttribute("y1")||0,s=w.getAttribute("x2")||1,v=w.getAttribute("y2")||0;n=d.width*n+d.x;g=d.height*g+d.y;s=d.width*s+d.x;v=d.height*v+d.y;n=ka(n,g,c);v=ka(s,v,c);s={};s.x1=(n.x-d.x)/d.width;s.y1=(n.y-d.y)/d.height;s.x2=(v.x-d.x)/d.width;s.y2=(v.y-d.y)/d.height;
w=w.cloneNode(true);$(w).attr(s);w.id=Ea();Ta().appendChild(w);b.setAttribute(k,"url(#"+w.id+")")}}}}var o="http://www.w3.org/2000/svg",A={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};L&&$.extend(A,L);var G=A.dimensions,e=this,f=a.ownerDocument,h=f.importNode(svgedit.utilities.text2xml('<svg id="svgroot" xmlns="'+o+'" xlinkns="http://www.w3.org/1999/xlink" width="'+G[0]+'" height="'+G[1]+'" x="'+G[0]+'" y="'+G[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(h);var p=f.createElementNS(o,"svg");(e.clearSvgContentElement=function(){for(;p.firstChild;)p.removeChild(p.firstChild);$(p).attr({id:"svgcontent",width:G[0],height:G[1],x:G[0],y:G[1],overflow:A.show_outside_canvas?"visible":"hidden",xmlns:o,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(h);var b=f.createComment(" Created with SVG-edit - http://svg-edit.googlecode.com/ ");p.appendChild(b)})();var C="svg_";e.setIdPrefix=function(b){C=
b};e.current_drawing_=new svgedit.draw.Drawing(p,C);var F=e.getCurrentDrawing=function(){return e.current_drawing_},z=1,N=null,aa={shape:{fill:"#"+A.initFill.color,fill_paint:null,fill_opacity:A.initFill.opacity,stroke:"#"+A.initStroke.color,stroke_paint:null,stroke_opacity:A.initStroke.opacity,stroke_width:A.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:A.initOpacity}};aa.text=$.extend(true,{},aa.shape);$.extend(aa.text,{fill:"#000000",stroke_width:0,
font_size:24,font_family:"serif"});var O=aa.shape,J=Array(1),Z=this.addSvgElementFromJson=function(b){var c=svgedit.utilities.getElem(b.attr.id),d=F().getCurrentLayer();if(c&&b.element!=c.tagName){d.removeChild(c);c=null}if(!c){c=f.createElementNS(o,b.element);if(d)(N||d).appendChild(c)}b.curStyles&&svgedit.utilities.assignAttributes(c,{fill:O.fill,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,
"stroke-opacity":O.stroke_opacity,"fill-opacity":O.fill_opacity,opacity:O.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(c,b.attr,100);svgedit.utilities.cleanupElement(c);return c},W=e.getTransformList=svgedit.transformlist.getTransformList,ka=svgedit.math.transformPoint,oa=e.matrixMultiply=svgedit.math.matrixMultiply,Pa=e.hasMatrixTransform=svgedit.math.hasMatrixTransform,sa=e.transformListToTransform=svgedit.math.transformListToTransform,Cb=svgedit.math.snapToAngle,
Pb=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return A.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return p.getAttribute("height")/z},getWidth:function(){return p.getAttribute("width")/z},getRoundDigits:function(){return lb.round_digits}});var ca=e.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return h},getSelectedElements:function(){return J},
getSVGContent:function(){return p}});var qb=e.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,db=e.getHref=svgedit.utilities.getHref,fb=e.setHref=svgedit.utilities.setHref,cc=svgedit.utilities.getPathBBox;e.getBBox=svgedit.utilities.getBBox;var Ua=e.getRotationAngle=svgedit.utilities.getRotationAngle,ya=e.getElem=svgedit.utilities.getElem,Ca=e.assignAttributes=svgedit.utilities.assignAttributes,Qb=this.cleanupElement=svgedit.utilities.cleanupElement,Ha=svgedit.sanitize.getNSMap(),rb=e.sanitizeSvg=
svgedit.sanitize.sanitizeSvg,ia=svgedit.history.MoveElementCommand,wa=svgedit.history.InsertElementCommand,Ia=svgedit.history.RemoveElementCommand,Fa=svgedit.history.ChangeElementCommand,qa=svgedit.history.BatchCommand;e.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(b,c){var d=svgedit.history.HistoryEventTypes;if(b==d.BEFORE_UNAPPLY||b==d.BEFORE_APPLY)e.clearSelection();else if(b==d.AFTER_APPLY||b==d.AFTER_UNAPPLY){var l=c.elements();e.pathActions.clear();fa("changed",l);l=
c.type();d=b==d.AFTER_APPLY;if(l==ia.type()){d=d?c.newParent:c.oldParent;d==p&&e.identifyLayers()}else if(l==wa.type()||l==Ia.type()){c.parent==p&&e.identifyLayers();if(l==wa.type())d&&Db(c.elem);else d||Db(c.elem);c.elem.tagName==="use"&&Eb(c.elem)}else if(l==Fa.type()){c.elem.tagName=="title"&&c.elem.parentNode.parentNode==p&&e.identifyLayers();d=d?c.newValues:c.oldValues;d.stdDeviation&&e.setBlurOffsets(c.elem.parentNode,d.stdDeviation);if(c.elem.tagName==="use"&&svgedit.browser.isWebkit()){l=
c.elem;if(!l.getAttribute("x")&&!l.getAttribute("y")){d=l.parentNode;var k=l.nextSibling;d.removeChild(l);d.insertBefore(l,k)}}}}}});var la=function(b){e.undoMgr.addCommandToHistory(b)};svgedit.select.init(A,{createSVGElement:function(b){return e.addSvgElementFromJson(b)},svgRoot:function(){return h},svgContent:function(){return p},currentZoom:function(){return z},getStrokedBBox:function(b){return e.getStrokedBBox([b])}});var ua=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return z},
getSVGRoot:function(){return h}});svgedit.utilities.snapToGrid=function(b){var c=A.snappingStep,d=A.baseUnit;if(d!=="px")c*=svgedit.units.getTypeMap()[d];return b=Math.round(b/c)*c};var na=svgedit.utilities.snapToGrid,mb={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"},Rb=["clip-path","fill","filter","marker-end","marker-mid","marker-start",
"mask","stroke"],sb=$.data,Fb=document.createElementNS(o,"animate");$(Fb).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(h);var Db=function(b){var c=$(b).attr(Rb),d;for(d in c){var l=c[d];if(l&&l.indexOf("url(")===0){l=qb(l).substr(1);if(!ya(l)){Ta().appendChild(Sb[l]);delete Sb[l]}}}b=b.getElementsByTagName("*");if(b.length){c=0;for(d=b.length;c<d;c++)Db(b[c])}},nb={},Tb=A.imgPath+"logo.png",tb=[],lb={round_digits:5},ra=false,Ja=null,ta="select",Ya="none",ob={},Qa=
aa.text,Ma=O,Gb=null,ja=null,eb=[],xb={},yb=null,Sb={};e.clipBoard=[];var zb=this.runExtensions=function(b,c,d){var l=false;if(d)l=[];$.each(xb,function(k,w){if(b in w)if(d)l.push(w[b](c));else l=w[b](c)});return l};this.addExtension=function(b,c){if(b in xb)console.log('Cannot add extension "'+b+'", an extension by that name already exists"');else{var d=$.isFunction(c)?c($.extend(e.getPrivateMethods(),{svgroot:h,svgcontent:p,nonce:F().getNonce(),selectorManager:ua})):c;xb[b]=d;fa("extension_added",
d)}};var Ab=this.round=function(b){return parseInt(b*z)/z},Ub=this.getIntersectionList=function(b){if(ja==null)return null;var c=N||F().getCurrentLayer();eb.length||(eb=lc(c));var d=null;try{d=c.getIntersectionList(b,null)}catch(l){}if(d==null||typeof d.item!="function"){d=[];if(b)b=b;else{b=ja.getBBox();c={};for(var k in b)c[k]=b[k]/z;b=c}for(k=eb.length;k--;)b.width&&b.width&&svgedit.math.rectsIntersect(b,eb[k].bbox)&&d.push(eb[k].elem)}return d};getStrokedBBox=this.getStrokedBBox=function(b){b||
(b=Hb());if(!b.length)return false;var c=function(v){try{var u=svgedit.utilities.getBBox(v),t=svgedit.utilities.getRotationAngle(v);if(t&&t%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(v))){t=false;if(["ellipse","path","line","polyline","polygon"].indexOf(v.tagName)>=0)u=t=e.convertToPath(v,true);else if(v.tagName=="rect"){var B=v.getAttribute("rx"),D=v.getAttribute("ry");if(B||D)u=t=e.convertToPath(v,true)}if(!t){var H=v.cloneNode(true),K=document.createElementNS(o,
"g"),P=v.parentNode;P.appendChild(K);K.appendChild(H);u=svgedit.utilities.bboxToObj(K.getBBox());P.removeChild(K)}}return u}catch(X){console.log(v,X);return null}},d;$.each(b,function(){if(!d)if(this.parentNode)d=c(this)});if(d==null)return null;var l=d.x+d.width,k=d.y+d.height,w=d.x,n=d.y,g=function(v){var u=v.getAttribute("stroke-width"),t=0;if(v.getAttribute("stroke")!="none"&&!isNaN(u))t+=u/2;return t},s=[];$.each(b,function(v,u){var t=c(u);if(t){var B=g(u);w=Math.min(w,t.x-B);n=Math.min(n,t.y-
B);s.push(t)}});d.x=w;d.y=n;$.each(b,function(v,u){var t=s[v];if(t&&u.nodeType==1){var B=g(u);l=Math.max(l,t.x+t.width+B);k=Math.max(k,t.y+t.height+B)}});d.width=l-w;d.height=k-n;return d};var Hb=this.getVisibleElements=function(b){b||(b=$(p).children());var c=[];$(b).children().each(function(d,l){try{l.getBBox()&&c.push(l)}catch(k){}});return c.reverse()},lc=this.getVisibleElementsAndBBoxes=function(b){b||(b=$(p).children());var c=[];$(b).children().each(function(d,l){try{l.getBBox()&&c.push({elem:l,
bbox:getStrokedBBox([l])})}catch(k){}});return c.reverse()},dc=this.groupSvgElem=function(b){var c=document.createElementNS(o,"g");b.parentNode.replaceChild(c,b);$(c).append(b).data("gsvg",b)[0].id=Ea()},ub=function(b){var c=document.createElementNS(b.namespaceURI,b.nodeName);$.each(b.attributes,function(l,k){k.localName!="-moz-math-font-style"&&c.setAttributeNS(k.namespaceURI,k.nodeName,k.nodeValue)});c.removeAttribute("id");c.id=Ea();if(svgedit.browser.isWebkit()&&b.nodeName=="path"){var d=pa.convertPath(b);
c.setAttribute("d",d)}$.each(b.childNodes,function(l,k){switch(k.nodeType){case 1:c.appendChild(ub(k));break;case 3:c.textContent=k.nodeValue}});if($(b).data("gsvg"))$(c).data("gsvg",c.firstChild);else if($(b).data("symbol")){b=$(b).data("symbol");$(c).data("ref",b).data("symbol",b)}else c.tagName=="image"&&Ib(c);return c},Za,Ea,fa;(function(b){var c={};Za=b.getId=function(){return F().getId()};Ea=b.getNextId=function(){return F().getNextId()};fa=b.call=function(d,l){if(c[d])return c[d](this,l)};
b.bind=function(d,l){var k=c[d];c[d]=l;return k}})(e);this.prepareSvg=function(b){this.sanitizeSvg(b.documentElement);b=b.getElementsByTagNameNS(o,"path");for(var c=0,d=b.length;c<d;++c){var l=b[c];l.setAttribute("d",pa.convertPath(l));pa.fixEnd(l)}};var pb=this.getRefElem=function(b){return ya(qb(b).substr(1))},Vb=function(b){if(!svgedit.browser.isGecko())return b;var c=b.cloneNode(true);b.parentNode.insertBefore(c,b);b.parentNode.removeChild(b);ua.releaseSelector(b);J[0]=c;ua.requestSelector(c).showGrips(true);
return c};this.setRotationAngle=function(b,c){b=parseFloat(b);var d=J[0],l=d.getAttribute("transform"),k=svgedit.utilities.getBBox(d),w=k.x+k.width/2,n=k.y+k.height/2;k=W(d);k.numberOfItems>0&&k.getItem(0).type==4&&k.removeItem(0);if(b!=0){w=ka(w,n,sa(k).matrix);n=h.createSVGTransform();n.setRotate(b,w.x,w.y);k.numberOfItems?k.insertItemBefore(n,0):k.appendItem(n)}else k.numberOfItems==0&&d.removeAttribute("transform");if(!c){k=d.getAttribute("transform");d.setAttribute("transform",l);Na("transform",
k,J);fa("changed",J)}ya("pathpointgrip_container");d=ua.requestSelector(J[0]);d.resize();d.updateGripCursors(b)};var Jb=this.recalculateAllSelectedDimensions=function(){for(var b=new qa(Ya=="none"?"position":"size"),c=J.length;c--;){var d=Ra(J[c]);d&&b.addSubCommand(d)}if(!b.isEmpty()){la(b);fa("changed",J)}},Wb=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],ec=function(b){console.log([b.a,b.b,b.c,b.d,b.e,b.f])},Kb=this.remapElement=function(b,c,d){var l=A.gridSnapping&&
b.parentNode.parentNode.localName==="svg",k=function(){if(l)for(var t in c)c[t]=na(c[t]);Ca(b,c,1E3,true)};box=svgedit.utilities.getBBox(b);for(var w=0;w<2;w++){var n=w===0?"fill":"stroke",g=b.getAttribute(n);if(g&&g.indexOf("url(")===0)if(d.a<0||d.d<0){g=pb(g).cloneNode(true);if(d.a<0){var s=g.getAttribute("x1"),v=g.getAttribute("x2");g.setAttribute("x1",-(s-1));g.setAttribute("x2",-(v-1))}if(d.d<0){s=g.getAttribute("y1");v=g.getAttribute("y2");g.setAttribute("y1",-(s-1));g.setAttribute("y2",-(v-
1))}g.id=Ea();Ta().appendChild(g);b.setAttribute(n,"url(#"+g.id+")")}}w=b.tagName;if(w==="g"||w==="text"||w==="use")if(d.a==1&&d.b==0&&d.c==0&&d.d==1&&(d.e!=0||d.f!=0)){n=sa(b).matrix;n=oa(n.inverse(),d,n);c.x=parseFloat(c.x)+n.e;c.y=parseFloat(c.y)+n.f}else{n=W(b);g=h.createSVGTransform();g.setMatrix(oa(sa(n).matrix,d));n.clear();n.appendItem(g)}switch(w){case "foreignObject":case "rect":case "image":if(w==="image"&&(d.a<0||d.d<0)){n=W(b);g=h.createSVGTransform();g.setMatrix(oa(sa(n).matrix,d));
n.clear();n.appendItem(g)}else{n=ka(c.x,c.y,d);c.width=d.a*c.width;c.height=d.d*c.height;c.x=n.x+Math.min(0,c.width);c.y=n.y+Math.min(0,c.height);c.width=Math.abs(c.width);c.height=Math.abs(c.height)}k();break;case "ellipse":w=ka(c.cx,c.cy,d);c.cx=w.x;c.cy=w.y;c.rx=d.a*c.rx;c.ry=d.d*c.ry;c.rx=Math.abs(c.rx);c.ry=Math.abs(c.ry);k();break;case "circle":w=ka(c.cx,c.cy,d);c.cx=w.x;c.cy=w.y;d=svgedit.math.transformBox(box.x,box.y,box.width,box.height,d);c.r=Math.min((d.tr.x-d.tl.x)/2,(d.bl.y-d.tl.y)/2);
if(c.r)c.r=Math.abs(c.r);k();break;case "line":n=ka(c.x1,c.y1,d);s=ka(c.x2,c.y2,d);c.x1=n.x;c.y1=n.y;c.x2=s.x;c.y2=s.y;case "text":case "use":k();break;case "g":(d=$(b).data("gsvg"))&&Ca(d,c,1E3,true);break;case "polyline":case "polygon":k=c.points.length;for(w=0;w<k;++w){v=c.points[w];v=ka(v.x,v.y,d);c.points[w].x=v.x;c.points[w].y=v.y}k=c.points.length;d="";for(w=0;w<k;++w){v=c.points[w];d+=v.x+","+v.y+" "}b.setAttribute("points",d);break;case "path":n=b.pathSegList;k=n.numberOfItems;c.d=Array(k);
for(w=0;w<k;++w){g=n.getItem(w);c.d[w]={type:g.pathSegType,x:g.x,y:g.y,x1:g.x1,y1:g.y1,x2:g.x2,y2:g.y2,r1:g.r1,r2:g.r2,angle:g.angle,largeArcFlag:g.largeArcFlag,sweepFlag:g.sweepFlag}}k=c.d.length;w=c.d[0];var u=ka(w.x,w.y,d);c.d[0].x=u.x;c.d[0].y=u.y;for(w=1;w<k;++w){g=c.d[w];n=g.type;if(n%2==0){v=ka(g.x!=undefined?g.x:u.x,g.y!=undefined?g.y:u.y,d);n=ka(g.x1,g.y1,d);s=ka(g.x2,g.y2,d);g.x=v.x;g.y=v.y;g.x1=n.x;g.y1=n.y;g.x2=s.x;g.y2=s.y}else{g.x=d.a*g.x;g.y=d.d*g.y;g.x1=d.a*g.x1;g.y1=d.d*g.y1;g.x2=
d.a*g.x2;g.y2=d.d*g.y2}g.r1=d.a*g.r1;g.r2=d.d*g.r2}d="";k=c.d.length;for(w=0;w<k;++w){g=c.d[w];n=g.type;d+=Wb[n];switch(n){case 13:case 12:d+=g.x+" ";break;case 15:case 14:d+=g.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:d+=g.x+","+g.y+" ";break;case 7:case 6:d+=g.x1+","+g.y1+" "+g.x2+","+g.y2+" "+g.x+","+g.y+" ";break;case 9:case 8:d+=g.x1+","+g.y1+" "+g.x+","+g.y+" ";break;case 11:case 10:d+=g.r1+","+g.r2+" "+g.angle+" "+ +g.largeArcFlag+" "+ +g.sweepFlag+" "+g.x+","+g.y+" ";break;case 17:case 16:d+=
g.x2+","+g.y2+" "+g.x+","+g.y+" "}}b.setAttribute("d",d)}},fc=function(b,c,d){b=pb(b).firstChild;var l=W(b),k=h.createSVGTransform();k.setTranslate(c,d);l.appendItem(k);Ra(b)},Ra=this.recalculateDimensions=function(b){if(b==null)return null;var c=W(b);if(c&&c.numberOfItems>0){for(var d=c.numberOfItems;d--;){var l=c.getItem(d);if(l.type===0)c.removeItem(d);else if(l.type===1)svgedit.math.isIdentity(l.matrix)&&c.removeItem(d);else l.type===4&&l.angle===0&&c.removeItem(d)}if(c.numberOfItems===1&&Ua(b))return null}if(!c||
c.numberOfItems==0){b.removeAttribute("transform");return null}if(c){d=c.numberOfItems;for(var k=[];d--;){l=c.getItem(d);if(l.type===1)k.push([l.matrix,d]);else if(k.length)k=[]}if(k.length===2){d=h.createSVGTransformFromMatrix(oa(k[1][0],k[0][0]));c.removeItem(k[0][1]);c.removeItem(k[1][1]);c.insertItemBefore(d,k[1][1])}d=c.numberOfItems;if(d>=2&&c.getItem(d-2).type===1&&c.getItem(d-1).type===2){k=h.createSVGTransform();l=oa(c.getItem(d-2).matrix,c.getItem(d-1).matrix);k.setMatrix(l);c.removeItem(d-
2);c.removeItem(d-2);c.appendItem(k)}}switch(b.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(c.numberOfItems===1&&c.getItem(0).type===1||c.numberOfItems===2&&c.getItem(0).type===1&&c.getItem(0).type===4)return null}var w=$(b).data("gsvg");d=new qa("Transform");var n={},g=null;l=[];switch(b.tagName){case "line":l=["x1","y1","x2","y2"];break;case "circle":l=["cx","cy","r"];break;case "ellipse":l=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":l=
["width","height","x","y"];break;case "use":case "text":l=["x","y"];break;case "polygon":case "polyline":g={};g.points=b.getAttribute("points");k=b.points;var s=k.numberOfItems;n.points=Array(s);for(var v=0;v<s;++v){var u=k.getItem(v);n.points[v]={x:u.x,y:u.y}}break;case "path":g={};g.d=b.getAttribute("d");n.d=b.getAttribute("d")}if(l.length){n=$(b).attr(l);$.each(n,function($a,gb){n[$a]=ca($a,gb)})}else if(w)n={x:$(w).attr("x")||0,y:$(w).attr("y")||0};if(g==null){g=$.extend(true,{},n);$.each(g,function($a,
gb){g[$a]=ca($a,gb)})}g.transform=Ja?Ja:"";if(b.tagName=="g"&&!w||b.tagName=="a"){k=svgedit.utilities.getBBox(b);var t={x:k.x+k.width/2,y:k.y+k.height/2},B=ka(k.x+k.width/2,k.y+k.height/2,sa(c).matrix);l=h.createSVGMatrix();if(k=Ua(b)){v=k*Math.PI/180;s=Math.abs(v)>1.0E-10?Math.sin(v)/(1-Math.cos(v)):2/v;for(v=0;v<c.numberOfItems;++v){l=c.getItem(v);if(l.type==4){l=l.matrix;t.y=(s*l.e+l.f)/2;t.x=(l.e-s*l.f)/2;c.removeItem(v);break}}}v=l=w=0;var D=c.numberOfItems;if(D)var H=c.getItem(0).matrix;if(D>=
3&&c.getItem(D-2).type==3&&c.getItem(D-3).type==2&&c.getItem(D-1).type==2){v=3;var K=c.getItem(D-3).matrix,P=c.getItem(D-2).matrix,X=c.getItem(D-1).matrix;s=b.childNodes;for(u=s.length;u--;){var ba=s.item(u);l=w=0;if(ba.nodeType==1){var R=W(ba);if(R){l=sa(R).matrix;w=Ua(ba);var T=Ja,V=[];Ja=ba.getAttribute("transform");if(w||Pa(R)){var da=h.createSVGTransform();da.setMatrix(oa(K,P,X,l));R.clear();R.appendItem(da);V.push(da)}else{w=oa(l.inverse(),X,l);da=h.createSVGMatrix();da.e=-w.e;da.f=-w.f;l=oa(da.inverse(),
l.inverse(),K,P,X,l,w.inverse());var za=h.createSVGTransform(),Va=h.createSVGTransform(),hb=h.createSVGTransform();za.setTranslate(w.e,w.f);Va.setScale(l.a,l.d);hb.setTranslate(da.e,da.f);R.appendItem(hb);R.appendItem(Va);R.appendItem(za);V.push(hb);V.push(Va);V.push(za)}d.addSubCommand(Ra(ba));Ja=T}}}c.removeItem(D-1);c.removeItem(D-2);c.removeItem(D-3)}else if(D>=3&&c.getItem(D-1).type==1){v=3;l=sa(c).matrix;da=h.createSVGTransform();da.setMatrix(l);c.clear();c.appendItem(da)}else if((D==1||D>1&&
c.getItem(1).type!=3)&&c.getItem(0).type==2){v=2;w=sa(c).matrix;c.removeItem(0);l=sa(c).matrix.inverse();l=oa(l,w);w=l.e;l=l.f;if(w!=0||l!=0){s=b.childNodes;u=s.length;for(D=[];u--;){ba=s.item(u);if(ba.nodeType==1){if(ba.getAttribute("clip-path")){T=ba.getAttribute("clip-path");if(D.indexOf(T)===-1){fc(T,w,l);D.push(T)}}T=Ja;Ja=ba.getAttribute("transform");if(R=W(ba)){K=h.createSVGTransform();K.setTranslate(w,l);R.numberOfItems?R.insertItemBefore(K,0):R.appendItem(K);d.addSubCommand(Ra(ba));R=b.getElementsByTagNameNS(o,
"use");ba="#"+ba.id;for(K=R.length;K--;){P=R.item(K);if(ba==db(P)){X=h.createSVGTransform();X.setTranslate(-w,-l);W(P).insertItemBefore(X,0);d.addSubCommand(Ra(P))}}Ja=T}}}D=[];Ja=T}}else if(D==1&&c.getItem(0).type==1&&!k){v=1;l=c.getItem(0).matrix;s=b.childNodes;for(u=s.length;u--;){ba=s.item(u);if(ba.nodeType==1){T=Ja;Ja=ba.getAttribute("transform");if(R=W(ba)){w=oa(l,sa(R).matrix);D=h.createSVGTransform();D.setMatrix(w);R.clear();R.appendItem(D,0);d.addSubCommand(Ra(ba));Ja=T;T=ba.getAttribute("stroke-width");
ba.getAttribute("stroke")!=="none"&&!isNaN(T)&&ba.setAttribute("stroke-width",T*((Math.abs(w.a)+Math.abs(w.d))/2))}}}c.clear()}else{if(k){t=h.createSVGTransform();t.setRotate(k,B.x,B.y);c.numberOfItems?c.insertItemBefore(t,0):c.appendItem(t)}c.numberOfItems==0&&b.removeAttribute("transform");return null}if(v==2){if(k){B={x:t.x+H.e,y:t.y+H.f};t=h.createSVGTransform();t.setRotate(k,B.x,B.y);c.numberOfItems?c.insertItemBefore(t,0):c.appendItem(t)}}else if(v==3){l=sa(c).matrix;H=h.createSVGTransform();
H.setRotate(k,t.x,t.y);H=H.matrix;t=h.createSVGTransform();t.setRotate(k,B.x,B.y);B=t.matrix.inverse();T=l.inverse();B=oa(T,B,H,l);w=B.e;l=B.f;if(w!=0||l!=0){s=b.childNodes;for(u=s.length;u--;){ba=s.item(u);if(ba.nodeType==1){T=Ja;Ja=ba.getAttribute("transform");R=W(ba);K=h.createSVGTransform();K.setTranslate(w,l);R.numberOfItems?R.insertItemBefore(K,0):R.appendItem(K);d.addSubCommand(Ra(ba));Ja=T}}}if(k)c.numberOfItems?c.insertItemBefore(t,0):c.appendItem(t)}}else{k=svgedit.utilities.getBBox(b);
if(!k&&b.tagName!="path")return null;l=h.createSVGMatrix();if(w=Ua(b)){t={x:k.x+k.width/2,y:k.y+k.height/2};B=ka(k.x+k.width/2,k.y+k.height/2,sa(c).matrix);v=w*Math.PI/180;s=Math.abs(v)>1.0E-10?Math.sin(v)/(1-Math.cos(v)):2/v;for(v=0;v<c.numberOfItems;++v){l=c.getItem(v);if(l.type==4){l=l.matrix;t.y=(s*l.e+l.f)/2;t.x=(l.e-s*l.f)/2;c.removeItem(v);break}}}v=0;D=c.numberOfItems;if(!svgedit.browser.isWebkit())if((H=b.getAttribute("fill"))&&H.indexOf("url(")===0){H=pb(H);T="pattern";if(H.tagName!==T)T=
"gradient";if(H.getAttribute(T+"Units")==="userSpaceOnUse"){l=sa(c).matrix;k=W(H);k=sa(k).matrix;l=oa(l,k);k="matrix("+[l.a,l.b,l.c,l.d,l.e,l.f].join(",")+")";H.setAttribute(T+"Transform",k)}}if(D>=3&&c.getItem(D-2).type==3&&c.getItem(D-3).type==2&&c.getItem(D-1).type==2){v=3;l=sa(c,D-3,D-1).matrix;c.removeItem(D-1);c.removeItem(D-2);c.removeItem(D-3)}else if(D==4&&c.getItem(D-1).type==1){v=3;l=sa(c).matrix;da=h.createSVGTransform();da.setMatrix(l);c.clear();c.appendItem(da);l=h.createSVGMatrix()}else if((D==
1||D>1&&c.getItem(1).type!=3)&&c.getItem(0).type==2){v=2;H=c.getItem(0).matrix;T=sa(c,1).matrix;k=T.inverse();l=oa(k,H,T);c.removeItem(0)}else if(D==1&&c.getItem(0).type==1&&!w){l=sa(c).matrix;switch(b.tagName){case "line":n=$(b).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":n.points=b.getAttribute("points");if(n.points){k=b.points;s=k.numberOfItems;n.points=Array(s);for(v=0;v<s;++v){u=k.getItem(v);n.points[v]={x:u.x,y:u.y}}}case "path":n.d=b.getAttribute("d");v=1;c.clear()}}else{v=4;
if(w){t=h.createSVGTransform();t.setRotate(w,B.x,B.y);c.numberOfItems?c.insertItemBefore(t,0):c.appendItem(t)}c.numberOfItems==0&&b.removeAttribute("transform");return null}if(v==1||v==2||v==3)Kb(b,n,l);if(v==2){if(w){Pa(c)||(B={x:t.x+l.e,y:t.y+l.f});t=h.createSVGTransform();t.setRotate(w,B.x,B.y);c.numberOfItems?c.insertItemBefore(t,0):c.appendItem(t)}}else if(v==3&&w){l=sa(c).matrix;H=h.createSVGTransform();H.setRotate(w,t.x,t.y);H=H.matrix;t=h.createSVGTransform();t.setRotate(w,B.x,B.y);B=t.matrix.inverse();
T=l.inverse();B=oa(T,B,H,l);Kb(b,n,B);if(w)c.numberOfItems?c.insertItemBefore(t,0):c.appendItem(t)}}c.numberOfItems==0&&b.removeAttribute("transform");d.addSubCommand(new Fa(b,g));return d},ab=null,Aa=this.clearSelection=function(b){if(J[0]!=null)for(var c=J.length,d=0;d<c;++d){var l=J[d];if(l==null)break;ua.releaseSelector(l);J[d]=null}b||fa("selected",J)},bb=this.addToSelection=function(b,c){if(b.length!=0){for(var d=0;d<J.length;){if(J[d]==null)break;++d}for(var l=b.length;l--;){var k=b[l];if(k&&
svgedit.utilities.getBBox(k)){if(k.tagName==="a"&&k.childNodes.length===1)k=k.firstChild;if(J.indexOf(k)==-1){J[d]=k;d++;k=ua.requestSelector(k);J.length>1&&k.showGrips(false)}}}fa("selected",J);c||J.length==1?ua.requestSelector(J[0]).showGrips(true):ua.requestSelector(J[0]).showGrips(false);for(J.sort(function(w,n){if(w&&n&&w.compareDocumentPosition)return 3-(n.compareDocumentPosition(w)&6);else if(w==null)return 1});J[0]==null;)J.shift(0)}},ib=this.selectOnly=function(b,c){Aa(true);bb(b,c)};this.removeFromSelection=
function(b){if(J[0]!=null)if(b.length!=0){var c=Array(J.length);j=0;len=J.length;for(var d=0;d<len;++d){var l=J[d];if(l)if(b.indexOf(l)==-1){c[j]=l;j++}else ua.releaseSelector(l)}J=c}};this.selectAllInCurrentLayer=function(){var b=F().getCurrentLayer();if(b){ta="select";ib($(N||b).children())}};var cb=this.getMouseTarget=function(b){if(b==null)return null;b=b.target;if(b.correspondingUseElement)b=b.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(b.namespaceURI)>=
0&&b.id!="svgcanvas")for(;b.nodeName!="foreignObject";){b=b.parentNode;if(!b)return h}var c=F().getCurrentLayer();if([h,a,p,c].indexOf(b)>=0)return h;if($(b).closest("#selectorParentGroup").length)return ua.selectorParentGroup;for(;b.parentNode!==(N||c);)b=b.parentNode;return b};(function(){var b=null,c=null,d=null,l=null,k=null,w={},n={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(g){if(!(e.spaceKey||g.button===1)){var s=g.button===2;g.altKey&&svgCanvas.cloneSelectedElements(0,
0);ab=p.getScreenCTM().inverse();var v=ka(g.pageX,g.pageY,ab),u=v.x*z,t=v.y*z;g.preventDefault();if(s){ta="select";yb=v}v=u/z;t=t/z;var B=cb(g);if(B.tagName==="a"&&B.childNodes.length===1)B=B.firstChild;u=l=c=v;var D=k=d=t;if(A.gridSnapping){v=na(v);t=na(t);c=na(c);d=na(d)}if(B==ua.selectorParentGroup&&J[0]!=null){B=g.target;var H=sb(B,"type");if(H=="rotate")ta="rotate";else if(H=="resize"){ta="resize";Ya=sb(B,"dir")}B=J[0]}Ja=B.getAttribute("transform");H=W(B);switch(ta){case "select":ra=true;Ya=
"none";if(s)ra=false;if(B!=h){if(J.indexOf(B)==-1){g.shiftKey||Aa(true);bb([B]);Gb=B;pa.clear()}if(!s)for(s=0;s<J.length;++s)if(J[s]!=null){v=W(J[s]);v.numberOfItems?v.insertItemBefore(h.createSVGTransform(),0):v.appendItem(h.createSVGTransform())}}else if(!s){Aa();ta="multiselect";if(ja==null)ja=ua.getRubberBandBox();l*=z;k*=z;Ca(ja,{x:l,y:k,width:0,height:0,display:"inline"},100)}break;case "zoom":ra=true;if(ja==null)ja=ua.getRubberBandBox();Ca(ja,{x:u*z,y:u*z,width:0,height:0,display:"inline"},
100);break;case "resize":ra=true;c=v;d=t;w=svgedit.utilities.getBBox($("#selectedBox0")[0]);var K={};$.each(w,function(P,X){K[P]=X/z});w=K;s=Ua(B)?1:0;if(Pa(H)){H.insertItemBefore(h.createSVGTransform(),s);H.insertItemBefore(h.createSVGTransform(),s);H.insertItemBefore(h.createSVGTransform(),s)}else{H.appendItem(h.createSVGTransform());H.appendItem(h.createSVGTransform());H.appendItem(h.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){B.style.vectorEffect="non-scaling-stroke";
v=B.getElementsByTagName("*");for(s=0;s<v.length;s++)v[s].style.vectorEffect="non-scaling-stroke"}}break;case "fhellipse":case "fhrect":case "fhpath":ra=true;b=u+","+D+" ";s=O.stroke_width==0?1:O.stroke_width;Z({element:"polyline",curStyles:true,attr:{points:b,id:Ea(),fill:"none",opacity:O.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});n.minx=u;n.maxx=u;n.miny=D;n.maxy=D;break;case "image":ra=true;s=Z({element:"image",attr:{x:v,y:t,width:0,height:0,id:Ea(),opacity:O.opacity/2,style:"pointer-events:inherit"}});
fb(s,Tb);Ib(s);break;case "square":case "rect":ra=true;c=v;d=t;Z({element:"rect",curStyles:true,attr:{x:v,y:t,width:0,height:0,id:Ea(),opacity:O.opacity/2}});break;case "line":ra=true;s=O.stroke_width==0?1:O.stroke_width;Z({element:"line",curStyles:true,attr:{x1:v,y1:t,x2:v,y2:t,id:Ea(),stroke:O.stroke,"stroke-width":s,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,fill:"none",opacity:O.opacity/2,style:"pointer-events:none"}});
break;case "circle":ra=true;Z({element:"circle",curStyles:true,attr:{cx:v,cy:t,r:0,id:Ea(),opacity:O.opacity/2}});break;case "ellipse":ra=true;Z({element:"ellipse",curStyles:true,attr:{cx:v,cy:t,rx:0,ry:0,id:Ea(),opacity:O.opacity/2}});break;case "text":ra=true;Z({element:"text",curStyles:true,attr:{x:v,y:t,id:Ea(),fill:Qa.fill,"stroke-width":Qa.stroke_width,"font-size":Qa.font_size,"font-family":Qa.font_family,"text-anchor":"middle","xml:space":"preserve",opacity:O.opacity}});break;case "path":case "pathedit":c*=
z;d*=z;pa.mouseDown(g,B,c,d);ra=true;break;case "textedit":c*=z;d*=z;Oa.mouseDown(g,B,c,d);ra=true;break;case "rotate":ra=true;e.undoMgr.beginUndoableChange("transform",J)}g=zb("mouseDown",{event:g,start_x:c,start_y:d,selectedElements:J},true);$.each(g,function(P,X){if(X&&X.started)ra=true})}}).mousemove(function(g){if(ra)if(!(g.button===1||e.spaceKey)){var s=J[0],v=ka(g.pageX,g.pageY,ab),u=v.x*z;v=v.y*z;var t=ya(Za()),B=x=u/z,D=y=v/z;if(A.gridSnapping){x=na(x);y=na(y)}g.preventDefault();switch(ta){case "select":if(J[0]!==
null){B=x-c;var H=y-d;if(A.gridSnapping){B=na(B);H=na(H)}if(g.shiftKey){var K=Cb(c,d,x,y);x=K.x;y=K.y}if(B!=0||H!=0){K=J.length;for(D=0;D<K;++D){s=J[D];if(s==null)break;var P=h.createSVGTransform();t=W(s);P.setTranslate(B,H);t.numberOfItems?t.replaceItem(P,0):t.appendItem(P);ua.requestSelector(s).resize()}fa("transition",J)}}break;case "multiselect":B*=z;D*=z;Ca(ja,{x:Math.min(l,B),y:Math.min(k,D),width:Math.abs(B-l),height:Math.abs(D-k)},100);t=[];B=[];P=Ub();K=J.length;for(D=0;D<K;++D){H=P.indexOf(J[D]);
if(H==-1)t.push(J[D]);else P[H]=null}K=P.length;for(D=0;D<K;++D)P[D]&&B.push(P[D]);t.length>0&&e.removeFromSelection(t);B.length>0&&bb(B);break;case "resize":t=W(s);H=(K=Pa(t))?w:svgedit.utilities.getBBox(s);D=H.x;P=H.y;var X=H.width,ba=H.height;B=x-c;H=y-d;if(A.gridSnapping){B=na(B);H=na(H);ba=na(ba);X=na(X)}var R=Ua(s);if(R){var T=Math.sqrt(B*B+H*H);H=Math.atan2(H,B)-R*Math.PI/180;B=T*Math.cos(H);H=T*Math.sin(H)}if(Ya.indexOf("n")==-1&&Ya.indexOf("s")==-1)H=0;if(Ya.indexOf("e")==-1&&Ya.indexOf("w")==
-1)B=0;var V=T=0,da=ba?(ba+H)/ba:1,za=X?(X+B)/X:1;if(Ya.indexOf("n")>=0){da=ba?(ba-H)/ba:1;V=ba}if(Ya.indexOf("w")>=0){za=X?(X-B)/X:1;T=X}B=h.createSVGTransform();H=h.createSVGTransform();X=h.createSVGTransform();if(A.gridSnapping){D=na(D);T=na(T);P=na(P);V=na(V)}B.setTranslate(-(D+T),-(P+V));if(g.shiftKey)if(za==1)za=da;else da=za;H.setScale(za,da);X.setTranslate(D+T,P+V);if(K){K=R?1:0;t.replaceItem(B,2+K);t.replaceItem(H,1+K);t.replaceItem(X,0+K)}else{K=t.numberOfItems;t.replaceItem(X,K-3);t.replaceItem(H,
K-2);t.replaceItem(B,K-1)}ua.requestSelector(s).resize();fa("transition",J);break;case "zoom":B*=z;D*=z;Ca(ja,{x:Math.min(l*z,B),y:Math.min(k*z,D),width:Math.abs(B-l*z),height:Math.abs(D-k*z)},100);break;case "text":Ca(t,{x:x,y:y},1E3);break;case "line":D=null;window.opera||h.suspendRedraw(1E3);if(A.gridSnapping){x=na(x);y=na(y)}B=x;K=y;if(g.shiftKey){K=Cb(c,d,B,K);B=K.x;K=K.y}t.setAttributeNS(null,"x2",B);t.setAttributeNS(null,"y2",K);window.opera||h.unsuspendRedraw(D);break;case "foreignObject":case "square":case "rect":case "image":B=
Math.abs(x-c);K=Math.abs(y-d);if(ta=="square"||g.shiftKey){B=K=Math.max(B,K);D=c<x?c:c-B;P=d<y?d:d-K}else{D=Math.min(c,x);P=Math.min(d,y)}if(A.gridSnapping){B=na(B);K=na(K);D=na(D);P=na(P)}Ca(t,{width:B,height:K,x:D,y:P},1E3);break;case "circle":K=$(t).attr(["cx","cy"]);B=K.cx;K=K.cy;B=Math.sqrt((x-B)*(x-B)+(y-K)*(y-K));if(A.gridSnapping)B=na(B);t.setAttributeNS(null,"r",B);break;case "ellipse":K=$(t).attr(["cx","cy"]);B=K.cx;K=K.cy;D=null;window.opera||h.suspendRedraw(1E3);if(A.gridSnapping){x=na(x);
B=na(B);y=na(y);K=na(K)}t.setAttributeNS(null,"rx",Math.abs(x-B));t.setAttributeNS(null,"ry",Math.abs(g.shiftKey?x-B:y-K));window.opera||h.unsuspendRedraw(D);break;case "fhellipse":case "fhrect":n.minx=Math.min(B,n.minx);n.maxx=Math.max(B,n.maxx);n.miny=Math.min(D,n.miny);n.maxy=Math.max(D,n.maxy);case "fhpath":b+=+B+","+D+" ";t.setAttributeNS(null,"points",b);break;case "path":case "pathedit":x*=z;y*=z;if(A.gridSnapping){x=na(x);y=na(y);c=na(c);d=na(d)}if(g.shiftKey){if(K=svgedit.path.path){t=K.dragging?
K.dragging[0]:c;K=K.dragging?K.dragging[1]:d}else{t=c;K=d}K=Cb(t,K,x,y);x=K.x;y=K.y}if(ja&&ja.getAttribute("display")!=="none"){B*=z;D*=z;Ca(ja,{x:Math.min(l*z,B),y:Math.min(k*z,D),width:Math.abs(B-l*z),height:Math.abs(D-k*z)},100)}pa.mouseMove(x,y);break;case "textedit":x*=z;y*=z;Oa.mouseMove(u,v);break;case "rotate":H=svgedit.utilities.getBBox(s);B=H.x+H.width/2;K=H.y+H.height/2;t=Pb(s);t=ka(B,K,t);B=t.x;K=t.y;R=(Math.atan2(K-y,B-x)*(180/Math.PI)-90)%360;if(A.gridSnapping)R=na(R);if(g.shiftKey)R=
Math.round(R/45)*45;e.setRotationAngle(R<-180?360+R:R,true);fa("transition",J)}zb("mouseMove",{event:g,mouse_x:u,mouse_y:v,selected:s})}}).click(function(g){g.preventDefault();return false}).dblclick(function(g){var s=g.target.parentNode;if(s!==N){var v=cb(g),u=v.tagName;if(u==="text"&&ta!=="textedit"){g=ka(g.pageX,g.pageY,ab);Oa.select(v,g.x,g.y)}if((u==="g"||u==="a")&&Ua(v)){Xb(v);v=J[0];Aa(true)}N&&Lb();s.tagName!=="g"&&s.tagName!=="a"||s===F().getCurrentLayer()||v===ua.selectorParentGroup||mc(v)}}).mouseup(function(g){if(g.button!==
2){var s=Gb;Gb=null;if(ra){var v=ka(g.pageX,g.pageY,ab),u=v.x*z;v=v.y*z;var t=u/z,B=v/z,D=ya(Za()),H=false;ra=false;switch(ta){case "resize":case "multiselect":if(ja!=null){ja.setAttribute("display","none");eb=[]}ta="select";case "select":if(J[0]!=null){if(J[1]==null){u=J[0];switch(u.tagName){case "g":case "use":case "image":case "foreignObject":break;default:Ma.fill=u.getAttribute("fill");Ma.fill_opacity=u.getAttribute("fill-opacity");Ma.stroke=u.getAttribute("stroke");Ma.stroke_opacity=u.getAttribute("stroke-opacity");
Ma.stroke_width=u.getAttribute("stroke-width");Ma.stroke_dasharray=u.getAttribute("stroke-dasharray");Ma.stroke_linejoin=u.getAttribute("stroke-linejoin");Ma.stroke_linecap=u.getAttribute("stroke-linecap")}if(u.tagName=="text"){Qa.font_size=u.getAttribute("font-size");Qa.font_family=u.getAttribute("font-family")}ua.requestSelector(u).showGrips(true)}Jb();if(t!=l||B!=k){g=J.length;for(u=0;u<g;++u){if(J[u]==null)break;J[u].firstChild||ua.requestSelector(J[u]).resize()}}else{u=g.target;if(J[0].nodeName===
"path"&&J[1]==null)pa.select(J[0]);else g.shiftKey&&s!=u&&e.removeFromSelection([u])}if(svgedit.browser.supportsNonScalingStroke())if(g=J[0]){g.removeAttribute("style");svgedit.utilities.walkTree(g,function(X){X.removeAttribute("style")})}}return;case "zoom":ja!=null&&ja.setAttribute("display","none");fa("zoomed",{x:Math.min(l,t),y:Math.min(k,B),width:Math.abs(t-l),height:Math.abs(B-k),factor:g.shiftKey?0.5:2});return;case "fhpath":s=D.getAttribute("points");t=s.indexOf(",");if(H=t>=0?s.indexOf(",",
t+1)>=0:s.indexOf(" ",s.indexOf(" ")+1)>=0)D=pa.smoothPolylineIntoPath(D);break;case "line":s=$(D).attr(["x1","x2","y1","y2"]);H=s.x1!=s.x2||s.y1!=s.y2;break;case "foreignObject":case "square":case "rect":case "image":s=$(D).attr(["width","height"]);H=s.width!=0||s.height!=0||ta==="image";break;case "circle":H=D.getAttribute("r")!=0;break;case "ellipse":s=$(D).attr(["rx","ry"]);H=s.rx!=null||s.ry!=null;break;case "fhellipse":if(n.maxx-n.minx>0&&n.maxy-n.miny>0){D=Z({element:"ellipse",curStyles:true,
attr:{cx:(n.minx+n.maxx)/2,cy:(n.miny+n.maxy)/2,rx:(n.maxx-n.minx)/2,ry:(n.maxy-n.miny)/2,id:Za()}});fa("changed",[D]);H=true}break;case "fhrect":if(n.maxx-n.minx>0&&n.maxy-n.miny>0){D=Z({element:"rect",curStyles:true,attr:{x:n.minx,y:n.miny,width:n.maxx-n.minx,height:n.maxy-n.miny,id:Za()}});fa("changed",[D]);H=true}break;case "text":H=true;ib([D]);Oa.start(D);break;case "path":D=null;ra=true;s=pa.mouseUp(g,D,u,v);D=s.element;H=s.keep;break;case "pathedit":H=true;D=null;pa.mouseUp(g);break;case "textedit":H=
false;D=null;Oa.mouseUp(g,u,v);break;case "rotate":H=true;D=null;ta="select";s=e.undoMgr.finishUndoableChange();s.isEmpty()||la(s);Jb();fa("changed",J)}u=zb("mouseUp",{event:g,mouse_x:u,mouse_y:v},true);$.each(u,function(X,ba){if(ba){H=ba.keep||H;D=ba.element;ra=ba.started||ra}});if(!H&&D!=null){F().releaseId(Za());D.parentNode.removeChild(D);D=null;for(u=g.target;u.parentNode.parentNode.tagName=="g";)u=u.parentNode;if((ta!="path"||!drawn_path)&&u.parentNode.id!="selectorParentGroup"&&u.id!="svgcanvas"&&
u.id!="svgroot"){e.setMode("select");ib([u],true)}}else if(D!=null){e.addedNew=true;g=0.2;var K;if(Fb.beginElement&&D.getAttribute("opacity")!=O.opacity){K=$(Fb).clone().attr({to:O.opacity,dur:g}).appendTo(D);try{K[0].beginElement()}catch(P){}}else g=0;setTimeout(function(){K&&K.remove();D.setAttribute("opacity",O.opacity);D.setAttribute("style","pointer-events:inherit");Qb(D);if(ta==="path")pa.toEditMode(D);else A.selectNew&&ib([D],true);la(new wa(D));fa("changed",[D])},g*1E3)}Ja=null}}});$(a).bind("mousewheel DOMMouseScroll",
function(g){if(g.shiftKey){g.preventDefault();ab=p.getScreenCTM().inverse();var s=ka(g.pageX,g.pageY,ab);s={x:s.x,y:s.y,width:0,height:0};if(g.wheelDelta)if(g.wheelDelta>=120)s.factor=2;else{if(g.wheelDelta<=-120)s.factor=0.5}else if(g.detail)if(g.detail>0)s.factor=0.5;else if(g.detail<0)s.factor=2;s.factor&&fa("zoomed",s)}})})();var Ib=function(b){$(b).click(function(c){c.preventDefault()})},Oa=e.textActions=function(){function b(R){var T=v.value==="";$(v).focus();if(!arguments.length)if(T)R=0;else{if(v.selectionEnd!==
v.selectionStart)return;R=v.selectionEnd}var V;V=D[R];T||v.setSelectionRange(R,R);u=ya("text_cursor");if(!u){u=document.createElementNS(o,"line");Ca(u,{id:"text_cursor",stroke:"#333","stroke-width":1});u=ya("selectorParentGroup").appendChild(u)}B||(B=setInterval(function(){var da=u.getAttribute("display")==="none";u.setAttribute("display",da?"inline":"none")},600));T=w(V.x,H.y);V=w(V.x,H.y+H.height);Ca(u,{x1:T.x,y1:T.y,x2:V.x,y2:V.y,visibility:"visible",display:"inline"});t&&t.setAttribute("d","")}
function c(R,T,V){if(R===T)b(T);else{V||v.setSelectionRange(R,T);t=ya("text_selectblock");if(!t){t=document.createElementNS(o,"path");Ca(t,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});ya("selectorParentGroup").appendChild(t)}R=D[R];var da=D[T];u.setAttribute("visibility","hidden");T=w(R.x,H.y);V=w(R.x+(da.x-R.x),H.y);var za=w(R.x,H.y+H.height);R=w(R.x+(da.x-R.x),H.y+H.height);Ca(t,{d:"M"+T.x+","+T.y+" L"+V.x+","+V.y+" "+R.x+","+R.y+" "+za.x+","+za.y+"z",display:"inline"})}}
function d(R,T){var V=h.createSVGPoint();V.x=R;V.y=T;if(D.length==1)return 0;V=s.getCharNumAtPosition(V);if(V<0){V=D.length-2;if(R<=D[0].x)V=0}else if(V>=D.length-2)V=D.length-2;var da=D[V];R>da.x+da.width/2&&V++;return V}function l(R,T,V){var da=v.selectionStart;R=d(R,T);c(Math.min(da,R),Math.max(da,R),!V)}function k(R,T){var V={x:R,y:T};V.x/=z;V.y/=z;if(K){var da=ka(V.x,V.y,K.inverse());V.x=da.x;V.y=da.y}return V}function w(R,T){var V={x:R,y:T};if(K){var da=ka(V.x,V.y,K);V.x=da.x;V.y=da.y}V.x*=
z;V.y*=z;return V}function n(R){c(0,s.textContent.length);$(this).unbind(R)}function g(R){if(ba&&s){var T=ka(R.pageX,R.pageY,ab);T=k(T.x*z,T.y*z);T=d(T.x,T.y);var V=s.textContent,da=V.substr(0,T).replace(/[a-z0-9]+$/i,"").length;V=V.substr(T).match(/^[a-z0-9]+/i);c(da,(V?V[0].length:0)+T);$(R.target).click(n);setTimeout(function(){$(R.target).unbind("click",n)},300)}}var s,v,u,t,B,D=[],H,K,P,X,ba;return{select:function(R,T,V){s=R;Oa.toEditMode(T,V)},start:function(R){s=R;Oa.toEditMode()},mouseDown:function(R,
T,V,da){R=k(V,da);v.focus();b(d(R.x,R.y));P=V;X=da},mouseMove:function(R,T){var V=k(R,T);l(V.x,V.y)},mouseUp:function(R,T,V){var da=k(T,V);l(da.x,da.y,true);R.target!==s&&T<P+2&&T>P-2&&V<X+2&&V>X-2&&Oa.toSelectMode(true)},setCursor:b,toEditMode:function(R,T){ba=false;ta="textedit";ua.requestSelector(s).showGrips(false);ua.requestSelector(s);Oa.init();$(s).css("cursor","text");if(arguments.length){var V=k(R,T);b(d(V.x,V.y))}else b();setTimeout(function(){ba=true},300)},toSelectMode:function(R){ta=
"select";clearInterval(B);B=null;t&&$(t).attr("display","none");u&&$(u).attr("visibility","hidden");$(s).css("cursor","move");if(R){Aa();$(s).css("cursor","move");fa("selected",[s]);bb([s],true)}s&&!s.textContent.length&&e.deleteSelectedElements();$(v).blur();s=false},setInputElem:function(R){v=R},clear:function(){ta=="textedit"&&Oa.toSelectMode()},init:function(){if(s){if(!s.parentNode){s=J[0];ua.requestSelector(s).showGrips(false)}var R=s.textContent.length,T=s.getAttribute("transform");H=svgedit.utilities.getBBox(s);
K=T?Pb(s):null;D=Array(R);v.focus();$(s).unbind("dblclick",g).dblclick(g);if(!R)var V={x:H.x+H.width/2,width:0};for(T=0;T<R;T++){var da=s.getStartPositionOfChar(T);V=s.getEndPositionOfChar(T);if(!svgedit.browser.supportsGoodTextCharPos()){var za=e.contentW*z;da.x-=za;V.x-=za;da.x/=z;V.x/=z}D[T]={x:da.x,y:H.y,width:V.x-da.x,height:H.height}}D.push({x:V.x,width:0});c(v.selectionStart,v.selectionEnd,true)}}}}(),pa=e.pathActions=function(){var b=false,c,d,l;svgedit.path.Path.prototype.endChanges=function(n){if(svgedit.browser.isWebkit()){var g=
this.elem;g.setAttribute("d",pa.convertPath(g))}n=new Fa(this.elem,{d:this.last_d},n);la(n);fa("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(n){$.isArray(n)||(n=[n]);for(var g=0;g<n.length;g++){var s=n[g],v=this.segs[s];v.ptgrip&&this.selected_pts.indexOf(s)==-1&&s>=0&&this.selected_pts.push(s)}this.selected_pts.sort();g=this.selected_pts.length;for(n=Array(g);g--;){v=this.segs[this.selected_pts[g]];v.select(true);n[g]=v.ptgrip}pa.canDeleteNodes=true;pa.closed_subpath=
this.subpathIsClosed(this.selected_pts[0]);fa("selected",n)};var k=c=null,w=false;return{mouseDown:function(n,g,s,v){if(ta==="path"){mouse_x=s;mouse_y=v;v=mouse_x/z;g=mouse_y/z;s=ya("path_stretch_line");d=[v,g];if(A.gridSnapping){v=na(v);g=na(g);mouse_x=na(mouse_x);mouse_y=na(mouse_y)}if(!s){s=document.createElementNS(o,"path");Ca(s,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});s=ya("selectorParentGroup").appendChild(s)}s.setAttribute("display","inline");var u=null;if(k){u=
k.pathSegList;for(var t=u.numberOfItems,B=6/z,D=false;t;){t--;var H=u.getItem(t),K=H.x;H=H.y;if(v>=K-B&&v<=K+B&&g>=H-B&&g<=H+B){D=true;break}}B=Za();svgedit.path.removePath_(B);B=ya(B);K=u.numberOfItems;if(D){if(t<=1&&K>=2){v=u.getItem(0).x;g=u.getItem(0).y;n=s.pathSegList.getItem(1);n=n.pathSegType===4?k.createSVGPathSegLinetoAbs(v,g):k.createSVGPathSegCurvetoCubicAbs(v,g,n.x1/z,n.y1/z,v,g);v=k.createSVGPathSegClosePath();u.appendItem(n);u.appendItem(v)}else if(K<3)return u=false;$(s).remove();element=
B;k=null;ra=false;if(b){svgedit.path.path.matrix&&Kb(B,{},svgedit.path.path.matrix.inverse());s=B.getAttribute("d");n=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",n+s);$(B).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();pa.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,cb(n))){console.log("Clicked outside canvas");return false}u=k.pathSegList.numberOfItems;t=k.pathSegList.getItem(u-
1);B=t.x;t=t.y;if(n.shiftKey){n=Cb(B,t,v,g);v=n.x;g=n.y}n=s.pathSegList.getItem(1);n=n.pathSegType===4?k.createSVGPathSegLinetoAbs(Ab(v),Ab(g)):k.createSVGPathSegCurvetoCubicAbs(Ab(v),Ab(g),n.x1/z,n.y1/z,n.x2/z,n.y2/z);k.pathSegList.appendItem(n);v*=z;g*=z;s.setAttribute("d",["M",v,g,v,g].join(" "));s=u;if(b)s+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(s,v,g)}}else{d_attr="M"+v+","+g+" ";k=Z({element:"path",curStyles:true,attr:{d:d_attr,id:Ea(),opacity:O.opacity/2}});s.setAttribute("d",
["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));s=b?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(s,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();B=n.target.id;if(B.substr(0,14)=="pathpointgrip_"){g=svgedit.path.path.cur_pt=parseInt(B.substr(14));svgedit.path.path.dragging=[s,v];u=svgedit.path.path.segs[g];if(n.shiftKey)u.selected?svgedit.path.path.removePtFromSelection(g):svgedit.path.path.addPtsToSelection(g);else{if(svgedit.path.path.selected_pts.length<=
1||!u.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(g)}}else if(B.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[s,v];n=B.split("_")[1].split("c");g=n[0]-0;svgedit.path.path.selectPt(g,n[1]-0)}if(!svgedit.path.path.dragging){if(ja==null)ja=ua.getRubberBandBox();Ca(ja,{x:s*z,y:v*z,width:0,height:0,display:"inline"},100)}}},mouseMove:function(n,g){w=true;if(ta==="path"){if(k){var s=k.pathSegList,v=s.numberOfItems-1;if(d){var u=svgedit.path.addCtrlGrip("1c1"),
t=svgedit.path.addCtrlGrip("0c2");u.setAttribute("cx",n);u.setAttribute("cy",g);u.setAttribute("display","inline");u=d[0];var B=d[1];s.getItem(v);var D=u+(u-n/z),H=B+(B-g/z);t.setAttribute("cx",D*z);t.setAttribute("cy",H*z);t.setAttribute("display","inline");t=svgedit.path.getCtrlLine(1);Ca(t,{x1:n,y1:g,x2:D*z,y2:H*z,display:"inline"});if(v===0)l=[n,g];else{var K=s.getItem(v-1);s=K.x;t=K.y;if(K.pathSegType===6){s+=s-K.x2;t+=t-K.y2}else if(l){s=l[0]/z;t=l[1]/z}svgedit.path.replacePathSeg(6,v,[u,B,
s,t,D,H],k)}}else if(u=ya("path_stretch_line")){v=s.getItem(v);if(v.pathSegType===6)svgedit.path.replacePathSeg(6,1,[n,g,(v.x+(v.x-v.x2))*z,(v.y+(v.y-v.y2))*z,n,g],u);else l?svgedit.path.replacePathSeg(6,1,[n,g,l[0],l[1],n,g],u):svgedit.path.replacePathSeg(4,1,[n,g],u)}}}else if(svgedit.path.path.dragging){u=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);B=svgedit.path.getPointFromGrip({x:n,y:g},svgedit.path.path);v=B.x-u.x;u=B.y-
u.y;svgedit.path.path.dragging=[n,g];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(v,u):svgedit.path.path.movePts(v,u)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var P=ja.getBBox(),X=svgedit.path.getGripPt(this);P=svgedit.math.rectsIntersect(P,{x:X.x,y:X.y,width:0,height:0});this.select(P);P&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(n,g){if(ta==="path"){d=null;if(!k){g=ya(Za());ra=false;l=null}return{keep:true,
element:g}}if(svgedit.path.path.dragging){var s=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();w&&svgedit.path.path.endChanges("Move path point(s)");!n.shiftKey&&!w&&svgedit.path.path.selectPt(s)}else if(ja&&ja.getAttribute("display")!="none"){ja.setAttribute("display","none");ja.getAttribute("width")<=2&&ja.getAttribute("height")<=2&&pa.toSelectMode(n.target)}else pa.toSelectMode(n.target);w=false},toEditMode:function(n){svgedit.path.path=
svgedit.path.getPath_(n);ta="pathedit";Aa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);b=false},toSelectMode:function(n){var g=n==svgedit.path.path.elem;ta="select";svgedit.path.path.show(false);c=false;Aa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(g){fa("selected",[n]);bb([n],true)}},addSubPath:function(n){if(n){ta="path";b=true}else{pa.clear(true);pa.toEditMode(svgedit.path.path.elem)}},select:function(n){if(c===
n){pa.toEditMode(n);ta="pathedit"}else c=n},reorient:function(){var n=J[0];if(n)if(Ua(n)!=0){var g=new qa("Reorient path"),s={d:n.getAttribute("d"),transform:n.getAttribute("transform")};g.addSubCommand(new Fa(n,s));Aa();this.resetOrientation(n);la(g);svgedit.path.getPath_(n).show(false).matrix=null;this.clear();bb([n],true);fa("changed",J)}},clear:function(){c=null;if(k){var n=ya(Za());$(ya("path_stretch_line")).remove();$(n).remove();$(ya("pathpointgrip_container")).find("*").attr("display","none");
k=l=null;ra=false}else ta=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(n){if(n==null||n.nodeName!="path")return false;var g=W(n),s=sa(g).matrix;g.clear();n.removeAttribute("transform");g=n.pathSegList;for(var v=g.numberOfItems,u=0;u<v;++u){var t=g.getItem(u),B=t.pathSegType;if(B!=1){var D=[];$.each(["",1,2],function(H,K){var P=t["x"+K],X=t["y"+K];if(P!==undefined&&X!==undefined){P=ka(P,X,s);D.splice(D.length,0,P.x,P.y)}});svgedit.path.replacePathSeg(B,
u,D,n)}}m(n,s)},zoomChange:function(){ta=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var n=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:n.item.x,y:n.item.y,type:n.type}},linkControlPoints:function(n){svgedit.path.setLinkControlPoints(n)},clonePathNode:function(){svgedit.path.path.storeD();for(var n=svgedit.path.path.selected_pts,g=n.length,s=[];g--;){var v=n[g];svgedit.path.path.addSeg(v);s.push(v+g);s.push(v+g+1)}svgedit.path.path.init().addPtsToSelection(s);
svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var n=svgedit.path.path.selected_pts;if(n.length===1){var g=svgedit.path.path.elem,s=g.pathSegList,v=n[0],u=null,t=null;svgedit.path.path.eachSeg(function(K){if(this.type===2&&K<=v)t=this.item;if(K<=v)return true;if(this.type===2){u=K;return false}else if(this.type===1)return u=false});if(u==null)u=svgedit.path.path.segs.length-1;if(u!==false){var B=g.createSVGPathSegLinetoAbs(t.x,t.y),D=g.createSVGPathSegClosePath();
if(u==svgedit.path.path.segs.length-1){s.appendItem(B);s.appendItem(D)}else{svgedit.path.insertItemBefore(g,D,u);svgedit.path.insertItemBefore(g,B,u)}svgedit.path.path.init().selectPt(u+1)}else if(svgedit.path.path.segs[v].mate){s.removeItem(v);s.removeItem(v);svgedit.path.path.init().selectPt(v-1)}else{for(n=0;n<s.numberOfItems;n++){var H=s.getItem(n);if(H.pathSegType===2)B=n;else if(n===v)s.removeItem(B);else if(H.pathSegType===1&&v<n){D=n-1;s.removeItem(n);break}}for(n=v-B-1;n--;)svgedit.path.insertItemBefore(g,
s.getItem(B),D);g=s.getItem(B);svgedit.path.replacePathSeg(2,B,[g.x,g.y]);n=v;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(pa.canDeleteNodes){svgedit.path.path.storeD();for(var n=svgedit.path.path.selected_pts,g=n.length;g--;)svgedit.path.path.deleteSeg(n[g]);var s=function(){var v=svgedit.path.path.elem.pathSegList,u=v.numberOfItems,t=function(H,K){for(;K--;)v.removeItem(H)};if(u<=1)return true;for(;u--;){var B=v.getItem(u);if(B.pathSegType===1){B=v.getItem(u-1);var D=v.getItem(u-
2);if(B.pathSegType===2){t(u-1,2);s();break}else if(D.pathSegType===2){t(u-2,3);s();break}}else if(B.pathSegType===2)if(u>0){B=v.getItem(u-1).pathSegType;if(B===2){t(u-1,1);s();break}else if(B===1&&v.numberOfItems-1===u){t(u,1);s();break}}}return false};s();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){pa.toSelectMode(svgedit.path.path.elem);e.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){n=$(svgedit.path.path.elem);n.attr("d",
n.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(n){var g=n.points,s=g.numberOfItems;if(s>=4){var v=g.getItem(0),u=null;n=[];n.push(["M",v.x,",",v.y," C"].join(""));for(var t=1;t<=s-4;t+=3){var B=g.getItem(t),D=g.getItem(t+1),H=g.getItem(t+2);if(u)if((v=svgedit.path.smoothControlPoints(u,B,v))&&v.length==2){B=n[n.length-1].split(",");B[2]=v[0].x;B[3]=v[0].y;n[n.length-1]=B.join(",");B=v[1]}n.push([B.x,B.y,D.x,D.y,H.x,H.y].join(","));v=H;u=D}for(n.push("L");t<
s;++t){D=g.getItem(t);n.push([D.x,D.y].join(","))}n=n.join(" ");n=Z({element:"path",curStyles:true,attr:{id:Za(),d:n,fill:"none"}})}return n},setSegType:function(n){svgedit.path.path.setSegType(n)},moveNode:function(n,g){var s=svgedit.path.path.selected_pts;if(s.length){svgedit.path.path.storeD();s=svgedit.path.path.segs[s[0]];var v={x:0,y:0};v[n]=g-s.item[n];s.move(v.x,v.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(n){for(var g=n.pathSegList,s=g.numberOfItems,v,u=0;u<s;++u){var t=
g.getItem(u);if(t.pathSegType===2)v=t;if(t.pathSegType===1){t=g.getItem(u-1);if(t.x!=v.x||t.y!=v.y){g=n.createSVGPathSegLinetoAbs(v.x,v.y);svgedit.path.insertItemBefore(n,g,u);pa.fixEnd(n);break}}}svgedit.browser.isWebkit()&&n.setAttribute("d",pa.convertPath(n))},convertPath:function(n,g){for(var s=n.pathSegList,v=s.numberOfItems,u=0,t=0,B="",D=null,H=0;H<v;++H){var K=s.getItem(H),P=K.x||0,X=K.y||0,ba=K.x1||0,R=K.y1||0,T=K.x2||0,V=K.y2||0,da=K.pathSegType,za=Wb[da]["to"+(g?"Lower":"Upper")+"Case"](),
Va=function(hb,$a,gb){$a=$a?" "+$a.join(" "):"";gb=gb?" "+svgedit.units.shortFloat(gb):"";$.each(hb,function(Mb,gc){hb[Mb]=svgedit.units.shortFloat(gc)});B+=za+hb.join(" ")+$a+gb};switch(da){case 1:B+="z";break;case 12:P-=u;case 13:if(g){u+=P;za="l"}else{P+=u;u=P;za="L"}Va([[P,t]]);break;case 14:X-=t;case 15:if(g){t+=X;za="l"}else{X+=t;t=X;za="L"}Va([[u,X]]);break;case 2:case 4:case 18:P-=u;X-=t;case 5:case 3:if(D&&s.getItem(H-1).pathSegType===1&&!g){u=D[0];t=D[1]}case 19:if(g){u+=P;t+=X}else{P+=
u;X+=t;u=P;t=X}if(da===3)D=[u,t];Va([[P,X]]);break;case 6:P-=u;ba-=u;T-=u;X-=t;R-=t;V-=t;case 7:if(g){u+=P;t+=X}else{P+=u;ba+=u;T+=u;X+=t;R+=t;V+=t;u=P;t=X}Va([[ba,R],[T,V],[P,X]]);break;case 8:P-=u;ba-=u;X-=t;R-=t;case 9:if(g){u+=P;t+=X}else{P+=u;ba+=u;X+=t;R+=t;u=P;t=X}Va([[ba,R],[P,X]]);break;case 10:P-=u;X-=t;case 11:if(g){u+=P;t+=X}else{P+=u;X+=t;u=P;t=X}Va([[K.r1,K.r2]],[K.angle,K.largeArcFlag?1:0,K.sweepFlag?1:0],[P,X]);break;case 16:P-=u;T-=u;X-=t;V-=t;case 17:if(g){u+=P;t+=X}else{P+=u;T+=
u;X+=t;V+=t;u=P;t=X}Va([[T,V],[P,X]])}}return B}}}(),hc=this.removeUnusedDefElems=function(){var b=p.getElementsByTagNameNS(o,"defs");if(!b||!b.length)return 0;b=[];for(var c=0,d=["fill","stroke","filter","marker-start","marker-mid","marker-end"],l=d.length,k=p.getElementsByTagNameNS(o,"*"),w=k.length,n=0;n<w;n++){for(var g=k[n],s=0;s<l;s++){var v=qb(g.getAttribute(d[s]));v&&b.push(v.substr(1))}(g=db(g))&&g.indexOf("#")===0&&b.push(g.substr(1))}d=$(p).find("linearGradient, radialGradient, filter, marker, svg, symbol");
defelem_ids=[];for(n=d.length;n--;){l=d[n];k=l.id;if(b.indexOf(k)<0){Sb[k]=l;l.parentNode.removeChild(l);c++}}return c};this.svgCanvasToString=function(){for(;hc()>0;);pa.clear(true);$.each(p.childNodes,function(d,l){d&&l.nodeType===8&&l.data.indexOf("Created with")>=0&&p.insertBefore(l,p.firstChild)});if(N){Lb();ib([N])}var b=[];$(p).find("g:data(gsvg)").each(function(){for(var d=this.attributes,l=d.length,k=0;k<l;k++)if(d[k].nodeName=="id"||d[k].nodeName=="style")l--;if(l<=0){d=this.firstChild;
b.push(d);$(this).replaceWith(d)}});var c=this.svgToString(p,0);b.length&&$(b).each(function(){dc(this)});return c};this.svgToString=function(b,c){var d=[],l=svgedit.utilities.toXml,k=A.baseUnit,w=RegExp("^-?[\\d\\.]+"+k+"$");if(b){Qb(b);var n=b.attributes,g,s,v=b.childNodes;for(s=0;s<c;s++)d.push(" ");d.push("<");d.push(b.nodeName);if(b.id==="svgcontent"){s=vb();if(k!=="px"){s.w=svgedit.units.convertUnit(s.w,k)+k;s.h=svgedit.units.convertUnit(s.h,k)+k}d.push(' width="'+s.w+'" height="'+s.h+'" xmlns="'+
o+'"');var u={};$(b).find("*").andSelf().each(function(){$.each(this.attributes,function(H,K){var P=K.namespaceURI;if(P&&!u[P]&&Ha[P]!=="xmlns"&&Ha[P]!=="xml"){u[P]=true;d.push(" xmlns:"+Ha[P]+'="'+P+'"')}})});s=n.length;for(k=["width","height","xmlns","x","y","viewBox","id","overflow"];s--;){g=n.item(s);var t=l(g.nodeValue);if(g.nodeName.indexOf("xmlns:")!==0)if(t!=""&&k.indexOf(g.localName)==-1)if(!g.namespaceURI||Ha[g.namespaceURI]){d.push(" ");d.push(g.nodeName);d.push('="');d.push(t);d.push('"')}}}else{if(b.nodeName===
"defs"&&!b.firstChild)return;var B=["-moz-math-font-style","_moz-math-font-style"];for(s=n.length-1;s>=0;s--){g=n.item(s);t=l(g.nodeValue);if(!(B.indexOf(g.localName)>=0))if(t!="")if(t.indexOf("pointer-events")!==0)if(!(g.localName==="class"&&t.indexOf("se_")===0)){d.push(" ");if(g.localName==="d")t=pa.convertPath(b,true);if(isNaN(t)){if(w.test(t))t=svgedit.units.shortFloat(t)+k}else t=svgedit.units.shortFloat(t);if(lb.apply&&b.nodeName==="image"&&g.localName==="href"&&lb.images&&lb.images==="embed"){var D=
nb[t];if(D)t=D}if(!g.namespaceURI||g.namespaceURI==o||Ha[g.namespaceURI]){d.push(g.nodeName);d.push('="');d.push(t);d.push('"')}}}}if(b.hasChildNodes()){d.push(">");c++;n=false;for(s=0;s<v.length;s++){k=v.item(s);switch(k.nodeType){case 1:d.push("\n");d.push(this.svgToString(v.item(s),c));break;case 3:k=k.nodeValue.replace(/^\s+|\s+$/g,"");if(k!=""){n=true;d.push(l(k)+"")}break;case 8:d.push("\n");d.push(Array(c+1).join(" "));d.push("<!--");d.push(k.data);d.push("--\>")}}c--;if(!n){d.push("\n");for(s=
0;s<c;s++)d.push(" ")}d.push("</");d.push(b.nodeName);d.push(">")}else d.push("/>")}return d.join("")};this.embedImage=function(b,c){$(new Image).load(function(){var d=document.createElement("canvas");d.width=this.width;d.height=this.height;d.getContext("2d").drawImage(this,0,0);try{var l=";svgedit_url="+encodeURIComponent(b);l=d.toDataURL().replace(";base64",l+";base64");nb[b]=l}catch(k){nb[b]=false}Tb=b;c&&c(nb[b])}).attr("src",b)};this.setGoodImage=function(b){Tb=b};this.open=function(){};this.save=
function(b){Aa();b&&$.extend(lb,b);lb.apply=true;b=this.svgCanvasToString();fa("saved",b)};this.rasterExport=function(){Aa();var b=[],c={feGaussianBlur:mb.exportNoBlur,foreignObject:mb.exportNoforeignObject,"[stroke-dasharray]":mb.exportNoDashArray},d=$(p);if(!("font"in $("<canvas>")[0].getContext("2d")))c.text=mb.exportNoText;$.each(c,function(l,k){d.find(l).length&&b.push(k)});c=this.svgCanvasToString();fa("exported",{svg:c,issues:b})};this.getSvgString=function(){lb.apply=false;return this.svgCanvasToString()};
this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,F()):svgedit.draw.randomizeIds(true,F())};var Yb=this.uniquifyElems=function(b){var c={},d=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(b,function(g){if(g.nodeType==1){if(g.id){g.id in c||(c[g.id]={elem:null,attrs:[],hrefs:[]});c[g.id].elem=g}$.each(Rb,function(v,u){var t=g.getAttributeNode(u);if(t){var B=svgedit.utilities.getUrlFromAttr(t.value);
if(B=B?B.substr(1):null){B in c||(c[B]={elem:null,attrs:[],hrefs:[]});c[B].attrs.push(t)}}});var s=svgedit.utilities.getHref(g);if(s&&d.indexOf(g.nodeName)>=0)if(s=s.substr(1)){s in c||(c[s]={elem:null,attrs:[],hrefs:[]});c[s].hrefs.push(g)}}});for(var l in c)if(l){var k=c[l].elem;if(k){b=Ea();k.id=b;k=c[l].attrs;for(var w=k.length;w--;){var n=k[w];n.ownerElement.setAttribute(n.name,"url(#"+b+")")}k=c[l].hrefs;for(w=k.length;w--;)svgedit.utilities.setHref(k[w],"#"+b)}}},Eb=this.setUseData=function(b){var c=
$(b);if(b.tagName!=="use")c=c.find("use");c.each(function(){var d=db(this).substr(1);if(d=ya(d)){$(this).data("ref",d);if(d.tagName=="symbol"||d.tagName=="svg")$(this).data("symbol",d).data("ref",d)}})},Nb=this.convertGradients=function(b){var c=$(b).find("linearGradient, radialGradient");if(!c.length&&svgedit.browser.isWebkit())c=$(b).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});c.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var d=$(p).find("[fill=url(#"+
this.id+")],[stroke=url(#"+this.id+")]");if(d.length)if(d=svgedit.utilities.getBBox(d[0]))if(this.tagName==="linearGradient"){var l=$(this).attr(["x1","y1","x2","y2"]),k=this.gradientTransform.baseVal;if(k&&k.numberOfItems>0){var w=sa(k).matrix;k=ka(l.x1,l.y1,w);w=ka(l.x2,l.y2,w);l.x1=k.x;l.y1=k.y;l.x2=w.x;l.y2=w.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(l.x1-d.x)/d.width,y1:(l.y1-d.y)/d.height,x2:(l.x2-d.x)/d.width,y2:(l.y2-d.y)/d.height});this.removeAttribute("gradientUnits")}}})},
Bb=this.convertToGroup=function(b){b||(b=J[0]);var c=$(b),d=new qa,l;if(c.data("gsvg")){d=$(b.firstChild).attr(["x","y"]);$(b.firstChild.firstChild).unwrap();$(b).removeData("gsvg");l=W(b);var k=h.createSVGTransform();k.setTranslate(d.x,d.y);l.appendItem(k);Ra(b);fa("selected",[b])}else if(c.data("symbol")){b=c.data("symbol");l=c.attr("transform");k=c.attr(["x","y"]);var w=b.getAttribute("viewBox");if(w){w=w.split(" ");k.x-=+w[0];k.y-=+w[1]}l+=" translate("+(k.x||0)+","+(k.y||0)+")";k=c.prev();d.addSubCommand(new Ia(c[0],
c[0].nextSibling,c[0].parentNode));c.remove();w=$(p).find("use:data(symbol)").length;c=f.createElementNS(o,"g");for(var n=b.childNodes,g=0;g<n.length;g++)c.appendChild(n[g].cloneNode(true));if(svgedit.browser.isGecko()){n=$(Ta()).children("linearGradient,radialGradient,pattern").clone();$(c).append(n)}l&&c.setAttribute("transform",l);l=b.parentNode;Yb(c);svgedit.browser.isGecko()&&$(Ta()).append($(c).find("linearGradient,radialGradient,pattern"));c.id=Ea();k.after(c);if(l){if(!w){k=b.nextSibling;
l.removeChild(b);d.addSubCommand(new Ia(b,k,l))}d.addSubCommand(new wa(c))}Eb(c);svgedit.browser.isGecko()?Nb(Ta()):Nb(c);svgedit.utilities.walkTreePost(c,function(s){try{Ra(s)}catch(v){console.log(v)}});$(c).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=Ea()});ib([c]);(b=Xb(c,true))&&d.addSubCommand(b);la(d)}else console.log("Unexpected element to ungroup:",b)};this.setSvgString=function(b){try{var c=svgedit.utilities.text2xml(b);
this.prepareSvg(c);var d=new qa("Change Source"),l=p.nextSibling,k=h.removeChild(p);d.addSubCommand(new Ia(k,l,h));p=h.appendChild(f.importNode(c.documentElement,true));var w=$(p);e.current_drawing_=new svgedit.draw.Drawing(p,C);var n=F().getNonce();n?fa("setnonce",n):fa("unsetnonce");w.find("image").each(function(){var D=this;Ib(D);var H=db(this);if(H.indexOf("data:")===0){var K=H.match(/svgedit_url=(.*?);/);if(K){var P=decodeURIComponent(K[1]);$(new Image).load(function(){D.setAttributeNS("http://www.w3.org/1999/xlink",
"xlink:href",P)}).attr("src",P)}}e.embedImage(H)});w.find("svg").each(function(){if(!$(this).closest("defs").length){Yb(this);var D=this.parentNode;if(D.childNodes.length===1&&D.nodeName==="g"){$(D).data("gsvg",this);D.id=D.id||Ea()}else dc(this)}});svgedit.browser.isGecko()&&w.find("linearGradient, radialGradient, pattern").appendTo(Ta());Eb(w);Nb(w[0]);svgedit.utilities.walkTreePost(p,function(D){try{Ra(D)}catch(H){console.log(H)}});var g={id:"svgcontent",overflow:A.show_outside_canvas?"visible":
"hidden"},s=false;if(w.attr("viewBox")){var v=w.attr("viewBox").split(" ");g.width=v[2];g.height=v[3]}else $.each(["width","height"],function(D,H){var K=w.attr(H);K||(K="100%");if((K+"").substr(-1)==="%")s=true;else g[H]=ca(H,K)});wb();w.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=Ea()});if(s){var u=getStrokedBBox();g.width=u.width+u.x;g.height=u.height+u.y}if(g.width<=0)g.width=100;if(g.height<=0)g.height=
100;w.attr(g);this.contentW=g.width;this.contentH=g.height;d.addSubCommand(new wa(p));var t=w.attr(["width","height"]);d.addSubCommand(new Fa(h,t));z=1;svgedit.transformlist.resetListMap();Aa();svgedit.path.clearData();h.appendChild(ua.selectorParentGroup);la(d);fa("changed",[p])}catch(B){console.log(B);return false}return true};this.importSvgString=function(b){try{var c=svgedit.utilities.encode64(b.length+b).substr(0,32),d=false;if(ob[c])if($(ob[c].symbol).parents("#svgroot").length)d=true;var l=
new qa("Import SVG");if(d)var k=ob[c].symbol,w=ob[c].xform;else{var n=svgedit.utilities.text2xml(b);this.prepareSvg(n);var g=f.importNode(n.documentElement,true);Yb(g);var s=ca("width",g.getAttribute("width")),v=ca("height",g.getAttribute("height")),u=g.getAttribute("viewBox"),t=u?u.split(" "):[0,0,s,v];for(b=0;b<4;++b)t[b]=+t[b];p.getAttribute("width");var B=+p.getAttribute("height");w=v>s?"scale("+B/3/t[3]+")":"scale("+B/3/t[2]+")";w="translate(0) "+w+" translate(0)";k=f.createElementNS(o,"symbol");
var D=Ta();for(svgedit.browser.isGecko()&&$(g).find("linearGradient, radialGradient, pattern").appendTo(D);g.firstChild;)k.appendChild(g.firstChild);var H=g.attributes;for(g=0;g<H.length;g++){var K=H[g];k.setAttribute(K.nodeName,K.nodeValue)}k.id=Ea();ob[c]={symbol:k,xform:w};Ta().appendChild(k);l.addSubCommand(new wa(k))}var P=f.createElementNS(o,"use");P.id=Ea();fb(P,"#"+k.id);(N||F().getCurrentLayer()).appendChild(P);l.addSubCommand(new wa(P));Aa();P.setAttribute("transform",w);Ra(P);$(P).data("symbol",
k).data("ref",k);bb([P]);la(l);fa("changed",[p])}catch(X){console.log(X);return false}return true};var wb=e.identifyLayers=function(){Lb();F().identifyLayers()};this.createLayer=function(b){var c=new qa("Create Layer");b=F().createLayer(b);c.addSubCommand(new wa(b));la(c);Aa();fa("changed",[b])};this.cloneLayer=function(b){var c=new qa("Duplicate Layer"),d=f.createElementNS(o,"g"),l=f.createElementNS(o,"title");l.textContent=b;d.appendChild(l);l=F().getCurrentLayer();$(l).after(d);l=l.childNodes;
for(var k=0;k<l.length;k++){var w=l[k];w.localName!="title"&&d.appendChild(ub(w))}Aa();wb();c.addSubCommand(new wa(d));la(c);e.setCurrentLayer(b);fa("changed",[d])};this.deleteCurrentLayer=function(){var b=F().getCurrentLayer(),c=b.nextSibling,d=b.parentNode;if(b=F().deleteCurrentLayer()){var l=new qa("Delete Layer");l.addSubCommand(new Ia(b,c,d));la(l);Aa();fa("changed",[d]);return true}return false};this.setCurrentLayer=function(b){(b=F().setCurrentLayer(svgedit.utilities.toXml(b)))&&Aa();return b};
this.renameCurrentLayer=function(b){var c=F();if(c.current_layer){var d=c.current_layer;if(!e.setCurrentLayer(b)){for(var l=new qa("Rename Layer"),k=0;k<c.getNumLayers();++k)if(c.all_layers[k][1]==d)break;var w=c.getLayerName(k);c.all_layers[k][0]=svgedit.utilities.toXml(b);var n=d.childNodes.length;for(k=0;k<n;++k){var g=d.childNodes.item(k);if(g&&g.tagName=="title"){for(;g.firstChild;)g.removeChild(g.firstChild);g.textContent=b;l.addSubCommand(new Fa(g,{"#text":w}));la(l);fa("changed",[d]);return true}}}c.current_layer=
d}return false};this.setCurrentLayerPosition=function(b){var c=F();if(c.current_layer&&b>=0&&b<c.getNumLayers()){for(var d=0;d<c.getNumLayers();++d)if(c.all_layers[d][1]==c.current_layer)break;if(d==c.getNumLayers())return false;if(d!=b){var l=null,k=c.current_layer.nextSibling;if(b>d){if(b<c.getNumLayers()-1)l=c.all_layers[b+1][1]}else l=c.all_layers[b][1];p.insertBefore(c.current_layer,l);la(new ia(c.current_layer,k,p));wb();e.setCurrentLayer(c.getLayerName(b));return true}}return false};this.setLayerVisibility=
function(b,c){var d=F(),l=d.getLayerVisibility(b),k=d.setLayerVisibility(b,c);if(k)la(new Fa(k,{display:l?"inline":"none"},"Layer Visibility"));else return false;if(k==d.getCurrentLayer()){Aa();pa.clear()}return true};this.moveSelectedToLayer=function(b){for(var c=null,d=F(),l=0;l<d.getNumLayers();++l)if(d.getLayerName(l)==b){c=d.all_layers[l][1];break}if(!c)return false;b=new qa("Move Elements to Layer");d=J;for(l=d.length;l--;){var k=d[l];if(k){var w=k.nextSibling,n=k.parentNode;c.appendChild(k);
b.addSubCommand(new ia(k,w,n))}}la(b);return true};this.mergeLayer=function(b){var c=new qa("Merge Layer"),d=F(),l=$(d.current_layer).prev()[0];if(l){for(c.addSubCommand(new Ia(d.current_layer,d.current_layer.nextSibling,p));d.current_layer.firstChild;){var k=d.current_layer.firstChild;if(k.localName=="title"){c.addSubCommand(new Ia(k,k.nextSibling,d.current_layer));d.current_layer.removeChild(k)}else{var w=k.nextSibling;l.appendChild(k);c.addSubCommand(new ia(k,w,d.current_layer))}}p.removeChild(d.current_layer);
if(!b){Aa();wb();fa("changed",[p]);la(c)}d.current_layer=l;return c}};this.mergeAllLayers=function(){var b=new qa("Merge all Layers"),c=F();for(c.current_layer=c.all_layers[c.getNumLayers()-1][1];$(p).children("g").length>1;)b.addSubCommand(e.mergeLayer(true));Aa();wb();fa("changed",[p]);la(b)};var Lb=this.leaveContext=function(){var b=tb.length;if(b){for(var c=0;c<b;c++){var d=tb[c],l=sb(d,"orig_opac");l!==1?d.setAttribute("opacity",l):d.removeAttribute("opacity");d.setAttribute("style","pointer-events: inherit")}tb=
[];Aa(true);fa("contextset",null)}N=null},mc=this.setContext=function(b){Lb();if(typeof b==="string")b=ya(b);N=b;$(b).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var c=this.getAttribute("opacity")||1;sb(this,"orig_opac",c);this.setAttribute("opacity",c*0.33);this.setAttribute("style","pointer-events: none");tb.push(this)});Aa();fa("contextset",N)};this.clear=function(){pa.clear();Aa();e.clearSvgContentElement();e.current_drawing_=new svgedit.draw.Drawing(p);e.createLayer("Layer 1");
e.undoMgr.resetUndoStack();ua.initGroup();ja=ua.getRubberBandBox();fa("cleared")};this.linkControlPoints=pa.linkControlPoints;this.getContentElem=function(){return p};this.getRootElem=function(){return h};this.getSelectedElems=function(){return J};var vb=this.getResolution=function(){var b=p.getAttribute("width")/z,c=p.getAttribute("height")/z;return{w:b,h:c,zoom:z}};this.getZoom=function(){return z};this.getVersion=function(){return"svgcanvas.js ($Rev: 2047 $)"};this.setUiStrings=function(b){$.extend(mb,
b.notification)};this.setConfig=function(b){$.extend(A,b)};this.getTitle=function(b){if(b=b||J[0]){b=$(b).data("gsvg")||$(b).data("symbol")||b;b=b.childNodes;for(var c=0;c<b.length;c++)if(b[c].nodeName=="title")return b[c].textContent;return""}};this.setGroupTitle=function(b){var c=J[0];c=$(c).data("gsvg")||c;var d=$(c).children("title"),l=new qa("Set Label");if(b.length)if(d.length){d=d[0];l.addSubCommand(new Fa(d,{"#text":d.textContent}));d.textContent=b}else{d=f.createElementNS(o,"title");d.textContent=
b;$(c).prepend(d);l.addSubCommand(new wa(d))}else{l.addSubCommand(new Ia(d[0],d.nextSibling,c));d.remove()}la(l)};this.getDocumentTitle=function(){return e.getTitle(p)};this.setDocumentTitle=function(b){for(var c=p.childNodes,d=false,l="",k=new qa("Change Image Title"),w=0;w<c.length;w++)if(c[w].nodeName=="title"){d=c[w];l=d.textContent;break}if(!d){d=f.createElementNS(o,"title");p.insertBefore(d,p.firstChild)}if(b.length)d.textContent=b;else d.parentNode.removeChild(d);k.addSubCommand(new Fa(d,{"#text":l}));
la(k)};this.getEditorNS=function(b){b&&p.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(b,c){var d=vb(),l=d.w;d=d.h;var k;if(b=="fit"){var w=getStrokedBBox();if(w){k=new qa("Fit Canvas to Content");var n=Hb();bb(n);var g=[],s=[];$.each(n,function(){g.push(w.x*-1);s.push(w.y*-1)});n=e.moveSelectedElements(g,s,true);k.addSubCommand(n);Aa();b=Math.round(w.width);c=Math.round(w.height)}else return false}if(b!=l||c!=d){n=h.suspendRedraw(1E3);
k||(k=new qa("Change Image Dimensions"));b=ca("width",b);c=ca("height",c);p.setAttribute("width",b);p.setAttribute("height",c);this.contentW=b;this.contentH=c;k.addSubCommand(new Fa(p,{width:l,height:d}));p.setAttribute("viewBox",[0,0,b/z,c/z].join(" "));k.addSubCommand(new Fa(p,{viewBox:["0 0",l,d].join(" ")}));la(k);h.unsuspendRedraw(n);fa("changed",[p])}return true};this.getOffset=function(){return $(p).attr(["x","y"])};this.setBBoxZoom=function(b,c,d){var l=0.85,k=function(w){if(!w)return false;
var n=Math.min(Math.round(c/w.width*100*l)/100,Math.round(d/w.height*100*l)/100);e.setZoom(n);return{zoom:n,bbox:w}};if(typeof b=="object"){b=b;if(b.width==0||b.height==0){e.setZoom(b.zoom?b.zoom:z*b.factor);return{zoom:z,bbox:b}}return k(b)}switch(b){case "selection":if(!J[0])return;b=$.map(J,function(w){if(w)return w});b=getStrokedBBox(b);break;case "canvas":b=vb();l=0.95;b={width:b.w,height:b.h,x:0,y:0};break;case "content":b=getStrokedBBox();break;case "layer":b=getStrokedBBox(Hb(F().getCurrentLayer()));
break;default:return}return k(b)};this.setZoom=function(b){var c=vb();p.setAttribute("viewBox","0 0 "+c.w/b+" "+c.h/b);z=b;$.each(J,function(d,l){l&&ua.requestSelector(l).resize()});pa.zoomChange();zb("zoomChanged",b)};this.getMode=function(){return ta};this.setMode=function(b){pa.clear(true);Oa.clear();Ma=J[0]&&J[0].nodeName=="text"?Qa:O;ta=b};this.getColor=function(b){return Ma[b]};this.setColor=function(b,c,d){O[b]=c;Ma[b+"_paint"]={type:"solidColor"};for(var l=[],k=J.length;k--;){var w=J[k];if(w)if(w.tagName==
"g")svgedit.utilities.walkTree(w,function(n){n.nodeName!="g"&&l.push(n)});else if(b=="fill")w.tagName!="polyline"&&w.tagName!="line"&&l.push(w);else l.push(w)}if(l.length>0)if(d)jb(b,c,l);else{Na(b,c,l);fa("changed",l)}};var Ta=function(){var b=p.getElementsByTagNameNS(o,"defs");if(b.length>0)b=b[0];else{b=f.createElementNS(o,"defs");p.firstChild?p.insertBefore(b,p.firstChild.nextSibling):p.appendChild(b)}return b},ic=this.setGradient=function(b){if(!(!Ma[b+"_paint"]||Ma[b+"_paint"].type=="solidColor")){var c=
e[b+"Grad"],d=Zb(c),l=Ta();if(d)c=d;else{c=l.appendChild(f.importNode(c,true));c.id=Ea()}e.setColor(b,"url(#"+c.id+")")}},Zb=function(b){var c=Ta();c=$(c).find("linearGradient, radialGradient");for(var d=c.length,l=["r","cx","cy","fx","fy"];d--;){var k=c[d];if(b.tagName=="linearGradient"){if(b.getAttribute("x1")!=k.getAttribute("x1")||b.getAttribute("y1")!=k.getAttribute("y1")||b.getAttribute("x2")!=k.getAttribute("x2")||b.getAttribute("y2")!=k.getAttribute("y2"))continue}else{var w=$(b).attr(l),
n=$(k).attr(l),g=false;$.each(l,function(D,H){if(w[H]!=n[H])g=true});if(g)continue}var s=b.getElementsByTagNameNS(o,"stop"),v=k.getElementsByTagNameNS(o,"stop");if(s.length==v.length){for(var u=s.length;u--;){var t=s[u],B=v[u];if(t.getAttribute("offset")!=B.getAttribute("offset")||t.getAttribute("stop-opacity")!=B.getAttribute("stop-opacity")||t.getAttribute("stop-color")!=B.getAttribute("stop-color"))break}if(u==-1)return k}}return null};this.setPaint=function(b,c){var d=new $.jGraduate.Paint(c);
this.setPaintOpacity(b,d.alpha/100,true);Ma[b+"_paint"]=d;switch(d.type){case "solidColor":this.setColor(b,d.solidColor!="none"?"#"+d.solidColor:"none");break;case "linearGradient":case "radialGradient":e[b+"Grad"]=d[d.type];ic(b)}};this.getStrokeWidth=function(){return Ma.stroke_width};this.setStrokeWidth=function(b){if(b==0&&["line","path"].indexOf(ta)>=0)e.setStrokeWidth(1);else{Ma.stroke_width=b;for(var c=[],d=J.length;d--;){var l=J[d];if(l)l.tagName=="g"?svgedit.utilities.walkTree(l,function(k){k.nodeName!=
"g"&&c.push(k)}):c.push(l)}if(c.length>0){Na("stroke-width",b,c);fa("changed",J)}}};this.setStrokeAttr=function(b,c){O[b.replace("-","_")]=c;for(var d=[],l=J.length;l--;){var k=J[l];if(k)k.tagName=="g"?svgedit.utilities.walkTree(k,function(w){w.nodeName!="g"&&d.push(w)}):d.push(k)}if(d.length>0){Na(b,c,d);fa("changed",J)}};this.getStyle=function(){return O};this.getOpacity=function(){return O.opacity};this.setOpacity=function(b){O.opacity=b;Na("opacity",b)};this.getFillOpacity=function(){return O.fill_opacity};
this.getStrokeOpacity=function(){return O.stroke_opacity};this.setPaintOpacity=function(b,c,d){O[b+"_opacity"]=c;d?jb(b+"-opacity",c):Na(b+"-opacity",c)};this.getBlur=function(b){var c=0;if(b)if(b.getAttribute("filter"))if(b=ya(b.id+"_blur"))c=b.firstChild.getAttribute("stdDeviation");return c};(function(){function b(){var k=e.undoMgr.finishUndoableChange();c.addSubCommand(k);la(c);d=c=null}var c=null,d=null,l=false;e.setBlurNoUndo=function(k){if(d)if(k===0){jb("filter","");l=true}else{var w=J[0];
l&&jb("filter","url(#"+w.id+"_blur)");if(svgedit.browser.isWebkit()){console.log("e",w);w.removeAttribute("filter");w.setAttribute("filter","url(#"+w.id+"_blur)")}jb("stdDeviation",k,[d.firstChild]);e.setBlurOffsets(d,k)}else e.setBlur(k)};e.setBlurOffsets=function(k,w){if(w>3)Ca(k,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100);else if(!svgedit.browser.isWebkit()){k.removeAttribute("x");k.removeAttribute("y");k.removeAttribute("width");k.removeAttribute("height")}};e.setBlur=function(k,w){if(c)b();
else{var n=J[0],g=n.id;d=ya(g+"_blur");k-=0;var s=new qa;if(d){if(k===0)d=null}else{var v=Z({element:"feGaussianBlur",attr:{"in":"SourceGraphic",stdDeviation:k}});d=Z({element:"filter",attr:{id:g+"_blur"}});d.appendChild(v);Ta().appendChild(d);s.addSubCommand(new wa(d))}v={filter:n.getAttribute("filter")};if(k===0){n.removeAttribute("filter");s.addSubCommand(new Fa(n,v))}else{Na("filter","url(#"+g+"_blur)");s.addSubCommand(new Fa(n,v));e.setBlurOffsets(d,k);c=s;e.undoMgr.beginUndoableChange("stdDeviation",
[d?d.firstChild:null]);if(w){e.setBlurNoUndo(k);b()}}}}})();this.getBold=function(){var b=J[0];if(b!=null&&b.tagName=="text"&&J[1]==null)return b.getAttribute("font-weight")=="bold";return false};this.setBold=function(b){var c=J[0];if(c!=null&&c.tagName=="text"&&J[1]==null)Na("font-weight",b?"bold":"normal");J[0].textContent||Oa.setCursor()};this.getItalic=function(){var b=J[0];if(b!=null&&b.tagName=="text"&&J[1]==null)return b.getAttribute("font-style")=="italic";return false};this.setItalic=function(b){var c=
J[0];if(c!=null&&c.tagName=="text"&&J[1]==null)Na("font-style",b?"italic":"normal");J[0].textContent||Oa.setCursor()};this.getFontFamily=function(){return Qa.font_family};this.setFontFamily=function(b){Qa.font_family=b;Na("font-family",b);J[0]&&!J[0].textContent&&Oa.setCursor()};this.setFontColor=function(b){Qa.fill=b;Na("fill",b)};this.getFontSize=function(){return Qa.fill};this.getFontSize=function(){return Qa.font_size};this.setFontSize=function(b){Qa.font_size=b;Na("font-size",b);J[0].textContent||
Oa.setCursor()};this.getText=function(){var b=J[0];if(b==null)return"";return b.textContent};this.setTextContent=function(b){Na("#text",b);Oa.init(b);Oa.setCursor()};this.setImageURL=function(b){var c=J[0];if(c){var d=$(c).attr(["width","height"]);d=!d.width||!d.height;var l=db(c);if(l!==b)d=true;else if(!d)return;var k=new qa("Change Image URL");fb(c,b);k.addSubCommand(new Fa(c,{"#href":l}));d?$(new Image).load(function(){var w=$(c).attr(["width","height"]);$(c).attr({width:this.width,height:this.height});
ua.requestSelector(c).resize();k.addSubCommand(new Fa(c,w));la(k);fa("changed",[c])}).attr("src",b):la(k)}};this.setLinkURL=function(b){var c=J[0];if(c){if(c.tagName!=="a"){c=$(c).parents("a");if(c.length)c=c[0];else return}var d=db(c);if(d!==b){var l=new qa("Change Link URL");fb(c,b);l.addSubCommand(new Fa(c,{"#href":d}));la(l)}}};this.setRectRadius=function(b){var c=J[0];if(c!=null&&c.tagName=="rect"){var d=c.getAttribute("rx");if(d!=b){c.setAttribute("rx",b);c.setAttribute("ry",b);la(new Fa(c,
{rx:d,ry:d},"Radius"));fa("changed",[c])}}};this.makeHyperlink=function(b){e.groupSelectedElements("a",b)};this.removeHyperlink=function(){e.ungroupSelectedElement()};this.setSegType=function(b){pa.setSegType(b)};this.convertToPath=function(b,c){if(b==null)$.each(J,function(ba,R){R&&e.convertToPath(R)});else{if(!c)var d=new qa("Convert element to Path");var l=c?{}:{fill:O.fill,"fill-opacity":O.fill_opacity,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,
"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,opacity:O.opacity,visibility:"hidden"};$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(b.getAttribute(this))l[this]=b.getAttribute(this)});var k=Z({element:"path",attr:l}),w=b.getAttribute("transform");w&&k.setAttribute("transform",w);var n=b.id,g=b.parentNode;b.nextSibling?g.insertBefore(k,b):g.appendChild(k);var s="",v=function(ba){$.each(ba,function(R,T){var V=T[1];s+=T[0];for(var da=0;da<V.length;da+=
2)s+=V[da]+","+V[da+1]+" "})},u=1.81;switch(b.tagName){case "ellipse":case "circle":var t=$(b).attr(["rx","ry","cx","cy"]),B=t.cx,D=t.cy,H=t.rx;t=t.ry;if(b.tagName=="circle")H=t=$(b).attr("r");v([["M",[B-H,D]],["C",[B-H,D-t/u,B-H/u,D-t,B,D-t]],["C",[B+H/u,D-t,B+H,D-t/u,B+H,D]],["C",[B+H,D+t/u,B+H/u,D+t,B,D+t]],["C",[B-H/u,D+t,B-H,D+t/u,B-H,D]],["Z",[]]]);break;case "path":s=b.getAttribute("d");break;case "line":t=$(b).attr(["x1","y1","x2","y2"]);s="M"+t.x1+","+t.y1+"L"+t.x2+","+t.y2;break;case "polyline":case "polygon":s=
"M"+b.getAttribute("points");break;case "rect":t=$(b).attr(["rx","ry"]);H=t.rx;t=t.ry;var K=b.getBBox();B=K.x;D=K.y;var P=K.width;K=K.height;u=4-u;!H&&!t?v([["M",[B,D]],["L",[B+P,D]],["L",[B+P,D+K]],["L",[B,D+K]],["L",[B,D]],["Z",[]]]):v([["M",[B,D+t]],["C",[B,D+t/u,B+H/u,D,B+H,D]],["L",[B+P-H,D]],["C",[B+P-H/u,D,B+P,D+t/u,B+P,D+t]],["L",[B+P,D+K-t]],["C",[B+P,D+K-t/u,B+P-H/u,D+K,B+P-H,D+K]],["L",[B+H,D+K]],["C",[B+H/u,D+K,B,D+K-t/u,B,D+K-t]],["L",[B,D+t]],["Z",[]]]);break;default:k.parentNode.removeChild(k)}s&&
k.setAttribute("d",s);if(c){pa.resetOrientation(k);d=false;try{d=k.getBBox()}catch(X){}k.parentNode.removeChild(k);return d}else{if(w){w=W(k);Pa(w)&&pa.resetOrientation(k)}d.addSubCommand(new Ia(b,b.nextSibling,g));d.addSubCommand(new wa(k));Aa();b.parentNode.removeChild(b);k.setAttribute("id",n);k.removeAttribute("visibility");bb([k],true);la(d)}}};var jb=function(b,c,d){var l=h.suspendRedraw(1E3);ta=="pathedit"&&pa.moveNode(b,c);d=d||J;for(var k=d.length,w=["g","polyline","path"],n=["transform",
"opacity","filter"];k--;){var g=d[k];if(g!=null){ta==="textedit"&&b!=="#text"&&g.textContent.length&&Oa.toSelectMode(g);if((b==="x"||b==="y")&&w.indexOf(g.tagName)>=0){var s=getStrokedBBox([g]);e.moveSelectedElements((b==="x"?c-s.x:0)*z,(b==="y"?c-s.y:0)*z,true)}else{g.tagName==="g"&&n.indexOf(b);s=b==="#text"?g.textContent:g.getAttribute(b);if(s==null)s="";if(s!==String(c)){if(b=="#text"){svgedit.utilities.getBBox(g);g.textContent=c;if(/rotate/.test(g.getAttribute("transform")))g=Vb(g)}else b=="#href"?
fb(g,c):g.setAttribute(b,c);if(svgedit.browser.isGecko()&&g.nodeName==="text"&&/rotate/.test(g.getAttribute("transform")))if((c+"").indexOf("url")===0||["font-size","font-family","x","y"].indexOf(b)>=0&&g.textContent)g=Vb(g);J.indexOf(g)>=0&&setTimeout(function(){g.parentNode&&ua.requestSelector(g).resize()},0);s=Ua(g);if(s!=0&&b!="transform")for(var v=W(g),u=v.numberOfItems;u--;)if(v.getItem(u).type==4){v.removeItem(u);var t=svgedit.utilities.getBBox(g),B=ka(t.x+t.width/2,t.y+t.height/2,sa(v).matrix);
t=B.x;B=B.y;var D=h.createSVGTransform();D.setRotate(s,t,B);v.insertItemBefore(D,u);break}}}}}h.unsuspendRedraw(l)},Na=this.changeSelectedAttribute=function(b,c,d){d=d||J;e.undoMgr.beginUndoableChange(b,d);jb(b,c,d);b=e.undoMgr.finishUndoableChange();b.isEmpty()||la(b)};this.deleteSelectedElements=function(){for(var b=new qa("Delete Elements"),c=J.length,d=[],l=0;l<c;++l){var k=J[l];if(k==null)break;var w=k.parentNode,n=k;ua.releaseSelector(n);svgedit.path.removePath_(n.id);if(w.tagName==="a"&&w.childNodes.length===
1){n=w;w=w.parentNode}var g=n.nextSibling;n=w.removeChild(n);d.push(k);J[l]=null;b.addSubCommand(new Ia(n,g,w))}b.isEmpty()||la(b);fa("changed",d);Aa()};this.cutSelectedElements=function(){for(var b=new qa("Cut Elements"),c=J.length,d=[],l=0;l<c;++l){var k=J[l];if(k==null)break;var w=k.parentNode,n=k;ua.releaseSelector(n);svgedit.path.removePath_(n.id);var g=n.nextSibling;n=w.removeChild(n);d.push(k);J[l]=null;b.addSubCommand(new Ia(n,g,w))}b.isEmpty()||la(b);fa("changed",d);Aa();e.clipBoard=d};this.copySelectedElements=
function(){e.clipBoard=$.merge([],J)};this.pasteElements=function(b,c,d){var l=e.clipBoard,k=l.length;if(k){for(var w=[],n=new qa("Paste elements");k--;){var g=l[k];if(g){var s=ub(g);if(!ya(g.id))s.id=g.id;w.push(s);(N||F().getCurrentLayer()).appendChild(s);n.addSubCommand(new wa(s))}}ib(w);if(b!=="in_place"){var v,u;if(b){if(b==="point"){v=c;u=d}}else{v=yb.x;u=yb.y}b=getStrokedBBox(w);var t=v-(b.x+b.width/2),B=u-(b.y+b.height/2),D=[],H=[];$.each(w,function(){D.push(t);H.push(B)});v=e.moveSelectedElements(D,
H,false);n.addSubCommand(v)}la(n);fa("changed",w)}};this.groupSelectedElements=function(b){b||(b="g");var c="";switch(b){case "a":c="Make hyperlink";var d="";if(arguments.length>1)d=arguments[1];break;default:b="g";c="Group Elements"}c=new qa(c);var l=Z({element:b,attr:{id:Ea()}});b==="a"&&fb(l,d);c.addSubCommand(new wa(l));for(d=J.length;d--;){var k=J[d];if(k!=null){if(k.parentNode.tagName==="a"&&k.parentNode.childNodes.length===1)k=k.parentNode;var w=k.nextSibling,n=k.parentNode;l.appendChild(k);
c.addSubCommand(new ia(k,w,n))}}c.isEmpty()||la(c);ib([l],true)};var Xb=this.pushGroupProperties=function(b,c){var d=b.childNodes,l=d.length,k=b.getAttribute("transform"),w=W(b),n=sa(w).matrix,g=new qa("Push group properties"),s=0,v=Ua(b),u=$(b).attr(["filter","opacity"]),t,B;for(s=0;s<l;s++){var D=d[s];if(D.nodeType===1){if(u.opacity!==null&&u.opacity!==1){D.getAttribute("opacity");var H=Math.round((D.getAttribute("opacity")||1)*u.opacity*100)/100;Na("opacity",H,[D])}if(u.filter){var K=H=this.getBlur(D);
B||(B=this.getBlur(b));if(H)H=B-0+(H-0);else if(H===0)H=B;if(K)t=pb(D.getAttribute("filter"));else if(t){t=ub(t);Ta().appendChild(t)}else t=pb(u.filter);t.id=D.id+"_"+(t.firstChild.tagName==="feGaussianBlur"?"blur":"filter");Na("filter","url(#"+t.id+")",[D]);if(H){Na("stdDeviation",H,[t.firstChild]);e.setBlurOffsets(t,H)}}H=W(D);if(~D.tagName.indexOf("Gradient"))H=null;if(H)if(D.tagName!=="defs")if(w.numberOfItems){if(v&&w.numberOfItems==1){var P=w.getItem(0).matrix,X=h.createSVGMatrix();if(K=Ua(D))X=
H.getItem(0).matrix;var ba=svgedit.utilities.getBBox(D),R=sa(H).matrix,T=ka(ba.x+ba.width/2,ba.y+ba.height/2,R);ba=v+K;R=h.createSVGTransform();R.setRotate(ba,T.x,T.y);P=oa(P,X,R.matrix.inverse());K&&H.removeItem(0);if(ba)H.numberOfItems?H.insertItemBefore(R,0):H.appendItem(R);if(P.e||P.f){K=h.createSVGTransform();K.setTranslate(P.e,P.f);H.numberOfItems?H.insertItemBefore(K,0):H.appendItem(K)}}else{K=D.getAttribute("transform");P={};P.transform=K?K:"";K=h.createSVGTransform();P=sa(H).matrix;X=P.inverse();
P=oa(X,n,P);K.setMatrix(P);H.appendItem(K)}(D=Ra(D))&&g.addSubCommand(D)}}}if(k){P={};P.transform=k;b.setAttribute("transform","");b.removeAttribute("transform");g.addSubCommand(new Fa(b,P))}if(c&&!g.isEmpty())return g};this.ungroupSelectedElement=function(){var b=J[0];if($(b).data("gsvg")||$(b).data("symbol"))Bb(b);else if(b.tagName==="use"){var c=ya(db(b).substr(1));$(b).data("symbol",c).data("ref",c);Bb(b)}else{c=$(b).parents("a");if(c.length)b=c[0];if(b.tagName==="g"||b.tagName==="a"){c=new qa("Ungroup Elements");
var d=Xb(b,true);d&&c.addSubCommand(d);d=b.parentNode;for(var l=b.nextSibling,k=Array(b.childNodes.length),w=0;b.firstChild;){var n=b.firstChild,g=n.nextSibling,s=n.parentNode;if(n.tagName==="title"){c.addSubCommand(new Ia(n,n.nextSibling,s));s.removeChild(n)}else{k[w++]=n=d.insertBefore(n,l);c.addSubCommand(new ia(n,g,s))}}Aa();l=b.nextSibling;b=d.removeChild(b);c.addSubCommand(new Ia(b,l,d));c.isEmpty()||la(c);bb(k)}}};this.moveToTopSelectedElement=function(){var b=J[0];if(b!=null){b=b;var c=b.parentNode,
d=b.nextSibling;b=b.parentNode.appendChild(b);if(d!=b.nextSibling){la(new ia(b,d,c,"top"));fa("changed",[b])}}};this.moveToBottomSelectedElement=function(){var b=J[0];if(b!=null){b=b;var c=b.parentNode,d=b.nextSibling,l=b.parentNode.firstChild;if(l.tagName=="title")l=l.nextSibling;if(l.tagName=="defs")l=l.nextSibling;b=b.parentNode.insertBefore(b,l);if(d!=b.nextSibling){la(new ia(b,d,c,"bottom"));fa("changed",[b])}}};this.moveUpDownSelected=function(b){var c=J[0];if(c){eb=[];var d,l,k=$(Ub(getStrokedBBox([c]))).toArray();
b=="Down"&&k.reverse();$.each(k,function(){if(l){d=this;return false}else if(this==c)l=true});if(d){k=c.parentNode;var w=c.nextSibling;$(d)[b=="Down"?"before":"after"](c);if(w!=c.nextSibling){la(new ia(c,w,k,"Move "+b));fa("changed",[c])}}}};this.moveSelectedElements=function(b,c,d){if(b.constructor!=Array){b/=z;c/=z}d=d||true;for(var l=new qa("position"),k=J.length;k--;){var w=J[k];if(w!=null){var n=h.createSVGTransform(),g=W(w);b.constructor==Array?n.setTranslate(b[k],c[k]):n.setTranslate(b,c);
g.numberOfItems?g.insertItemBefore(n,0):g.appendItem(n);(n=Ra(w))&&l.addSubCommand(n);ua.requestSelector(w).resize()}}if(!l.isEmpty()){d&&la(l);fa("changed",J);return l}};this.cloneSelectedElements=function(b,c){for(var d=new qa("Clone Elements"),l=J.length,k=0;k<l;++k){var w=J[k];if(w==null)break}l=J.slice(0,k);this.clearSelection(true);for(k=l.length;k--;){w=l[k]=ub(l[k]);(N||F().getCurrentLayer()).appendChild(w);d.addSubCommand(new wa(w))}if(!d.isEmpty()){bb(l.reverse());this.moveSelectedElements(b,
c,false);la(d)}};this.alignSelectedElements=function(b,c){var d=[],l=Number.MAX_VALUE,k=Number.MIN_VALUE,w=Number.MAX_VALUE,n=Number.MIN_VALUE,g=Number.MIN_VALUE,s=Number.MIN_VALUE,v=J.length;if(v){for(var u=0;u<v;++u){if(J[u]==null)break;d[u]=getStrokedBBox([J[u]]);switch(c){case "smallest":if((b=="l"||b=="c"||b=="r")&&(g==Number.MIN_VALUE||g>d[u].width)||(b=="t"||b=="m"||b=="b")&&(s==Number.MIN_VALUE||s>d[u].height)){l=d[u].x;w=d[u].y;k=d[u].x+d[u].width;n=d[u].y+d[u].height;g=d[u].width;s=d[u].height}break;
case "largest":if((b=="l"||b=="c"||b=="r")&&(g==Number.MIN_VALUE||g<d[u].width)||(b=="t"||b=="m"||b=="b")&&(s==Number.MIN_VALUE||s<d[u].height)){l=d[u].x;w=d[u].y;k=d[u].x+d[u].width;n=d[u].y+d[u].height;g=d[u].width;s=d[u].height}break;default:if(d[u].x<l)l=d[u].x;if(d[u].y<w)w=d[u].y;if(d[u].x+d[u].width>k)k=d[u].x+d[u].width;if(d[u].y+d[u].height>n)n=d[u].y+d[u].height}}if(c=="page"){w=l=0;k=e.contentW;n=e.contentH}g=Array(v);s=Array(v);for(u=0;u<v;++u){if(J[u]==null)break;var t=d[u];g[u]=0;s[u]=
0;switch(b){case "l":g[u]=l-t.x;break;case "c":g[u]=(l+k)/2-(t.x+t.width/2);break;case "r":g[u]=k-(t.x+t.width);break;case "t":s[u]=w-t.y;break;case "m":s[u]=(w+n)/2-(t.y+t.height/2);break;case "b":s[u]=n-(t.y+t.height)}}this.moveSelectedElements(g,s)}};this.contentW=vb().w;this.contentH=vb().h;this.updateCanvas=function(b,c){h.setAttribute("width",b);h.setAttribute("height",c);var d=$("#canvasBackground")[0],l=p.getAttribute("x"),k=p.getAttribute("y"),w=b/2-this.contentW*z/2,n=c/2-this.contentH*
z/2;Ca(p,{width:this.contentW*z,height:this.contentH*z,x:w,y:n,viewBox:"0 0 "+this.contentW+" "+this.contentH});Ca(d,{width:p.getAttribute("width"),height:p.getAttribute("height"),x:w,y:n});(d=ya("background_image"))&&Ca(d,{width:"100%",height:"100%"});ua.selectorParentGroup.setAttribute("transform","translate("+w+","+n+")");return{x:w,y:n,old_x:l,old_y:k,d_x:w-l,d_y:n-k}};this.setBackground=function(b,c){var d=ya("canvasBackground"),l=$(d).find("rect")[0],k=ya("background_image");l.setAttribute("fill",
b);if(c){if(!k){k=f.createElementNS(o,"image");Ca(k,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}fb(k,c);d.appendChild(k)}else k&&k.parentNode.removeChild(k)};this.cycleElement=function(b){var c=J[0],d=false,l=Hb(N||F().getCurrentLayer());if(l.length){if(c==null){b=b?l.length-1:0;d=l[b]}else for(var k=l.length;k--;)if(l[k]==c){b=b?k-1:k+1;if(b>=l.length)b=0;else if(b<0)b=l.length-1;d=l[b];break}ib([d],true);fa("selected",J)}};this.clear();
this.getPrivateMethods=function(){return{addCommandToHistory:la,setGradient:ic,addSvgElementFromJson:Z,assignAttributes:Ca,BatchCommand:qa,call:fa,ChangeElementCommand:Fa,copyElem:ub,ffClone:Vb,findDefs:Ta,findDuplicateGradient:Zb,getElem:ya,getId:Za,getIntersectionList:Ub,getMouseTarget:cb,getNextId:Ea,getPathBBox:cc,getUrlFromAttr:qb,hasMatrixTransform:Pa,identifyLayers:wb,InsertElementCommand:wa,isIdentity:svgedit.math.isIdentity,logMatrix:ec,matrixMultiply:oa,MoveElementCommand:ia,preventClickDefault:Ib,
recalculateAllSelectedDimensions:Jb,recalculateDimensions:Ra,remapElement:Kb,RemoveElementCommand:Ia,removeUnusedDefElems:hc,round:Ab,runExtensions:zb,sanitizeSvg:rb,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:sa,transformPoint:ka,walkTree:svgedit.utilities.walkTree}}};(function(){if(!window.svgEditor)window.svgEditor=function(a){function L(F,z){var N=m.setSvgString(F)!==false;z=z||a.noop;N?z(true):a.alert(h.notification.errorLoadingSVG,function(){z(false)})}var m,o={},A=false,G={lang:"en",iconsize:"m",bkgd_color:"#FFF",bkgd_url:"",img_save:"embed"},e={},f={canvas_expansion:3,dimensions:[640,480],initFill:{color:"FF0000",opacity:1},initStroke:{width:5,color:"000000",opacity:1},initOpacity:1,imgPath:"images/",langPath:"locale/",extPath:"extensions/",jGraduatePath:"jgraduate/images/",
extensions:["ext-markers.js","ext-connector.js","ext-eyedropper.js","ext-shapes.js","ext-imagelib.js","ext-grid.js"],initTool:"select",wireframe:false,colorPickerCSS:null,gridSnapping:false,baseUnit:"px",snappingStep:10,showRulers:true},h=o.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" ...'}};e={};var p={};o.curConfig=f;o.tool_scale=1;a.pref=function(F,z){if(z)e[F]=z;F="svg-edit-"+F;var N=location.hostname,aa=N&&N.indexOf(".")>=0,O=z!=undefined,J=false;try{if(window.localStorage)J=localStorage}catch(Z){}try{if(window.globalStorage&&aa)J=globalStorage[N]}catch(W){}if(J)if(O)J.setItem(F,z);else{if(J.getItem(F))return J.getItem(F)+""}else if(window.widget)if(O)widget.setPreferenceForKey(z,
F);else return widget.preferenceForKey(F);else if(O){N=new Date;N.setTime(N.getTime()+31536E6);z=encodeURIComponent(z);document.cookie=F+"="+z+"; expires="+N.toUTCString()}else return(N=document.cookie.match(RegExp(F+"=([^;]+)")))?decodeURIComponent(N[1]):""};o.setConfig=function(F){a.each(F,function(z,N){z in G&&a.pref(z,N)});a.extend(true,f,F);if(F.extensions)f.extensions=F.extensions};o.setCustomHandlers=function(F){o.ready(function(){if(F.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();
m.open=F.open}if(F.save){show_save_warning=false;m.bind("saved",F.save)}F.pngsave&&m.bind("exported",F.pngsave);p=F})};o.randomizeIds=function(){m.randomizeIds(arguments)};o.init=function(){function F(i,q){var E=i.id,I=E.split("_"),M=I[0];I=I[1];q&&m.setStrokeAttr("stroke-"+M,I);Ma();B("#cur_"+M,E,20);a(i).addClass("current").siblings().removeClass("current")}function z(i,q){a.pref("bkgd_color",i);a.pref("bkgd_url",q);m.setBackground(i,q)}function N(){var i=m.getHref(ia);i=i.indexOf("data:")===0?
"":i;a.prompt(h.notification.enterNewImgURL,i,function(q){q&&tb(q)})}function aa(){if(m.deleteCurrentLayer()){ra();Wa();a("#layerlist tr.layer").removeClass("layersel");a("#layerlist tr.layer:first").addClass("layersel")}}function O(){var i=m.getCurrentDrawing().getCurrentLayerName()+" copy";a.prompt(h.notification.enterUniqueLayerName,i,function(q){if(q)if(m.getCurrentDrawing().hasLayer(q))a.alert(h.notification.dupeLayerName);else{m.cloneLayer(q);ra();Wa()}})}function J(i){var q=a("#layerlist tr.layersel").index(),
E=m.getCurrentDrawing().getNumLayers();if(q>0||q<E-1){q+=i;m.setCurrentLayerPosition(E-q-1);Wa()}}function Z(i,q){q||(q=m.getZoom());i||(i=a("#svgcanvas"));for(var E=m.getContentElem(),I=svgedit.units.getTypeMap()[f.baseUnit],M=0;M<2;M++){var Q=M===0,U=Q?"x":"y",Y=Q?"width":"height",ga=E.getAttribute(U)-0;U=a("#ruler_"+U+" canvas:first");$hcanv=U.clone();U.replaceWith($hcanv);var ea=$hcanv[0];var ma=U=i[Y]();ea.parentNode.style[Y]=ma+"px";var xa=0,Sa,S=ea.getContext("2d");S.fillStyle="rgb(200,0,0)";
S.fillRect(0,0,ea.width,ea.height);$hcanv.siblings().remove();if(U>=3E4){var Da=parseInt(U/3E4)+1;Sa=Array(Da);Sa[0]=S;for(var ha=1;ha<Da;ha++){ea[Y]=3E4;var va=ea.cloneNode(true);ea.parentNode.appendChild(va);Sa[ha]=va.getContext("2d")}va[Y]=U%3E4;U=3E4}ea[Y]=U;Y=I*q;var Ka=50/Y;ea=1;for(ha=0;ha<$b.length;ha++){ea=Da=$b[ha];if(Ka<=Da)break}Ka=ea*Y;S.font="9px sans-serif";for(var Ga=ga/Y%ea*Y,La=Ga-Ka;Ga<ma;Ga+=Ka){La+=Ka;ha=Math.round(Ga)+0.5;if(Q){S.moveTo(ha,15);S.lineTo(ha,0)}else{S.moveTo(15,
ha);S.lineTo(0,ha)}Da=(La-ga)/Y;if(ea>=1)ha=Math.round(Da);else{ha=(ea+"").split(".")[1].length;ha=Da.toFixed(ha)-0}if(ha!==0&&ha!==1E3&&ha%1E3===0)ha=ha/1E3+"K";if(Q)S.fillText(ha,Ga+2,8);else{Da=(ha+"").split("");for(ha=0;ha<Da.length;ha++)S.fillText(Da[ha],1,Ga+9+ha*9)}Da=Ka/10;for(ha=1;ha<10;ha++){var Ba=Math.round(Ga+Da*ha)+0.5;if(Sa&&Ba>U){xa++;S.stroke();if(xa>=Sa.length){ha=10;Ga=ma;continue}S=Sa[xa];Ga-=3E4;Ba=Math.round(Ga+Da*ha)+0.5}var Xa=ha%2?12:10;if(Q){S.moveTo(Ba,15);S.lineTo(Ba,Xa)}else{S.moveTo(15,
Ba);S.lineTo(Xa,Ba)}}}S.strokeStyle="#000";S.stroke()}}(function(){var i=window.opener;if(i)try{var q=i.document.createEvent("Event");q.initEvent("svgEditorReady",true,true);i.document.documentElement.dispatchEvent(q)}catch(E){}})();(function(){var i=a.deparam.querystring(true);if(!a.isEmptyObject(i)){if(i.dimensions)i.dimensions=i.dimensions.split(",");if(i.extensions)i.extensions=i.extensions.split(",");if(i.bkgd_color)i.bkgd_color="#"+i.bkgd_color;svgEditor.setConfig(i);var q=i.source,E=a.param.querystring();
if(!q)if(E.indexOf("source=data:")>=0)q=E.match(/source=(data:[^&]*)/)[1];if(q)if(q.indexOf("data:")===0){q=q.replace(/ /g,"+");o.loadFromDataURI(q)}else o.loadFromString(q);else if(E.indexOf("paramurl=")!==-1)svgEditor.loadFromURL(E.substr(9));else i.url&&svgEditor.loadFromURL(i.url)}})();var W=function(){a.each(f.extensions,function(){var q=this;a.getScript(f.extPath+q,function(E){if(!E){E=document.createElement("script");E.src=f.extPath+q;document.querySelector("head").appendChild(E)}})});var i=
[];a("#lang_select option").each(function(){i.push(this.value)});o.putLocale(null,i)};document.location.protocol==="file:"?setTimeout(W,100):W();a.svgIcons(f.imgPath+"svg_edit_icons.svg",{w:24,h:24,id_match:false,no_img:!svgedit.browser.isWebkit(),fallback_path:f.imgPath,fallback:{new_image:"clear.png",save:"save.png",open:"open.png",source:"source.png",docprops:"document-properties.png",wireframe:"wireframe.png",undo:"undo.png",redo:"redo.png",select:"select.png",select_node:"select_node.png",pencil:"fhpath.png",
pen:"line.png",square:"square.png",rect:"rect.png",fh_rect:"freehand-square.png",circle:"circle.png",ellipse:"ellipse.png",fh_ellipse:"freehand-circle.png",path:"path.png",text:"text.png",image:"image.png",zoom:"zoom.png",clone:"clone.png",node_clone:"node_clone.png","delete":"delete.png",node_delete:"node_delete.png",group:"shape_group.png",ungroup:"shape_ungroup.png",move_top:"move_top.png",move_bottom:"move_bottom.png",to_path:"to_path.png",link_controls:"link_controls.png",reorient:"reorient.png",
align_left:"align-left.png",align_center:"align-center",align_right:"align-right",align_top:"align-top",align_middle:"align-middle",align_bottom:"align-bottom",go_up:"go-up.png",go_down:"go-down.png",ok:"save.png",cancel:"cancel.png",arrow_right:"flyouth.png",arrow_down:"dropdown.gif"},placement:{"#logo":"logo","#tool_clear div,#layer_new":"new_image","#tool_save div":"save","#tool_export div":"export","#tool_open div div":"open","#tool_import div div":"import","#tool_source":"source","#tool_docprops > div":"docprops",
"#tool_wireframe":"wireframe","#tool_undo":"undo","#tool_redo":"redo","#tool_select":"select","#tool_fhpath":"pencil","#tool_line":"pen","#tool_rect,#tools_rect_show":"rect","#tool_square":"square","#tool_fhrect":"fh_rect","#tool_ellipse,#tools_ellipse_show":"ellipse","#tool_circle":"circle","#tool_fhellipse":"fh_ellipse","#tool_path":"path","#tool_text,#layer_rename":"text","#tool_image":"image","#tool_zoom":"zoom","#tool_clone,#tool_clone_multi":"clone","#tool_node_clone":"node_clone","#layer_delete,#tool_delete,#tool_delete_multi":"delete",
"#tool_node_delete":"node_delete","#tool_add_subpath":"add_subpath","#tool_openclose_path":"open_path","#tool_move_top":"move_top","#tool_move_bottom":"move_bottom","#tool_topath":"to_path","#tool_node_link":"link_controls","#tool_reorient":"reorient","#tool_group":"group","#tool_ungroup":"ungroup","#tool_unlink_use":"unlink_use","#tool_alignleft, #tool_posleft":"align_left","#tool_aligncenter, #tool_poscenter":"align_center","#tool_alignright, #tool_posright":"align_right","#tool_aligntop, #tool_postop":"align_top",
"#tool_alignmiddle, #tool_posmiddle":"align_middle","#tool_alignbottom, #tool_posbottom":"align_bottom","#cur_position":"align","#linecap_butt,#cur_linecap":"linecap_butt","#linecap_round":"linecap_round","#linecap_square":"linecap_square","#linejoin_miter,#cur_linejoin":"linejoin_miter","#linejoin_round":"linejoin_round","#linejoin_bevel":"linejoin_bevel","#url_notice":"warning","#layer_up":"go_up","#layer_down":"go_down","#layer_moreopts":"context_menu","#layerlist td.layervis":"eye","#linelist td.linelink":"eye",
"#tool_source_save,#tool_docprops_save,#tool_prefs_save":"ok","#tool_source_cancel,#tool_docprops_cancel,#tool_prefs_cancel":"cancel","#rwidthLabel, #iwidthLabel":"width","#rheightLabel, #iheightLabel":"height","#cornerRadiusLabel span":"c_radius","#angleLabel":"angle","#linkLabel,#tool_make_link,#tool_make_link_multi":"globe_link","#zoomLabel":"zoom","#tool_fill label":"fill","#tool_stroke .icon_label":"stroke","#group_opacityLabel":"opacity","#blurLabel":"blur","#font_sizeLabel":"fontsize",".flyout_arrow_horiz":"arrow_right",
".dropdown button, #main_button .dropdown":"arrow_down","#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,".dropdown button .svg_icon":7,"#main_button .dropdown .svg_icon":9,".palette_item:first .svg_icon, #fill_bg .svg_icon, #stroke_bg .svg_icon":16,".toolbar_button button .svg_icon":16,".stroke_tool div div .svg_icon":20,"#tools_bottom label .svg_icon":18},
callback:function(){a(".toolbar_button button > svg, .toolbar_button button > img").each(function(){a(this).parent().prepend(this)});var i=a("#tools_left");if(i.length!=0){i.offset();i.outerHeight()}a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show"),E=q.attr("data-curopt");if(!q.children("svg, img").length){E=a(E).children().clone();if(E.length){E[0].removeAttribute("style");q.append(E)}}});svgEditor.runCallbacks();setTimeout(function(){a(".flyout_arrow_horiz:empty").each(function(){a(this).append(a.getSvgIcon("arrow_right").width(5).height(5))})},
1)}});o.canvas=m=new a.SvgCanvas(document.getElementById("svgcanvas"),f);W=navigator.platform.indexOf("Mac")>=0;var ka=navigator.userAgent.indexOf("AppleWebKit")>=0,oa=W?"meta+":"ctrl+",Pa=m.pathActions,sa=m.undoMgr,Cb=svgedit.utilities,Pb=f.imgPath+"logo.png",ca=a("#workarea"),qb=a("#cmenu_canvas");a("#cmenu_layers");var db=false,fb=null,cc=1,Ua="crosshair",ya="crosshair",Ca="toolbars",Qb="",Ha={fill:null,stroke:null};(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",
containment:"window"});var i=a("#dialog_box"),q=a("#dialog_buttons"),E=function(I,M,Q,U){a("#dialog_content").html("<p>"+M.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",I=="prompt");q.empty();var Y=a('<input type="button" value="'+h.common.ok+'">').appendTo(q);I!="alert"&&a('<input type="button" value="'+h.common.cancel+'">').appendTo(q).click(function(){i.hide();Q(false)});if(I=="prompt"){var ga=a('<input type="text">').prependTo(q);ga.val(U||"");ga.bind("keydown","return",function(){Y.click()})}I==
"process"&&Y.hide();i.show();Y.click(function(){i.hide();var ea=I=="prompt"?ga.val():true;Q&&Q(ea)}).focus();I=="prompt"&&ga.focus()};a.alert=function(I,M){E("alert",I,M)};a.confirm=function(I,M){E("confirm",I,M)};a.process_cancel=function(I,M){E("process",I,M)};a.prompt=function(I,M,Q){E("prompt",I,Q,M)}})();var rb=function(){var i=a(".tool_button_current");if(i.length&&i[0].id!=="tool_select"){i.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}")}m.setMode("select");ca.css("cursor","auto")},ia=null,wa=false,Ia=false,Fa=false,qa=false,la="",ua=a("title:first").text(),na=function(i,q,E){m.getResolution();a("#svgcanvas").position();if(q=m.setBBoxZoom(q,ca.width()-15,ca.height()-15)){i=q.zoom;q=q.bbox;if(i<0.0010)Ya({value:0.1});else{a("#zoom").val(i*100);E?kb():kb(false,{x:q.x*i+q.width*i/2,y:q.y*i+q.height*i/2});m.getMode()=="zoom"&&
q.width&&rb();l()}}};a("#cur_context_panel").delegate("a","click",function(){var i=a(this);i.attr("data-root")?m.leaveContext():m.setContext(i.text());return false});var mb={},Rb=function(i){a.each(i,function(q,E){var I=a(q).children(),M=q+"_show",Q=a(M),U=false;I.addClass("tool_button").unbind("click mousedown mouseup").each(function(ea){var ma=E[ea];mb[ma.sel]=ma.fn;if(ma.isDefault)U=ea;ea=function(){if(a(this).hasClass("disabled"))return false;ja(M)&&ma.fn();var xa=ma.icon?a.getSvgIcon(ma.icon,
true):a(ma.sel).children().eq(0).clone();xa[0].setAttribute("width",Q.width());xa[0].setAttribute("height",Q.height());Q.children(":not(.flyout_arrow_horiz)").remove();Q.append(xa).attr("data-curopt",ma.sel)};a(this).mouseup(ea);ma.key&&a(document).bind("keydown",ma.key+"",ea)});if(U)Q.attr("data-curopt",E[U].sel);else Q.attr("data-curopt")||Q.attr("data-curopt",E[0].sel);var Y,ga=a(M).position();a(q).css({left:ga.left+34,top:ga.top+77});Q.mousedown(function(ea){if(Q.hasClass("disabled"))return false;
var ma=a(q),xa=ga.left+34,Sa=ma.width()*-1,S=ma.data("shown_popop")?200:0;Y=setTimeout(function(){Q.data("isLibrary")?ma.css("left",xa).show():ma.css("left",Sa).show().animate({left:xa},150);ma.data("shown_popop",true)},S);ea.preventDefault()}).mouseup(function(){clearTimeout(Y);var ea=a(this).attr("data-curopt");if(Q.data("isLibrary")&&a(M.replace("_show","")).is(":visible"))ja(M,true);else ja(M)&&ea in mb&&mb[ea]()})});Db()},sb=function(i,q){return a("<div>",{"class":"tools_flyout",id:i}).appendTo("#svg_editor").append(q)},
Fb=function(){a(".tools_flyout").each(function(){var i=a("#"+this.id+"_show"),q=i.offset();i=i.outerWidth();a(this).css({left:(q.left+i)*cc,top:q.top})})},Db=function(){a(".tools_flyout").each(function(){var i=a("#"+this.id+"_show");if(!i.data("isLibrary")){var q=[];a(this).children().each(function(){q.push(this.title)});i[0].title=q.join(" / ")}})},nb,Tb=function(i,q,E){var I=null;if(i.indexOf("url(#")===0){i=(i=m.getRefElem(i))?i.cloneNode(true):a("#"+E+"_color defs *")[0];I={alpha:q};I[i.tagName]=
i}else I=i.indexOf("#")===0?{alpha:q,solidColor:i.substr(1)}:{alpha:q,solidColor:"none"};return new a.jGraduate.Paint(I)},tb=o.setImageURL=function(i){i||(i=Pb);m.setImageURL(i);a("#image_url").val(i);if(i.indexOf("data:")===0){a("#image_url").hide();a("#change_image_url").show()}else{m.embedImage(i,function(q){q?a("#url_notice").hide():a("#url_notice").show();Pb=i});a("#image_url").show();a("#change_image_url").hide()}},lb=function(i){var q=Math.min(Math.max(12+i.value.length*6,50),300);a(i).width(q)},
ra=function(){var i=ia;if(i!=null&&!i.parentNode)i=null;var q=m.getCurrentDrawing().getCurrentLayerName(),E=m.getMode(),I=f.baseUnit!=="px"?f.baseUnit:null,M=E=="pathedit",Q=a("#cmenu_canvas li");a("#selected_panel, #multiselected_panel, #g_panel, #rect_panel, #circle_panel,\t\t\t\t\t#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide();if(i!=null){var U=i.nodeName,Y=m.getRotationAngle(i);a("#angle").val(Y);var ga=m.getBlur(i);a("#blur").val(ga);a("#blur_slider").slider("option",
"value",ga);m.addedNew&&U==="image"&&m.getHref(i).indexOf("data:")!==0&&N();if(!M&&E!="pathedit"){a("#selected_panel").show();if(["line","circle","ellipse"].indexOf(U)>=0)a("#xy_panel").hide();else{var ea,ma;if(["g","polyline","path"].indexOf(U)>=0){if(E=m.getStrokedBBox([i])){ea=E.x;ma=E.y}}else{ea=i.getAttribute("x");ma=i.getAttribute("y")}if(I){ea=svgedit.units.convertUnit(ea);ma=svgedit.units.convertUnit(ma)}a("#selected_x").val(ea||0);a("#selected_y").val(ma||0);a("#xy_panel").show()}I=["image",
"text","path","g","use"].indexOf(U)==-1;a("#tool_topath").toggle(I);a("#tool_reorient").toggle(U=="path");a("#tool_reorient").toggleClass("disabled",Y==0)}else{q=Pa.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!Pa.canDeleteNodes);B("#tool_openclose_path",Pa.closed_subpath?"open_path":"close_path");if(q){M=a("#seg_type");if(I){q.x=svgedit.units.convertUnit(q.x);q.y=svgedit.units.convertUnit(q.y)}a("#path_node_x").val(q.x);
a("#path_node_y").val(q.y);q.type?M.val(q.type).removeAttr("disabled"):M.val(4).attr("disabled","disabled")}return}I={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 xa=i.tagName;U=null;if(xa==="a"){U=m.getHref(i);a("#g_panel").show()}if(i.parentNode.tagName==="a")if(!a(i).siblings().length){a("#a_panel").show();U=m.getHref(i.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!U);
U&&a("#link_url").val(U);if(I[xa]){I=I[xa];a("#"+xa+"_panel").show();a.each(I,function(Sa,S){var Da=i.getAttribute(S);if(f.baseUnit!=="px"&&i[S])Da=svgedit.units.convertUnit(i[S].baseVal.value);a("#"+xa+"_"+S).val(Da||0)});if(xa=="text"){a("#text_panel").css("display","inline");m.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");m.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(i.getAttribute("font-family"));a("#font_size").val(i.getAttribute("font-size"));a("#text").val(i.textContent);m.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(xa=="image")tb(m.getHref(i));else if(xa==="g"||xa==="use"){a("#container_panel").show();I=m.getTitle();U=a("#g_title")[0];U.value=I;lb(U);xa=="use"?U.setAttribute("disabled","disabled"):U.removeAttribute("disabled")}}Q[(xa===
"g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");Q[(xa==="g"||!wa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(wa){a("#multiselected_panel").show();Q.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else Q.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");sa.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");sa.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):
a("#tool_redo").addClass("disabled");m.addedNew=false;if(i&&!M||wa){a("#selLayerNames").removeAttr("disabled").val(q);qb.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(){});m.bind("selected",function(i,q){var E=m.getMode();E==="select"&&rb();E=E=="pathedit";ia=q.length==1||q[1]==null?q[0]:null;wa=q.length>=2&&q[1]!=null;if(ia!=null)if(!E){if(ia!=null)switch(ia.tagName){case "use":case "image":case "foreignObject":break;
case "g":case "a":for(var I=null,M=ia.getElementsByTagName("*"),Q=0,U=M.length;Q<U;Q++){var Y=M[Q].getAttribute("stroke-width");if(Q===0)I=Y;else if(I!==Y)I=null}a("#stroke_width").val(I===null?"":I);Ha.fill.update(true);Ha.stroke.update(true);break;default:Ha.fill.update(true);Ha.stroke.update(true);a("#stroke_width").val(ia.getAttribute("stroke-width")||1);a("#stroke_style").val(ia.getAttribute("stroke-dasharray")||"none");I=ia.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+I).length!=
0&&F(a("#linejoin_"+I)[0]);I=ia.getAttribute("stroke-linecap")||"butt";a("#linecap_"+I).length!=0&&F(a("#linecap_"+I)[0])}if(ia!=null){I=(ia.getAttribute("opacity")||1)*100;a("#group_opacity").val(I);a("#opac_slider").slider("option","value",I);a("#elem_id").val(ia.id)}Mb()}a("#path_node_panel").toggle(E);a("#tools_bottom_2,#tools_bottom_3").toggle(!E);if(E){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");
B("#tool_select","select_node");wa=false;if(q.length)ia=q[0]}else B("#tool_select","select");ra();m.runExtensions("selectedChanged",{elems:q,selectedElement:ia,multiselected:wa})});m.bind("transition",function(i,q){var E=m.getMode(),I=q[0];if(I){wa=q.length>=2&&q[1]!=null;if(!wa)switch(E){case "rotate":E=m.getRotationAngle(I);a("#angle").val(E);a("#tool_reorient").toggleClass("disabled",E==0)}m.runExtensions("elementTransition",{elems:q})}});m.bind("changed",function(i,q){var E=m.getMode();E==="select"&&
rb();for(var I=0;I<q.length;++I){var M=q[I];if(M&&M.tagName==="svg"){Wa();kb()}else if(M&&ia&&ia.parentNode==null)ia=M}db=true;ra();if(ia&&E==="select"){Ha.fill.update();Ha.stroke.update()}m.runExtensions("elementChanged",{elems:q})});m.bind("saved",function(i,q){db=false;q='<?xml version="1.0"?>\n'+q;var E=navigator.userAgent;if(~E.indexOf("Chrome")&&a.browser.version>=533||~E.indexOf("MSIE"))k(0,true);else{var I=i.open("data:image/svg+xml;base64,"+Cb.encode64(q)),M=a.pref("save_notice_done");if(M!==
"all"){var Q=h.notification.saveFromBrowser.replace("%s","SVG");if(E.indexOf("Gecko/")!==-1)if(q.indexOf("<defs")!==-1){Q+="\n\n"+h.notification.defsFailOnSave;a.pref("save_notice_done","all");M="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");M!=="part"&&I.alert(Q)}}});m.bind("exported",function(i,q){var E=q.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var I=a("#export_canvas")[0];I.width=m.contentW;I.height=m.contentH;
canvg(I,q.svg,{renderCallback:function(){var M=I.toDataURL("image/png");fb.location.href=M;if(a.pref("export_notice_done")!=="all"){M=h.notification.saveFromBrowser.replace("%s","PNG");if(E.length)M+="\n\n"+h.notification.noteTheseIssues+"\n \u2022 "+E.join("\n \u2022 ");a.pref("export_notice_done","all");fb.alert(M)}}})});m.bind("zoomed",na);m.bind("contextset",function(i,q){a("#workarea,#sidepanels").css("top",q?100:75);a("#rulers").toggleClass("moved",q);if(la&&!q)ca[0].scrollTop-=25;else if(!la&&
q)ca[0].scrollTop+=25;var E="";if(q){var I="";E='<a href="#" data-root="y">'+m.getCurrentDrawing().getCurrentLayerName()+"</a>";a(q).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){I+=" > "+this.id;E+=this!==q?' > <a href="#">'+this.id+"</a>":" > "+this.id}});la=I}else la=null;a("#cur_context_panel").toggle(!!q).html(E);v()});m.bind("extension_added",function(i,q){function E(){if(nb){clearTimeout(nb);nb=null}M||(nb=setTimeout(function(){M=true;K(e.iconsize)},50))}var I=false,
M=false,Q=true,U=function(){if(q.callback&&!I&&Q){I=true;q.callback()}},Y=[];q.context_tools&&a.each(q.context_tools,function(Sa,S){var Da=S.container_id?' id="'+S.container_id+'"':"",ha=a("#"+S.panel);ha.length||(ha=a("<div>",{id:S.panel}).appendTo("#tools_top"));switch(S.type){case "tool_button":var va='<div class="tool_button">'+S.id+"</div>",Ka=a(va).appendTo(ha);S.events&&a.each(S.events,function(Ba,Xa){a(Ka).bind(Ba,Xa)});break;case "select":va="<label"+Da+'><select id="'+S.id+'">';a.each(S.options,
function(Ba,Xa){va+='<option value="'+Ba+'"'+(Ba==S.defval?" selected":"")+">"+Xa+"</option>"});va+="</select></label>";var Ga=a(va).appendTo(ha).find("select");a.each(S.events,function(Ba,Xa){a(Ga).bind(Ba,Xa)});break;case "button-select":va='<div id="'+S.id+'" class="dropdown toolset" title="'+S.title+'"><div id="cur_'+S.id+'" class="icon_label"></div><button></button></div>';Da=a('<ul id="'+S.id+'_opts"></ul>').appendTo("#option_lists");S.colnum&&Da.addClass("optcols"+S.colnum);a(va).appendTo(ha).children();
Y.push({elem:"#"+S.id,list:"#"+S.id+"_opts",title:S.title,callback:S.events.change,cur:"#cur_"+S.id});break;case "input":va="<label"+Da+'><span id="'+S.id+'_label">'+S.label+':</span><input id="'+S.id+'" title="'+S.title+'" size="'+(S.size||"4")+'" value="'+(S.defval||"")+'" type="text"/></label>';var La=a(va).appendTo(ha).find("input");S.spindata&&La.SpinButton(S.spindata);S.events&&a.each(S.events,function(Ba,Xa){La.bind(Ba,Xa)})}});if(q.buttons){var ga={},ea={},ma=q.svgicons,xa={};a.each(q.buttons,
function(Sa,S){for(var Da,ha=S.id,va=Sa;a("#"+ha).length;)ha=S.id+"_"+ ++va;if(ma){ga[ha]=S.icon;va=S.svgicon?S.svgicon:S.id;if(S.type=="app_menu")ea["#"+ha+" > div"]=va;else ea["#"+ha]=va}else Da=a('<img src="'+S.icon+'">');var Ka,Ga;switch(S.type){case "mode_flyout":case "mode":Ka="tool_button";Ga="#tools_left";break;case "context":Ka="tool_button";Ga="#"+S.panel;a(Ga).length||a("<div>",{id:S.panel}).appendTo("#tools_top");break;case "app_menu":Ka="";Ga="#main_menu ul"}var La=a(S.list||S.type==
"app_menu"?"<li/>":"<div/>").attr("id",ha).attr("title",S.title).addClass(Ka);if(!S.includeWith&&!S.list){"position"in S?a(Ga).children().eq(S.position).before(La):La.appendTo(Ga);if(S.type=="mode_flyout"){va=a(La);Ka=va.parent();if(!va.parent().hasClass("tools_flyout")){var Ba=va[0].id.replace("tool_","tools_"),Xa=va.clone().attr("id",Ba+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));va.before(Xa);Ka=sb(Ba,va);Ka.data("isLibrary",true);Xa.data("isLibrary",true)}ea["#"+Ba+"_show"]=S.id;
ha=xa["#"+Ka[0].id]=[{sel:"#"+ha,fn:S.events.click,icon:S.id,isDefault:true},jc]}else S.type=="app_menu"&&La.append("<div>").append(S.title)}else if(S.list){La.addClass("push_button");a("#"+S.list+"_opts").append(La);if(S.isDefault){a("#cur_"+S.list).append(La.children().clone());va=S.svgicon?S.svgicon:S.id;ea["#cur_"+S.list]=va}}else if(S.includeWith){Ga=S.includeWith;va=a(Ga.button);Ka=va.parent();if(!va.parent().hasClass("tools_flyout")){Ba=va[0].id.replace("tool_","tools_");Xa=va.clone().attr("id",
Ba+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));va.before(Xa);Ka=sb(Ba,va)}var jc=nc.getButtonData(Ga.button);if(Ga.isDefault)ea["#"+Ba+"_show"]=S.id;ha=xa["#"+Ka[0].id]=[{sel:"#"+ha,fn:S.events.click,icon:S.id,key:S.key,isDefault:S.includeWith?S.includeWith.isDefault:0},jc];Ba="position"in Ga?Ga.position:"last";jc=Ka.children().length;if(!isNaN(Ba)&&Ba>=0&&Ba<jc)Ka.children().eq(Ba).before(La);else{Ka.append(La);ha.reverse()}}ma||La.append(Da);S.list||a.each(S.events,function(ac,bc){if(ac==
"click")if(S.type=="mode"){S.includeWith?La.bind(ac,bc):La.bind(ac,function(){ja(La)&&bc()});if(S.key){a(document).bind("keydown",S.key,bc);S.title&&La.attr("title",S.title+" ["+S.key+"]")}}else La.bind(ac,bc);else La.bind(ac,bc)});Rb(xa)});a.each(Y,function(){eb(this.elem,this.list,this.callback,{seticon:true})});if(ma)Q=false;a.svgIcons(ma,{w:24,h:24,id_match:false,no_img:!ka,fallback:ga,placement:ea,callback:function(){e.iconsize&&e.iconsize!="m"&&E();Q=true;U()}})}U()});m.textActions.setInputElem(a("#text")[0]);
var Ja='<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","#aaaaff","#d4aaff","#ffaaff","#ffaad4"],function(i,q){Ja+='<div class="palette_item" style="background-color: '+
q+';" data-rgb="'+q+'"></div>'});a("#palette").append(Ja);Ja="";a.each(["#FFF","#888","#000"],function(){Ja+='<div class="color_block" style="background-color:'+this+';"></div>'});a("#bg_blocks").append(Ja);var ta=a("#bg_blocks div");ta.each(function(){a(this).click(function(){ta.removeClass("cur_background");a(this).addClass("cur_background")})});if(a.pref("bkgd_color"))z(a.pref("bkgd_color"),a.pref("bkgd_url"));else a.pref("bkgd_url")&&z(G.bkgd_color,a.pref("bkgd_url"));if(a.pref("img_save")){e.img_save=
a.pref("img_save");a("#image_save_opts input").val([e.img_save])}var Ya=function(i){var q=i.value/100;if(q<0.0010)i.value=0.1;else{i=m.getZoom();na(window,{width:0,height:0,x:(ca[0].scrollLeft+ca.width()/2)/i,y:(ca[0].scrollTop+ca.height()/2)/i,zoom:q},true)}},ob=function(i,q){if(q==null)q=i.value;a("#group_opacity").val(q);if(!i||!i.handle)a("#opac_slider").slider("option","value",q);m.setOpacity(q/100)},Qa=function(i,q,E){if(q==null)q=i.value;a("#blur").val(q);var I=false;if(!i||!i.handle){a("#blur_slider").slider("option",
"value",q);I=true}E?m.setBlurNoUndo(q):m.setBlur(q,I)},Ma=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){m.setStrokeAttr("stroke-dasharray",a(this).val());Ma()});a("#stroke_linejoin").change(function(){m.setStrokeAttr("stroke-linejoin",a(this).val());Ma()});a("select").change(function(){a(this).blur()});var Gb=false;a("#selLayerNames").change(function(){var i=this.options[this.selectedIndex].value,q=h.notification.QmoveElemsToLayer.replace("%s",
i),E=function(I){if(I){Gb=true;m.moveSelectedToLayer(i);m.clearSelection();Wa()}};if(i)Gb?E(true):a.confirm(q,E)});a("#font_family").change(function(){m.setFontFamily(this.value)});a("#seg_type").change(function(){m.setSegType(a(this).val())});a("#text").keyup(function(){m.setTextContent(this.value)});a("#image_url").change(function(){tb(this.value)});a("#link_url").change(function(){this.value.length?m.setLinkURL(this.value):m.removeHyperlink()});a("#g_title").change(function(){m.setGroupTitle(this.value)});
a(".attr_changer").change(function(){var i=this.getAttribute("data-attr"),q=this.value;if(!svgedit.units.isValidUnit(i,q)){a.alert(h.notification.invalidAttrValGiven);this.value=ia.getAttribute(i);return false}if(i!=="id")if(isNaN(q))q=m.convertToNum(i,q);else if(f.baseUnit!=="px"){var E=svgedit.units.getTypeMap();if(ia[i]||m.getMode()==="pathedit"||i==="x"||i==="y")q*=E[f.baseUnit]}if(i==="id"){i=ia;m.clearSelection();i.id=q;m.addToSelection([i],true)}else m.changeSelectedAttribute(i,q)});a("#palette").mouseover(function(){var i=
a('<input type="hidden">');a(this).append(i);i.focus().remove()});a(".palette_item").mousedown(function(i){var q=i.button===2;q=(i=i.shiftKey||q)?"stroke":"fill";var E=a(this).attr("data-rgb"),I=null;if(E==="transparent"||E==="initial"){E="none";I=new a.jGraduate.Paint}else I=new a.jGraduate.Paint({alpha:100,solidColor:E.substr(1)});Ha[q].setPaint(I);if(i){m.setColor("stroke",E);E!="none"&&m.getStrokeOpacity()!=1&&m.setPaintOpacity("stroke",1)}else{m.setColor("fill",E);E!="none"&&m.getFillOpacity()!=
1&&m.setPaintOpacity("fill",1)}Mb()}).bind("contextmenu",function(i){i.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).text("<<");V()},function(){a(".stroke_tool").css("display","none");a(this).text(">>");V()});var ja=function(i,q){if(a(i).hasClass("disabled"))return false;if(a(i).parent().hasClass("tools_flyout"))return true;var E=E||"normal";q||a(".tools_flyout").fadeOut(E);a("#styleoverrides").text("");ca.css("cursor","auto");
a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(i).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var i=null,q=null,E=ca[0],I=false,M=false;a("#svgcanvas").bind("mousemove mouseup",function(Q){if(I!==false){E.scrollLeft-=Q.clientX-i;E.scrollTop-=Q.clientY-q;i=Q.clientX;q=Q.clientY;if(Q.type==="mouseup")I=false;return false}}).mousedown(function(Q){if(Q.button===1||M===true){I=true;i=Q.clientX;q=Q.clientY;return false}});a(window).mouseup(function(){I=
false});a(document).bind("keydown","space",function(Q){m.spaceKey=M=true;Q.preventDefault()}).bind("keyup","space",function(Q){Q.preventDefault();m.spaceKey=M=false}).bind("keydown","shift",function(){m.getMode()==="zoom"&&ca.css("cursor",ya)}).bind("keyup","shift",function(){m.getMode()==="zoom"&&ca.css("cursor",Ua)})})();(function(){var i=a("#main_icon"),q=a("#main_icon span"),E=a("#main_menu"),I=false,M=0,Q=true,U=false;a(window).mouseup(function(ga){if(!I){i.removeClass("buttondown");if(ga.target.tagName!=
"INPUT")E.fadeOut(200);else if(!U){U=true;a(ga.target).click(function(){E.css("margin-left","-9999px").show()})}}I=false}).mousedown(function(ga){a(ga.target).closest("div.tools_flyout, .contextMenu").length||a(".tools_flyout:visible,.contextMenu").fadeOut(250)});q.bind("mousedown",function(){if(i.hasClass("buttondown")){i.removeClass("buttondown").addClass("buttonup");E.fadeOut(200)}else{i.addClass("buttondown").removeClass("buttonup");E.css("margin-left",0).show();M||(M=E.height());E.css("height",
0).animate({height:M},200);I=true;return false}}).hover(function(){I=true}).mouseout(function(){I=false});var Y=a("#main_menu li");Y.mouseover(function(){Q=a(this).css("background-color")=="rgba(0, 0, 0, 0)";Y.unbind("mouseover");Q&&Y.mouseover(function(){this.style.backgroundColor="#FFC"}).mouseout(function(){this.style.backgroundColor="transparent";return true})})})();o.addDropDown=function(i,q,E){if(a(i).length!=0){var I=a(i).find("button"),M=a(i).find("ul").attr("id",a(i)[0].id+"-list");E||a("#option_lists").append(M);
var Q=false;E&&a(i).addClass("dropup");M.find("li").bind("mouseup",q);a(window).mouseup(function(){if(!Q){I.removeClass("down");M.hide()}Q=false});I.bind("mousedown",function(){if(I.hasClass("down")){I.removeClass("down");M.hide()}else{I.addClass("down");if(!E){var U=a(i).position();M.css({top:U.top+24,left:U.left-10})}M.show();Q=true}}).hover(function(){Q=true}).mouseout(function(){Q=false})}};var eb=function(i,q,E,I){var M=a(i);q=a(q);var Q=false,U=I.dropUp;U&&a(i).addClass("dropup");q.find("li").bind("mouseup",
function(){if(I.seticon){B("#cur_"+M[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}E.apply(this,arguments)});a(window).mouseup(function(){if(!Q){M.removeClass("down");q.hide();q.css({top:0,left:0})}Q=false});q.height();a(i).bind("mousedown",function(){var Y=a(i).offset();if(U){Y.top-=q.height();Y.left+=8}else Y.top+=a(i).height();a(q).offset(Y);if(M.hasClass("down")){M.removeClass("down");q.hide();q.css({top:0,left:0})}else{M.addClass("down");q.show();Q=true;
return false}}).hover(function(){Q=true}).mouseout(function(){Q=false});I.multiclick&&q.mousedown(function(){Q=true})};o.addDropDown("#font_family_dropdown",function(){a(this).text();a("#font_family").val(a(this).text()).change()});o.addDropDown("#opacity_dropdown",function(){if(!a(this).find("div").length){var i=parseInt(a(this).text().split("%")[0]);ob(false,i)}},true);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(i,q){ob(q)}});o.addDropDown("#blur_dropdown",a.noop);var xb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(i,q){xb=false;Qa(q);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){xb=true},slide:function(i,q){Qa(q,null,xb)}});o.addDropDown("#zoom_dropdown",function(){var i=a(this),q=i.attr("data-val");q?na(window,q):Ya({value:parseInt(i.text())})},true);eb("#stroke_linecap","#linecap_opts",function(){F(this,true)},{dropUp:true});eb("#stroke_linejoin",
"#linejoin_opts",function(){F(this,true)},{dropUp:true});eb("#tool_position","#position_opts",function(){var i=this.id.replace("tool_pos","").charAt(0);m.alignSelectedElements(i,"page")},{multiclick:true});(function(){var i,q=function(){a(i).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){i=this;Ca="toolbars";ca.mousedown(q)}).blur(function(){Ca="canvas";ca.unbind("mousedown",q);m.getMode()=="textedit"&&a("#text").focus()})})();var yb=function(){if(ja("#tool_select")){m.setMode("select");
a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},Sb=function(){ja("#tool_fhpath")&&m.setMode("fhpath")},zb=function(){ja("#tool_line")&&m.setMode("line")},Ab=function(){ja("#tool_square")&&m.setMode("square")},Ub=function(){ja("#tool_rect")&&m.setMode("rect")},Hb=function(){ja("#tool_fhrect")&&m.setMode("fhrect")},lc=function(){ja("#tool_circle")&&m.setMode("circle")},dc=function(){ja("#tool_ellipse")&&m.setMode("ellipse")},ub=function(){ja("#tool_fhellipse")&&
m.setMode("fhellipse")},Za=function(){ja("#tool_image")&&m.setMode("image")},Ea=function(){if(ja("#tool_zoom")){m.setMode("zoom");ca.css("cursor",Ua)}},fa=function(){if(ja("#tool_zoom")){c();rb()}},pb=function(){ja("#tool_text")&&m.setMode("text")},Vb=function(){ja("#tool_path")&&m.setMode("path")},Jb=function(){if(ia!=null||wa)m.deleteSelectedElements()},Wb=function(){if(ia!=null||wa)m.cutSelectedElements()},ec=function(){if(ia!=null||wa)m.copySelectedElements()},Kb=function(){var i=m.getZoom(),
q=(ca[0].scrollLeft+ca.width()/2)/i-m.contentW;i=(ca[0].scrollTop+ca.height()/2)/i-m.contentH;m.pasteElements("point",q,i)},fc=function(){ia!=null&&m.moveToTopSelectedElement()},Ra=function(){ia!=null&&m.moveToBottomSelectedElement()},ab=function(i){ia!=null&&m.moveUpDownSelected(i)},Aa=function(){ia!=null&&m.convertToPath()},bb=function(){ia!=null&&Pa.reorient()},ib=function(){if(ia!=null||wa)a.prompt(h.notification.enterNewLinkURL,"http://",function(i){i&&m.makeHyperlink(i)})},cb=function(i,q){if(ia!=
null||wa){if(f.gridSnapping){var E=m.getZoom()*f.snappingStep;i*=E;q*=E}m.moveSelectedElements(i,q)}},Ib=function(){var i=!a("#tool_node_link").hasClass("push_button_pressed");i?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button");Pa.linkControlPoints(i)},Oa=function(){Pa.getNodePoint()&&Pa.clonePathNode()},pa=function(){Pa.getNodePoint()&&Pa.deletePathNode()},hc=function(){var i=a("#tool_add_subpath"),
q=!i.hasClass("push_button_pressed");q?i.addClass("push_button_pressed").removeClass("tool_button"):i.removeClass("push_button_pressed").addClass("tool_button");Pa.addSubPath(q)},Yb=function(){Pa.opencloseSubPath()},Eb=function(){m.cycleElement(1)},Nb=function(){m.cycleElement(0)},Bb=function(i,q){if(!(ia==null||wa)){i||(q*=-1);var E=a("#angle").val()*1+q;m.setRotationAngle(E);ra()}},wb=function(){var i=f.dimensions;a.confirm(h.notification.QwantToClear,function(q){if(q){rb();m.clear();m.setResolution(i[0],
i[1]);kb(true);c();Wa();ra();Ha.fill.prep();Ha.stroke.prep()}})},Lb=function(){m.setBold(!m.getBold());ra();return false},mc=function(){m.setItalic(!m.getItalic());ra();return false},vb=function(){if(!p.pngsave){var i=h.notification.loadingImage;fb=window.open("data:text/html;charset=utf-8,<title>"+i+"</title><h1>"+i+"</h1>")}window.canvg?m.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){m.rasterExport()})})},Ta=function(){m.open()},ic=function(){},
Zb=function(){if(sa.getUndoStackSize()>0){sa.undo();Wa()}},jb=function(){if(sa.getRedoStackSize()>0){sa.redo();Wa()}},Na=function(){if(wa)m.groupSelectedElements();else ia&&m.ungroupSelectedElement()},Xb=function(){m.cloneSelectedElements(20,20)},b=function(){var i=this.id.replace("tool_align","").charAt(0);m.alignSelectedElements(i,a("#align_relative_to").val())},c=function(i){var q=m.getResolution();i=i?q.zoom*i:1;a("#zoom").val(i*100);m.setZoom(i);l();kb(true)},d=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?
a("#tool_wireframe").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_wireframe").removeClass("push_button_pressed").addClass("tool_button");ca.toggleClass("wireframe");if(!gc){var i=a("#wireframe_rules");i.length?i.empty():a('<style id="wireframe_rules"></style>').appendTo("head");l()}},l=function(){if(!gc){var i="#workarea.wireframe #svgcontent * { stroke-width: "+1/m.getZoom()+"px; }";a("#wireframe_rules").text(ca.hasClass("wireframe")?i:"")}},k=function(i,q){if(!Ia){Ia=true;
a("#save_output_btns").toggle(!!q);a("#tool_source_back").toggle(!q);var E=Qb=m.getSvgString();a("#svg_source_textarea").val(E);a("#svg_source_editor").fadeIn();g();a("#svg_source_textarea").focus()}};a("#svg_docprops_container, #svg_prefs_container").draggable({cancel:"button,fieldset",containment:"window"});var w=function(){if(!Fa){Fa=true;a("#image_save_opts input").val([e.img_save]);var i=m.getResolution();if(f.baseUnit!=="px"){i.w=svgedit.units.convertUnit(i.w)+f.baseUnit;i.h=svgedit.units.convertUnit(i.h)+
f.baseUnit}a("#canvas_width").val(i.w);a("#canvas_height").val(i.h);a("#canvas_title").val(m.getDocumentTitle());a("#svg_docprops").show()}},n=function(){if(!qa){qa=true;a("#main_menu").hide();var i=a("#bg_blocks div"),q=a.pref("bkgd_color"),E=a.pref("bkgd_url");i.each(function(){var I=a(this),M=I.css("background-color")==q;I.toggleClass("cur_background",M);M&&a("#canvas_bg_url").removeClass("cur_background")});q||i.eq(0).addClass("cur_background");E&&a("#canvas_bg_url").val(E);a("grid_snapping_step").attr("value",
f.snappingStep);f.gridSnapping==true?a("#grid_snapping_on").attr("checked","checked"):a("#grid_snapping_on").removeAttr("checked");a("#svg_prefs").show()}},g=function(){var i=a("#svg_source_container").height()-80;a("#svg_source_textarea").css("height",i)},s=function(){if(Ia){var i=function(){m.clearSelection();X();c();Wa();v();Ha.fill.prep();Ha.stroke.prep()};m.setSvgString(a("#svg_source_textarea").val())?i():a.confirm(h.notification.QerrorsRevertToSource,function(q){if(!q)return false;i()});rb()}},
v=function(i){i=i||m.getDocumentTitle();i=ua+(i?": "+i:"");a("title:first").text(i)},u=function(){var i=a("#canvas_title").val();v(i);m.setDocumentTitle(i);i=a("#canvas_width");var q=i.val(),E=a("#canvas_height"),I=E.val();if(q!="fit"&&!svgedit.units.isValidUnit("width",q)){a.alert(h.notification.invalidAttrValGiven);i.parent().addClass("error");return false}i.parent().removeClass("error");if(I!="fit"&&!svgedit.units.isValidUnit("height",I)){a.alert(h.notification.invalidAttrValGiven);E.parent().addClass("error");
return false}E.parent().removeClass("error");if(!m.setResolution(q,I)){a.alert(h.notification.noContentToFitTo);return false}e.img_save=a("#image_save_opts :checked").val();a.pref("img_save",e.img_save);kb();ba()},t=function(){var i=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";z(i,a("#canvas_bg_url").val());i=a("#lang_select").val();i!=e.lang&&o.putLocale(i);K(a("#iconsize").val());f.gridSnapping=a("#grid_snapping_on")[0].checked;f.snappingStep=a("#grid_snapping_step").val();
f.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(f.showRulers);f.showRulers&&Z();f.baseUnit=a("#base_unit").val();m.setConfig(f);kb();R()},B=o.setIcon=function(i,q){var E=typeof q==="string"?a.getSvgIcon(q,true):q.clone();E?a(i).empty().append(E):console.log("NOTE: Icon image missing: "+q)},D;D=function(){var i=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,q=document.getElementsByTagName("script")[0],E;for(E in q.style)if(i.test(E))return E.match(i)[0];if("WebkitOpacity"in q.style)return"Webkit";
if("KhtmlOpacity"in q.style)return"Khtml";return""}();var H=function(i,q){D.toLowerCase();var E=["top","left","bottom","right"];i.each(function(){for(var I=a(this),M=I.outerWidth()*(q-1),Q=I.outerHeight()*(q-1),U=0;U<4;U++){var Y=E[U],ga=I.data("orig_margin-"+Y);if(ga==null){ga=parseInt(I.css("margin-"+Y));I.data("orig_margin-"+Y,ga)}ga=ga*q;if(Y==="right")ga+=M;else if(Y==="bottom")ga+=Q;I.css("margin-"+Y,ga)}})},K=o.setIconSize=function(i,q){if(!(i==e.size&&!q)){console.log("size",i);var E=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"),
I=1;I=typeof i=="number"?i:{s:0.75,m:1,l:1.25,xl:1.5}[i];o.tool_scale=cc=I;Fb();var M=E.parents(":hidden");M.css("visibility","hidden").show();H(E,I);M.css("visibility","visible").hide();a.pref("iconsize",i);a("#iconsize").val(i);M={"#tools_top":{left:50,height:72},"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};E=a("#tool_size_rules");if(E.length)E.empty();else E=a('<style id="tool_size_rules"></style>').appendTo("head");if(i!="m"){var Q="";a.each(M,function(U,Y){U="#svg_editor "+
U.replace(/,/g,", #svg_editor");Q+=U+"{";a.each(Y,function(ga,ea){if(typeof ea==="number")var ma=ea*I+"px";else if(ea[i]||ea.all)ma=ea[i]||ea.all;Q+=ga+":"+ma+";"});Q+="}"});M="-"+D.toLowerCase()+"-";Q+="#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{"+M+"transform: scale("+I+");} #svg_editor div.toolset .toolset {"+M+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+
M+"transform: scale("+1/I+");}";E.text(Q)}Fb()}},P=function(){a("#dialog_box").hide();if(!Ia&&!Fa&&!qa)la&&m.leaveContext();else{if(Ia)Qb!==a("#svg_source_textarea").val()?a.confirm(h.notification.QignoreSourceChanges,function(i){i&&X()}):X();else if(Fa)ba();else qa&&R();V()}},X=function(){a("#svg_source_editor").hide();Ia=false;a("#svg_source_textarea").blur()},ba=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=0;a("#image_save_opts input").val([e.img_save]);
Fa=false},R=function(){a("#svg_prefs").hide();qa=false},T={width:a(window).width(),height:a(window).height()},V=a.noop,da;svgedit.browser.isIE()&&function(){V=function(){if(ca[0].scrollLeft===0&&ca[0].scrollTop===0){ca[0].scrollLeft=da.left;ca[0].scrollTop=da.top}};da={left:ca[0].scrollLeft,top:ca[0].scrollTop};a(window).resize(V);svgEditor.ready(function(){setTimeout(function(){V()},500)});ca.scroll(function(){da={left:ca[0].scrollLeft,top:ca[0].scrollTop}})}();a(window).resize(function(){Ia&&g();
a.each(T,function(i,q){var E=a(window)[i]();ca[0]["scroll"+(i==="width"?"Left":"Top")]-=(E-q)/2;T[i]=E})});(function(){ca.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=ca[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=ca[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(N);(function(){var i=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],
q="";a.each(i,function(E,I){q+="#tool_"+I+(E==i.length-1?",":"")});a(q).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(W&&!window.opera){W=["tool_clear","tool_save","tool_source","tool_undo","tool_redo",
"tool_clone"];for(var za=W.length;za--;){var Va=document.getElementById(W[za]);if(Va!=null){var hb=Va.title,$a=hb.indexOf("Ctrl+");Va.title=[hb.substr(0,$a),"Cmd+",hb.substr($a+5)].join("")}}}var gb=function(i){var q=i.attr("id")=="stroke_color"?"stroke":"fill",E=Ha[q].paint,I=q=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";i=i.position();a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(f.colorPickerCSS||
{left:i.left,bottom:50-i.top}).jGraduate({paint:E,window:{pickerTitle:I},images:{clientPath:f.jGraduatePath},newstop:"inverse"},function(M){E=new a.jGraduate.Paint(M);Ha[q].setPaint(E);m.setPaint(q,E);a("#color_picker").hide()},function(){a("#color_picker").hide()})},Mb=function(){var i=m.getColor("fill")=="none",q=m.getColor("stroke")=="none",E=["#tool_fhpath","#tool_line"],I=["#tools_rect .tool_button","#tools_ellipse .tool_button","#tool_text","#tool_path"];if(q)for(var M in E){var Q=E[M];a(Q).hasClass("tool_button_current")&&
yb();a(Q).addClass("disabled")}else for(M in E){Q=E[M];a(Q).removeClass("disabled")}if(q&&i)for(M in I){Q=I[M];a(Q).hasClass("tool_button_current")&&yb();a(Q).addClass("disabled")}else for(M in I){Q=I[M];a(Q).removeClass("disabled")}m.runExtensions("toolButtonStateUpdate",{nofill:i,nostroke:q});a(".tools_flyout").each(function(){var U=a("#"+this.id+"_show"),Y=false;a(this).children().each(function(){a(this).hasClass("disabled")||(Y=true)});U.toggleClass("disabled",!Y)});Ma()};W=function(i,q){var E=
f[q==="fill"?"initFill":"initStroke"],I=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+E.color+'" opacity="'+E.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;I=a(i)[0].appendChild(document.importNode(I,true));I.setAttribute("width",16.5);this.rect=I.firstChild;this.defs=I.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:E.color});
this.type=q;this.setPaint=function(M,Q){this.paint=M;var U="none",Y=M.type,ga=M.alpha/100;switch(Y){case "solidColor":U="#"+M[Y];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(M[Y]);U="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",U);this.rect.setAttribute("opacity",ga);if(Q){m.setColor(this.type,paintColor,true);m.setPaintOpacity(this.type,paintOpacity,true)}};this.update=function(M){if(ia){var Q=this.type;
switch(ia.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var U=null,Y=ia.getElementsByTagName("*"),ga=0,ea=Y.length;ga<ea;ga++){var ma=Y[ga].getAttribute(Q);if(ga===0)U=ma;else if(U!==ma){U=null;break}}if(U===null){Y=null;return}Y=U;U=1;break;default:U=parseFloat(ia.getAttribute(Q+"-opacity"));if(isNaN(U))U=1;Y=Q==="fill"?"black":"none";Y=ia.getAttribute(Q)||Y}if(M){m.setColor(Q,Y,true);m.setPaintOpacity(Q,U,true)}U*=100;this.setPaint(Tb(Y,U,Q))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var M=
new a.jGraduate.Paint({copy:this.paint});m.setPaint(q,M)}}};Ha.fill=new W("#fill_color","fill");Ha.stroke=new W("#stroke_color","stroke");a("#stroke_width").val(f.initStroke.width);a("#group_opacity").val(f.initOpacity*100);W=Ha.fill.rect.cloneNode(false);W.setAttribute("style","vector-effect:non-scaling-stroke");var gc=W.style.vectorEffect==="non-scaling-stroke";W.removeAttribute("style");W=Ha.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof W.stdDeviationX===
"undefined"&&a("#tool_blur").hide();a(W).remove();(function(){var i="-"+D.toLowerCase()+"-zoom-",q=i+"in";ca.css("cursor",q);if(ca.css("cursor")===q){Ua=q;ya=i+"out"}ca.css("cursor","auto")})();setTimeout(function(){m.embedImage("images/logo.png",function(i){if(!i){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);e.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",h.notification.featNotSupported)}})},1E3);a("#fill_color, #tool_fill .icon_label").click(function(){gb(a("#fill_color"));
Mb()});a("#stroke_color, #tool_stroke .icon_label").click(function(){gb(a("#stroke_color"));Mb()});a("#group_opacityLabel").click(function(){a("#opacity_dropdown button").mousedown();a(window).mouseup()});a("#zoomLabel").click(function(){a("#zoom_dropdown button").mousedown();a(window).mouseup()});a("#tool_move_top").mousedown(function(i){a("#tools_stacking").show();i.preventDefault()});a(".layer_button").mousedown(function(){a(this).addClass("layer_buttonpressed")}).mouseout(function(){a(this).removeClass("layer_buttonpressed")}).mouseup(function(){a(this).removeClass("layer_buttonpressed")});
a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});a("#layer_new").click(function(){var i=m.getCurrentDrawing().getNumLayers();do var q=h.layers.layer+" "+ ++i;while(m.getCurrentDrawing().hasLayer(q));a.prompt(h.notification.enterUniqueLayerName,
q,function(E){if(E)if(m.getCurrentDrawing().hasLayer(E))a.alert(h.notification.dupeLayerName);else{m.createLayer(E);ra();Wa()}})});a("#layer_delete").click(aa);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 i=a("#layerlist tr.layersel td.layername").text();a.prompt(h.notification.enterNewLayerName,"",function(q){if(q)if(i==q||m.getCurrentDrawing().hasLayer(q))a.alert(h.notification.layerHasThatName);
else{m.renameCurrentLayer(q);Wa()}})});var Ob=-1,kc=false,oc=false,qc=function(i){if(oc)if(Ob!=-1){kc=true;i=Ob-i.pageX;var q=a("#sidepanels"),E=parseInt(q.css("width"));if(E+i>300)i=300-E;else if(E+i<2)i=2-E;if(i!=0){Ob-=i;E=a("#layerpanel");ca.css("right",parseInt(ca.css("right"))+i);q.css("width",parseInt(q.css("width"))+i);E.css("width",parseInt(E.css("width"))+i);q=a("#ruler_x");q.css("right",parseInt(q.css("right"))+i)}}};a("#sidepanel_handle").mousedown(function(i){Ob=i.pageX;a(window).mousemove(qc);
oc=false;setTimeout(function(){oc=true},20)}).mouseup(function(){kc||pc();Ob=-1;kc=false});a(window).mouseup(function(){Ob=-1;kc=false;a("#svg_editor").unbind("mousemove",qc)});var pc=function(i){var q=parseInt(a("#sidepanels").css("width"));i=(q>2||i?2:150)-q;q=a("#sidepanels");var E=a("#layerpanel"),I=a("#ruler_x");ca.css("right",parseInt(ca.css("right"))+i);q.css("width",parseInt(q.css("width"))+i);E.css("width",parseInt(E.css("width"))+i);I.css("right",parseInt(I.css("right"))+i)},rc=function(i){for(var q=
Array(m.getCurrentDrawing().getNumLayers()),E=0;E<q.length;++E)q[E]=m.getCurrentDrawing().getLayerName(E);if(i)for(E=0;E<q.length;++E)q[E]!=i&&m.getCurrentDrawing().setLayerOpacity(q[E],0.5);else for(E=0;E<q.length;++E)m.getCurrentDrawing().setLayerOpacity(q[E],1)},Wa=function(){var i=a("#layerlist tbody"),q=a("#selLayerNames");i.empty();q.empty();for(var E=m.getCurrentDrawing().getCurrentLayerName(),I=m.getCurrentDrawing().getNumLayers(),M=a.getSvgIcon("eye");I--;){var Q=m.getCurrentDrawing().getLayerName(I),
U='<tr class="layer';if(Q==E)U+=" layersel";U+='">';U+=m.getCurrentDrawing().getLayerVisibility(Q)?'<td class="layervis"/><td class="layername" >'+Q+"</td></tr>":'<td class="layervis layerinvis"/><td class="layername" >'+Q+"</td></tr>";i.append(U);q.append('<option value="'+Q+'">'+Q+"</option>")}if(M!==undefined){M.clone();a("td.layervis",i).append(M.clone());a.resizeSvgIcons({"td.layervis .svg_icon":14})}a("#layerlist td.layername").mouseup(function(Y){a("#layerlist tr.layer").removeClass("layersel");
a(this.parentNode).addClass("layersel");m.setCurrentLayer(this.textContent);Y.preventDefault()}).mouseover(function(){a(this).css({"font-style":"italic",color:"blue"});rc(this.textContent)}).mouseout(function(){a(this).css({"font-style":"normal",color:"black"});rc()});a("#layerlist td.layervis").click(function(){var Y=a(this.parentNode).prevAll().length;Y=a("#layerlist tr.layer:eq("+Y+") td.layername").text();var ga=a(this).hasClass("layerinvis");m.setLayerVisibility(Y,ga);ga?a(this).removeClass("layerinvis"):
a(this).addClass("layerinvis")});for(q=5-a("#layerlist tr.layer").size();q-- >0;)i.append('<tr><td style="color:white">_</td><td/></tr>')};Wa();a(window).bind("load resize",function(){ca.css("line-height",ca.height()+"px")});a("#resolution").change(function(){var i=a("#canvas_width,#canvas_height");if(this.selectedIndex)if(this.value=="content")i.val("fit").attr("disabled","disabled");else{var q=this.value.split("x");a("#canvas_width").val(q[0]);a("#canvas_height").val(q[1]);i.removeAttr("disabled")}else a("#canvas_width").val()==
"fit"&&i.removeAttr("disabled").val(100)});a("input,select").attr("autocomplete","off");var nc=function(){var i=[{sel:"#tool_select",fn:yb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Sb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:zb,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Ub,evt:"mouseup",key:["R",true],parent:"#tools_rect",icon:"rect"},{sel:"#tool_square",fn:Ab,evt:"mouseup",parent:"#tools_rect",icon:"square"},{sel:"#tool_fhrect",fn:Hb,evt:"mouseup",parent:"#tools_rect",icon:"fh_rect"},
{sel:"#tool_ellipse",fn:dc,evt:"mouseup",key:["E",true],parent:"#tools_ellipse",icon:"ellipse"},{sel:"#tool_circle",fn:lc,evt:"mouseup",parent:"#tools_ellipse",icon:"circle"},{sel:"#tool_fhellipse",fn:ub,evt:"mouseup",parent:"#tools_ellipse",icon:"fh_ellipse"},{sel:"#tool_path",fn:Vb,evt:"click",key:["P",true]},{sel:"#tool_text",fn:pb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:Za,evt:"mouseup"},{sel:"#tool_zoom",fn:Ea,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:wb,evt:"mouseup",key:["N",
true]},{sel:"#tool_save",fn:function(){Ia?s():m.save({images:e.img_save,round_digits:6})},evt:"mouseup",key:["S",true]},{sel:"#tool_export",fn:vb,evt:"mouseup"},{sel:"#tool_open",fn:Ta,evt:"mouseup",key:["O",true]},{sel:"#tool_import",fn:ic,evt:"mouseup"},{sel:"#tool_source",fn:k,evt:"click",key:["U",true]},{sel:"#tool_wireframe",fn:d,evt:"click",key:["F",true]},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:P,evt:"click",key:["esc",false,false],hidekey:true},
{sel:"#tool_source_save",fn:s,evt:"click"},{sel:"#tool_docprops_save",fn:u,evt:"click"},{sel:"#tool_docprops",fn:w,evt:"mouseup"},{sel:"#tool_prefs_save",fn:t,evt:"click"},{sel:"#tool_prefs_option",fn:function(){n();return false},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:Jb,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:bb,evt:"click"},{sel:"#tool_node_link",fn:Ib,evt:"click"},{sel:"#tool_node_clone",fn:Oa,evt:"click"},{sel:"#tool_node_delete",fn:pa,evt:"click"},{sel:"#tool_openclose_path",
fn:Yb,evt:"click"},{sel:"#tool_add_subpath",fn:hc,evt:"click"},{sel:"#tool_move_top",fn:fc,evt:"click",key:"ctrl+shift+]"},{sel:"#tool_move_bottom",fn:Ra,evt:"click",key:"ctrl+shift+["},{sel:"#tool_topath",fn:Aa,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ib,evt:"click"},{sel:"#tool_undo",fn:Zb,evt:"click",key:["Z",true]},{sel:"#tool_redo",fn:jb,evt:"click",key:["Y",true]},{sel:"#tool_clone,#tool_clone_multi",fn:Xb,evt:"click",key:["D",true]},{sel:"#tool_group",fn:Na,evt:"click",
key:["G",true]},{sel:"#tool_ungroup",fn:Na,evt:"click"},{sel:"#tool_unlink_use",fn:Na,evt:"click"},{sel:"[id^=tool_align]",fn:b,evt:"click"},{sel:"#tool_bold",fn:Lb,evt:"mousedown"},{sel:"#tool_italic",fn:mc,evt:"mousedown"},{sel:"#sidepanel_handle",fn:pc,key:["X"]},{sel:"#copy_save_done",fn:P,evt:"click"},{key:"ctrl+left",fn:function(){Bb(0,1)}},{key:"ctrl+right",fn:function(){Bb(1,1)}},{key:"ctrl+shift+left",fn:function(){Bb(0,5)}},{key:"ctrl+shift+right",fn:function(){Bb(1,5)}},{key:"shift+O",
fn:Nb},{key:"shift+P",fn:Eb},{key:[oa+"up",true],fn:function(){c(2)}},{key:[oa+"down",true],fn:function(){c(0.5)}},{key:[oa+"]",true],fn:function(){ab("Up")}},{key:[oa+"[",true],fn:function(){ab("Down")}},{key:["up",true],fn:function(){cb(0,-1)}},{key:["down",true],fn:function(){cb(0,1)}},{key:["left",true],fn:function(){cb(-1,0)}},{key:["right",true],fn:function(){cb(1,0)}},{key:"shift+up",fn:function(){cb(0,-10)}},{key:"shift+down",fn:function(){cb(0,10)}},{key:"shift+left",fn:function(){cb(-10,
0)}},{key:"shift+right",fn:function(){cb(10,0)}},{key:["alt+up",true],fn:function(){m.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){m.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){m.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){m.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){m.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){m.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){m.cloneSelectedElements(-10,
0)}},{key:["alt+shift+right",true],fn:function(){m.cloneSelectedElements(10,0)}},{key:"A",fn:function(){m.selectAllInCurrentLayer()}},{key:oa+"z",fn:Zb},{key:oa+"shift+z",fn:jb},{key:oa+"y",fn:jb},{key:oa+"x",fn:Wb},{key:oa+"c",fn:ec},{key:oa+"v",fn:Kb}],q={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var E={};a.each(i,function(I,M){if(M.sel){var Q=a(M.sel);if(Q.length==0)return true;M.evt&&Q[M.evt](M.fn);if(M.parent&&a(M.parent+"_show").length!=0){var U=
a(M.parent);U.length||(U=sb(M.parent.substr(1)));U.append(Q);a.isArray(E[M.parent])||(E[M.parent]=[]);E[M.parent].push(M)}}if(M.key){var Y=M.fn,ga=false;if(a.isArray(M.key)){U=M.key[0];if(M.key.length>1)ga=M.key[1]}else U=M.key;U+="";a.each(U.split("/"),function(ma,xa){a(document).bind("keydown",xa,function(Sa){Y();ga&&Sa.preventDefault();return false})});if(M.sel&&!M.hidekey){var ea=Q.attr("title").split("[")[0]+" ("+U+")";q[U]=M.sel;Q.parents("#main_menu").length||Q.attr("title",ea)}}});Rb(E);a(".attr_changer, #image_url").bind("keydown",
"return",function(I){a(this).change();I.preventDefault()});a(window).bind("keydown","tab",function(I){if(Ca==="canvas"){I.preventDefault();Eb()}}).bind("keydown","shift+tab",function(I){if(Ca==="canvas"){I.preventDefault();Nb()}});a("#tool_zoom").dblclick(fa)},setTitles:function(){a.each(q,function(E,I){var M=a(I).parents("#main_menu").length;a(I).each(function(){var Q=M?a(this).text().split(" [")[0]:this.title.split(" [")[0],U="";a.each(E.split("/"),function(Y,ga){var ea=ga.split("+"),ma="";if(ea.length>
1){ma=ea[0]+"+";ga=ea[1]}U+=(Y?"/":"")+ma+(h["key_"+ga]||ga)});if(M)this.lastChild.textContent=Q+" ["+U+"]";else this.title=Q+" ["+U+"]"})})},getButtonData:function(E){var I;a.each(i,function(M,Q){if(Q.sel===E)I=Q});return I}}}();nc.setAll();o.ready(function(){var i=f.initTool,q=a("#tools_left, #svg_editor .tools_flyout"),E=q.find("#tool_"+i);i=q.find("#"+i);(E.length?E:i.length?i:a("#tool_select")).click().mouseup();f.wireframe&&a("#tool_wireframe").click();f.showlayers&&pc();a("#rulers").toggle(!!f.showRulers);
if(f.showRulers)a("#show_rulers")[0].checked=true;if(f.gridSnapping)a("#grid_snapping_on")[0].checked=true;f.baseUnit&&a("#base_unit").val(f.baseUnit);f.snappingStep&&a("#grid_snapping_step").val(f.snappingStep)});a("#rect_rx").SpinButton({min:0,max:1E3,step:1,callback:function(i){m.setRectRadius(i.value)}});a("#stroke_width").SpinButton({min:0,max:99,step:1,smallStep:0.1,callback:function(i){var q=i.value;if(q==0&&ia&&["line","polyline"].indexOf(ia.nodeName)>=0)q=i.value=1;m.setStrokeWidth(q)}});
a("#angle").SpinButton({min:-180,max:180,step:5,callback:function(i){m.setRotationAngle(i.value);a("#tool_reorient").toggleClass("disabled",i.value==0)}});a("#font_size").SpinButton({step:1,min:0.0010,stepfunc:function(i,q){var E=i.value-0,I=E+q,M=I>=E;if(q===0)return E;return E>=24?M?Math.round(E*1.1):Math.round(E/1.1):E<=1?M?E*2:E/2:I},callback:function(i){m.setFontSize(i.value)}});a("#group_opacity").SpinButton({step:5,min:0,max:100,callback:ob});a("#blur").SpinButton({step:0.1,min:0,max:10,callback:Qa});
a("#zoom").SpinButton({min:0.0010,max:1E4,step:50,stepfunc:function(i,q){var E=i.value-0;if(E===0)return 100;var I=E+q;if(q===0)return E;return E>=100?I:I>=E?E*2:E/2},callback:Ya}).val(m.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(i){switch(i){case "delete":Jb();break;case "cut":Wb();break;case "copy":ec();break;case "paste":m.pasteElements();break;case "paste_in_place":m.pasteElements("in_place");break;case "group":m.groupSelectedElements();break;case "ungroup":m.ungroupSelectedElement();
break;case "move_front":fc();break;case "move_up":ab("Up");break;case "move_down":ab("Down");break;case "move_back":Ra()}m.clipBoard.length&&qb.enableContextMenuItems("#paste,#paste_in_place")});W=function(i){switch(i){case "dupe":O();break;case "delete":aa();break;case "merge_down":if(a("#layerlist tr.layersel").index()!=m.getCurrentDrawing().getNumLayers()-1){m.mergeLayer();ra();Wa()}break;case "merge_all":m.mergeAllLayers();ra();Wa()}};a("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},
W);a("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:true},W);a(".contextMenu li").mousedown(function(i){i.preventDefault()});a("#cmenu_canvas li").disableContextMenu();qb.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(sa.getUndoStackSize()===0)db=false;if(!f.no_save_warning&&db)return h.notification.unsavedChanges};o.openPrep=function(i){a("#main_menu").hide();sa.getUndoStackSize()===0?i(true):a.confirm(h.notification.QwantToOpen,i)};if(window.FileReader){W=
a('<input type="file">').change(function(){var i=this;o.openPrep(function(q){if(q){m.clear();if(i.files.length==1){q=new FileReader;q.onloadend=function(E){L(E.target.result);kb()};q.readAsText(i.files[0])}}})});a("#tool_open").show().prepend(W);W=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var i=new FileReader;i.onloadend=function(q){m.importSvgString(q.target.result,true);kb()};i.readAsText(this.files[0])}});a("#tool_import").show().prepend(W)}var kb=
o.updateCanvas=function(i,q){var E=ca.width(),I=ca.height(),M=E,Q=I,U=m.getZoom(),Y=a("#svgcanvas"),ga={x:ca[0].scrollLeft+M/2,y:ca[0].scrollTop+Q/2},ea=f.canvas_expansion;E=Math.max(M,m.contentW*U*ea);I=Math.max(Q,m.contentH*U*ea);E==M&&I==Q?ca.css("overflow","hidden"):ca.css("overflow","scroll");ea=Y.height()/2;var ma=Y.width()/2;Y.width(E).height(I);var xa=I/2,Sa=E/2,S=m.updateCanvas(E,I),Da=Sa/ma;E=E/2-M/2;I=I/2-Q/2;if(q){q.x+=S.x;q.y+=S.y}else q={x:Sa+(ga.x-ma)*Da,y:xa+(ga.y-ea)*Da};if(i)if(m.contentW>
ca.width()){ca[0].scrollLeft=S.x-10;ca[0].scrollTop=S.y-10}else{ca[0].scrollLeft=E;ca[0].scrollTop=I}else{ca[0].scrollLeft=q.x-M/2;ca[0].scrollTop=q.y-Q/2}if(f.showRulers){Z(Y,U);ca.scroll()}},$b=[];for(za=0.1;za<1E5;za*=10){$b.push(1*za);$b.push(2*za);$b.push(5*za)}kb(true);try{var sc=function(i){if(window.JSON&&JSON.stringify)return JSON.stringify(i);var q=arguments.callee;if(typeof i=="boolean"||typeof i=="number")return i+"";else if(typeof i=="string")return'"'+i.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
function(M){return"\\u"+("0000"+M.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(i.length){for(var E=0;E<i.length;E++)i[E]=q(i[E]);return"["+i.join(",")+"]"}else{E=[];for(var I in i)E.push(q(I)+":"+q(i[I]));return"{"+E.join(",")+"}"}};window.addEventListener("message",function(i){var q=parseInt(i.data.substr(0,i.data.indexOf(";")));try{i.source.postMessage("SVGe"+q+";"+sc(eval(i.data)),"*")}catch(E){i.source.postMessage("SVGe"+q+";error:"+E.message,"*")}},false)}catch(tc){window.embed_error=
tc}a(function(){window.svgCanvas=m;m.ready=svgEditor.ready});o.setLang=function(i,q){a.pref("lang",i);a("#lang_select").val(i);if(q){var E=a("#layerlist tr.layersel td.layername").text()==h.common.layer+" 1";a.extend(h,q);m.setUiStrings(q);nc.setTitles();if(E){m.renameCurrentLayer(h.common.layer+" 1");Wa()}m.runExtensions("langChanged",i);Db();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(I,M){a(M).attr("title",a(I)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var C=[];o.ready=function(F){A?F():C.push(F)};o.runCallbacks=function(){a.each(C,function(){this()});A=true};o.loadFromString=function(F){o.ready(function(){L(F)})};o.disableUI=function(){};o.loadFromURL=function(F,z){z||(z={});var N=z.cache,aa=z.callback;o.ready(function(){a.ajax({url:F,dataType:"text",
cache:!!N,success:function(O){L(O,aa)},error:function(O,J,Z){O.status!=404&&O.responseText?L(O.responseText,aa):a.alert(h.notification.URLloadFail+": \n"+Z+"",aa)}})})};o.loadFromDataURI=function(F){o.ready(function(){var z=F.substring(26);L(svgedit.utilities.decode64(z))})};o.addExtension=function(){var F=arguments;a(function(){m&&m.addExtension.apply(this,F)})};return o}(jQuery);$(svgEditor.init)})();var svgEditor=function(a,L){function m(A,G,e){var f=a("#svg_editor").parent(),h;for(h in G){var p=G[h];p||console.log(h);if(e)h="#"+h;if(f.find(h).length){var C=f.find(h)[0];switch(A){case "content":for(var F=0;F<C.childNodes.length;F++){var z=C.childNodes[F];if(z.nodeType===3&&z.textContent.replace(/\s/g,"")){z.textContent=p;break}}break;case "title":C.title=p}}else console.log("Missing: "+h)}}var o;L.readLang=function(A){var G=L.canvas.runExtensions("addlangData",o,true);a.each(G,function(aa,O){if(O.data)A=
a.merge(A,O.data)});if(A.tools){var e=A.tools;G=A.properties;var f=A.config,h=A.layers,p=A.common,C=A.ui;m("content",{copyrightLabel:A.misc.powered_by,curve_segments:G.curve_segments,fitToContent:e.fitToContent,fit_to_all:e.fit_to_all,fit_to_canvas:e.fit_to_canvas,fit_to_layer_content:e.fit_to_layer_content,fit_to_sel:e.fit_to_sel,icon_large:f.icon_large,icon_medium:f.icon_medium,icon_small:f.icon_small,icon_xlarge:f.icon_xlarge,image_opt_embed:f.image_opt_embed,image_opt_ref:f.image_opt_ref,includedImages:f.included_images,
largest_object:e.largest_object,layersLabel:h.layers,page:e.page,relativeToLabel:e.relativeTo,selLayerLabel:h.move_elems_to,selectedPredefined:f.select_predefined,selected_objects:e.selected_objects,smallest_object:e.smallest_object,straight_segments:G.straight_segments,svginfo_bg_url:f.editor_img_url+":",svginfo_bg_note:f.editor_bg_note,svginfo_change_background:f.background,svginfo_dim:f.doc_dims,svginfo_editor_prefs:f.editor_prefs,svginfo_height:p.height,svginfo_icons:f.icon_size,svginfo_image_props:f.image_props,
svginfo_lang:f.language,svginfo_title:f.doc_title,svginfo_width:p.width,tool_docprops_cancel:p.cancel,tool_docprops_save:p.ok,tool_source_cancel:p.cancel,tool_source_save:p.ok,tool_prefs_cancel:p.cancel,tool_prefs_save:p.ok,sidepanel_handle:h.layers.split("").join(" "),tool_clear:e.new_doc,tool_docprops:e.docprops,tool_export:e.export_png,tool_import:e.import_doc,tool_imagelib:e.imagelib,tool_open:e.open_doc,tool_save:e.save_doc,svginfo_units_rulers:f.units_and_rulers,svginfo_rulers_onoff:f.show_rulers,
svginfo_unit:f.base_unit,svginfo_grid_settings:f.grid,svginfo_snap_onoff:f.snapping_onoff,svginfo_snap_step:f.snapping_stepsize},true);var F={},z;for(z in A.shape_cats)F['#shape_cats [data-cat="'+z+'"]']=A.shape_cats[z];setTimeout(function(){m("content",F)},2E3);var N={};a.each(["cut","copy","paste","paste_in_place","delete","group","ungroup","move_front","move_up","move_down","move_back"],function(){N['#cmenu_canvas a[href="#'+this+'"]']=e[this]});a.each(["dupe","merge_down","merge_all"],function(){N['#cmenu_layers a[href="#'+
this+'"]']=h[this]});N['#cmenu_layers a[href="#delete"]']=h.del;m("content",N);m("title",{align_relative_to:e.align_relative_to,circle_cx:G.circle_cx,circle_cy:G.circle_cy,circle_r:G.circle_r,cornerRadiusLabel:G.corner_radius,ellipse_cx:G.ellipse_cx,ellipse_cy:G.ellipse_cy,ellipse_rx:G.ellipse_rx,ellipse_ry:G.ellipse_ry,fill_color:G.fill_color,font_family:G.font_family,idLabel:G.id,image_height:G.image_height,image_url:G.image_url,image_width:G.image_width,layer_delete:h.del,layer_down:h.move_down,
layer_new:h["new"],layer_rename:h.rename,layer_moreopts:p.more_opts,layer_up:h.move_up,line_x1:G.line_x1,line_x2:G.line_x2,line_y1:G.line_y1,line_y2:G.line_y2,linecap_butt:G.linecap_butt,linecap_round:G.linecap_round,linecap_square:G.linecap_square,linejoin_bevel:G.linejoin_bevel,linejoin_miter:G.linejoin_miter,linejoin_round:G.linejoin_round,main_icon:e.main_menu,mode_connect:e.mode_connect,tools_shapelib_show:e.mode_shapelib,palette:C.palette_info,zoom_panel:C.zoom_level,path_node_x:G.node_x,path_node_y:G.node_y,
rect_height_tool:G.rect_height,rect_width_tool:G.rect_width,seg_type:G.seg_type,selLayerNames:h.move_selected,selected_x:G.pos_x,selected_y:G.pos_y,stroke_color:G.stroke_color,stroke_style:G.stroke_style,stroke_width:G.stroke_width,svginfo_title:f.doc_title,text:G.text_contents,toggle_stroke_tools:C.toggle_stroke_tools,tool_add_subpath:e.add_subpath,tool_alignbottom:e.align_bottom,tool_aligncenter:e.align_center,tool_alignleft:e.align_left,tool_alignmiddle:e.align_middle,tool_alignright:e.align_right,
tool_aligntop:e.align_top,tool_angle:G.angle,tool_blur:G.blur,tool_bold:G.bold,tool_circle:e.mode_circle,tool_clone:e.clone,tool_clone_multi:e.clone,tool_delete:e.del,tool_delete_multi:e.del,tool_ellipse:e.mode_ellipse,tool_eyedropper:e.mode_eyedropper,tool_fhellipse:e.mode_fhellipse,tool_fhpath:e.mode_fhpath,tool_fhrect:e.mode_fhrect,tool_font_size:G.font_size,tool_group:e.group,tool_make_link:e.make_link,tool_link_url:e.set_link_url,tool_image:e.mode_image,tool_italic:G.italic,tool_line:e.mode_line,
tool_move_bottom:e.move_bottom,tool_move_top:e.move_top,tool_node_clone:e.node_clone,tool_node_delete:e.node_delete,tool_node_link:e.node_link,tool_opacity:G.opacity,tool_openclose_path:e.openclose_path,tool_path:e.mode_path,tool_position:e.align_to_page,tool_rect:e.mode_rect,tool_redo:e.redo,tool_reorient:e.reorient_path,tool_select:e.mode_select,tool_source:e.source_save,tool_square:e.mode_square,tool_text:e.mode_text,tool_topath:e.to_path,tool_undo:e.undo,tool_ungroup:e.ungroup,tool_wireframe:e.wireframe_mode,
view_grid:e.toggle_grid,tool_zoom:e.mode_zoom,url_notice:e.no_embed},true);L.setLang(o,A)}};L.putLocale=function(A,G){if(A)o=A;else{o=a.pref("lang");if(!o){if(navigator.userLanguage)o=navigator.userLanguage;else if(navigator.language)o=navigator.language;if(o=="")return}console.log("Lang: "+o);if(a.inArray(o,G)==-1&&o!=="test")o="en";if(o.indexOf("en")==0)return}var e=L.curConfig.langPath+"lang."+o+".js";a.getScript(e,function(f){if(!f){f=document.createElement("script");f.src=e;document.querySelector("head").appendChild(f)}})};
return L}(jQuery,svgEditor);