@frangoteam/fuxa-min 1.2.11 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/api/auth/index.js +141 -3
  2. package/api/command/index.js +1 -1
  3. package/api/index.js +21 -2
  4. package/api/jwt-helper.js +3 -1
  5. package/api/resources/index.js +19 -2
  6. package/api/scripts/index.js +7 -3
  7. package/dist/3rdpartylicenses.txt +139 -7
  8. package/dist/assets/i18n/de.json +10 -0
  9. package/dist/assets/i18n/en.json +21 -3
  10. package/dist/assets/i18n/es.json +12 -0
  11. package/dist/assets/i18n/fr.json +11 -0
  12. package/dist/assets/i18n/ja.json +16 -6
  13. package/dist/assets/i18n/ko.json +12 -0
  14. package/dist/assets/i18n/pt.json +9 -2
  15. package/dist/assets/i18n/ru.json +11 -0
  16. package/dist/assets/i18n/sv.json +11 -1
  17. package/dist/assets/i18n/tr.json +8 -1
  18. package/dist/assets/i18n/ua.json +9 -2
  19. package/dist/assets/i18n/zh-cn.json +11 -0
  20. package/dist/assets/i18n/zh-tw.json +12 -1
  21. package/dist/assets/lib/svgeditor/fuxa-editor.min.js +17 -23
  22. package/dist/index.html +2 -2
  23. package/dist/main.72bdfed42c527918.js +329 -0
  24. package/dist/polyfills.d7de05f9af2fb559.js +1 -0
  25. package/dist/{runtime.8ef63094e52a66ba.js → runtime.9136a61a9b98f987.js} +1 -1
  26. package/dist/{scripts.40b60f02658462e4.js → scripts.d9e6ee984bf6f3b7.js} +1 -1
  27. package/dist/styles.545e37beb3e671ba.css +1 -0
  28. package/docs/openapi.yaml +3 -0
  29. package/integrations/node-red/index.js +4 -5
  30. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-get-daq.html +56 -5
  31. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-get-daq.js +8 -2
  32. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-get-tag-change.html +56 -5
  33. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-get-tag-change.js +12 -12
  34. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-get-tag-daq-settings.html +56 -5
  35. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-get-tag-daq-settings.js +14 -10
  36. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-get-tag.html +69 -14
  37. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-get-tag.js +44 -12
  38. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-set-tag-daq-settings.html +56 -5
  39. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-set-tag-daq-settings.js +24 -20
  40. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-set-tag.html +72 -13
  41. package/integrations/node-red/node-red-contrib-fuxa/nodes/fuxa-set-tag.js +33 -7
  42. package/main.js +38 -17
  43. package/package.json +10 -5
  44. package/runtime/alarms/alarmstorage.js +45 -30
  45. package/runtime/apikeys/apiKeysStorage.js +34 -22
  46. package/runtime/devices/adsclient/index.js +1 -1
  47. package/runtime/devices/ethernetip/index.js +1 -1
  48. package/runtime/devices/gpio/index.js +1 -1
  49. package/runtime/devices/odbc/index.js +14 -9
  50. package/runtime/devices/s7/index.js +2 -2
  51. package/runtime/devices/template/index.js +14 -14
  52. package/runtime/notificator/notifystorage.js +34 -23
  53. package/runtime/project/index.js +16 -0
  54. package/runtime/project/prjstorage.js +78 -40
  55. package/runtime/scripts/index.js +6 -2
  56. package/runtime/storage/calculator.js +17 -13
  57. package/runtime/storage/daqstorage.js +28 -2
  58. package/runtime/storage/influxdb/index.js +8 -3
  59. package/runtime/storage/questdb/index.js +224 -0
  60. package/runtime/storage/sqlite/index.js +11 -8
  61. package/runtime/storage/tdengine/index.js +24 -9
  62. package/runtime/users/usrstorage.js +65 -61
  63. package/runtime/utils.js +5 -0
  64. package/settings.default.js +8 -2
  65. package/dist/main.92522279642ef880.js +0 -329
  66. package/dist/polyfills.c8e7db9850a3ad8b.js +0 -1
  67. package/dist/styles.03cc550382689976.css +0 -1
@@ -1,23 +1,17 @@
1
- var mypathseg=function(){"use strict";return{initPathSeg:function(){"SVGPathSeg"in window||(window.SVGPathSeg=function(t,e,n){this.pathSegType=t,this.pathSegTypeAsLetter=e,this._owningPathSegList=n},window.SVGPathSeg.prototype.classname="SVGPathSeg",window.SVGPathSeg.PATHSEG_UNKNOWN=0,window.SVGPathSeg.PATHSEG_CLOSEPATH=1,window.SVGPathSeg.PATHSEG_MOVETO_ABS=2,window.SVGPathSeg.PATHSEG_MOVETO_REL=3,window.SVGPathSeg.PATHSEG_LINETO_ABS=4,window.SVGPathSeg.PATHSEG_LINETO_REL=5,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS=6,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL=7,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS=8,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL=9,window.SVGPathSeg.PATHSEG_ARC_ABS=10,window.SVGPathSeg.PATHSEG_ARC_REL=11,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS=12,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL=13,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS=14,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL=15,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19,window.SVGPathSeg.prototype._segmentChanged=function(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)},window.SVGPathSegClosePath=function(t){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CLOSEPATH,"z",t)},window.SVGPathSegClosePath.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegClosePath.prototype.toString=function(){return"[object SVGPathSegClosePath]"},window.SVGPathSegClosePath.prototype._asPathString=function(){return this.pathSegTypeAsLetter},window.SVGPathSegClosePath.prototype.clone=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathSegMovetoAbs=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_ABS,"M",t),this._x=e,this._y=n},window.SVGPathSegMovetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoAbs.prototype.toString=function(){return"[object SVGPathSegMovetoAbs]"},window.SVGPathSegMovetoAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegMovetoAbs.prototype.clone=function(){return new window.SVGPathSegMovetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegMovetoRel=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_REL,"m",t),this._x=e,this._y=n},window.SVGPathSegMovetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoRel.prototype.toString=function(){return"[object SVGPathSegMovetoRel]"},window.SVGPathSegMovetoRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegMovetoRel.prototype.clone=function(){return new window.SVGPathSegMovetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoAbs=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_ABS,"L",t),this._x=e,this._y=n},window.SVGPathSegLinetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoAbs.prototype.toString=function(){return"[object SVGPathSegLinetoAbs]"},window.SVGPathSegLinetoAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegLinetoAbs.prototype.clone=function(){return new window.SVGPathSegLinetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoRel=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_REL,"l",t),this._x=e,this._y=n},window.SVGPathSegLinetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoRel.prototype.toString=function(){return"[object SVGPathSegLinetoRel]"},window.SVGPathSegLinetoRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegLinetoRel.prototype.clone=function(){return new window.SVGPathSegLinetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicAbs=function(t,e,n,i,o,r,h){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,"C",t),this._x=e,this._y=n,this._x1=i,this._y1=o,this._x2=r,this._y2=h},window.SVGPathSegCurvetoCubicAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicAbs]"},window.SVGPathSegCurvetoCubicAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicAbs(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicRel=function(t,e,n,i,o,r,h){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,"c",t),this._x=e,this._y=n,this._x1=i,this._y1=o,this._x2=r,this._y2=h},window.SVGPathSegCurvetoCubicRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicRel]"},window.SVGPathSegCurvetoCubicRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicRel(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticAbs=function(t,e,n,i,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",t),this._x=e,this._y=n,this._x1=i,this._y1=o},window.SVGPathSegCurvetoQuadraticAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticAbs]"},window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticRel=function(t,e,n,i,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL,"q",t),this._x=e,this._y=n,this._x1=i,this._y1=o},window.SVGPathSegCurvetoQuadraticRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticRel]"},window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticRel(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcAbs=function(t,e,n,i,o,r,h,s){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_ABS,"A",t),this._x=e,this._y=n,this._r1=i,this._r2=o,this._angle=r,this._largeArcFlag=h,this._sweepFlag=s},window.SVGPathSegArcAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcAbs.prototype.toString=function(){return"[object SVGPathSegArcAbs]"},window.SVGPathSegArcAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y},window.SVGPathSegArcAbs.prototype.clone=function(){return new window.SVGPathSegArcAbs(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r1",{get:function(){return this._r1},set:function(t){this._r1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r2",{get:function(){return this._r2},set:function(t){this._r2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(t){this._largeArcFlag=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(t){this._sweepFlag=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcRel=function(t,e,n,i,o,r,h,s){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_REL,"a",t),this._x=e,this._y=n,this._r1=i,this._r2=o,this._angle=r,this._largeArcFlag=h,this._sweepFlag=s},window.SVGPathSegArcRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcRel.prototype.toString=function(){return"[object SVGPathSegArcRel]"},window.SVGPathSegArcRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y},window.SVGPathSegArcRel.prototype.clone=function(){return new window.SVGPathSegArcRel(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r1",{get:function(){return this._r1},set:function(t){this._r1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r2",{get:function(){return this._r2},set:function(t){this._r2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(t){this._largeArcFlag=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(t){this._sweepFlag=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalAbs=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS,"H",t),this._x=e},window.SVGPathSegLinetoHorizontalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalAbs]"},window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x},window.SVGPathSegLinetoHorizontalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalAbs(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalRel=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL,"h",t),this._x=e},window.SVGPathSegLinetoHorizontalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalRel.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalRel]"},window.SVGPathSegLinetoHorizontalRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x},window.SVGPathSegLinetoHorizontalRel.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalRel(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalAbs=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS,"V",t),this._y=e},window.SVGPathSegLinetoVerticalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalAbs]"},window.SVGPathSegLinetoVerticalAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._y},window.SVGPathSegLinetoVerticalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalAbs(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalRel=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL,"v",t),this._y=e},window.SVGPathSegLinetoVerticalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalRel.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalRel]"},window.SVGPathSegLinetoVerticalRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._y},window.SVGPathSegLinetoVerticalRel.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalRel(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothAbs=function(t,e,n,i,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",t),this._x=e,this._y=n,this._x2=i,this._y2=o},window.SVGPathSegCurvetoCubicSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"},window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothRel=function(t,e,n,i,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",t),this._x=e,this._y=n,this._x2=i,this._y2=o},window.SVGPathSegCurvetoCubicSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothRel]"},window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothAbs=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",t),this._x=e,this._y=n},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothRel=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",t),this._x=e,this._y=n},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(t,e){return new window.SVGPathSegMovetoAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegMovetoRel=function(t,e){return new window.SVGPathSegMovetoRel(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(t,e){return new window.SVGPathSegLinetoAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoRel=function(t,e){return new window.SVGPathSegLinetoRel(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(t,e,n,i,o,r){return new window.SVGPathSegCurvetoCubicAbs(void 0,t,e,n,i,o,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(t,e,n,i,o,r){return new window.SVGPathSegCurvetoCubicRel(void 0,t,e,n,i,o,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(t,e,n,i){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,t,e,n,i)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(t,e,n,i){return new window.SVGPathSegCurvetoQuadraticRel(void 0,t,e,n,i)},window.SVGPathElement.prototype.createSVGPathSegArcAbs=function(t,e,n,i,o,r,h){return new window.SVGPathSegArcAbs(void 0,t,e,n,i,o,r,h)},window.SVGPathElement.prototype.createSVGPathSegArcRel=function(t,e,n,i,o,r,h){return new window.SVGPathSegArcRel(void 0,t,e,n,i,o,r,h)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(t){return new window.SVGPathSegLinetoHorizontalAbs(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(t){return new window.SVGPathSegLinetoHorizontalRel(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(t){return new window.SVGPathSegLinetoVerticalAbs(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(t){return new window.SVGPathSegLinetoVerticalRel(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(t,e,n,i){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,t,e,n,i)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(t,e,n,i){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,t,e,n,i)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(t,e){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(t,e){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,t,e)},"getPathSegAtLength"in window.SVGPathElement.prototype||(window.SVGPathElement.prototype.getPathSegAtLength=function(t){if(void 0===t||!isFinite(t))throw"Invalid arguments.";var e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d",this.getAttribute("d"));var n=e.pathSegList.numberOfItems-1;if(n<=0)return 0;do{if(e.pathSegList.removeItem(n),t>e.getTotalLength())break;n--}while(n>0);return n})),"SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype||(window.SVGPathSegList=function(t){this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.classname="SVGPathSegList",Object.defineProperty(window.SVGPathSegList.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"pathSegList",{get:function(){return this._pathSegList||(this._pathSegList=new window.SVGPathSegList(this)),this._pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"normalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedNormalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),window.SVGPathSegList.prototype._checkPathSynchronizedToList=function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())},window.SVGPathSegList.prototype._updateListFromPathMutations=function(t){if(this._pathElement){var e=!1;t.forEach(function(t){"d"==t.attributeName&&(e=!0)}),e&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}},window.SVGPathSegList.prototype._writeListToPath=function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",window.SVGPathSegList._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.segmentChanged=function(t){this._writeListToPath()},window.SVGPathSegList.prototype.clear=function(){this._checkPathSynchronizedToList(),this._list.forEach(function(t){t._owningPathSegList=null}),this._list=[],this._writeListToPath()},window.SVGPathSegList.prototype.initialize=function(t){return this._checkPathSynchronizedToList(),this._list=[t],t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype._checkValidIndex=function(t){if(isNaN(t)||t<0||t>=this.numberOfItems)throw"INDEX_SIZE_ERR"},window.SVGPathSegList.prototype.getItem=function(t){return this._checkPathSynchronizedToList(),this._checkValidIndex(t),this._list[t]},window.SVGPathSegList.prototype.insertItemBefore=function(t,e){return this._checkPathSynchronizedToList(),e>this.numberOfItems&&(e=this.numberOfItems),t._owningPathSegList&&(t=t.clone()),this._list.splice(e,0,t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.replaceItem=function(t,e){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._checkValidIndex(e),this._list[e]=t,t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.removeItem=function(t){this._checkPathSynchronizedToList(),this._checkValidIndex(t);var e=this._list[t];return this._list.splice(t,1),this._writeListToPath(),e},window.SVGPathSegList.prototype.appendItem=function(t){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._list.push(t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList._pathSegArrayAsString=function(t){var e="",n=!0;return t.forEach(function(t){n?(n=!1,e+=t._asPathString()):e+=" "+t._asPathString()}),e},window.SVGPathSegList.prototype._parsePath=function(t){if(!t||0==t.length)return[];var e=this,n=function(){this.pathSegList=[]};n.prototype.appendSegment=function(t){this.pathSegList.push(t)};var i=function(t){this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=window.SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()};i.prototype._isCurrentSpace=function(){var t=this._string[this._currentIndex];return t<=" "&&(" "==t||"\n"==t||"\t"==t||"\r"==t||"\f"==t)},i.prototype._skipOptionalSpaces=function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex},i.prototype._skipOptionalSpacesOrDelimiter=function(){return!(this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&","!=this._string.charAt(this._currentIndex))&&(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&","==this._string.charAt(this._currentIndex)&&(this._currentIndex++,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},i.prototype.hasMoreData=function(){return this._currentIndex<this._endIndex},i.prototype.peekSegmentType=function(){var t=this._string[this._currentIndex];return this._pathSegTypeFromChar(t)},i.prototype._pathSegTypeFromChar=function(t){switch(t){case"Z":case"z":return window.SVGPathSeg.PATHSEG_CLOSEPATH;case"M":return window.SVGPathSeg.PATHSEG_MOVETO_ABS;case"m":return window.SVGPathSeg.PATHSEG_MOVETO_REL;case"L":return window.SVGPathSeg.PATHSEG_LINETO_ABS;case"l":return window.SVGPathSeg.PATHSEG_LINETO_REL;case"C":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;case"c":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;case"Q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return window.SVGPathSeg.PATHSEG_ARC_ABS
2
- ;case"a":return window.SVGPathSeg.PATHSEG_ARC_REL;case"H":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;case"v":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;case"S":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return window.SVGPathSeg.PATHSEG_UNKNOWN}},i.prototype._nextCommandHelper=function(t,e){return("+"==t||"-"==t||"."==t||t>="0"&&t<="9")&&e!=window.SVGPathSeg.PATHSEG_CLOSEPATH?e==window.SVGPathSeg.PATHSEG_MOVETO_ABS?window.SVGPathSeg.PATHSEG_LINETO_ABS:e==window.SVGPathSeg.PATHSEG_MOVETO_REL?window.SVGPathSeg.PATHSEG_LINETO_REL:e:window.SVGPathSeg.PATHSEG_UNKNOWN},i.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return!0;var t=this.peekSegmentType();return t==window.SVGPathSeg.PATHSEG_MOVETO_ABS||t==window.SVGPathSeg.PATHSEG_MOVETO_REL},i.prototype._parseNumber=function(){var t=0,e=0,n=1,i=0,o=1,r=1,h=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&"+"==this._string.charAt(this._currentIndex)?this._currentIndex++:this._currentIndex<this._endIndex&&"-"==this._string.charAt(this._currentIndex)&&(this._currentIndex++,o=-1),!(this._currentIndex==this._endIndex||(this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")&&"."!=this._string.charAt(this._currentIndex))){for(var s=this._currentIndex;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!=s)for(var a=this._currentIndex-1,S=1;a>=s;)e+=S*(this._string.charAt(a--)-"0"),S*=10;if(this._currentIndex<this._endIndex&&"."==this._string.charAt(this._currentIndex)){if(this._currentIndex++,this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)n*=10,i+=(this._string.charAt(this._currentIndex)-"0")/n,this._currentIndex+=1}if(this._currentIndex!=h&&this._currentIndex+1<this._endIndex&&("e"==this._string.charAt(this._currentIndex)||"E"==this._string.charAt(this._currentIndex))&&"x"!=this._string.charAt(this._currentIndex+1)&&"m"!=this._string.charAt(this._currentIndex+1)){if(this._currentIndex++,"+"==this._string.charAt(this._currentIndex)?this._currentIndex++:"-"==this._string.charAt(this._currentIndex)&&(this._currentIndex++,r=-1),this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)t*=10,t+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var u=e+i;if(u*=o,t&&(u*=Math.pow(10,r*t)),h!=this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),u}},i.prototype._parseArcFlag=function(){if(!(this._currentIndex>=this._endIndex)){var t=!1,e=this._string.charAt(this._currentIndex++);if("0"==e)t=!1;else{if("1"!=e)return;t=!0}return this._skipOptionalSpacesOrDelimiter(),t}},i.prototype.parseSegment=function(){var t=this._string[this._currentIndex],n=this._pathSegTypeFromChar(t);if(n==window.SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==window.SVGPathSeg.PATHSEG_UNKNOWN)return null;if(n=this._nextCommandHelper(t,this._previousCommand),n==window.SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=n,n){case window.SVGPathSeg.PATHSEG_MOVETO_REL:return new window.SVGPathSegMovetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_MOVETO_ABS:return new window.SVGPathSegMovetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_REL:return new window.SVGPathSegLinetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_ABS:return new window.SVGPathSegLinetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new window.SVGPathSegLinetoHorizontalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new window.SVGPathSegLinetoHorizontalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new window.SVGPathSegLinetoVerticalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new window.SVGPathSegLinetoVerticalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new window.SVGPathSegClosePath(e);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicRel(e,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicAbs(e,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicSmoothRel(e,i.x,i.y,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicSmoothAbs(e,i.x,i.y,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:i={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoQuadraticRel(e,i.x,i.y,i.x1,i.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:i={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoQuadraticAbs(e,i.x,i.y,i.x1,i.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new window.SVGPathSegCurvetoQuadraticSmoothRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new window.SVGPathSegCurvetoQuadraticSmoothAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_ARC_REL:i={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcRel(e,i.x,i.y,i.x1,i.y1,i.arcAngle,i.arcLarge,i.arcSweep);case window.SVGPathSeg.PATHSEG_ARC_ABS:i={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcAbs(e,i.x,i.y,i.x1,i.y1,i.arcAngle,i.arcLarge,i.arcSweep);default:throw"Unknown path seg type."}};var o=new n,r=new i(t);if(!r.initialCommandIsMoveTo())return[];for(;r.hasMoreData();){var h=r.parseSegment();if(!h)return[];o.appendSegment(h)}return o.pathSegList})}}}();
3
- svgedit={NS:{HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://web-edit.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"}},svgedit.getReverseNS=function(){"use strict";var t={};return $.each(this.NS,function(w,e){t[e]=w.toLowerCase()}),t};
4
- var mybrowser=function(){"use strict";return{initBrowser:function(){svgedit.browser||(svgedit.browser={});var e=svgedit.NS,t=!!document.createElementNS&&!!document.createElementNS(e.SVG,"svg").createSVGRect;if(svgedit.browser.supportsSvg=function(){return t},svgedit.browser.supportsSvg()){var r,n=navigator.userAgent,o=document.createElementNS(e.SVG,"svg"),s=!!window.opera,i=n.indexOf("AppleWebKit")>=0,u=n.indexOf("Gecko/")>=0,c=n.indexOf("MSIE")>=0,d=n.indexOf("Chrome/")>=0,a=n.indexOf("Windows")>=0,m=n.indexOf("Macintosh")>=0,p="ontouchstart"in window,v=!!o.querySelector,l=!!document.evaluate,g=function(){var t=document.createElementNS(e.SVG,"path");t.setAttribute("d","M0,0 10,10");var r=t.pathSegList,n=t.createSVGPathSegLinetoAbs(5,5);try{return r.replaceItem(n,1),!0}catch(e){}return!1}(),S=function(){var t=document.createElementNS(e.SVG,"path");t.setAttribute("d","M0,0 10,10");var r=t.pathSegList,n=t.createSVGPathSegLinetoAbs(5,5);try{return r.insertItemBefore(n,1),!0}catch(e){}return!1}(),f=function(){var t=document.createElementNS(e.SVG,"svg"),r=document.createElementNS(e.SVG,"svg");document.documentElement.appendChild(t),r.setAttribute("x",5),t.appendChild(r);var n=document.createElementNS(e.SVG,"text");n.textContent="a",r.appendChild(n);var o=n.getStartPositionOfChar(0).x;return document.documentElement.removeChild(t),0===o}(),b=function(){var t=document.createElementNS(e.SVG,"svg");document.documentElement.appendChild(t);var r=document.createElementNS(e.SVG,"path");r.setAttribute("d","M0,0 C0,0 10,10 10,0"),t.appendChild(r);var n=r.getBBox();return document.documentElement.removeChild(t),n.height>4&&n.height<5}(),h=function(){var t=document.createElementNS(e.SVG,"svg");document.documentElement.appendChild(t);var r=document.createElementNS(e.SVG,"path");r.setAttribute("d","M0,0 10,0");var n=document.createElementNS(e.SVG,"path");n.setAttribute("d","M5,0 15,0");var o=document.createElementNS(e.SVG,"g");o.appendChild(r),o.appendChild(n),t.appendChild(o);var s=o.getBBox();return document.documentElement.removeChild(t),15==s.width}(),w=s,E=function(){var t=document.createElementNS(e.SVG,"rect");t.setAttribute("x",.1);var r=t.cloneNode(!1),n=-1==r.getAttribute("x").indexOf(",");return n||$.alert("NOTE: This version of Opera is known to contain bugs."),n}(),G=(r=document.createElementNS(e.SVG,"rect"),r.setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===r.style.vectorEffect),N=function(){var t=document.createElementNS(e.SVG,"rect"),r=t.transform.baseVal,n=o.createSVGTransform();return r.appendItem(n),r.getItem(0)==n}();svgedit.browser.isOpera=function(){return s},svgedit.browser.isWebkit=function(){return i},svgedit.browser.isGecko=function(){return u},svgedit.browser.isIE=function(){return c},svgedit.browser.isChrome=function(){return d},svgedit.browser.isWindows=function(){return a},svgedit.browser.isMac=function(){return m},svgedit.browser.isTouch=function(){return p},svgedit.browser.supportsSelectors=function(){return v},svgedit.browser.supportsXpath=function(){return l},svgedit.browser.supportsPathReplaceItem=function(){return g},svgedit.browser.supportsPathInsertItemBefore=function(){return S},svgedit.browser.supportsPathBBox=function(){return b},svgedit.browser.supportsHVLineContainerBBox=function(){return h},svgedit.browser.supportsGoodTextCharPos=function(){return f},svgedit.browser.supportsEditableText=function(){return w},svgedit.browser.supportsGoodDecimals=function(){return E},svgedit.browser.supportsNonScalingStroke=function(){return G},svgedit.browser.supportsNativeTransformLists=function(){return N}}else window.location="browser-not-supported.html"}}}();
5
- (function(){"use strict";function i(n){var t=n.matrix,i="",f,u,r;switch(n.type){case 1:i="matrix("+[t.a,t.b,t.c,t.d,t.e,t.f].join(",")+")";break;case 2:i="translate("+t.e+","+t.f+")";break;case 3:i=t.a==t.d?"scale("+t.a+")":"scale("+t.a+","+t.d+")";break;case 4:f=0;u=0;n.angle!=0&&(r=1-t.a,u=(r*t.f+t.b*t.e)/(r*r+t.b*t.b),f=(t.e-t.b*u)/r);i="rotate("+n.angle+" "+f+","+u+")"}return i}var t,n;svgedit.transformlist||(svgedit.transformlist={});t=document.createElementNS(svgedit.NS.SVG,"svg");n={};svgedit.transformlist.SVGTransformList=function(r){this._elem=r||null;this._xforms=[];this._update=function(){for(var r="",f=t.createSVGMatrix(),u,n=0;n<this.numberOfItems;++n)u=this._list.getItem(n),r+=i(u)+" ";this._elem.setAttribute("transform",r)};this._list=this;this._init=function(){var u=this._elem.getAttribute("transform"),e,r;if(u)for(e=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,r=!0;r;)if(r=u.match(e),u=u.replace(e,""),r&&r[1]){var l=r[1],h=l.split(/\s*\(/),i=h[0],o=h[1].match(/\s*(.*?)\s*\)/);o[1]=o[1].replace(/(\d)-/g,"$1 -");var f=o[1].split(/[, ]+/),a="abcdef".split(""),c=t.createSVGMatrix();$.each(f,function(n,t){f[n]=parseFloat(t);i=="matrix"&&(c[a[n]]=f[n])});var s=t.createSVGTransform(),v="set"+i.charAt(0).toUpperCase()+i.slice(1),n=i=="matrix"?[c]:f;i=="scale"&&n.length==1?n.push(n[0]):i=="translate"&&n.length==1?n.push(0):i=="rotate"&&n.length==1&&n.push(0,0);s[v].apply(s,n);this._list.appendItem(s)}};this._removeFromOtherLists=function(t){var u,f,r,i,e;if(t){u=!1;for(f in n){for(r=n[f],i=0,e=r._xforms.length;i<e;++i)if(r._xforms[i]==t){u=!0;r.removeItem(i);break}if(u)break}}};this.numberOfItems=0;this.clear=function(){this.numberOfItems=0;this._xforms=[]};this.initialize=function(n){this.numberOfItems=1;this._removeFromOtherLists(n);this._xforms=[n]};this.getItem=function(n){if(n<this.numberOfItems&&n>=0)return this._xforms[n];throw{code:1};};this.insertItemBefore=function(n,t){var u=null,r,i,f;if(t>=0)if(t<this.numberOfItems){for(this._removeFromOtherLists(n),r=new Array(this.numberOfItems+1),i=0;i<t;++i)r[i]=this._xforms[i];for(r[i]=n,f=i+1;i<this.numberOfItems;++f,++i)r[f]=this._xforms[i];this.numberOfItems++;this._xforms=r;u=n;this._list._update()}else u=this._list.appendItem(n);return u};this.replaceItem=function(n,t){var i=null;return t<this.numberOfItems&&t>=0&&(this._removeFromOtherLists(n),this._xforms[t]=n,i=n,this._list._update()),i};this.removeItem=function(n){if(n<this.numberOfItems&&n>=0){for(var u=this._xforms[n],r=new Array(this.numberOfItems-1),i,t=0;t<n;++t)r[t]=this._xforms[t];for(i=t;i<this.numberOfItems-1;++i,++t)r[i]=this._xforms[t+1];return this.numberOfItems--,this._xforms=r,this._list._update(),u}throw{code:1};};this.appendItem=function(n){return this._removeFromOtherLists(n),this._xforms.push(n),this.numberOfItems++,this._list._update(),n}};svgedit.transformlist.resetListMap=function(){n={}};svgedit.transformlist.removeElementFromListMap=function(t){t.id&&n[t.id]&&delete n[t.id]};svgedit.transformlist.getTransformList=function(t){if(!svgedit.browser.supportsNativeTransformLists()){var i=t.id||"temp",r=n[i];return r&&i!=="temp"||(n[i]=new svgedit.transformlist.SVGTransformList(t),n[i]._init(),r=n[i]),r}return t.transform?t.transform.baseVal:t.gradientTransform?t.gradientTransform.baseVal:t.patternTransform?t.patternTransform.baseVal:null}})();
6
- (function(){"use strict";var f;svgedit.units||(svgedit.units={});var i=svgedit.NS,r=["x","x1","cx","rx","width"],u=["y","y1","cy","ry","height"],e=["r","radius"].concat(r,u),n,t={};svgedit.units.init=function(r){var e,u,o,f;n=r;e=document.createElementNS(i.SVG,"svg");document.body.appendChild(e);u=document.createElementNS(i.SVG,"rect");u.setAttribute("width","1em");u.setAttribute("height","1ex");u.setAttribute("x","1in");e.appendChild(u);o=u.getBBox();document.body.removeChild(e);f=o.x;t={em:o.width,ex:o.height,"in":f,cm:f/2.54,mm:f/25.4,pt:f/72,pc:f/6,px:1,"%":0}};svgedit.units.getTypeMap=function(){return t};svgedit.units.shortFloat=function(t){var i=n.getRoundDigits();return isNaN(t)?$.isArray(t)?svgedit.units.shortFloat(t[0])+","+svgedit.units.shortFloat(t[1]):parseFloat(t).toFixed(i)-0:+(+t).toFixed(i)};svgedit.units.convertUnit=function(i,r){return r=r||n.getBaseUnit(),svgedit.units.shortFloat(i/t[r])};svgedit.units.setUnitAttr=function(n,t,i){n.setAttribute(t,i)};f={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(i){var c=i.tagName,s=n.getBaseUnit(),e=f[c],h,r,o,u;if(e)for(h=e.length,r=0;r<h;r++)o=e[r],u=i.getAttribute(o),u&&(isNaN(u)||i.setAttribute(o,u/t[s]+s))};svgedit.units.convertToNum=function(i,f){var e,o,s,h;return isNaN(f)?f.substr(-1)==="%"?(e=f.substr(0,f.length-1)/100,o=n.getWidth(),s=n.getHeight(),r.indexOf(i)>=0)?e*o:u.indexOf(i)>=0?e*s:e*Math.sqrt(o*o+s*s)/Math.sqrt(2):(h=f.substr(-2),e=f.substr(0,f.length-2),e*t[h]):+f};svgedit.units.isValidUnit=function(i,r,u){var f=!1,o,s;if(e.indexOf(i)>=0)isNaN(r)?(r=r.toLowerCase(),$.each(t,function(n){if(!f){var t=new RegExp("^-?[\\d\\.]+"+n+"$");t.test(r)&&(f=!0)}})):f=!0;else if(i=="id"){o=!1;try{s=n.getElement(r);o=s==null||s===u}catch(h){}return o}return f=!0}})();
7
- (function(){"use strict";svgedit.math||(svgedit.math={});var n=1e-14,t=document.createElementNS(svgedit.NS.SVG,"svg");svgedit.math.transformPoint=function(n,t,i){return{x:i.a*n+i.c*t+i.e,y:i.b*n+i.d*t+i.f}};svgedit.math.isIdentity=function(n){return n.a===1&&n.b===0&&n.c===0&&n.d===1&&n.e===0&&n.f===0};svgedit.math.matrixMultiply=function(){for(var i=arguments,r=i.length,t=i[r-1],u;r-->1;)u=i[r-1],t=u.multiply(t);return Math.abs(t.a)<n&&(t.a=0),Math.abs(t.b)<n&&(t.b=0),Math.abs(t.c)<n&&(t.c=0),Math.abs(t.d)<n&&(t.d=0),Math.abs(t.e)<n&&(t.e=0),Math.abs(t.f)<n&&(t.f=0),t};svgedit.math.hasMatrixTransform=function(n){var t,i;if(!n)return!1;for(t=n.numberOfItems;t--;)if(i=n.getItem(t),i.type==1&&!svgedit.math.isIdentity(i.matrix))return!0;return!1};svgedit.math.transformBox=function(n,t,i,r,u){var h=svgedit.math.transformPoint,f=h(n,t,u),e=h(n+i,t,u),o=h(n,t+r,u),s=h(n+i,t+r,u),c=Math.min(f.x,e.x,o.x,s.x),a=Math.max(f.x,e.x,o.x,s.x),l=Math.min(f.y,e.y,o.y,s.y),v=Math.max(f.y,e.y,o.y,s.y);return{tl:f,tr:e,bl:o,br:s,aabox:{x:c,y:l,width:a-c,height:v-l}}};svgedit.math.transformListToTransform=function(n,i,r){var e,f,u,o;if(n==null)return t.createSVGTransformFromMatrix(t.createSVGMatrix());for(i=i||0,r=r||n.numberOfItems-1,i=parseInt(i,10),r=parseInt(r,10),i>r&&(e=r,r=i,i=e),f=t.createSVGMatrix(),u=i;u<=r;++u)o=u>=0&&u<n.numberOfItems?n.getItem(u).matrix:t.createSVGMatrix(),f=svgedit.math.matrixMultiply(f,o);return t.createSVGTransformFromMatrix(f)};svgedit.math.getMatrix=function(n){var t=svgedit.transformlist.getTransformList(n);return svgedit.math.transformListToTransform(t).matrix};svgedit.math.snapToAngle=function(n,t,i,r){var o=Math.PI/4,u=i-n,f=r-t,h=Math.atan2(f,u),s=Math.sqrt(u*u+f*f),e=Math.round(h/o)*o;return{x:n+s*Math.cos(e),y:t+s*Math.sin(e),a:e}};svgedit.math.rectsIntersect=function(n,t){return t.x<n.x+n.width&&t.x+t.width>n.x&&t.y<n.y+n.height&&t.y+t.height>n.y}})();
8
- var mysvgutils=function(t){"use strict";return{initSvgutils:function(){function e(t){if(svgedit.browser.supportsHVLineContainerBBox())try{return t.getBBox()}catch(t){}var e,i,r=$.data(t,"ref"),n=null;r?(i=$(r).children().clone().attr("visibility","hidden"),$(l).append(i),n=i.filter("line, path")):n=$(t).find("line, path");var s=!1;if(n.length)if(n.each(function(){var t=this.getBBox();t.width&&t.height||(s=!0)}),s){var o=r?i:$(t).children();e=getStrokedBBox(o)}else e=t.getBBox();else e=t.getBBox();return r&&i.remove(),e}svgedit.utilities||(svgedit.utilities={});var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=svgedit.NS,n="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use",s=n.split(","),o=null,u=null,B=null,l=null;svgedit.utilities.init=function(t){o=t,u=t.getDOMDocument(),B=t.getDOMContainer(),l=t.getSVGRoot()},svgedit.utilities.toXml=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/,"&#x27;")},svgedit.utilities.fromXml=function(t){return $("<p/>").html(t).text()},svgedit.utilities.encode64=function(t){if(t=svgedit.utilities.encodeUTF8(t),window.btoa)return window.btoa(t);var e,r,n,s,o,u,B,l=[];l.length=4*Math.floor((t.length+2)/3);var a=0,D=0;do{e=t.charCodeAt(a++),r=t.charCodeAt(a++),n=t.charCodeAt(a++),s=e>>2,o=(3&e)<<4|r>>4,u=(15&r)<<2|n>>6,B=63&n,isNaN(r)?u=B=64:isNaN(n)&&(B=64),l[D++]=i.charAt(s),l[D++]=i.charAt(o),l[D++]=i.charAt(u),l[D++]=i.charAt(B)}while(a<t.length);return l.join("")},svgedit.utilities.decode64=function(t){if(window.atob)return svgedit.utilities.decodeUTF8(window.atob(t));var e,r,n,s,o,u="",B="",l="",a=0;t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{n=i.indexOf(t.charAt(a++)),s=i.indexOf(t.charAt(a++)),o=i.indexOf(t.charAt(a++)),l=i.indexOf(t.charAt(a++)),e=n<<2|s>>4,r=(15&s)<<4|o>>2,B=(3&o)<<6|l,u+=String.fromCharCode(e),64!=o&&(u+=String.fromCharCode(r)),64!=l&&(u+=String.fromCharCode(B)),e=r=B="",n=s=o=l=""}while(a<t.length);return svgedit.utilities.decodeUTF8(u)},svgedit.utilities.decodeUTF8=function(t){return decodeURIComponent(escape(t))},svgedit.utilities.encodeUTF8=function(t){return unescape(encodeURIComponent(t))},svgedit.utilities.crc32=function(t){t=svgedit.utilities.encodeUTF8(t);var e="00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D",i=0,r=0,n=0;i^=-1;for(var s=0,o=t.length;s<o;s++)n=255&(i^t.charCodeAt(s)),r="0x"+e.substr(9*n,8),i=i>>>8^r;return-1^i},svgedit.utilities.convertToXMLReferences=function(t){var e,i="";for(e=0;e<t.length;e++){var r=t.charCodeAt(e);r<128?i+=t[e]:r>127&&(i+="&#"+r+";")}return i},svgedit.utilities.text2xml=function(t){var e,i;t.indexOf("<svg:svg")>=0&&(t=t.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns"));try{i=window.DOMParser?new DOMParser:new ActiveXObject("Microsoft.XMLDOM"),i.async=!1}catch(t){throw new Error("XML Parser could not be instantiated")}try{e=i.loadXML?!!i.loadXML(t)&&i:i.parseFromString(t,"text/xml")}catch(t){throw new Error("Error parsing XML string")}return e},svgedit.utilities.bboxToObj=function(t){return{x:t.x,y:t.y,width:t.width,height:t.height}},svgedit.utilities.walkTree=function(t,e){if(t&&1==t.nodeType){e(t);for(var i=t.childNodes.length;i--;)svgedit.utilities.walkTree(t.childNodes.item(i),e)}},svgedit.utilities.walkTreePost=function(t,e){if(t&&1==t.nodeType){for(var i=t.childNodes.length;i--;)svgedit.utilities.walkTree(t.childNodes.item(i),e);e(t)}},svgedit.utilities.getUrlFromAttr=function(t){if(t){if(0===t.indexOf('url("'))return t.substring(5,t.indexOf('"',6));if(0===t.indexOf("url('"))return t.substring(5,t.indexOf("'",6));if(0===t.indexOf("url("))return t.substring(4,t.indexOf(")"))}return null},svgedit.utilities.getHref=function(t){return t.getAttributeNS(r.XLINK,"href")},svgedit.utilities.setHref=function(t,e){t.setAttributeNS(r.XLINK,"xlink:href",e)},svgedit.utilities.findDefs=function(){var t=o.getSVGContent(),e=t.getElementsByTagNameNS(r.SVG,"defs");return e.length>0?e=e[0]:(e=t.ownerDocument.createElementNS(r.SVG,"defs"),t.firstChild?t.insertBefore(e,t.firstChild.nextSibling):t.appendChild(e)),e},svgedit.utilities.getPathBBox=function(e){var i,r=e.pathSegList,n=r.numberOfItems,s=[[],[]],o=r.getItem(0),u=[o.x,o.y];for(i=0;i<n;i++){var B=r.getItem(i);if(B.x!==t)if(s[0].push(u[0]),s[1].push(u[1]),B.x1){var l,a=[B.x1,B.y1],D=[B.x2,B.y2],g=[B.x,B.y];for(l=0;l<2;l++){var d=function(t){return Math.pow(1-t,3)*u[l]+3*Math.pow(1-t,2)*t*a[l]+3*(1-t)*Math.pow(t,2)*D[l]+Math.pow(t,3)*g[l]},c=6*u[l]-12*a[l]+6*D[l],A=-3*u[l]+9*a[l]-9*D[l]+3*g[l],C=3*a[l]-3*u[l];if(0!=A){var f=Math.pow(c,2)-4*C*A;if(!(f<0)){var v=(-c+Math.sqrt(f))/(2*A);0<v&&v<1&&s[l].push(d(v));var E=(-c-Math.sqrt(f))/(2*A);0<E&&E<1&&s[l].push(d(E))}}else{if(0==c)continue;var F=-C/c;0<F&&F<1&&s[l].push(d(F))}}u=g}else s[0].push(B.x),s[1].push(B.y)}var h=Math.min.apply(null,s[0]),p=Math.max.apply(null,s[0])-h,x=Math.min.apply(null,s[1]),m=Math.max.apply(null,s[1])-x;return{x:h,y:x,width:p,height:m}},svgedit.utilities.getBBox=function(t){var i=t||o.geSelectedElements()[0];if(1!=t.nodeType)return null;var r=null,n=i.nodeName;switch(n){case"text":""===i.textContent?(i.textContent="a",r=i.getBBox(),i.textContent=""):i.getBBox&&(r=i.getBBox());break;case"path":svgedit.browser.supportsPathBBox()?i.getBBox&&(r=i.getBBox()):r=svgedit.utilities.getPathBBox(i);break;case"g":case"a":r=e(i);break;default:if("use"===n&&(r=e(i,!0)),"use"===n||"foreignObject"===n&&svgedit.browser.isWebkit()){if(r||(r=i.getBBox()),!svgedit.browser.isWebkit()){var u={};u.width=r.width,u.height=r.height,u.x=r.x+parseFloat(i.getAttribute("x")||0),u.y=r.y+parseFloat(i.getAttribute("y")||0),r=u}}else if(~s.indexOf(n))if(i)r=i.getBBox();else{var B=$(i).closest("foreignObject");B.length&&B[0].getBBox&&(r=B[0].getBBox())}}return r&&(r=svgedit.utilities.bboxToObj(r)),r},svgedit.utilities.getRotationAngle=function(t,e){var i=t||o.getSelectedElements()[0],r=svgedit.transformlist.getTransformList(i);if(!r)return 0;var n,s=r.numberOfItems;for(n=0;n<s;++n){var u=r.getItem(n);if(4==u.type)return e?u.angle*Math.PI/180:u.angle}return 0},svgedit.utilities.getRefElem=function(t){return svgedit.utilities.getElem(svgedit.utilities.getUrlFromAttr(t).substr(1))},svgedit.browser.supportsSelectors()?svgedit.utilities.getElem=function(t){return l.querySelector("#"+t)}:svgedit.browser.supportsXpath()?svgedit.utilities.getElem=function(t){return u.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+t+'"]',B,function(){return svgedit.NS.SVG},9,null).singleNodeValue}:svgedit.utilities.getElem=function(t){return $(l).find("[id="+t+"]")[0]},svgedit.utilities.assignAttributes=function(t,e,i,n){var s;for(s in e){var o="xml:"===s.substr(0,4)?r.XML:"xlink:"===s.substr(0,6)?r.XLINK:null;svgedit.utilities.isNullish(e[s])?o?t.removeAttributeNS(o,s):t.removeAttribute(s):o?t.setAttributeNS(o,s,e[s]):n?svgedit.units.setUnitAttr(t,s,e[s]):t.setAttribute(s,e[s])}},svgedit.utilities.cleanupElement=function(t){var e,i={"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};for(e in i){var r=i[e];t.getAttribute(e)==r&&t.removeAttribute(e)}},svgedit.utilities.snapToGrid=function(t){var e=o.getSnappingStep(),i=o.getBaseUnit();return"px"!==i&&(e*=svgedit.units.getTypeMap()[i]),t=Math.round(t/e)*e,t},svgedit.utilities.preg_quote=function(t,e){return String(t).replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\"+(e||"")+"-]","g"),"\\$&")},svgedit.utilities.executeAfterLoads=function(t,e,i){return function(){function r(){i.apply(null,n)}var n=arguments;window[t]?r():e.reduceRight(function(t,e){return function(){$.getScript(e,t)}},r)()}},svgedit.utilities.buildCanvgCallback=function(t){return svgedit.utilities.executeAfterLoads("canvg",["canvg/rgbcolor.js","canvg/canvg.js"],t)},svgedit.utilities.buildJSPDFCallback=function(e){return svgedit.utilities.executeAfterLoads("RGBColor",["canvg/rgbcolor.js"],function(){var i=[];RGBColor&&RGBColor.ok!==t||i.push("canvg/rgbcolor.js"),svgedit.utilities.executeAfterLoads("jsPDF",i.concat("jspdf/underscore-min.js","jspdf/jspdf.min.js","jspdf/jspdf.plugin.svgToPdf.js"),e)()})},svgedit.utilities.takePil=function(){var t=new Date,e=t.getFullYear(),i=t.getDay();Math.floor(3*Math.random());return e%2>0&&Math.floor(i/2),!0},svgedit.utilities.isNullish=function(t){return null==t}}}}(mysvgutils||{});
9
- (function(){"use strict";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(t,e,i,n){this.elem=t,this.text=n?"Move "+t.tagName+" to "+n:"Move "+t.tagName,this.oldNextSibling=e,this.oldParent=i,this.newNextSibling=t.nextSibling,this.newParent=t.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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this),this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)},svgedit.history.MoveElementCommand.prototype.unapply=function(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this),this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)},svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]},svgedit.history.InsertElementCommand=function(t,e){this.elem=t,this.text=e||"Create "+t.tagName,this.parent=t.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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this),this.elem=this.parent.insertBefore(this.elem,this.nextSibling),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)},svgedit.history.InsertElementCommand.prototype.unapply=function(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this),this.parent=this.elem.parentNode,this.elem=this.elem.parentNode.removeChild(this.elem),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)},svgedit.history.InsertElementCommand.prototype.elements=function(){return[this.elem]},svgedit.history.RemoveElementCommand=function(t,e,i,n){this.elem=t,this.text=n||"Delete "+t.tagName,this.nextSibling=e,this.parent=i,svgedit.transformlist.removeElementFromListMap(t)},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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this),svgedit.transformlist.removeElementFromListMap(this.elem),this.parent=this.elem.parentNode,this.elem=this.parent.removeChild(this.elem),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)},svgedit.history.RemoveElementCommand.prototype.unapply=function(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this),svgedit.transformlist.removeElementFromListMap(this.elem),null==this.nextSibling&&window.console&&console.log("Error: reference element was lost"),this.parent.insertBefore(this.elem,this.nextSibling),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)},svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]},svgedit.history.ChangeElementCommand=function(t,e,i){this.elem=t,this.text=i?"Change "+t.tagName+" "+i:"Change "+t.tagName,this.newValues={},this.oldValues=e;var n;for(n in e)"#text"==n?this.newValues[n]=t.textContent:"#href"==n?this.newValues[n]=svgedit.utilities.getHref(t):this.newValues[n]=t.getAttribute(n)},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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var e,i=!1;for(e in this.newValues)this.newValues[e]?"#text"==e?this.elem.textContent=this.newValues[e]:"#href"==e?svgedit.utilities.setHref(this.elem,this.newValues[e]):this.elem.setAttribute(e,this.newValues[e]):"#text"==e?this.elem.textContent="":(this.elem.setAttribute(e,""),this.elem.removeAttribute(e)),"transform"==e&&(i=!0);if(!i){var n=svgedit.utilities.getRotationAngle(this.elem);if(n){var s=elem.getBBox(),o=s.x+s.width/2,r=s.y+s.height/2,h=["rotate(",n," ",o,",",r,")"].join("");h!=elem.getAttribute("transform")&&elem.setAttribute("transform",h)}}return t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this),!0},svgedit.history.ChangeElementCommand.prototype.unapply=function(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var e,i=!1;for(e in this.oldValues)this.oldValues[e]?"#text"==e?this.elem.textContent=this.oldValues[e]:"#href"==e?svgedit.utilities.setHref(this.elem,this.oldValues[e]):this.elem.setAttribute(e,this.oldValues[e]):"#text"==e?this.elem.textContent="":this.elem.removeAttribute(e),"transform"==e&&(i=!0);if(!i){var n=svgedit.utilities.getRotationAngle(this.elem);if(n){var s=elem.getBBox(),o=s.x+s.width/2,r=s.y+s.height/2,h=["rotate(",n," ",o,",",r,")"].join("");h!=elem.getAttribute("transform")&&elem.setAttribute("transform",h)}}return svgedit.transformlist.removeElementFromListMap(this.elem),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this),!0},svgedit.history.ChangeElementCommand.prototype.elements=function(){return[this.elem]},svgedit.history.BatchCommand=function(t){this.text=t||"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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var e,i=this.stack.length;for(e=0;e<i;++e)this.stack[e].apply(t);t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)},svgedit.history.BatchCommand.prototype.unapply=function(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var e;for(e=this.stack.length-1;e>=0;e--)this.stack[e].unapply(t);t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)},svgedit.history.BatchCommand.prototype.elements=function(){for(var t=[],e=this.stack.length;e--;)for(var i=this.stack[e].elements(),n=i.length;n--;)t.indexOf(i[n])==-1&&t.push(i[n]);return t},svgedit.history.BatchCommand.prototype.addSubCommand=function(t){this.stack.push(t)},svgedit.history.BatchCommand.prototype.isEmpty=function(){return 0===this.stack.length},svgedit.history.UndoManager=function(t){this.handler_=t||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(){if(this.undoStackPointer>0){var t=this.undoStack[--this.undoStackPointer];t.unapply(this.handler_)}},svgedit.history.UndoManager.prototype.redo=function(){if(this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0){var t=this.undoStack[this.undoStackPointer++];t.apply(this.handler_)}},svgedit.history.UndoManager.prototype.addCommandToHistory=function(t){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(t),this.undoStackPointer=this.undoStack.length},svgedit.history.UndoManager.prototype.beginUndoableChange=function(t,e){for(var i=++this.undoChangeStackPointer,n=e.length,s=new Array(n),o=new Array(n);n--;){var r=e[n];null!=r&&(o[n]=r,s[n]=r.getAttribute(t))}this.undoableChangeStack[i]={attrName:t,oldValues:s,elements:o}},svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var t=this.undoChangeStackPointer--,e=this.undoableChangeStack[t],i=e.elements.length,n=e.attrName,s=new svgedit.history.BatchCommand("Change "+n);i--;){var o=e.elements[i];if(null!=o){var r={};r[n]=e.oldValues[i],r[n]!=o.getAttribute(n)&&s.addSubCommand(new svgedit.history.ChangeElementCommand(o,r,n))}}return this.undoableChangeStack[t]=null,s}})();
10
- (function(){"use strict";svgedit.sanitize||(svgedit.sanitize={});var e=svgedit.NS,t=svgedit.getReverseNS(),s={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class","clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters","filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["type","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:["type","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","type","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","type","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"],script:[],input:["class","id","type","style","value"],INPUT:["class","id","type","style","value"],textarea:["class","id","type","style","value"],TEXTAREA:["class","id","type","style","value"],select:["class","id","type","style"],SELECT:["class","id","type","style"],option:["value","text"],OPTION:["value","text"],button:["class","color","style","id"],BUTTON:["class","color","style","id"],span:["class","color","style","id"],SPAN:["class","color","style","id"],div:["class","style","id"],DIV:["class","style","id"],label:["class","style","id"],LABEL:["class","style","id"],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:[]},i={};$.each(s,function(t,s){var r={};$.each(s,function(t,s){if(s.indexOf(":")>=0){var i=s.split(":");r[i[1]]=e[i[0].toUpperCase()]}else r[s]="xmlns"==s?e.XMLNS:null}),i[t]=r}),svgedit.sanitize.sanitizeSvg=function(r){if(3==r.nodeType&&(r.nodeValue=r.nodeValue.replace(/^\s+|\s+$/g,""),0===r.nodeValue.length&&r.parentNode.removeChild(r)),1==r.nodeType){var a=r.ownerDocument,l=r.parentNode;if(a&&l){var o=s[r.nodeName],n=i[r.nodeName];if(void 0!==o){if("foreignObject"===l.nodeName||l.parentNode&&"foreignObject"===l.parentNode.nodeName){for(var d=document.createElement(r.tagName),c=r.attributes.length;c--;){var m=r.attributes.item(c);d.setAttribute(m.nodeName,m.value)}d.innerHTML=r.innerHTML,l.removeChild(r),l.appendChild(d),r=d}var f=[];for(c=r.attributes.length;c--;){m=r.attributes.item(c);var p=m.nodeName,y=m.localName,u=m.namespaceURI;if(n.hasOwnProperty(y)&&u==n[y]&&u!=e.XMLNS||u==e.XMLNS&&t[m.value]||(0===p.indexOf("se:")&&f.push([p,m.value]),r.removeAttributeNS(u,y)),svgedit.browser.isGecko())switch(p){case"transform":case"gradientTransform":case"patternTransform":var k=m.value.replace(/(\d)-/g,"$1 -");r.setAttribute(p,k)}if("style"==p&&"foreignObject"!==l.nodeName){for(var h=m.value.split(";"),g=h.length;g--;){var v=h[g].split(":"),x=$.trim(v[0]),w=$.trim(v[1]);o.indexOf(x)>=0&&r.setAttribute(x,w)}r.removeAttribute("style")}}$.each(f,function(t,s){r.setAttributeNS(e.SE,s[0],s[1])});var L=svgedit.utilities.getHref(r);if(L&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(r.nodeName)>=0&&"#"!=L[0]&&(svgedit.utilities.setHref(r,""),r.removeAttributeNS(e.XLINK,"href")),"use"==r.nodeName&&!svgedit.utilities.getHref(r))return void l.removeChild(r);for($.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],function(e,t){var s=r.getAttribute(t);s&&(s=svgedit.utilities.getUrlFromAttr(s),s&&"#"!==s[0]&&(r.setAttribute(t,""),r.removeAttribute(t)))}),c=r.childNodes.length;c--;)svgedit.sanitize.sanitizeSvg(r.childNodes.item(c))}else{for(var N=[];r.hasChildNodes();)N.push(l.insertBefore(r.firstChild,r));for(l.removeChild(r),c=N.length;c--;)svgedit.sanitize.sanitizeSvg(N[c])}}}}})();
11
- var svgedit=svgedit||{};(function(){"use strict";svgedit.coords||(svgedit.coords={});var t=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],n=null;svgedit.coords.init=function(t){n=t};svgedit.coords.remapElement=function(i,r,u){for(var v,h=function(n,t){return svgedit.math.transformPoint(n,t,u)},p=function(n){return u.a*n},w=function(n){return u.d*n},kt=n.getGridSnapping()&&i.parentNode.parentNode.localName==="svg",tt=function(){var n;if(kt)for(n in r)r[n]=svgedit.utilities.snapToGrid(r[n]);svgedit.utilities.assignAttributes(i,r,1e3,!0)},it=svgedit.utilities.getBBox(i),rt,lt,o,at,vt,yt,pt,b,y,k,ft,et,d,s,a,g,c,ot,st,f,ht,ct,nt,wt,bt,l,e=0;e<2;e++)v=e===0?"fill":"stroke",rt=i.getAttribute(v),rt&&rt.indexOf("url(")===0&&(u.a<0||u.d<0)&&(lt=svgedit.utilities.getRefElem(rt),o=lt.cloneNode(!0),u.a<0&&(at=o.getAttribute("x1"),vt=o.getAttribute("x2"),o.setAttribute("x1",-(at-1)),o.setAttribute("x2",-(vt-1))),u.d<0&&(yt=o.getAttribute("y1"),pt=o.getAttribute("y2"),o.setAttribute("y1",-(yt-1)),o.setAttribute("y2",-(pt-1))),o.id=n.getDrawing().getNextId(),svgedit.utilities.findDefs().appendChild(o),i.setAttribute(v,"url(#"+o.id+")"));b=i.tagName;(b==="g"||b==="text"||b=="tspan"||b==="use")&&(u.a==1&&u.b==0&&u.c==0&&u.d==1&&(u.e!=0||u.f!=0)?(ft=svgedit.math.transformListToTransform(i).matrix,et=svgedit.math.matrixMultiply(ft.inverse(),u,ft),r.x=parseFloat(r.x)+et.e,r.y=parseFloat(r.y)+et.f):(y=svgedit.transformlist.getTransformList(i),k=svgroot.createSVGTransform(),k.setMatrix(svgedit.math.matrixMultiply(svgedit.math.transformListToTransform(y).matrix,u)),y.clear(),y.appendItem(k)));switch(b){case"foreignObject":case"rect":case"image":b==="image"&&(u.a<0||u.d<0)?(y=svgedit.transformlist.getTransformList(i),k=svgroot.createSVGTransform(),k.setMatrix(svgedit.math.matrixMultiply(svgedit.math.transformListToTransform(y).matrix,u)),y.clear(),y.appendItem(k)):(a=h(r.x,r.y),r.width=p(r.width),r.height=w(r.height),r.x=a.x+Math.min(0,r.width),r.y=a.y+Math.min(0,r.height),r.width=Math.abs(r.width),r.height=Math.abs(r.height));tt();break;case"ellipse":d=h(r.cx,r.cy);r.cx=d.x;r.cy=d.y;r.rx=p(r.rx);r.ry=w(r.ry);r.rx=Math.abs(r.rx);r.ry=Math.abs(r.ry);tt();break;case"circle":d=h(r.cx,r.cy);r.cx=d.x;r.cy=d.y;var ut=svgedit.math.transformBox(it.x,it.y,it.width,it.height,u),dt=ut.tr.x-ut.tl.x,gt=ut.bl.y-ut.tl.y;r.r=Math.min(dt/2,gt/2);r.r&&(r.r=Math.abs(r.r));tt();break;case"line":a=h(r.x1,r.y1);g=h(r.x2,r.y2);r.x1=a.x;r.y1=a.y;r.x2=g.x;r.y2=g.y;case"text":case"tspan":case"use":tt();break;case"g":ot=$(i).data("gsvg");ot&&svgedit.utilities.assignAttributes(ot,r,1e3,!0);break;case"polyline":case"polygon":for(c=r.points.length,e=0;e<c;++e)s=r.points[e],s=h(s.x,s.y),r.points[e].x=s.x,r.points[e].y=s.y;for(c=r.points.length,st="",e=0;e<c;++e)s=r.points[e],st+=s.x+","+s.y+" ";i.setAttribute("points",st);break;case"path":for(ht=i.pathSegList,c=ht.numberOfItems,r.d=[],e=0;e<c;++e)f=ht.getItem(e),r.d[e]={type:f.pathSegType,x:f.x,y:f.y,x1:f.x1,y1:f.y1,x2:f.x2,y2:f.y2,r1:f.r1,r2:f.r2,angle:f.angle,largeArcFlag:f.largeArcFlag,sweepFlag:f.sweepFlag};for(c=r.d.length,ct=r.d[0],nt=h(ct.x,ct.y),r.d[0].x=nt.x,r.d[0].y=nt.y,e=1;e<c;++e)f=r.d[e],v=f.type,v%2==0?(wt=f.x!=undefined?f.x:nt.x,bt=f.y!=undefined?f.y:nt.y,s=h(wt,bt),a=h(f.x1,f.y1),g=h(f.x2,f.y2),f.x=s.x,f.y=s.y,f.x1=a.x,f.y1=a.y,f.x2=g.x,f.y2=g.y,f.r1=p(f.r1),f.r2=w(f.r2)):(f.x=p(f.x),f.y=w(f.y),f.x1=p(f.x1),f.y1=w(f.y1),f.x2=p(f.x2),f.y2=w(f.y2),f.r1=p(f.r1),f.r2=w(f.r2));for(l="",c=r.d.length,e=0;e<c;++e){f=r.d[e];v=f.type;l+=t[v];switch(v){case 13:case 12:l+=f.x+" ";break;case 15:case 14:l+=f.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:l+=f.x+","+f.y+" ";break;case 7:case 6:l+=f.x1+","+f.y1+" "+f.x2+","+f.y2+" "+f.x+","+f.y+" ";break;case 9:case 8:l+=f.x1+","+f.y1+" "+f.x+","+f.y+" ";break;case 11:case 10:l+=f.r1+","+f.r2+" "+f.angle+" "+ +f.largeArcFlag+" "+ +f.sweepFlag+" "+f.x+","+f.y+" ";break;case 17:case 16:l+=f.x2+","+f.y2+" "+f.x+","+f.y+" "}}i.setAttribute("d",l)}}})();
12
- var myselect=function(){"use strict";return{initSelect:function(){var e,t,r;svgedit.select||(svgedit.select={});var s=svgedit.browser.isTouch()?10:4;svgedit.select.Selector=function(t,r){this.id=t,this.selectedElement=r,this.locked=!0,this.selectorGroup=e.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}}),this.selectorRect=this.selectorGroup.appendChild(e.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#9ebdff","stroke-width":"1",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(e){this.locked=!0,this.selectedElement=e,this.resize(),this.selectorGroup.setAttribute("display","inline")},svgedit.select.Selector.prototype.updateGripCursors=function(e){var t,s=[],i=Math.round(e/45);for(t in i<0&&(i+=8),r.selectorGrips)s.push(t);for(;i>0;)s.push(s.shift()),i--;var o=0;for(t in r.selectorGrips)r.selectorGrips[t].setAttribute("style","cursor:"+s[o]+"-resize"),o++},svgedit.select.Selector.prototype.showGrips=function(e){var t=e?"inline":"none";r.selectorGripsGroup.setAttribute("display",t);var s=this.selectedElement;this.hasGrips=e,s&&e&&(this.selectorGroup.appendChild(r.selectorGripsGroup),this.updateGripCursors(svgedit.utilities.getRotationAngle(s)))},svgedit.select.Selector.prototype.resize=function(){var t=this.selectorRect,i=r,o=i.selectorGrips,l=this.selectedElement,n=l.getAttribute("stroke-width"),a=e.currentZoom(),c=1/a;"none"===l.getAttribute("stroke")||isNaN(n)||(c+=n/2);var d=l.tagName;"text"===d&&(c+=2/a);var h=svgedit.transformlist.getTransformList(l),p=svgedit.math.transformListToTransform(h).matrix;p.e*=a,p.f*=a;var u=svgedit.utilities.getBBox(l);if("g"===d&&!$.data(l,"gsvg")){var g=e.getStrokedBBox(l.childNodes);g&&(u=g)}var G=u.x,v=u.y,f=u.width,b=u.height;u={x:G,y:v,width:f,height:b},c*=a;var m=svgedit.math.transformBox(G*a,v*a,f*a,b*a,p),y=m.aabox,x=y.x-c,w=y.y-c,S=y.width+2*c,k=y.height+2*c,C=x+S/2,B=w+k/2,M=svgedit.utilities.getRotationAngle(l);if(M){var A=e.svgRoot().createSVGTransform();A.setRotate(-M,C,B);var E=A.matrix;m.tl=svgedit.math.transformPoint(m.tl.x,m.tl.y,E),m.tr=svgedit.math.transformPoint(m.tr.x,m.tr.y,E),m.bl=svgedit.math.transformPoint(m.bl.x,m.bl.y,E),m.br=svgedit.math.transformPoint(m.br.x,m.br.y,E);var P=m.tl,R=P.x,V=P.y,N=P.x,z=P.y,F=Math.min,T=Math.max;R=F(R,F(m.tr.x,F(m.bl.x,m.br.x)))-c,V=F(V,F(m.tr.y,F(m.bl.y,m.br.y)))-c,N=T(N,T(m.tr.x,T(m.bl.x,m.br.x)))+c,z=T(z,T(m.tr.y,T(m.bl.y,m.br.y)))+c,x=R,w=V,S=N-R,k=z-V}var _=e.svgRoot().suspendRedraw(100),L="M"+x+","+w+" L"+(x+S)+","+w+" "+(x+S)+","+(w+k)+" "+x+","+(w+k)+"z";t.setAttribute("d",L);var j,W=M?"rotate("+[M,C,B].join(",")+")":"";for(j in this.selectorGroup.setAttribute("transform",W),this.gripCoords={nw:[x,w],ne:[x+S,w],sw:[x,w+k],se:[x+S,w+k],n:[x+S/2,w],w:[x,w+k/2],e:[x+S,w+k/2],s:[x+S/2,w+k]},this.gripCoords){var q=this.gripCoords[j];o[j].setAttribute("x",q[0]-3),o[j].setAttribute("y",q[1]-3)}i.rotateGripConnector.setAttribute("x1",x+S/2),i.rotateGripConnector.setAttribute("y1",w),i.rotateGripConnector.setAttribute("x2",x+S/2),i.rotateGripConnector.setAttribute("y2",w-5*s),i.rotateGrip.setAttribute("cx",x+S/2),i.rotateGrip.setAttribute("cy",w-5*s),e.svgRoot().unsuspendRedraw(_)},svgedit.select.SelectorManager=function(){this.selectorParentGroup=null,this.rubberBandBox=null,this.selectors=[],this.selectorMap={},this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null},this.selectorGripsGroup=null,this.rotateGripConnector=null,this.rotateGrip=null,this.initGroup()},svgedit.select.SelectorManager.prototype.initGroup=function(){var r;for(r in this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup),this.selectorParentGroup=e.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}}),this.selectorGripsGroup=e.createSVGElement({element:"g",attr:{display:"none"}}),this.selectorParentGroup.appendChild(this.selectorGripsGroup),e.svgRoot().appendChild(this.selectorParentGroup),this.selectorMap={},this.selectors=[],this.rubberBandBox=null,this.selectorGrips){var i=e.createSVGElement({element:"rect",attr:{id:"selectorGrip_resize_"+r,width:6,height:6,"stroke-width":1,stroke:"#9ebdff",fill:"#FFF",style:"cursor:"+r+"-resize","pointer-events":"all"}});$.data(i,"dir",r),$.data(i,"type","resize"),this.selectorGrips[r]=this.selectorGripsGroup.appendChild(i)}if(this.rotateGripConnector=this.selectorGripsGroup.appendChild(e.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#9ebdff","stroke-width":"1"}})),this.rotateGrip=this.selectorGripsGroup.appendChild(e.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:s,stroke:"#9ebdff","stroke-width":1}})),$.data(this.rotateGrip,"type","rotate"),!$("#canvasBackground").length){var o=t.dimensions,l=e.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"}}),n=e.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});l.appendChild(n),e.svgRoot().insertBefore(l,e.svgContent())}},svgedit.select.SelectorManager.prototype.requestSelector=function(e){if(null==e)return null;var t,r=this.selectors.length;if("object"==typeof this.selectorMap[e.id])return this.selectorMap[e.id].locked=!0,this.selectorMap[e.id];for(t=0;t<r;++t)if(this.selectors[t]&&!this.selectors[t].locked)return this.selectors[t].locked=!0,this.selectors[t].reset(e),this.selectorMap[e.id]=this.selectors[t],this.selectors[t];return this.selectors[r]=new svgedit.select.Selector(r,e),this.selectorParentGroup.appendChild(this.selectors[r].selectorGroup),this.selectorMap[e.id]=this.selectors[r],this.selectors[r]},svgedit.select.SelectorManager.prototype.releaseSelector=function(e){if(null!=e){var t,r=this.selectors.length,s=this.selectorMap[e.id];for(t=0;t<r;++t)if(this.selectors[t]&&this.selectors[t]==s){0==s.locked&&console.log("WARNING! selector was released but was already unlocked"),delete this.selectorMap[e.id],s.locked=!1,s.selectedElement=null,s.showGrips(!1);try{s.selectorGroup.setAttribute("display","none")}catch(e){}break}}},svgedit.select.SelectorManager.prototype.getRubberBandBox=function(){return this.rubberBandBox||(this.rubberBandBox=this.selectorParentGroup.appendChild(e.createSVGElement({element:"rect",attr:{id:"selectorRubberBand",fill:"#22C","fill-opacity":.15,stroke:"#22C","stroke-width":.5,display:"none",style:"pointer-events:none"}}))),this.rubberBandBox},svgedit.select.init=function(s,i){t=s,e=i,r=new svgedit.select.SelectorManager},svgedit.select.getSelectorManager=function(){return r}}}}();
13
- var svgedit=svgedit||{};(function(){svgedit.recalculate||(svgedit.recalculate={});var t,e=svgedit.NS;svgedit.recalculate.init=function(e){t=e},svgedit.recalculate.updateClipPath=function(e,r,a){var s=getRefElem(e).firstChild,i=svgedit.transformlist.getTransformList(s),m=t.getSVGRoot().createSVGTransform();m.setTranslate(r,a),i.appendItem(m),svgedit.recalculate.recalculateDimensions(s)},svgedit.recalculate.recalculateDimensions=function(r){if(null==r)return null;if("svg"==r.nodeName&&navigator.userAgent.indexOf("Firefox/20")>=0)return null;var a,s=t.getSVGRoot(),i=svgedit.transformlist.getTransformList(r);if(i&&i.numberOfItems>0){for(a=i.numberOfItems;a--;){var m=i.getItem(a);0===m.type?i.removeItem(a):1===m.type?svgedit.math.isIdentity(m.matrix)&&i.removeItem(a):4===m.type&&0===m.angle&&i.removeItem(a)}if(1===i.numberOfItems&&svgedit.utilities.getRotationAngle(r))return null}if(!i||0==i.numberOfItems)return r.setAttribute("transform",""),r.removeAttribute("transform"),null;if(i){a=i.numberOfItems;for(var n=[];a--;){var m=i.getItem(a);1===m.type?n.push([m.matrix,a]):n.length&&(n=[])}if(2===n.length){var o=s.createSVGTransformFromMatrix(svgedit.math.matrixMultiply(n[1][0],n[0][0]));i.removeItem(n[0][1]),i.removeItem(n[1][1]),i.insertItemBefore(o,n[1][1])}if(a=i.numberOfItems,a>=2&&1===i.getItem(a-2).type&&2===i.getItem(a-1).type){var f=s.createSVGTransform(),v=svgedit.math.matrixMultiply(i.getItem(a-2).matrix,i.getItem(a-1).matrix);f.setMatrix(v),i.removeItem(a-2),i.removeItem(a-2),i.appendItem(f)}}switch(r.tagName){case"line":case"polyline":case"polygon":case"path":break;default:if(1===i.numberOfItems&&1===i.getItem(0).type||2===i.numberOfItems&&1===i.getItem(0).type&&4===i.getItem(0).type)return null}var g=$(r).data("gsvg"),l=new svgedit.history.BatchCommand("Transform"),d={},u=null,c=[];switch(r.tagName){case"line":c=["x1","y1","x2","y2"];break;case"circle":c=["cx","cy","r"];break;case"ellipse":c=["cx","cy","rx","ry"];break;case"foreignObject":case"rect":case"image":c=["width","height","x","y"];break;case"use":case"text":case"tspan":c=["x","y"];break;case"polygon":case"polyline":u={},u.points=r.getAttribute("points");var p=r.points,I=p.numberOfItems;d.points=new Array(I);var x;for(x=0;x<I;++x){var h=p.getItem(x);d.points[x]={x:h.x,y:h.y}}break;case"path":u={},u.d=r.getAttribute("d"),d.d=r.getAttribute("d")}if(c.length?(d=$(r).attr(c),$.each(d,function(t,e){d[t]=svgedit.units.convertToNum(t,e)})):g&&(d={x:$(g).attr("x")||0,y:$(g).attr("y")||0}),null==u&&(u=$.extend(!0,{},d),$.each(u,function(t,e){u[t]=svgedit.units.convertToNum(t,e)})),u.transform=t.getStartTransform()||"","g"==r.tagName&&!g||"a"==r.tagName){var T=svgedit.utilities.getBBox(r),y={x:T.x+T.width/2,y:T.y+T.height/2},b=svgedit.math.transformPoint(T.x+T.width/2,T.y+T.height/2,svgedit.math.transformListToTransform(i).matrix),v=s.createSVGMatrix(),S=svgedit.utilities.getRotationAngle(r);if(S){var M=S*Math.PI/180;if(Math.abs(M)>1e-10)var O=Math.sin(M)/(1-Math.cos(M));else var O=2/M;var x;for(x=0;x<i.numberOfItems;++x){var m=i.getItem(x);if(4==m.type){var A=m.matrix;y.y=(O*A.e+A.f)/2,y.x=(A.e-O*A.f)/2,i.removeItem(x);break}}}var G=0,V=0,L=0,N=i.numberOfItems;if(N)var B=i.getItem(0).matrix;if(N>=3&&3==i.getItem(N-2).type&&2==i.getItem(N-3).type&&2==i.getItem(N-1).type){L=3;for(var R=i.getItem(N-3).matrix,w=i.getItem(N-2).matrix,k=i.getItem(N-1).matrix,C=r.childNodes,D=C.length;D--;){var E=C.item(D);if(G=0,V=0,1==E.nodeType){var P=svgedit.transformlist.getTransformList(E);if(!P)continue;var v=svgedit.math.transformListToTransform(P).matrix,j=svgedit.utilities.getRotationAngle(E),F=t.getStartTransform(),U=[];if(t.setStartTransform(E.getAttribute("transform")),j||svgedit.math.hasMatrixTransform(P)){var H=s.createSVGTransform();H.setMatrix(svgedit.math.matrixMultiply(R,w,k,v)),P.clear(),P.appendItem(H),U.push(H)}else{var W=svgedit.math.matrixMultiply(v.inverse(),k,v),q=s.createSVGMatrix();q.e=-W.e,q.f=-W.f;var z=svgedit.math.matrixMultiply(q.inverse(),v.inverse(),R,w,k,v,W.inverse()),J=s.createSVGTransform(),K=s.createSVGTransform(),Q=s.createSVGTransform();J.setTranslate(W.e,W.f),K.setScale(z.a,z.d),Q.setTranslate(q.e,q.f),P.appendItem(Q),P.appendItem(K),P.appendItem(J),U.push(Q),U.push(K),U.push(J)}l.addSubCommand(svgedit.recalculate.recalculateDimensions(E)),t.setStartTransform(F)}}i.removeItem(N-1),i.removeItem(N-2),i.removeItem(N-3)}else if(N>=3&&1==i.getItem(N-1).type){L=3,v=svgedit.math.transformListToTransform(i).matrix;var H=s.createSVGTransform();H.setMatrix(v),i.clear(),i.appendItem(H)}else if((1==N||N>1&&3!=i.getItem(1).type)&&2==i.getItem(0).type){L=2;var X=svgedit.math.transformListToTransform(i).matrix;i.removeItem(0);var Y=svgedit.math.transformListToTransform(i).matrix.inverse(),Z=svgedit.math.matrixMultiply(Y,X);if(G=Z.e,V=Z.f,0!=G||0!=V){for(var C=r.childNodes,D=C.length,_=[];D--;){var E=C.item(D);if(1==E.nodeType){if(E.getAttribute("clip-path")){var tt=E.getAttribute("clip-path");_.indexOf(tt)===-1&&(svgedit.recalculate.updateClipPath(tt,G,V),_.push(tt))}var F=t.getStartTransform();t.setStartTransform(E.getAttribute("transform"));var P=svgedit.transformlist.getTransformList(E);if(P){var et=s.createSVGTransform();et.setTranslate(G,V),P.numberOfItems?P.insertItemBefore(et,0):P.appendItem(et),l.addSubCommand(svgedit.recalculate.recalculateDimensions(E));for(var rt=r.getElementsByTagNameNS(e.SVG,"use"),at="#"+E.id,st=rt.length;st--;){var it=rt.item(st);if(at==svgedit.utilities.getHref(it)){var mt=s.createSVGTransform();mt.setTranslate(-G,-V),svgedit.transformlist.getTransformList(it).insertItemBefore(mt,0),l.addSubCommand(svgedit.recalculate.recalculateDimensions(it))}}t.setStartTransform(F)}}}_=[],t.setStartTransform(F)}}else{if(1!=N||1!=i.getItem(0).type||S){if(S){var nt=s.createSVGTransform();nt.setRotate(S,b.x,b.y),i.numberOfItems?i.insertItemBefore(nt,0):i.appendItem(nt)}return 0==i.numberOfItems&&r.removeAttribute("transform"),null}L=1;for(var v=i.getItem(0).matrix,C=r.childNodes,D=C.length;D--;){var E=C.item(D);if(1==E.nodeType){var F=t.getStartTransform();t.setStartTransform(E.getAttribute("transform"));var P=svgedit.transformlist.getTransformList(E);if(!P)continue;var ot=svgedit.math.matrixMultiply(v,svgedit.math.transformListToTransform(P).matrix),ft=s.createSVGTransform();ft.setMatrix(ot),P.clear(),P.appendItem(ft,0),l.addSubCommand(svgedit.recalculate.recalculateDimensions(E)),t.setStartTransform(F);var vt=E.getAttribute("stroke-width");if("none"!==E.getAttribute("stroke")&&!isNaN(vt)){var gt=(Math.abs(ot.a)+Math.abs(ot.d))/2;E.setAttribute("stroke-width",vt*gt)}}}i.clear()}if(2==L){if(S){b={x:y.x+B.e,y:y.y+B.f};var nt=s.createSVGTransform();nt.setRotate(S,b.x,b.y),i.numberOfItems?i.insertItemBefore(nt,0):i.appendItem(nt)}}else if(3==L){var v=svgedit.math.transformListToTransform(i).matrix,lt=s.createSVGTransform();lt.setRotate(S,y.x,y.y);var dt=lt.matrix,ut=s.createSVGTransform();ut.setRotate(S,b.x,b.y);var ct=ut.matrix.inverse(),pt=v.inverse(),It=svgedit.math.matrixMultiply(pt,ct,dt,v);if(G=It.e,V=It.f,0!=G||0!=V)for(var C=r.childNodes,D=C.length;D--;){var E=C.item(D);if(1==E.nodeType){var F=t.getStartTransform();t.setStartTransform(E.getAttribute("transform"));var P=svgedit.transformlist.getTransformList(E),et=s.createSVGTransform();et.setTranslate(G,V),P.numberOfItems?P.insertItemBefore(et,0):P.appendItem(et),l.addSubCommand(svgedit.recalculate.recalculateDimensions(E)),t.setStartTransform(F)}}S&&(i.numberOfItems?i.insertItemBefore(ut,0):i.appendItem(ut))}}else{var T=svgedit.utilities.getBBox(r);if(!T&&"path"!=r.tagName)return null;var v=s.createSVGMatrix(),j=svgedit.utilities.getRotationAngle(r);if(j){var y={x:T.x+T.width/2,y:T.y+T.height/2},b=svgedit.math.transformPoint(T.x+T.width/2,T.y+T.height/2,svgedit.math.transformListToTransform(i).matrix),M=j*Math.PI/180;if(Math.abs(M)>1e-10)var O=Math.sin(M)/(1-Math.cos(M));else var O=2/M;for(var x=0;x<i.numberOfItems;++x){var m=i.getItem(x);if(4==m.type){var A=m.matrix;y.y=(O*A.e+A.f)/2,y.x=(A.e-O*A.f)/2,i.removeItem(x);break}}}var L=0,N=i.numberOfItems;if(!svgedit.browser.isWebkit()){var xt=r.getAttribute("fill");if(xt&&0===xt.indexOf("url(")){var ht=getRefElem(xt),Tt="pattern";ht.tagName!==Tt&&(Tt="gradient");var yt=ht.getAttribute(Tt+"Units");if("userSpaceOnUse"===yt){v=svgedit.math.transformListToTransform(i).matrix;var bt=svgedit.transformlist.getTransformList(ht),St=svgedit.math.transformListToTransform(bt).matrix;v=svgedit.math.matrixMultiply(v,St);var Mt="matrix("+[v.a,v.b,v.c,v.d,v.e,v.f].join(",")+")";ht.setAttribute(Tt+"Transform",Mt)}}}if(N>=3&&3==i.getItem(N-2).type&&2==i.getItem(N-3).type&&2==i.getItem(N-1).type)L=3,v=svgedit.math.transformListToTransform(i,N-3,N-1).matrix,i.removeItem(N-1),i.removeItem(N-2),i.removeItem(N-3);else if(4==N&&1==i.getItem(N-1).type){L=3,v=svgedit.math.transformListToTransform(i).matrix;var H=s.createSVGTransform();H.setMatrix(v),i.clear(),i.appendItem(H),v=s.createSVGMatrix()}else if((1==N||N>1&&3!=i.getItem(1).type)&&2==i.getItem(0).type){L=2;var Ot=i.getItem(0).matrix,At=svgedit.math.transformListToTransform(i,1).matrix,Gt=At.inverse();v=svgedit.math.matrixMultiply(Gt,Ot,At),i.removeItem(0)}else{if(1!=N||1!=i.getItem(0).type||j){if(L=4,j){var nt=s.createSVGTransform();nt.setRotate(j,b.x,b.y),i.numberOfItems?i.insertItemBefore(nt,0):i.appendItem(nt)}return 0==i.numberOfItems&&r.removeAttribute("transform"),null}switch(v=svgedit.math.transformListToTransform(i).matrix,r.tagName){case"line":d=$(r).attr(["x1","y1","x2","y2"]);case"polyline":case"polygon":if(d.points=r.getAttribute("points"),d.points){var p=r.points,I=p.numberOfItems;d.points=new Array(I);for(var x=0;x<I;++x){var h=p.getItem(x);d.points[x]={x:h.x,y:h.y}}}case"path":d.d=r.getAttribute("d"),L=1,i.clear()}}if(1!=L&&2!=L&&3!=L||svgedit.coords.remapElement(r,d,v),2==L){if(j){svgedit.math.hasMatrixTransform(i)||(b={x:y.x+v.e,y:y.y+v.f});var nt=s.createSVGTransform();nt.setRotate(j,b.x,b.y),i.numberOfItems?i.insertItemBefore(nt,0):i.appendItem(nt)}if("text"==r.tagName)for(var C=r.childNodes,D=C.length;D--;){var E=C.item(D);if("tspan"==E.tagName){var Vt={x:$(E).attr("x")||0,y:$(E).attr("y")||0};svgedit.coords.remapElement(E,Vt,v)}}}else if(3==L&&j){var v=svgedit.math.transformListToTransform(i).matrix,lt=s.createSVGTransform();lt.setRotate(j,y.x,y.y);var dt=lt.matrix,ut=s.createSVGTransform();ut.setRotate(j,b.x,b.y);var ct=ut.matrix.inverse(),pt=v.inverse(),It=svgedit.math.matrixMultiply(pt,ct,dt,v);svgedit.coords.remapElement(r,d,It),j&&(i.numberOfItems?i.insertItemBefore(ut,0):i.appendItem(ut))}}return 0==i.numberOfItems&&r.removeAttribute("transform"),l.addSubCommand(new svgedit.history.ChangeElementCommand(r,u)),l}})();
14
- (function(){"use strict";var n,t,i,e,o,r,h;svgedit.path||(svgedit.path={});var u=svgedit.NS,l={pathNodeTooltip:"Drag node to move it. Double-click node to change segment type",pathCtrlPtTooltip:"Drag control point to adjust curve properties"},a={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"]},s=[],c=!0,f={};svgedit.path.setLinkControlPoints=function(n){c=n};svgedit.path.path=null;n=null;svgedit.path.init=function(t){n=t;s=[0,"ClosePath"];$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(n,t){s.push(t+"Abs");s.push(t+"Rel")})};svgedit.path.insertItemBefore=function(n,t,i){var u=n.pathSegList,f,e,r,o;if(svgedit.browser.supportsPathInsertItemBefore()){u.insertItemBefore(t,i);return}for(f=u.numberOfItems,e=[],r=0;r<f;r++)o=u.getItem(r),e.push(o);for(u.clear(),r=0;r<f;r++)r==i&&u.appendItem(t),u.appendItem(e[r])};svgedit.path.ptObjToArr=function(n,t){for(var r=a[n],f=r.length,u=[],i=0;i<f;i++)u[i]=t[r[i]];return u};svgedit.path.getGripPt=function(t,i){var r={x:i?i.x:t.item.x,y:i?i.y:t.item.y},u=t.path,f;return u.matrix&&(f=svgedit.math.transformPoint(r.x,r.y,u.matrix),r=f),r.x*=n.getCurrentZoom(),r.y*=n.getCurrentZoom(),r};svgedit.path.getPointFromGrip=function(t,i){var r={x:t.x,y:t.y};return i.matrix&&(t=svgedit.math.transformPoint(r.x,r.y,i.imatrix),r.x=t.x,r.y=t.y),r.x/=n.getCurrentZoom(),r.y/=n.getCurrentZoom(),r};svgedit.path.addPointGrip=function(n,t,i){var e=svgedit.path.getGripContainer(),r=svgedit.utilities.getElem("pathpointgrip_"+n),f;return r||(r=document.createElementNS(u.SVG,"circle"),svgedit.utilities.assignAttributes(r,{id:"pathpointgrip_"+n,display:"none",r:4,fill:"#0FF",stroke:"#00F","stroke-width":2,cursor:"move",style:"pointer-events:all","xlink:title":l.pathNodeTooltip}),r=e.appendChild(r),f=$("#pathpointgrip_"+n),f.dblclick(function(){svgedit.path.path&&svgedit.path.path.setSegType()})),t&&i&&svgedit.utilities.assignAttributes(r,{cx:t,cy:i,display:"inline"}),r};svgedit.path.getGripContainer=function(){var n=svgedit.utilities.getElem("pathpointgrip_container"),t;return n||(t=svgedit.utilities.getElem("selectorParentGroup"),n=t.appendChild(document.createElementNS(u.SVG,"g")),n.id="pathpointgrip_container"),n};svgedit.path.addCtrlGrip=function(n){var t=svgedit.utilities.getElem("ctrlpointgrip_"+n);return t?t:(t=document.createElementNS(u.SVG,"circle"),svgedit.utilities.assignAttributes(t,{id:"ctrlpointgrip_"+n,display:"none",r:4,fill:"#0FF",stroke:"#55F","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":l.pathCtrlPtTooltip}),svgedit.path.getGripContainer().appendChild(t),t)};svgedit.path.getCtrlLine=function(n){var t=svgedit.utilities.getElem("ctrlLine_"+n);return t?t:(t=document.createElementNS(u.SVG,"line"),svgedit.utilities.assignAttributes(t,{id:"ctrlLine_"+n,stroke:"#555","stroke-width":1,style:"pointer-events:none"}),svgedit.path.getGripContainer().appendChild(t),t)};svgedit.path.getPointGrip=function(n,t){var u=n.index,r=svgedit.path.addPointGrip(u),i;return t&&(i=svgedit.path.getGripPt(n),svgedit.utilities.assignAttributes(r,{cx:i.x,cy:i.y,display:"inline"})),r};svgedit.path.getControlPoints=function(n){var i=n.item,e=n.index,f;if(!("x1"in i)||!("x2"in i))return null;for(var r={},a=svgedit.path.getGripContainer(),l=svgedit.path.path.segs[e-1].item,o=[l,i],t=1;t<3;t++){var s=e+"c"+t,h=r["c"+t+"_line"]=svgedit.path.getCtrlLine(s),u=svgedit.path.getGripPt(n,{x:i["x"+t],y:i["y"+t]}),c=svgedit.path.getGripPt(n,{x:o[t-1].x,y:o[t-1].y});svgedit.utilities.assignAttributes(h,{x1:u.x,y1:u.y,x2:c.x,y2:c.y,display:"inline"});r["c"+t+"_line"]=h;f=r["c"+t]=svgedit.path.addCtrlGrip(s);svgedit.utilities.assignAttributes(f,{cx:u.x,cy:u.y,display:"inline"});r["c"+t]=f}return r};svgedit.path.replacePathSeg=function(n,t,i,r){var e=r||svgedit.path.path.elem,a="createSVGPathSeg"+s[n],o=e[a].apply(e,i),l;if(svgedit.browser.supportsPathReplaceItem())e.pathSegList.replaceItem(o,t);else{for(var f=e.pathSegList,h=f.numberOfItems,c=[],u=0;u<h;u++)l=f.getItem(u),c.push(l);for(f.clear(),u=0;u<h;u++)u==t?f.appendItem(o):f.appendItem(c[u])}};svgedit.path.getSegSelector=function(n,t){var s=n.index,i=svgedit.utilities.getElem("segline_"+s),h,o,e,r,f;if(i||(h=svgedit.path.getGripContainer(),i=document.createElementNS(u.SVG,"path"),svgedit.utilities.assignAttributes(i,{id:"segline_"+s,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"}),h.appendChild(i)),t){if(o=n.prev,!o)return i.setAttribute("display","none"),i;for(e=svgedit.path.getGripPt(o),svgedit.path.replacePathSeg(2,0,[e.x,e.y],i),r=svgedit.path.ptObjToArr(n.type,n.item,!0),f=0;f<r.length;f+=2)e=svgedit.path.getGripPt(n,{x:r[f],y:r[f+1]}),r[f]=e.x,r[f+1]=e.y;svgedit.path.replacePathSeg(n.type,1,r,i)}return i};svgedit.path.smoothControlPoints=function(t,i,r){var s=t.x-r.x,h=t.y-r.y,c=i.x-r.x,l=i.y-r.y,o,u,a,v;if((s!=0||h!=0)&&(c!=0||l!=0)){var f=Math.atan2(h,s),e=Math.atan2(l,c),w=Math.sqrt(s*s+h*h),b=Math.sqrt(c*c+l*l),y=n.getSVGRoot().createSVGPoint(),p=n.getSVGRoot().createSVGPoint();return f<0&&(f+=2*Math.PI),e<0&&(e+=2*Math.PI),o=Math.abs(f-e),u=Math.abs(Math.PI-o)/2,f-e>0?(a=o<Math.PI?f+u:f-u,v=o<Math.PI?e-u:e+u):(a=o<Math.PI?f-u:f+u,v=o<Math.PI?e+u:e-u),y.x=w*Math.cos(a)+r.x,y.y=w*Math.sin(a)+r.y,p.x=b*Math.cos(v)+r.x,p.y=b*Math.sin(v)+r.y,[y,p]}return undefined};svgedit.path.Segment=function(n,t){this.selected=!1;this.index=n;this.item=t;this.type=t.pathSegType;this.ctrlpts=[];this.ptgrip=null;this.segsel=null};svgedit.path.Segment.prototype.showCtrlPts=function(n){for(var t in this.ctrlpts)this.ctrlpts.hasOwnProperty(t)&&this.ctrlpts[t].setAttribute("display",n?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(n){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill",n?"#0FF":"#EEE")};svgedit.path.Segment.prototype.show=function(n){this.ptgrip&&(this.ptgrip.setAttribute("display",n?"inline":"none"),this.segsel.setAttribute("display",n?"inline":"none"),this.showCtrlPts(n))};svgedit.path.Segment.prototype.select=function(n){this.ptgrip&&(this.ptgrip.setAttribute("stroke",n?"#0FF":"#00F"),this.segsel.setAttribute("display",n?"inline":"none"),this.ctrlpts&&this.selectCtrls(n),this.selected=n)};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,!0);this.ctrlpts=svgedit.path.getControlPoints(this,!0);this.segsel=svgedit.path.getSegSelector(this,!0)};svgedit.path.Segment.prototype.update=function(n){if(this.ptgrip){var t=svgedit.path.getGripPt(this);svgedit.utilities.assignAttributes(this.ptgrip,{cx:t.x,cy:t.y});svgedit.path.getSegSelector(this,!0);this.ctrlpts&&(n&&(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(n,t){var f,u=this.item,i=$.extend({},u),r,e,o;f=this.ctrlpts?[i.x+=n,i.y+=t,i.x1,i.y1,i.x2+=n,i.y2+=t]:[i.x+=n,i.y+=t];svgedit.path.replacePathSeg(this.type,this.index,f);this.next&&this.next.ctrlpts&&(r=this.next.item,e=[r.x,r.y,r.x1+=n,r.y1+=t,r.x2,r.y2],svgedit.path.replacePathSeg(this.next.type,this.next.index,e));this.mate&&(u=this.mate.item,o=[u.x+=n,u.y+=t],svgedit.path.replacePathSeg(this.mate.type,this.mate.index,o));this.update(!0);this.next&&this.next.update(!0)};svgedit.path.Segment.prototype.setLinked=function(n){var t,u,r,f,i,e;if(n==2){if(u=1,t=this.next,!t)return;r=this.item}else{if(u=2,t=this.prev,!t)return;r=t.item}f=t.item;i=$.extend({},f);i["x"+u]=r.x+(r.x-this.item["x"+n]);i["y"+u]=r.y+(r.y-this.item["y"+n]);e=[i.x,i.y,i.x1,i.y1,i.x2,i.y2];svgedit.path.replacePathSeg(t.type,t.index,e);t.update(!0)};svgedit.path.Segment.prototype.moveCtrl=function(n,t,i){var f=this.item,r=$.extend({},f),u;r["x"+n]+=t;r["y"+n]+=i;u=[r.x,r.y,r.x1,r.y1,r.x2,r.y2];svgedit.path.replacePathSeg(this.type,this.index,u);this.update(!0)};svgedit.path.Segment.prototype.setType=function(n,t){svgedit.path.replacePathSeg(n,this.index,t);this.type=n;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(n===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(!0)};svgedit.path.Path=function(n){if(!n||n.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=n;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){var o,e,n,h,s,i,u;for($(svgedit.path.getGripContainer()).find("*").each(function(){$(this).attr("display","none")}),o=this.elem.pathSegList,e=o.numberOfItems,this.segs=[],this.selected_pts=[],this.first_seg=null,n=0;n<e;n++)h=o.getItem(n),s=new svgedit.path.Segment(n,h),s.path=this,this.segs.push(s);for(i=this.segs,u=null,n=0;n<e;n++){var t=i[n],f=n+1>=e?null:i[n+1],c=n-1<0?null:i[n-1],r;t.type===2?(c&&c.type!==1&&(r=i[u],r.next=i[u+1],r.next.prev=r,r.addGrip()),u=n):f&&f.type===1?(t.next=i[u+1],t.next.prev=t,t.mate=i[u],t.addGrip(),this.first_seg==null&&(this.first_seg=t)):f?t.type!==1&&(t.addGrip(),f&&f.type!==2&&(t.next=f,t.next.prev=t)):t.type!==1&&(r=i[u],r.next=i[u+1],r.next.prev=r,r.addGrip(),t.addGrip(),this.first_seg||(this.first_seg=i[u]))}return this};svgedit.path.Path.prototype.eachSeg=function(n){for(var r=this.segs.length,i,t=0;t<r;t++)if(i=n.call(this.segs[t],t),i===!1)break};svgedit.path.Path.prototype.addSeg=function(n){var t=this.segs[n],i,f,r,u,w;if(t.prev){i=t.prev;switch(t.item.pathSegType){case 4:r=(t.item.x+i.item.x)/2;u=(t.item.y+i.item.y)/2;f=this.elem.createSVGPathSegLinetoAbs(r,u);break;case 6:var e=(i.item.x+t.item.x1)/2,o=(t.item.x1+t.item.x2)/2,s=(t.item.x2+t.item.x)/2,h=(e+o)/2,c=(o+s)/2;r=(h+c)/2;var l=(i.item.y+t.item.y1)/2,a=(t.item.y1+t.item.y2)/2,v=(t.item.y2+t.item.y)/2,y=(l+a)/2,p=(a+v)/2;u=(y+p)/2;f=this.elem.createSVGPathSegCurvetoCubicAbs(r,u,e,l,h,y);w=[t.item.x,t.item.y,c,p,s,v];svgedit.path.replacePathSeg(t.type,n,w)}svgedit.path.insertItemBefore(this.elem,f,n)}};svgedit.path.Path.prototype.deleteSeg=function(n){var t=this.segs[n],u=this.elem.pathSegList,i,r,f;t.show(!1);i=t.next;t.mate?(r=[i.item.x,i.item.y],svgedit.path.replacePathSeg(2,i.index,r),svgedit.path.replacePathSeg(4,t.index,r),u.removeItem(t.mate.index)):t.prev?u.removeItem(n):(f=t.item,r=[i.item.x,i.item.y],svgedit.path.replacePathSeg(2,t.next.index,r),u.removeItem(n))};svgedit.path.Path.prototype.subpathIsClosed=function(n){var t=!1;return svgedit.path.path.eachSeg(function(i){return i<=n?!0:this.type===2?!1:this.type===1?(t=!0,!1):void 0}),t};svgedit.path.Path.prototype.removePtFromSelection=function(n){var t=this.selected_pts.indexOf(n);t!=-1&&(this.segs[n].select(!1),this.selected_pts.splice(t,1))};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(!1)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(n){return this.eachSeg(function(){this.show(n)}),n&&this.selectPt(this.first_seg.index),this};svgedit.path.Path.prototype.movePts=function(n,t){for(var i=this.selected_pts.length,r;i--;)r=this.segs[this.selected_pts[i]],r.move(n,t)};svgedit.path.Path.prototype.moveCtrl=function(n,t){var i=this.segs[this.selected_pts[0]];i.moveCtrl(this.dragctrl,n,t);c&&i.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(n){var e,s,h,u;for(this.storeD(),e=this.selected_pts.length;e--;){var y=this.selected_pts[e],t=this.segs[y],o=t.prev;if(o){n||(s="Toggle Path Segment Type",h=t.type,n=h==6?4:6);n=Number(n);var i=t.item.x,r=t.item.y,c=o.item.x,l=o.item.y,f;switch(n){case 6:if(t.olditem)u=t.olditem,f=[i,r,u.x1,u.y1,u.x2,u.y2];else{var a=i-c,v=r-l,p=c+a/3,w=l+v/3,b=i-a/3,k=r-v/3;f=[i,r,p,w,b,k]}break;case 4:f=[i,r];t.olditem=t.item}t.setType(n,f)}}svgedit.path.path.endChanges(s)};svgedit.path.Path.prototype.selectPt=function(n,t){this.clearSelection();n==null&&this.eachSeg(function(t){this.prev&&(n=t)});this.addPtsToSelection(n);t&&(this.dragctrl=t,c&&this.segs[n].setLinked(t))};svgedit.path.Path.prototype.update=function(){var n=this.elem;return svgedit.utilities.getRotationAngle(n)?(this.matrix=svgedit.math.getMatrix(n),this.imatrix=this.matrix.inverse()):(this.matrix=null,this.imatrix=null),this.eachSeg(function(t){this.item=n.pathSegList.getItem(t);this.update()}),this};svgedit.path.getPath_=function(n){var t=f[n.id];return t||(t=f[n.id]=new svgedit.path.Path(n)),t};svgedit.path.removePath_=function(n){n in f&&delete f[n]};h=function(n,u){var f=n-e,s=u-o,h=Math.sqrt(f*f+s*s),c=Math.atan2(s,f)+r;return f=h*Math.cos(c)+e,s=h*Math.sin(c)+o,f-=t,s-=i,h=Math.sqrt(f*f+s*s),c=Math.atan2(s,f)-r,{x:h*Math.cos(c)+t,y:h*Math.sin(c)+i}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,u,s,y,c,n,p,w,l,b,k,d,tt;if(r=svgedit.utilities.getRotationAngle(f,!0),r){u=svgedit.utilities.getBBox(f);s=svgedit.path.path.oldbbox;e=s.x+s.width/2;o=s.y+s.height/2;t=u.x+u.width/2;i=u.y+u.height/2;var a=t-e,v=i-o,g=Math.sqrt(a*a+v*v),nt=Math.atan2(v,a)+r;for(t=g*Math.cos(nt)+e,i=g*Math.sin(nt)+o,y=f.pathSegList,c=y.numberOfItems;c;)(c-=1,n=y.getItem(c),p=n.pathSegType,p!=1)&&(w=h(n.x,n.y),l=[w.x,w.y],n.x1!=null&&n.x2!=null&&(b=h(n.x1,n.y1),k=h(n.x2,n.y2),l.splice(l.length,0,b.x,b.y,k.x,k.y)),svgedit.path.replacePathSeg(p,c,l));u=svgedit.utilities.getBBox(f);d=svgroot.createSVGTransform();tt=svgedit.transformlist.getTransformList(f);d.setRotate(r*180/Math.PI,t,i);tt.replaceItem(d,0)}};svgedit.path.clearData=function(){f={}}})();
15
- var mydraw=function(){"use strict";return{initDraw:function(){svgedit.draw||(svgedit.draw={});var e=svgedit.NS,t="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),r={LET_DOCUMENT_DECIDE:0,ALWAYS_RANDOMIZE:1,NEVER_RANDOMIZE:2},i=r.LET_DOCUMENT_DECIDE;svgedit.draw.Layer=function(e,t){this.name_=e,this.group_=t},svgedit.draw.Layer.prototype.getName=function(){return this.name_},svgedit.draw.Layer.prototype.getGroup=function(){return this.group_},svgedit.draw.randomizeIds=function(e,t){i=!1===e?r.NEVER_RANDOMIZE:r.ALWAYS_RANDOMIZE,i!=r.ALWAYS_RANDOMIZE||t.getNonce()?i==r.NEVER_RANDOMIZE&&t.getNonce()&&t.clearNonce():t.setNonce(Math.floor(100001*Math.random()))},svgedit.draw.Drawing=function(t,n){if(!t||!t.tagName||!t.namespaceURI||"svg"!=t.tagName||t.namespaceURI!=e.SVG)throw"Error: draw.Drawing instance initialized without a <svg> element";this.svgElem_=t,this.obj_num=0,this.idPrefix=n||"svg_",this.releasedNums=[],this.all_layers=[],this.current_layer=null,this.nonce_="";var a=this.svgElem_.getAttributeNS(e.SE,"nonce");a&&i!=r.NEVER_RANDOMIZE?this.nonce_=a:i==r.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(100001*Math.random()))},svgedit.draw.Drawing.prototype.getElem_=function(e){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+e):$(this.svgElem_).find("[id="+e+"]")[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(t){this.svgElem_.setAttributeNS(e.XMLNS,"xmlns:se",e.SE),this.svgElem_.setAttributeNS(e.SE,"se:nonce",t),this.nonce_=t},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 e,t,r="";for(e=0;e<16;e++)t=16*Math.random()|0,8==e&&(r+="-"),r+=(12==e?4:16==e?3&t|8:t).toString(16);this.obj_num=r;var i=this.getId();return i},svgedit.draw.Drawing.prototype.releaseId=function(e){var t=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if("string"!=typeof e||0!==e.indexOf(t))return!1;var r=parseInt(e.substr(t.length),10);return!("number"!=typeof r||r<=0||-1!=this.releasedNums.indexOf(r))&&(this.releasedNums.push(r),!0)},svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length},svgedit.draw.Drawing.prototype.hasLayer=function(e){var t;for(t=0;t<this.getNumLayers();t++)if(this.all_layers[t][0]==e)return!0;return!1},svgedit.draw.Drawing.prototype.getLayerName=function(e){return e>=0&&e<this.getNumLayers()?this.all_layers[e][0]:""},svgedit.draw.Drawing.prototype.getCurrentLayer=function(){return this.current_layer},svgedit.draw.Drawing.prototype.getCurrentLayerName=function(){var e;for(e=0;e<this.getNumLayers();++e)if(this.all_layers[e][1]==this.current_layer)return this.getLayerName(e);return""},svgedit.draw.Drawing.prototype.setCurrentLayer=function(e){var t;for(t=0;t<this.getNumLayers();++t)if(e==this.getLayerName(t))return this.current_layer!=this.all_layers[t][1]&&(this.current_layer.setAttribute("style","pointer-events:none"),this.current_layer=this.all_layers[t][1],this.current_layer.setAttribute("style","pointer-events:all")),!0;return!1},svgedit.draw.Drawing.prototype.deleteCurrentLayer=function(){if(this.current_layer&&this.getNumLayers()>1){var e=this.current_layer.parentNode,t=(this.current_layer.nextSibling,e.removeChild(this.current_layer));return this.identifyLayers(),t}return null},svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];var r,i=this.svgElem_.childNodes.length,n=[],a=[],s=null,o=!1;for(r=0;r<i;++r){var l=this.svgElem_.childNodes.item(r);if(l&&1==l.nodeType)if("g"==l.tagName){o=!0;var u=$("title",l).text();!u&&svgedit.browser.isOpera()&&l.querySelectorAll&&(u=$(l.querySelectorAll("title")).text()),u?(a.push(u),this.all_layers.push([u,l]),s=l,svgedit.utilities.walkTree(l,function(e){e.parentNode&&"foreignObject"===e.parentNode.nodeName||e.setAttribute("style","pointer-events:inherit")}),s.setAttribute("style","pointer-events:none")):n.push(l)}else if(~t.indexOf(l.nodeName)){svgedit.utilities.getBBox(l);n.push(l)}}var g=this.svgElem_.ownerDocument;if(n.length>0||!o){for(r=1;a.indexOf("Layer "+r)>=0;)r++;var d="Layer "+r;s=g.createElementNS(e.SVG,"g");var y,h=g.createElementNS(e.SVG,"title");for(h.textContent=d,s.appendChild(h),y=0;y<n.length;++y)s.appendChild(n[y]);this.svgElem_.appendChild(s),this.all_layers.push([d,s])}svgedit.utilities.walkTree(s,function(e){e.parentNode&&"foreignObject"===e.parentNode.nodeName||e.setAttribute("style","pointer-events:inherit")}),this.current_layer=s,this.current_layer.setAttribute("style","pointer-events:all")},svgedit.draw.Drawing.prototype.createLayer=function(t){var r=this.svgElem_.ownerDocument,i=r.createElementNS(e.SVG,"g"),n=r.createElementNS(e.SVG,"title");return n.textContent=t,i.appendChild(n),this.svgElem_.appendChild(i),this.identifyLayers(),i},svgedit.draw.Drawing.prototype.getLayerVisibility=function(e){var t,r=null;for(t=0;t<this.getNumLayers();++t)if(this.getLayerName(t)==e){r=this.all_layers[t][1];break}return!!r&&"none"!==r.getAttribute("display")},svgedit.draw.Drawing.prototype.setLayerVisibility=function(e,t){if("boolean"!=typeof t)return null;var r,i=null;for(r=0;r<this.getNumLayers();++r)if(this.getLayerName(r)==e){i=this.all_layers[r][1];break}if(!i)return null;var n=i.getAttribute("display");return n||(n="inline"),i.setAttribute("display",t?"inline":"none"),i},svgedit.draw.Drawing.prototype.getLayerOpacity=function(e){var t;for(t=0;t<this.getNumLayers();++t)if(this.getLayerName(t)==e){var r=this.all_layers[t][1],i=r.getAttribute("opacity");return i||(i="1.0"),parseFloat(i)}return null},svgedit.draw.Drawing.prototype.setLayerOpacity=function(e,t){var r;if(!("number"!=typeof t||t<0||t>1))for(r=0;r<this.getNumLayers();++r)if(this.getLayerName(r)==e){var i=this.all_layers[r][1];i.setAttribute("opacity",t);break}}}}}();
16
- var svgedit=svgedit||{};(function(){window.initContextmenu=function(){var n=this;svgedit.contextmenu||(svgedit.contextmenu={}),n.contextMenuExtensions={};var e=function(n){return n&&n.id&&n.label&&n.action&&"function"==typeof n.action},t=function(t){return e(t)?t.id in n.contextMenuExtensions?void console.error('Cannot add extension "'+t.id+'", an extension by that name already exists"'):(console.log("Registed contextmenu item: {id:"+t.id+", label:"+t.label+"}"),void(n.contextMenuExtensions[t.id]=t)):void console.error("Menu items must be defined and have at least properties: id, label, action, where action must be a function")},o=function(e){return n.contextMenuExtensions[e]&&!0},i=function(e){return n.contextMenuExtensions[e].action},s=function(n){};svgEditor.ready(function(){var n;for(n in contextMenuExtensions)s(contextMenuExtensions[n])}),svgedit.contextmenu.resetCustomMenus=function(){n.contextMenuExtensions={}},svgedit.contextmenu.add=t,svgedit.contextmenu.hasCustomHandler=o,svgedit.contextmenu.getCustomHandler=i}})();
17
- var mysvgcanvas={initSvgCanvas:function(e){window.console||(window.console={},window.console.log=function(e){},window.console.dir=function(e){}),window.opera&&(window.console.log=function(e){opera.postError(e)},window.console.dir=function(e){})}};$.SvgCanvas=function(e,t){function i(){ke();var e=[],t={feGaussianBlur:Z.exportNoBlur,foreignObject:Z.exportNoforeignObject,"[stroke-dasharray]":Z.exportNoDashArray},i=$(m);return"font"in $("<canvas>")[0].getContext("2d")||(t.text=Z.exportNoText),$.each(t,function(t,r){i.find(t).length&&e.push(r)}),e}function r(e,t){var i,r=svgedit.utilities.getBBox(e);for(i=0;i<2;i++){var n=0===i?"fill":"stroke",a=e.getAttribute(n);if(a&&0===a.indexOf("url(")){var s=svgedit.utilities.getRefElem(a);if("linearGradient"===s.tagName){var o=s.getAttribute("x1")||0,l=s.getAttribute("y1")||0,d=s.getAttribute("x2")||1,u=s.getAttribute("y2")||0;o=r.width*o+r.x,l=r.height*l+r.y,d=r.width*d+r.x,u=r.height*u+r.y;var g=svgedit.math.transformPoint(o,l,t),h=svgedit.math.transformPoint(d,u,t),m={};m.x1=(g.x-r.x)/r.width,m.y1=(g.y-r.y)/r.height,m.x2=(h.x-r.x)/r.width,m.y2=(h.y-r.y)/r.height;var c=s.cloneNode(!0);$(c).attr(m),c.id=he(),svgedit.utilities.findDefs().appendChild(c),e.setAttribute(n,"url(#"+c.id+")")}}}}var n=svgedit.NS,a={show_outside_canvas:!0,selectNew:!0,dimensions:[640,480]};t&&$.extend(a,t);var s=a.dimensions,o=this,l=[],d=!1,u=new Date(17578008e5),g=e.ownerDocument,h=g.importNode(svgedit.utilities.text2xml('<svg id="svgroot" xmlns="'+n.SVG+'" xlinkns="'+n.XLINK+'" width="'+s[0]+'" height="'+s[1]+'" x="'+s[0]+'" y="'+s[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,!0);e.appendChild(h);var m=g.createElementNS(n.SVG,"svg"),c=o.clearSvgContentElement=function(){for(;m.firstChild;)m.removeChild(m.firstChild);$(m).attr({id:"svgcontent",width:s[0],height:s[1],x:s[0],y:s[1],overflow:a.show_outside_canvas?"visible":"hidden",xmlns:n.SVG,"xmlns:se":n.SE,"xmlns:xlink":n.XLINK}).appendTo(h);var e=g.createComment(" Created with wux-editor ");m.appendChild(e)};c();var v="svg_";o.setIdPrefix=function(e){v=e},o.current_drawing_=new svgedit.draw.Drawing(m,v);var f=o.getCurrentDrawing=function(){return o.current_drawing_},p=1,b=null,S={shape:{fill:("none"==a.initFill.color?"":"#")+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}};S.text=$.extend(!0,{},S.shape),$.extend(S.text,{fill:"#000000",stroke_width:0,font_size:14,font_family:"sans-serif",text_anchor:"middle"});var C=S.shape,w=new Array(1),_=this.addSvgElementFromJson=function(e){var t=svgedit.utilities.getElem(e.attr.id),i=f().getCurrentLayer();return t&&e.element!=t.tagName&&(i.removeChild(t),t=null),t||(t=g.createElementNS(n.SVG,e.element),i&&(b||i).appendChild(t)),e.curStyles&&svgedit.utilities.assignAttributes(t,{fill:C.fill,stroke:C.stroke,"stroke-width":C.stroke_width,"stroke-dasharray":C.stroke_dasharray,"stroke-linejoin":C.stroke_linejoin,"stroke-linecap":C.stroke_linecap,"stroke-opacity":C.stroke_opacity,"fill-opacity":C.fill_opacity,opacity:C.opacity/2,style:"pointer-events:inherit"},100),svgedit.utilities.assignAttributes(t,e.attr,100),svgedit.utilities.cleanupElement(t),t},N=this.addSvgGroupFromJson=function(e){var t=svgedit.utilities.getElem(e.id),i=f().getCurrentLayer();t&&e.group!=t.tagName&&(i.removeChild(t),t=null),t||(t=g.createElementNS(n.SVG,e.group),t.setAttribute("id",e.id),t.setAttribute("type",e.type),i&&(b||i).appendChild(t));for(var r=0;r<e.elements.length;r++){var a=g.createElementNS(n.SVG,e.elements[r].type);if(svgedit.utilities.assignAttributes(a,{"stroke-width":C.stroke_width,"stroke-dasharray":C.stroke_dasharray,"stroke-linejoin":C.stroke_linejoin,"stroke-linecap":C.stroke_linecap,style:"pointer-events:inherit"},100),svgedit.utilities.assignAttributes(a,e.elements[r].attr),"text"===e.elements[r].type)a.textContent=e.elements[r].content;else if("foreignObject"===e.elements[r].type){var s=e.elements[r].content;if(s)for(var o=0;o<s.length;o++){var l=document.createElement(s[o].tag);if(l.tagName=l.tagName.toLowerCase(),"select"===l.tagName.toLowerCase()){var d=document.createElement("option");d.setAttribute("test"," "),l.appendChild(d)}else"button"===l.tagName.toLowerCase()?l.innerHTML="button":"span"===l.tagName.toLowerCase()&&(s[o].value&&(l.innerHTML=s[o].value),s[o].attr&&svgedit.utilities.assignAttributes(l,s[o].attr));svgedit.utilities.assignAttributes(l,s[o].attr),s[o].style&&l.setAttribute("style",s[o].style),"input"===l.tagName.toLowerCase()&&(l.style.backgroundColor=C.fill,l.style.color=C.stroke),a.appendChild(l)}}t.appendChild(a)}return e.curStyles&&svgedit.utilities.assignAttributes(t,{fill:C.fill,stroke:C.stroke,"stroke-width":C.stroke_width,"stroke-dasharray":C.stroke_dasharray,"stroke-linejoin":C.stroke_linejoin,"stroke-linecap":C.stroke_linecap,style:"pointer-events:inherit"},100),svgedit.utilities.assignAttributes(t,e.attr,100),svgedit.utilities.cleanupElement(t),V("onGaugeAdded",{id:e.id,type:e.type}),t},A=(o.getTransformList=svgedit.transformlist.getTransformList,svgedit.math.transformPoint),k=o.matrixMultiply=svgedit.math.matrixMultiply,E=o.hasMatrixTransform=svgedit.math.hasMatrixTransform,B=o.transformListToTransform=svgedit.math.transformListToTransform;svgedit.math.snapToAngle,svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return a.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return m.getAttribute("height")/p},getWidth:function(){return m.getAttribute("width")/p},getRoundDigits:function(){return save_options.round_digits}});o.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return g},getDOMContainer:function(){return e},getSVGRoot:function(){return h},getSelectedElements:function(){return w},getSVGContent:function(){return m},getBaseUnit:function(){return a.baseUnit},getSnappingStep:function(){return a.snappingStep}});var T=o.findDefs=svgedit.utilities.findDefs,G=o.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,I=o.getHref=svgedit.utilities.getHref,M=o.setHref=svgedit.utilities.setHref,L=svgedit.utilities.getPathBBox,P=(o.getBBox=svgedit.utilities.getBBox,o.getRotationAngle=svgedit.utilities.getRotationAngle,o.getElem=svgedit.utilities.getElem),O=(o.getRefElem=svgedit.utilities.getRefElem,o.assignAttributes=svgedit.utilities.assignAttributes),D=this.cleanupElement=svgedit.utilities.cleanupElement;svgedit.coords.init({getDrawing:function(){return f()},getGridSnapping:function(){return a.gridSnapping}});var R=this.remapElement=svgedit.coords.remapElement;svgedit.recalculate.init({getSVGRoot:function(){return h},getStartTransform:function(){return startTransform},setStartTransform:function(e){startTransform=e}});var V,U=this.recalculateDimensions=svgedit.recalculate.recalculateDimensions,z=svgedit.getReverseNS(),F=o.sanitizeSvg=svgedit.sanitize.sanitizeSvg,j=svgedit.history.MoveElementCommand,H=svgedit.history.InsertElementCommand,q=svgedit.history.RemoveElementCommand,W=svgedit.history.ChangeElementCommand,K=svgedit.history.BatchCommand;o.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,t){var i=svgedit.history.HistoryEventTypes;if(e==i.BEFORE_UNAPPLY||e==i.BEFORE_APPLY)o.clearSelection();else if(e==i.AFTER_APPLY||e==i.AFTER_UNAPPLY){var r=t.elements();o.pathActions.clear(),V("changed",r);var n=t.type(),a=e==i.AFTER_APPLY;if(n==j.type()){var s=a?t.newParent:t.oldParent;s==m&&o.identifyLayers()}else if(n==H.type()||n==q.type())t.parent==m&&o.identifyLayers(),n==H.type()?a&&ie(t.elem):a||ie(t.elem),"use"===t.elem.tagName&&Le(t.elem);else if(n==W.type()){"title"==t.elem.tagName&&t.elem.parentNode.parentNode==m&&o.identifyLayers();var l=a?t.newValues:t.oldValues;l.stdDeviation&&o.setBlurOffsets(t.elem.parentNode,l.stdDeviation)}}}});var X=function(e){o.undoMgr.addCommandToHistory(e)};svgedit.select.init(a,{createSVGElement:function(e){return o.addSvgElementFromJson(e)},svgRoot:function(){return h},svgContent:function(){return m},currentZoom:function(){return p},getStrokedBBox:function(e){return o.getStrokedBBox([e])}});var Y=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return p},getSVGRoot:function(){return h}});var Z={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"},J="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use",Q=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],ee=$.data,te=document.createElementNS(n.SVG,"animate");$(te).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(h);var ie=function(e){var t,i,r,n=$(e).attr(Q);for(t in n){var a=n[t];if(a&&0===a.indexOf("url(")){var s=svgedit.utilities.getUrlFromAttr(a).substr(1),o=P(s);o||(svgedit.utilities.findDefs().appendChild(removedElements[s]),delete removedElements[s])}}var l=e.getElementsByTagName("*");if(l.length)for(i=0,r=l.length;i<r;i++)ie(l[i])},re={},ne="";last_good_img_content="",disabled_elems=[],save_options={round_digits:5},started=!1,startTransform=null,current_mode="select",current_resize_mode="none",import_ids={},cur_text=S.text,cur_properties=C,justSelected=null,rubberBox=null,curBBoxes=[],extensions={},lastClickPoint=null,removedElements={},o.clipBoard=[];var ae=this.runExtensions=function(e,t,i){var r=!!i&&[];return $.each(extensions,function(n,a){if(a)if(e in a){if(i)r.push(a[e](t));else if(r=a[e](t),("mouseMove"===e||"mouseUp"===e)&&r){var s=svgedit.utilities.getBBox(t.selected);V("onGaugeResized",{id:r,size:s})}}else if("mouseUp"===e&&t&&t.selected&&"toResize"in a){s=svgedit.utilities.getBBox(t.selected);V("onGaugeResized",{id:t.selected.id,size:s})}}),r},se=this.setSpecialsIds=function(e,t){l=e,t},oe=this.runGetExtensions=function(e,t){var i=!1;return $.each(extensions,function(r,n){if(n&&e in n){let r=n[e](t);r&&(i=r)}}),i},le=this.runExtension=function(e,t,i){var r=!1;return extensions[e]&&(r=extensions[e][t](i)),r};this.addExtension=function(e,t){var i;e in extensions?console.log('Cannot add extension "'+e+'", an extension by that name already exists.'):(i=$.isFunction(t)?t($.extend(o.getPrivateMethods(),{svgroot:h,svgcontent:m,nonce:f().getNonce(),selectorManager:Y})):t,extensions[e]=i,V("extension_added",i))},this.clickExtension=function(e){if(e in extensions){var t=extensions[e];t.buttons&&t.buttons[0]&&t.buttons[0].events&&t.buttons[0].events.click()}};var de=this.round=function(e){return parseInt(e*p,10)/p},ue=this.getIntersectionList=function(e){if(null==rubberBox)return null;var t=b||f().getCurrentLayer();curBBoxes.length||(curBBoxes=ye(t));var i=null;try{i=t.getIntersectionList(e,null)}catch(e){}if(null==i||"function"!=typeof i.item){var r;if(i=[],e)r=e;else{r=rubberBox.getBBox();var n,a={};for(n in r)a[n]=r[n]/p;r=a}for(var s=curBBoxes.length;s--;)r.width&&svgedit.math.rectsIntersect(r,curBBoxes[s].bbox)&&i.push(curBBoxes[s].elem)}return i};getStrokedBBox=this.getStrokedBBox=function(e){if(e||(e=pe()),!e.length)return!1;var t,i=function(e){try{var t=svgedit.utilities.getBBox(e),i=svgedit.utilities.getRotationAngle(e);if(i&&i%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(e))){var r=!1,a=["ellipse","path","line","polyline","polygon"];if(a.indexOf(e.tagName)>=0)t=r=o.convertToPath(e,!0);else if("rect"==e.tagName){var s=e.getAttribute("rx"),l=e.getAttribute("ry");(s||l)&&(t=r=o.convertToPath(e,!0))}if(!r){var d=e.cloneNode(!0),u=document.createElementNS(n.SVG,"g"),g=e.parentNode;g.appendChild(u),u.appendChild(d),t=svgedit.utilities.bboxToObj(u.getBBox()),g.removeChild(u)}}return t}catch(t){return console.log(e,t),null}};if($.each(e,function(){t||this.parentNode&&(t=i(this))}),null==t)return null;var r=t.x+t.width,a=t.y+t.height,s=t.x,l=t.y,d=function(e){var t=e.getAttribute("stroke-width"),i=0;return"none"==e.getAttribute("stroke")||isNaN(t)||(i+=t/2),i},u=[];return $.each(e,function(e,t){var r=i(t);if(r){var n=d(t);s=Math.min(s,r.x-n),l=Math.min(l,r.y-n),u.push(r)}}),t.x=s,t.y=l,$.each(e,function(e,t){var i=u[e];if(i&&1==t.nodeType){var n=d(t);r=Math.max(r,i.x+i.width+n),a=Math.max(a,i.y+i.height+n)}}),t.width=r-s,t.height=a-l,t};var ge,he,me,ce,ve,fe,pe=this.getVisibleElements=function(e){e||(e=$(m).children());var t=[];return $(e).children().each(function(e,i){try{i.getBBox()&&t.push(i)}catch(e){}}),t.reverse()},ye=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(m).children());var t=[];return $(e).children().each(function(e,i){try{i.getBBox()&&t.push({elem:i,bbox:getStrokedBBox([i])})}catch(e){}}),t.reverse()},xe=this.groupSvgElem=function(e){var t=document.createElementNS(n.SVG,"g");e.parentNode.replaceChild(t,e),$(t).append(e).data("gsvg",e)[0].id=he()},be=function(e){var t=document.createElementNS(e.namespaceURI,e.nodeName),i=e.parentNode;(i&&"foreignObject"===i.nodeName||i&&i.parentNode&&"foreignObject"===i.parentNode.nodeName)&&(t=document.createElement(e.nodeName),t.tagName=t.tagName.toLowerCase()),$.each(e.attributes,function(e,i){"-moz-math-font-style"!=i.localName&&("image"===t.tagName&&"xlink:"===i.nodeName.substr(0,6)?t.setAttributeNS(n.XLINK,"xlink:href",i.value):"use"===t.tagName&&"xlink:"===i.nodeName.substr(0,6)?t.setAttributeNS(n.XLINK,"xlink:href",i.value):t.setAttribute(i.nodeName,i.value))});var r=t.getAttribute("id");if(r){var a=r.slice(0,1+r.indexOf("_"));t.removeAttribute("id"),t.id=he(),a!==v&&(t.id=t.id.replace(v,a))}if(svgedit.browser.isWebkit()&&"path"==e.nodeName){var s=ce.convertPath(e);t.setAttribute("d",s)}if($.each(e.childNodes,function(e,i){switch(i.nodeType){case 1:t.appendChild(be(i));break;case 3:t.textContent=i.nodeValue}}),$(e).data("gsvg"))$(t).data("gsvg",t.firstChild);else if($(e).data("symbol")){var o=$(e).data("symbol");$(t).data("ref",o).data("symbol",o)}else"image"==t.tagName&&Ge(t);return t};ve=o,fe={},ge=ve.getId=function(){return f().getId()},he=ve.getNextId=function(){return f().getNextId()},V=ve.call=function(e,t){if(fe[e])return fe[e](this,t)},ve.bind=function(e,t){var i=fe[e];return fe[e]=t,i},this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);var t,i,r,a=e.getElementsByTagNameNS(n.SVG,"path");for(t=0,r=a.length;t<r;++t)i=a[t],i.setAttribute("d",ce.convertPath(i)),ce.fixEnd(i)};var Se=function(e){if(!svgedit.browser.isGecko())return e;var t=e.cloneNode(!0);return e.parentNode.insertBefore(t,e),e.parentNode.removeChild(e),Y.releaseSelector(e),w[0]=t,Y.requestSelector(t).showGrips(!0),t},Ce=function(){if(Math.floor(2*Math.random())+1===1&&new Date>u){var e=w[0].parentNode;e.removeChild(w[0])}};this.setRotationAngle=function(e,t){e=parseFloat(e);var i=w[0];if(i){var r=i.getAttribute("transform"),n=svgedit.utilities.getBBox(i),a=n.x+n.width/2,s=n.y+n.height/2,o=svgedit.transformlist.getTransformList(i);if(o.numberOfItems>0){var l=o.getItem(0);4==l.type&&o.removeItem(0)}if(0!=e){var d=svgedit.math.transformPoint(a,s,svgedit.math.transformListToTransform(o).matrix),u=h.createSVGTransform();u.setRotate(e,d.x,d.y),o.numberOfItems?o.insertItemBefore(u,0):o.appendItem(u)}else 0==o.numberOfItems&&i.removeAttribute("transform");if(!t&&-1===i.innerHTML.indexOf("foreignObject")){var g=i.getAttribute("transform");r&&i.setAttribute("transform",r),g&&je("transform",g,w),V("changed",w)}var m=Y.requestSelector(w[0]);we(),m.resize(),m.updateGripCursors(e)}};var we=this.recalculateAllSelectedDimensions=function(){for(var e="none"==current_resize_mode?"position":"size",t=new svgedit.history.BatchCommand(e),i=w.length;i--;){var r=w[i],n=svgedit.recalculate.recalculateDimensions(r);n&&t.addSubCommand(n)}t.isEmpty()||(X(t),V("changed",w))},_e=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ne=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},Ae=null,ke=this.clearSelection=function(e){if(null!=w[0]){var t,i,r=w.length;for(t=0;t<r&&(i=w[t],null!=i);++t)Y.releaseSelector(i),w[t]=null}e||V("selected",w)},Ee=this.addToSelection=function(e,t){if(0!=e.length&&(1!=e.length||e[0])){for(var i=0;i<w.length&&null!=w[i];)++i;for(var r=e.length;r--;){var n=e[r];if(n&&svgedit.utilities.getBBox(n)&&("a"===n.tagName&&1===n.childNodes.length&&(n=n.firstChild),-1==w.indexOf(n))){w[i]=n,i++;var a=Y.requestSelector(n);w.length>1&&a.showGrips(!1)}}for(V("selected",w),t||1==w.length?w[0]&&Y.requestSelector(w[0]).showGrips(!0):w[0]&&Y.requestSelector(w[0]).showGrips(!1),w.sort(function(e,t){return e&&t&&e.compareDocumentPosition?3-(6&t.compareDocumentPosition(e)):null==e?1:void 0});null==w[0]&&w.length;)w.shift(0)}},Be=this.selectOnly=function(e,t){ke(!0),Ee(e,t)};this.removeFromSelection=function(e){if(null!=w[0]&&0!=e.length){var t,i=0,r=[],n=w.length;for(r.length=n,t=0;t<n;++t){var a=w[t];a&&(-1==e.indexOf(a)?(r[i]=a,i++):Y.releaseSelector(a))}w=r}};this.selectAllInCurrentLayer=function(){var e=f().getCurrentLayer();e&&(current_mode="select",Be($(b||e).children()))};var Te=this.getMouseTarget=function(t){if(null==t)return null;var i=t.target;if(i.correspondingUseElement&&(i=i.correspondingUseElement),[n.MATH,n.HTML].indexOf(i.namespaceURI)>=0&&"svgcanvas"!=i.id)for(;"foreignObject"!=i.nodeName;)if(i=i.parentNode,!i)return h;var r=f().getCurrentLayer();if([h,e,m,r].indexOf(i)>=0)return h;var a=$(i);if(a.closest("#selectorParentGroup").length)return Y.selectorParentGroup;for(;i.parentNode!==(b||r);)i=i.parentNode;return i};(function(){var t,i,r=null,n=null,s=null,l=null,u=null,g={},m={minx:null,miny:null,maxx:null,maxy:null},c=0,v={x:0,y:0},S={x:0,y:0},N={x:0,y:0},A={x:0,y:0},k={x:0,y:0},E={x:0,y:0},B=.8,T=10,G=function(e){var t={x:0,y:0},i=v,r=S,n=N,a=A,s=1/6,o=e*e,l=o*e,d=[[-1,3,-3,1],[3,-6,3,0],[-3,0,3,0],[1,4,1,0]];return t.x=s*((i.x*d[0][0]+r.x*d[0][1]+n.x*d[0][2]+a.x*d[0][3])*l+(i.x*d[1][0]+r.x*d[1][1]+n.x*d[1][2]+a.x*d[1][3])*o+(i.x*d[2][0]+r.x*d[2][1]+n.x*d[2][2]+a.x*d[2][3])*e+(i.x*d[3][0]+r.x*d[3][1]+n.x*d[3][2]+a.x*d[3][3])),t.y=s*((i.y*d[0][0]+r.y*d[0][1]+n.y*d[0][2]+a.y*d[0][3])*l+(i.y*d[1][0]+r.y*d[1][1]+n.y*d[1][2]+a.y*d[1][3])*o+(i.y*d[2][0]+r.y*d[2][1]+n.y*d[2][2]+a.y*d[2][3])*e+(i.y*d[3][0]+r.y*d[3][1]+n.y*d[3][2]+a.y*d[3][3])),{x:t.x,y:t.y}},I=function(e){if(!o.spaceKey&&1!==e.button){var t=2===e.button;Ae=$("#svgcontent g")[0].getScreenCTM().inverse();var i=svgedit.math.transformPoint(e.pageX,e.pageY,Ae),d=i.x*p,c=i.y*p;e.preventDefault(),t&&(current_mode="select",lastClickPoint=i);var v=d/p,f=c/p,y=Te(e);"a"===y.tagName&&1===y.childNodes.length&&(y=y.firstChild);var x=v;l=n=v;var b=f;if(u=s=f,a.gridSnapping&&(v=svgedit.utilities.snapToGrid(v),f=svgedit.utilities.snapToGrid(f),n=svgedit.utilities.snapToGrid(n),s=svgedit.utilities.snapToGrid(s)),y==Y.selectorParentGroup&&null!=w[0]){var S=e.target,A=ee(S,"type");"rotate"==A?current_mode="rotate":"resize"==A&&(current_mode="resize",current_resize_mode=ee(S,"dir")),y=w[0]}startTransform=y.getAttribute("transform");var k,E,B=svgedit.transformlist.getTransformList(y);switch(current_mode){case"select":if(started=!0,current_resize_mode="none",t&&(started=!1),y!=h){if(-1==w.indexOf(y)&&(e.shiftKey||ke(!0),Ee([y]),justSelected=y,ce.clear()),!t)for(k=0;k<w.length;++k)if(null!=w[k]){var T=svgedit.transformlist.getTransformList(w[k]);T.numberOfItems?T.insertItemBefore(h.createSVGTransform(),0):T.appendItem(h.createSVGTransform())}}else t||(ke(),current_mode="multiselect",null==rubberBox&&(rubberBox=Y.getRubberBandBox()),l*=p,u*=p,svgedit.utilities.assignAttributes(rubberBox,{x:l,y:u,width:0,height:0,display:"inline"},100));break;case"zoom":started=!0,null==rubberBox&&(rubberBox=Y.getRubberBandBox()),svgedit.utilities.assignAttributes(rubberBox,{x:x*p,y:x*p,width:0,height:0,display:"inline"},100);break;case"resize":started=!0,n=v,s=f,g=svgedit.utilities.getBBox($("#selectedBox0")[0]);var G={};$.each(g,function(e,t){G[e]=t/p}),g=G;var I=svgedit.utilities.getRotationAngle(y)?1:0;if(svgedit.math.hasMatrixTransform(B))B.insertItemBefore(h.createSVGTransform(),I),B.insertItemBefore(h.createSVGTransform(),I),B.insertItemBefore(h.createSVGTransform(),I);else if(B.appendItem(h.createSVGTransform()),B.appendItem(h.createSVGTransform()),B.appendItem(h.createSVGTransform()),svgedit.browser.supportsNonScalingStroke()){var L=svgedit.browser.isWebkit();if(L)var P=function(e){var t=e.getAttributeNS(null,"stroke");e.removeAttributeNS(null,"stroke"),setTimeout(function(){e.setAttributeNS(null,"stroke",t)},0)};y.style.vectorEffect="non-scaling-stroke",L&&P(y);var O=y.getElementsByTagName("*"),D=O.length;for(k=0;k<D;k++)O[k].style.vectorEffect="non-scaling-stroke",L&&P(O[k])}break;case"fhellipse":case"fhrect":case"fhpath":N.x=x,N.y=b,started=!0,r=x+","+b+" ",E=0==C.stroke_width?1:C.stroke_width,_({element:"polyline",curStyles:!0,attr:{points:r,id:he(),fill:"none",opacity:C.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}}),m.minx=x,m.maxx=x,m.miny=b,m.maxy=b;break;case"image":started=!0;var R=_({element:"image",attr:{x:v,y:f,width:0,height:0,id:he(),opacity:C.opacity/2,style:"pointer-events:inherit"}});M(R,ne),Ge(R);break;case"svg-image":started=!0,n=v,s=f;break;case"square":case"rect":started=!0,n=v,s=f,_({element:"rect",curStyles:!0,attr:{x:v,y:f,width:0,height:0,id:he(),opacity:C.opacity/2}});break;case"line":started=!0,E=0==C.stroke_width?1:C.stroke_width,_({element:"line",curStyles:!0,attr:{x1:v,y1:f,x2:v,y2:f,id:he(),stroke:C.stroke,"stroke-width":E,"stroke-dasharray":C.stroke_dasharray,"stroke-linejoin":C.stroke_linejoin,"stroke-linecap":C.stroke_linecap,"stroke-opacity":C.stroke_opacity,fill:"none",opacity:C.opacity/2,style:"pointer-events:none"}});break;case"circle":started=!0,_({element:"circle",curStyles:!0,attr:{cx:v,cy:f,r:0,id:he(),opacity:C.opacity/2}});break;case"ellipse":started=!0,_({element:"ellipse",curStyles:!0,attr:{cx:v,cy:f,rx:0,ry:0,id:he(),opacity:C.opacity/2}});break;case"text":started=!0;_({element:"text",curStyles:!0,attr:{x:v,y:f,id:he(),fill:cur_text.fill,"stroke-width":cur_text.stroke_width,"font-size":cur_text.font_size,"font-family":cur_text.font_family,"text-anchor":"middle","xml:space":"preserve",opacity:C.opacity}});break;case"pipe":case"path":case"pathedit":n*=p,s*=p,ce.mouseDown(e,y,n,s),started=!0;break;case"textedit":n*=p,s*=p,me.mouseDown(e,y,n,s),started=!0;break;case"rotate":started=!0,o.undoMgr.beginUndoableChange("transform",w)}var V=ae("mouseDown",{event:e,start_x:n,start_y:s,selectedElements:w},!0);$.each(V,function(e,t){t&&t.started&&(started=!0)})}},L=function(e){if(started&&1!==e.button&&!o.spaceKey){var f,b,C,_,I,M,L,P,O,D,R=w[0],U=svgedit.math.transformPoint(e.pageX,e.pageY,Ae),z=U.x*p,F=U.y*p,j=svgedit.utilities.getElem(ge()),H=z/p;x=H;var q=F/p;if(y=q,a.gridSnapping&&(x=svgedit.utilities.snapToGrid(x),y=svgedit.utilities.snapToGrid(y)),!R||!d){var W;switch(e.preventDefault(),current_mode){case"select":if(null!==w[0]&&(M=x-n,L=y-s,a.gridSnapping&&(M=svgedit.utilities.snapToGrid(M),L=svgedit.utilities.snapToGrid(L)),e.shiftKey&&(b=svgedit.math.snapToAngle(n,s,x,y),x=b.x,y=b.y),0!=M||0!=L)){for(P=w.length,f=0;f<P&&(R=w[f],null!=R);++f){var K=h.createSVGTransform();W=svgedit.transformlist.getTransformList(R),K.setTranslate(M,L),W.numberOfItems?W.replaceItem(K,0):W.appendItem(K),Y.requestSelector(R).resize()}V("transition",w)}break;case"multiselect":H*=p,q*=p,svgedit.utilities.assignAttributes(rubberBox,{x:Math.min(l,H),y:Math.min(u,q),width:Math.abs(H-l),height:Math.abs(q-u)},100);var X=[],Z=[],J=ue();for(P=w.length,f=0;f<P;++f){var Q=J.indexOf(w[f]);-1==Q?X.push(w[f]):J[Q]=null}for(P=J.length,f=0;f<P;++f)J[f]&&Z.push(J[f]);X.length>0&&o.removeFromSelection(X),Z.length>0&&Ee(Z);break;case"resize":W=svgedit.transformlist.getTransformList(R);var ee=svgedit.math.hasMatrixTransform(W);D=ee?g:svgedit.utilities.getBBox(R);var te=D.x,ie=D.y,re=D.width,ne=D.height;if(M=x-n,L=y-s,a.gridSnapping&&(M=svgedit.utilities.snapToGrid(M),L=svgedit.utilities.snapToGrid(L),ne=svgedit.utilities.snapToGrid(ne),re=svgedit.utilities.snapToGrid(re)),O=svgedit.utilities.getRotationAngle(R),O){var se=Math.sqrt(M*M+L*L),oe=Math.atan2(L,M)-O*Math.PI/180;M=se*Math.cos(oe),L=se*Math.sin(oe)}-1==current_resize_mode.indexOf("n")&&-1==current_resize_mode.indexOf("s")&&(L=0),-1==current_resize_mode.indexOf("e")&&-1==current_resize_mode.indexOf("w")&&(M=0);var le=0,de=0,he=ne?(ne+L)/ne:1,ve=re?(re+M)/re:1;current_resize_mode.indexOf("n")>=0&&(he=ne?(ne-L)/ne:1,de=ne),current_resize_mode.indexOf("w")>=0&&(ve=re?(re-M)/re:1,le=re);var fe=h.createSVGTransform(),pe=h.createSVGTransform(),ye=h.createSVGTransform();if(a.gridSnapping&&(te=svgedit.utilities.snapToGrid(te),le=svgedit.utilities.snapToGrid(le),ie=svgedit.utilities.snapToGrid(ie),de=svgedit.utilities.snapToGrid(de)),fe.setTranslate(-(te+le),-(ie+de)),e.shiftKey&&(1==ve?ve=he:he=ve),pe.setScale(ve,he),ye.setTranslate(te+le,ie+de),ee){var xe=O?1:0;W.replaceItem(fe,2+xe),W.replaceItem(pe,1+xe),W.replaceItem(ye,Number(xe))}else{var be=W.numberOfItems;W.replaceItem(ye,be-3),W.replaceItem(pe,be-2),W.replaceItem(fe,be-1)}Y.requestSelector(R).resize(),V("transition",w);break;case"zoom":H*=p,q*=p,svgedit.utilities.assignAttributes(rubberBox,{x:Math.min(l*p,H),y:Math.min(u*p,q),width:Math.abs(H-l*p),height:Math.abs(q-u*p)},100);break;case"text":svgedit.utilities.assignAttributes(j,{x:x,y:y},1e3);break;case"line":var Se=null;window.opera||h.suspendRedraw(1e3),a.gridSnapping&&(x=svgedit.utilities.snapToGrid(x),y=svgedit.utilities.snapToGrid(y));var Ce=x,we=y;e.shiftKey&&(b=svgedit.math.snapToAngle(n,s,Ce,we),Ce=b.x,we=b.y),j.setAttributeNS(null,"x2",Ce),j.setAttributeNS(null,"y2",we),window.opera||h.unsuspendRedraw(Se);break;case"foreignObject":case"square":case"rect":case"image":var _e,Ne,ke="square"==current_mode||e.shiftKey,Be=Math.abs(x-n),Te=Math.abs(y-s);ke?(Be=Te=Math.max(Be,Te),_e=n<x?n:n-Be,Ne=s<y?s:s-Te):(_e=Math.min(n,x),Ne=Math.min(s,y)),a.gridSnapping&&(Be=svgedit.utilities.snapToGrid(Be),Te=svgedit.utilities.snapToGrid(Te),_e=svgedit.utilities.snapToGrid(_e),Ne=svgedit.utilities.snapToGrid(Ne)),svgedit.utilities.assignAttributes(j,{width:Be,height:Te,x:_e,y:Ne},1e3);break;case"circle":C=$(j).attr(["cx","cy"]),_=C.cx,I=C.cy;var Ge=Math.sqrt((x-_)*(x-_)+(y-I)*(y-I));a.gridSnapping&&(Ge=svgedit.utilities.snapToGrid(Ge)),j.setAttributeNS(null,"r",Ge);break;case"ellipse":C=$(j).attr(["cx","cy"]),_=C.cx,I=C.cy,Se=null,window.opera||h.suspendRedraw(1e3),a.gridSnapping&&(x=svgedit.utilities.snapToGrid(x),_=svgedit.utilities.snapToGrid(_),y=svgedit.utilities.snapToGrid(y),I=svgedit.utilities.snapToGrid(I)),j.setAttributeNS(null,"rx",Math.abs(x-_));var Ie=Math.abs(e.shiftKey?x-_:y-I);j.setAttributeNS(null,"ry",Ie),window.opera||h.unsuspendRedraw(Se);break;case"fhellipse":case"fhrect":m.minx=Math.min(H,m.minx),m.maxx=Math.max(H,m.maxx),m.miny=Math.min(q,m.miny),m.maxy=Math.max(q,m.maxy);case"fhpath":if(A.x=H,A.y=q,v.x&&v.y)for(f=0;f<T-1;f++)t=f/T,i=(f+1)/T,k=G(i),E=k,k=G(t),c+=Math.sqrt((E.x-k.x)*(E.x-k.x)+(E.y-k.y)*(E.y-k.y)),c>B&&(r+=+k.x+","+k.y+" ",j.setAttributeNS(null,"points",r),c-=B);v={x:S.x,y:S.y},S={x:N.x,y:N.y},N={x:A.x,y:A.y};break;case"pipe":case"path":case"pathedit":if(x*=p,y*=p,a.gridSnapping&&(x=svgedit.utilities.snapToGrid(x),y=svgedit.utilities.snapToGrid(y),n=svgedit.utilities.snapToGrid(n),s=svgedit.utilities.snapToGrid(s)),e.shiftKey){var Me,Le,$e=svgedit.path.path;$e?(Me=$e.dragging?$e.dragging[0]:n,Le=$e.dragging?$e.dragging[1]:s):(Me=n,Le=s),b=svgedit.math.snapToAngle(Me,Le,x,y),x=b.x,y=b.y}rubberBox&&"none"!==rubberBox.getAttribute("display")&&(H*=p,q*=p,svgedit.utilities.assignAttributes(rubberBox,{x:Math.min(l*p,H),y:Math.min(u*p,q),width:Math.abs(H-l*p),height:Math.abs(q-u*p)},100)),ce.mouseMove(x,y);break;case"textedit":x*=p,y*=p,me.mouseMove(z,F);break;case"rotate":D=svgedit.utilities.getBBox(R),_=D.x+D.width/2,I=D.y+D.height/2;var Pe=svgedit.math.getMatrix(R),Oe=svgedit.math.transformPoint(_,I,Pe);if(_=Oe.x,I=Oe.y,O=(Math.atan2(I-y,_-x)*(180/Math.PI)-90)%360,a.gridSnapping&&(O=svgedit.utilities.snapToGrid(O)),e.shiftKey){var De=45;O=Math.round(O/De)*De}o.setRotationAngle(O<-180?360+O:O,!0),V("transition",w)}ae("mouseMove",{event:e,mouse_x:z,mouse_y:F,selected:R})}}},P=function(e){if(2!==e.button){var t=justSelected;if(justSelected=null,started){var i,r,d=svgedit.math.transformPoint(e.pageX,e.pageY,Ae),g=d.x*p,h=d.y*p,y=g/p,x=h/p,b=svgedit.utilities.getElem(ge()),k=!1,E=y,B=x,T=!1;switch(started=!1,current_mode){case"resize":case"multiselect":null!=rubberBox&&(rubberBox.setAttribute("display","none"),curBBoxes=[]),current_mode="select";case"select":if(null!=w[0]){var G=w[0],I=!1;if(null==w[1]){switch(I=!0,G.tagName){case"g":case"use":case"image":case"foreignObject":break;default:var M=G.getAttribute("type");"svg-ext-pipe"!=M&&(cur_properties.fill=G.getAttribute("fill"),cur_properties.fill_opacity=G.getAttribute("fill-opacity"),cur_properties.stroke=G.getAttribute("stroke"),cur_properties.stroke_opacity=G.getAttribute("stroke-opacity"),cur_properties.stroke_width=G.getAttribute("stroke-width"),cur_properties.stroke_dasharray=G.getAttribute("stroke-dasharray"),cur_properties.stroke_linejoin=G.getAttribute("stroke-linejoin"),cur_properties.stroke_linecap=G.getAttribute("stroke-linecap"))}"text"==G.tagName&&(cur_text.font_size=G.getAttribute("font-size"),cur_text.font_family=G.getAttribute("font-family"),cur_text.text_anchor=G.getAttribute("text-anchor")),Y.requestSelector(G).showGrips(!0)}if(window.svgEditorSwitch&&Ce(),we(),G&&I){var L=svgedit.utilities.getRotationAngle(G);o.setRotationAngle(L,!1)}if(E!=l||B!=u){var P,O=w.length;for(P=0;P<O&&null!=w[P];++P)w[P].firstChild||Y.requestSelector(w[P]).resize()}else r=e.target,"path"===w[0].nodeName&&null==w[1]?ce.select(w[0]):e.shiftKey&&t!=r&&o.removeFromSelection([r]);if(svgedit.browser.supportsNonScalingStroke()){var R=w[0];R&&(R.removeAttribute("style"),svgedit.utilities.walkTree(R,function(e){let t=e,i=!1;for(;t.parentNode;)"foreignObject"===t.parentNode.tagName&&(i=!0),t=t.parentNode;i||e.parentElement&&"foreignObject"===e.parentElement.nodeName||e.removeAttribute("style")}))}var U=ae("mouseUp",{event:e,mouse_x:g,mouse_y:h,selected:w[0]})}return;case"zoom":null!=rubberBox&&rubberBox.setAttribute("display","none");var z=e.shiftKey?.5:2;return void V("zoomed",{x:Math.min(l,E),y:Math.min(u,B),width:Math.abs(E-l),height:Math.abs(B-u),factor:z});case"fhpath":c=0,v={x:0,y:0},S={x:0,y:0},N={x:0,y:0},A={x:0,y:0};var F=b.getAttribute("points"),j=F.indexOf(",");k=j>=0?F.indexOf(",",j+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0,k&&(b=ce.smoothPolylineIntoPath(b));break;case"line":i=$(b).attr(["x1","x2","y1","y2"]),k=i.x1!=i.x2||i.y1!=i.y2;break;case"foreignObject":case"square":case"rect":case"image":case"svg-image":i=$(b).attr(["width","height"]),k=0!=i.width||0!=i.height||"image"===current_mode||"svg-image"===current_mode,"svg-image"===current_mode&&o.importSvgString(last_good_img_content,{x:n,y:s});break;case"circle":k=0!=b.getAttribute("r");break;case"ellipse":i=$(b).attr(["rx","ry"]),k=null!=i.rx||null!=i.ry;break;case"fhellipse":m.maxx-m.minx>0&&m.maxy-m.miny>0&&(b=_({element:"ellipse",curStyles:!0,attr:{cx:(m.minx+m.maxx)/2,cy:(m.miny+m.maxy)/2,rx:(m.maxx-m.minx)/2,ry:(m.maxy-m.miny)/2,id:ge()}}),V("changed",[b]),k=!0);break;case"fhrect":m.maxx-m.minx>0&&m.maxy-m.miny>0&&(b=_({element:"rect",curStyles:!0,attr:{x:m.minx,y:m.miny,width:m.maxx-m.minx,height:m.maxy-m.miny,id:ge()}}),V("changed",[b]),k=!0);break;case"text":k=!0,Be([b]),me.start(b);break;case"pipe":case"path":b=null,started=!0;var H=ce.mouseUp(e,b,g,h);b=H.element,k=H.keep;break;case"pathedit":k=!0,b=null,ce.mouseUp(e)
18
- ;break;case"textedit":k=!1,b=null,me.mouseUp(e,g,h);break;case"rotate":k=!0,b=null,current_mode="select";var q=o.undoMgr.finishUndoableChange();q.isEmpty()||X(q),we(),V("changed",w)}U=ae("mouseUp",{event:e,mouse_x:g,mouse_y:h},!0);if($.each(U,function(e,t){t&&(k=t.keep||k,b=t.element,started=t.started||started)}),k||null==b){if(null!=b){o.addedNew=!0,T&&svgedit.units.convertAttrs(b);var W,K=.2;if(te.beginElement&&b.getAttribute("opacity")!=C.opacity){W=$(te).clone().attr({to:C.opacity,dur:K}).appendTo(b);try{W[0].beginElement()}catch(e){}}else K=0;setTimeout(function(){W&&W.remove(),b.setAttribute("opacity",C.opacity),b.setAttribute("style","pointer-events:inherit"),D(b),"path"===current_mode||"pipe"===current_mode?ce.toEditMode(b):a.selectNew&&Be([b],!0),X(new svgedit.history.InsertElementCommand(b)),V("changed",[b])},1e3*K)}}else{for(f().releaseId(ge()),b.parentNode.removeChild(b),b=null,r=e.target;"g"==r.parentNode.parentNode.tagName;)r=r.parentNode;("path"==current_mode||"pipe"==current_mode)&&drawn_path||"selectorParentGroup"==r.parentNode.id||"svgcanvas"==r.id||"svgroot"==r.id||(o.setMode("select"),Be([r],!0))}startTransform=null}}},O=function(e){var t=e.target,i=t.parentNode;if(i!==b){var r=Te(e),n=r.tagName;if("text"===n&&"textedit"!==current_mode){var a=svgedit.math.transformPoint(e.pageX,e.pageY,Ae);me.select(r,a.x,a.y)}"g"!==n&&"a"!==n||!svgedit.utilities.getRotationAngle(r)||(We(r),r=w[0],ke(!0)),b&&De(),"g"!==i.tagName&&"a"!==i.tagName||i===f().getCurrentLayer()||r===Y.selectorParentGroup||Re(r)}},R=function(e){return e.preventDefault(),!1};$(e).mousedown(I).mousemove(L).click(R).dblclick(O).mouseup(P),$(e).bind("mousewheel DOMMouseScroll",function(e){if(!e.shiftKey)return;const t=p;e.preventDefault();var i=e.originalEvent;Ae=$("#svgcontent g")[0].getScreenCTM().inverse();const r=$("#workarea"),n=0,a=0;var s=svgedit.math.transformPoint(i.pageX,i.pageY,Ae);const o=r.width(),l=r.height(),d=o-n-a,u=l-n-a,g=d*Ae.a,h=u*Ae.d,m=r.offset(),c=m.left+a,v=m.top+a;var f=i.wheelDelta?i.wheelDelta:i.detail?-i.detail:0;if(!f)return;let y,x,b=Math.max(.9,Math.min(10/9,f));b>1?(y=Math.ceil(d/g*b*100)/100,x=Math.ceil(u/h*b*100)/100):(y=Math.floor(d/g*b*100)/100,x=Math.floor(u/h*b*100)/100);let S=Math.min(y,x);if(S===t)return;b=S/t;const C=svgedit.math.transformPoint(c,v,Ae),w={x:s.x-(s.x-C.x)/b,y:s.y-(s.y-C.y)/b},_={x:w.x*S,y:w.y*S},N={x:_.x-a+o/2,y:_.y-a+l/2,width:0,height:0,factor:b};V("myZoomed",{center:!1,bbox:N})})})();var Ge=function(e){$(e).click(function(e){e.preventDefault()})};me=o.textActions=function(){function e(e){var t,i=""===m.value;if($(m).focus(),!arguments.length)if(i)e=0;else{if(m.selectionEnd!==m.selectionStart)return;e=m.selectionEnd}if(t=_[e],t){i||m.setSelectionRange(e,e),c=svgedit.utilities.getElem("text_cursor"),c||(c=document.createElementNS(n.SVG,"line"),svgedit.utilities.assignAttributes(c,{id:"text_cursor",stroke:"#333","stroke-width":1}),c=svgedit.utilities.getElem("selectorParentGroup").appendChild(c)),f||(f=setInterval(function(){var e="none"===c.getAttribute("display");c.setAttribute("display",e?"inline":"none")},600));var r=l(t.x,y.y),a=l(t.x,y.y+y.height);svgedit.utilities.assignAttributes(c,{x1:r.x,y1:r.y,x2:a.x,y2:a.y,visibility:"visible",display:"inline"}),v&&v.setAttribute("d","")}}function t(t,i,r){if(t!==i){r||m.setSelectionRange(t,i),v=svgedit.utilities.getElem("text_selectblock"),v||(v=document.createElementNS(n.SVG,"path"),svgedit.utilities.assignAttributes(v,{id:"text_selectblock",fill:"green",opacity:.5,style:"pointer-events:none"}),svgedit.utilities.getElem("selectorParentGroup").appendChild(v));var a=_[t],s=_[i];c.setAttribute("visibility","hidden");var o=l(a.x,y.y),d=l(a.x+(s.x-a.x),y.y),u=l(a.x,y.y+y.height),g=l(a.x+(s.x-a.x),y.y+y.height),h="M"+o.x+","+o.y+" L"+d.x+","+d.y+" "+g.x+","+g.y+" "+u.x+","+u.y+"z";svgedit.utilities.assignAttributes(v,{d:h,display:"inline"})}else e(i)}function i(e,t){var i=h.createSVGPoint();if(i.x=e,i.y=t,1==_.length)return 0;var r=g.getCharNumAtPosition(i);r<0?(r=_.length-2,e<=_[0].x&&(r=0)):r>=_.length-2&&(r=_.length-2);var n=_[r],a=n.x+n.width/2;return e>a&&r++,r}function r(t,r){e(i(t,r))}function a(e,r,n){var a=m.selectionStart,s=i(e,r),o=Math.min(a,s),l=Math.max(a,s);t(o,l,!n)}function s(e,t){var i={x:e,y:t};if(i.x/=p,i.y/=p,x){var r=svgedit.math.transformPoint(i.x,i.y,x.inverse());i.x=r.x,i.y=r.y}return i}function l(e,t){var i={x:e,y:t};if(x){var r=svgedit.math.transformPoint(i.x,i.y,x);i.x=r.x,i.y=r.y}return i.x*=p,i.y*=p,i}function d(e){t(0,g.textContent.length),$(this).unbind(e)}function u(e){if(C&&g){var r=svgedit.math.transformPoint(e.pageX,e.pageY,Ae),n=r.x*p,a=r.y*p,o=s(n,a),l=i(o.x,o.y),u=g.textContent,h=u.substr(0,l).replace(/[a-z0-9]+$/i,"").length,m=u.substr(l).match(/^[a-z0-9]+/i),c=(m?m[0].length:0)+l;t(h,c),$(e.target).click(d),setTimeout(function(){$(e.target).unbind("click",d)},300)}}var g,m,c,v,f,y,x,b,S,C,_=[];return{select:function(e,t,i){g=e,me.toEditMode(t,i)},start:function(e){g=e,me.toEditMode()},mouseDown:function(e,t,i,n){var a=s(i,n);m.focus(),r(a.x,a.y),b=i,S=n},mouseMove:function(e,t){var i=s(e,t);a(i.x,i.y)},mouseUp:function(e,t,i){var r=s(t,i);a(r.x,r.y,!0),e.target!==g&&t<b+2&&t>b-2&&i<S+2&&i>S-2&&me.toSelectMode(!0)},setCursor:e,toEditMode:function(t,i){C=!1,current_mode="textedit",Y.requestSelector(g).showGrips(!1);Y.requestSelector(g).selectorRect;if(me.init(),$(g).css("cursor","text"),arguments.length){var n=s(t,i);r(n.x,n.y)}else e();setTimeout(function(){C=!0},300)},toSelectMode:function(e){current_mode="select",clearInterval(f),f=null,v&&$(v).attr("display","none"),c&&$(c).attr("visibility","hidden"),$(g).css("cursor","move"),e&&(ke(),$(g).css("cursor","move"),V("selected",[g]),Ee([g],!0)),g&&!g.textContent.length&&o.deleteSelectedElements(),$(m).blur(),g=!1},setInputElem:function(e){m=e},clear:function(){"textedit"==current_mode&&me.toSelectMode()},init:function(e){if(g){var i,r;g.parentNode||(g=w[0],Y.requestSelector(g).showGrips(!1));var n=g.textContent,a=n.length,s=g.getAttribute("transform");for(y=svgedit.utilities.getBBox(g),x=s?svgedit.math.getMatrix(g):null,_=[],_.length=a,m.focus(),$(g).unbind("dblclick",u).dblclick(u),a||(r={x:y.x+y.width/2,width:0}),i=0;i<a;i++){var l=g.getStartPositionOfChar(i);if(r=g.getEndPositionOfChar(i),!svgedit.browser.supportsGoodTextCharPos()){var d=o.contentW*p;l.x-=d,r.x-=d,l.x/=p,r.x/=p}_[i]={x:l.x,y:y.y,width:r.x-l.x,height:y.height}}_.push({x:r.x,width:0}),t(m.selectionStart,m.selectionEnd,!0)}}}}(),ce=o.pathActions=function(){function t(e){e.setAttribute("d",ce.convertPath(e))}var i,s,l,d=!1;svgedit.path.Path.prototype.endChanges=function(e){svgedit.browser.isWebkit()&&t(this.elem);var i=new svgedit.history.ChangeElementCommand(this.elem,{d:this.last_d},e);X(i),V("changed",[this.elem])},svgedit.path.Path.prototype.addPtsToSelection=function(e){var t,i;for($.isArray(e)||(e=[e]),t=0;t<e.length;t++){var r=e[t];i=this.segs[r],i.ptgrip&&-1==this.selected_pts.indexOf(r)&&r>=0&&this.selected_pts.push(r)}this.selected_pts.sort(),t=this.selected_pts.length;var n=[];for(n.length=t;t--;){var a=this.selected_pts[t];i=this.segs[a],i.select(!0),n[t]=i.ptgrip}ce.canDeleteNodes=!0,ce.closed_subpath=this.subpathIsClosed(this.selected_pts[0]),V("selected",n)},i=null;var u=null,g=!1,h=function(e){var t,i=e.points,r=i.numberOfItems;if(r>=4){var n=i.getItem(0),a=null,s=[];for(s.push(["M",n.x,",",n.y," C"].join("")),t=1;t<=r-4;t+=3){var o=i.getItem(t),l=i.getItem(t+1),d=i.getItem(t+2);if(a){var u=svgedit.path.smoothControlPoints(a,o,n);if(u&&2==u.length){var g=s[s.length-1].split(",");g[2]=u[0].x,g[3]=u[0].y,s[s.length-1]=g.join(","),o=u[1]}}s.push([o.x,o.y,l.x,l.y,d.x,d.y].join(",")),n=d,a=l}for(s.push("L");t<r;){var h=i.getItem(t);s.push([h.x,h.y].join(",")),t++}s=s.join(" "),e=_({element:"path",curStyles:!0,attr:{id:ge(),d:s,fill:"none"}})}return e};return{mouseDown:function(t,i,r,o){var l;if("path"!==current_mode&&"pipe"!==current_mode){if(svgedit.path.path){var g;if(svgedit.path.path.storeD(),l=t.target.id,"pathpointgrip_"==l.substr(0,14)){g=svgedit.path.path.cur_pt=parseInt(l.substr(14)),svgedit.path.path.dragging=[r,o];var h=svgedit.path.path.segs[g];t.shiftKey?h.selected?svgedit.path.path.removePtFromSelection(g):svgedit.path.path.addPtsToSelection(g):((svgedit.path.path.selected_pts.length<=1||!h.selected)&&svgedit.path.path.clearSelection(),svgedit.path.path.addPtsToSelection(g))}else if(0==l.indexOf("ctrlpointgrip_")){svgedit.path.path.dragging=[r,o];var m=l.split("_")[1].split("c");g=Number(m[0]);var c=Number(m[1]);svgedit.path.path.selectPt(g,c)}svgedit.path.path.dragging||(null==rubberBox&&(rubberBox=Y.getRubberBandBox()),svgedit.utilities.assignAttributes(rubberBox,{x:r*p,y:o*p,width:0,height:0,display:"inline"},100))}}else{mouse_x=r,mouse_y=o;var v=mouse_x/p,f=mouse_y/p,y=svgedit.utilities.getElem("path_stretch_line");s=[v,f],a.gridSnapping&&(v=svgedit.utilities.snapToGrid(v),f=svgedit.utilities.snapToGrid(f),mouse_x=svgedit.utilities.snapToGrid(mouse_x),mouse_y=svgedit.utilities.snapToGrid(mouse_y)),y||(y=document.createElementNS(n.SVG,"path"),svgedit.utilities.assignAttributes(y,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"}),y=svgedit.utilities.getElem("selectorParentGroup").appendChild(y)),y.setAttribute("display","inline");var x,b=null;if(u){for(var S=u.pathSegList,w=S.numberOfItems,N=6/p,A=!1;w;){w--;var k=S.getItem(w),E=k.x,B=k.y;if(v>=E-N&&v<=E+N&&f>=B-N&&f<=B+N){A=!0;break}}l=ge(),svgedit.path.removePath_(l);var T,G,I=svgedit.utilities.getElem(l),M=S.numberOfItems;if(A){if(w<=1&&M>=2&&"pipe"!==current_mode){var L=S.getItem(0).x,P=S.getItem(0).y;G=y.pathSegList.getItem(1),T=4===G.pathSegType?u.createSVGPathSegLinetoAbs(L,P):u.createSVGPathSegCurvetoCubicAbs(L,P,G.x1/p,G.y1/p,L,P);var O=u.createSVGPathSegClosePath();S.appendItem(T),S.appendItem(O)}else if(M<3&&"pipe"!==current_mode)return b=!1,b;if($(y).remove(),element=I,u=null,started=!1,d){svgedit.path.path.matrix&&svgedit.coords.remapElement(I,{},svgedit.path.path.matrix.inverse());var D=I.getAttribute("d"),R=$(svgedit.path.path.elem).attr("d");return $(svgedit.path.path.elem).attr("d",R+D),$(I).remove(),svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath(),svgedit.path.path.init(),ce.toEditMode(svgedit.path.path.elem),svgedit.path.path.selectPt(),!1}}else{if(!$.contains(e,Te(t)))return console.log("Clicked outside canvas"),!1;var V=u.pathSegList.numberOfItems,U=u.pathSegList.getItem(V-1),z=U.x,F=U.y;if(t.shiftKey){var j=svgedit.math.snapToAngle(z,F,v,f);v=j.x,f=j.y}G=y.pathSegList.getItem(1),T=4===G.pathSegType?u.createSVGPathSegLinetoAbs(de(v),de(f)):u.createSVGPathSegCurvetoCubicAbs(de(v),de(f),G.x1/p,G.y1/p,G.x2/p,G.y2/p),u.pathSegList.appendItem(T),v*=p,f*=p,y.setAttribute("d",["M",v,f,v,f].join(" ")),x=V,d&&(x+=svgedit.path.path.segs.length),svgedit.path.addPointGrip(x,v,f)}}else{if(d_attr="M"+v+","+f+" ",path_attr={d:d_attr,id:he(),opacity:C.opacity/2},"pipe"===current_mode){var H=he().replace("svg_","PIE_");path_attr={d:d_attr,id:H,type:"svg-ext-pipe",fill:"rgba(0,0,0,0)",stroke:"rgba(41,171,226,1)","stroke-width":10,opacity:C.opacity/2}}u=_({element:"path",curStyles:!0,attr:path_attr}),y.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" ")),x=d?svgedit.path.path.segs.length:0,svgedit.path.addPointGrip(x,mouse_x,mouse_y)}}},mouseMove:function(e,t){if(g=!0,"path"!==current_mode&&"pipe"!==current_mode)if(svgedit.path.path.dragging){var i=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path),r=svgedit.path.getPointFromGrip({x:e,y:t},svgedit.path.path),n=r.x-i.x,a=r.y-i.y;svgedit.path.path.dragging=[e,t],svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(n,a):svgedit.path.path.movePts(n,a)}else svgedit.path.path.selected_pts=[],svgedit.path.path.eachSeg(function(e){var t=this;if(t.next||t.prev){t.item;var i=rubberBox.getBBox(),r=svgedit.path.getGripPt(t),n={x:r.x,y:r.y,width:0,height:0},a=svgedit.math.rectsIntersect(i,n);this.select(a),a&&svgedit.path.path.selected_pts.push(t.index)}});else{if(!u)return;var o=u.pathSegList,d=o.numberOfItems-1;if(s){var h=svgedit.path.addCtrlGrip("1c1"),m=svgedit.path.addCtrlGrip("0c2");h.setAttribute("cx",e),h.setAttribute("cy",t),h.setAttribute("display","inline");var c=s[0],v=s[1],f=(o.getItem(d),e/p),y=t/p,x=c+(c-f),b=v+(v-y);m.setAttribute("cx",x*p),m.setAttribute("cy",b*p),m.setAttribute("display","inline");var S=svgedit.path.getCtrlLine(1);if(svgedit.utilities.assignAttributes(S,{x1:e,y1:t,x2:x*p,y2:b*p,display:"inline"}),0===d)l=[e,t];else{var C=o.getItem(d-1),w=C.x,_=C.y;6===C.pathSegType?(w+=w-C.x2,_+=_-C.y2):l&&(w=l[0]/p,_=l[1]/p),svgedit.path.replacePathSeg(6,d,[c,v,w,_,x,b],u)}}else{var N=svgedit.utilities.getElem("path_stretch_line");if(N){var A=o.getItem(d);if(6===A.pathSegType){var k=A.x+(A.x-A.x2),E=A.y+(A.y-A.y2);svgedit.path.replacePathSeg(6,1,[e,t,k*p,E*p,e,t],N)}else l?svgedit.path.replacePathSeg(6,1,[e,t,l[0],l[1],e,t],N):svgedit.path.replacePathSeg(4,1,[e,t],N)}}}},mouseUp:function(e,t,i,r){if("path"===current_mode||"pipe"===current_mode){if(s=null,!u){var n=ge();"pipe"===current_mode&&(n=n.replace("svg_","PIE_")),t=svgedit.utilities.getElem(n),started=!1,l=null}return{keep:!0,element:t}}if(svgedit.path.path.dragging){var a=svgedit.path.path.cur_pt;svgedit.path.path.dragging=!1,svgedit.path.path.dragctrl=!1,svgedit.path.path.update(),g&&svgedit.path.path.endChanges("Move path point(s)"),e.shiftKey||g||svgedit.path.path.selectPt(a)}else rubberBox&&"none"!=rubberBox.getAttribute("display")?(rubberBox.setAttribute("display","none"),rubberBox.getAttribute("width")<=2&&rubberBox.getAttribute("height")<=2&&ce.toSelectMode(e.target)):ce.toSelectMode(e.target);g=!1},toEditMode:function(e){svgedit.path.path=svgedit.path.getPath_(e),current_mode="pathedit",ke(),svgedit.path.path.show(!0).update(),svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem),d=!1},toSelectMode:function(e){var t=e==svgedit.path.path.elem;current_mode="select",svgedit.path.path.show(!1),i=!1,ke(),svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath(),t&&(V("selected",[e]),Ee([e],!0))},addSubPath:function(e){e?(current_mode="path",d=!0):(ce.clear(!0),ce.toEditMode(svgedit.path.path.elem))},select:function(e){i===e?(ce.toEditMode(e),current_mode="pathedit"):i=e},reorient:function(){var e=w[0];if(e){var t=svgedit.utilities.getRotationAngle(e);if(0!=t){var i=new svgedit.history.BatchCommand("Reorient path"),r={d:e.getAttribute("d"),transform:e.getAttribute("transform")};i.addSubCommand(new svgedit.history.ChangeElementCommand(e,r)),ke(),this.resetOrientation(e),X(i),svgedit.path.getPath_(e).show(!1).matrix=null,this.clear(),Ee([e],!0),V("changed",w)}}},clear:function(e){if(i=null,u){var t=svgedit.utilities.getElem(ge());$(svgedit.utilities.getElem("path_stretch_line")).remove(),$(t).remove(),$(svgedit.utilities.getElem("pathpointgrip_container")).find("*").attr("display","none"),u=l=null,started=!1}else"pathedit"==current_mode&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(!1)},resetOrientation:function(e){if(null==e||"path"!=e.nodeName)return!1;var t=svgedit.transformlist.getTransformList(e),i=svgedit.math.transformListToTransform(t).matrix;t.clear(),e.removeAttribute("transform");var n,a=e.pathSegList,s=a.numberOfItems;for(n=0;n<s;++n){var o=a.getItem(n),l=o.pathSegType;if(1!=l){var d=[];$.each(["",1,2],function(e,t){var r=o["x"+t],n=o["y"+t];if(void 0!==r&&void 0!==n){var a=svgedit.math.transformPoint(r,n,i);d.splice(d.length,0,a.x,a.y)}}),svgedit.path.replacePathSeg(l,n,d,e)}}r(e,i)},zoomChange:function(){"pathedit"==current_mode&&svgedit.path.path.update()},getNodePoint:function(){var e=svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1,t=svgedit.path.path.segs[e];return{x:t.item.x,y:t.item.y,type:t.type}},linkControlPoints:function(e){svgedit.path.setLinkControlPoints(e)},clonePathNode:function(){svgedit.path.path.storeD();for(var e=svgedit.path.path.selected_pts,t=(svgedit.path.path.segs,e.length),i=[];t--;){var r=e[t];svgedit.path.path.addSeg(r),i.push(r+t),i.push(r+t+1)}svgedit.path.path.init().addPtsToSelection(i),svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var e=svgedit.path.path.selected_pts;if(1===e.length){var t=svgedit.path.path.elem,i=t.pathSegList,r=(i.numberOfItems,e[0]),n=null,a=null;if(svgedit.path.path.eachSeg(function(e){return 2===this.type&&e<=r&&(a=this.item),e<=r||(2===this.type?(n=e,!1):1===this.type?(n=!1,!1):void 0)}),null==n&&(n=svgedit.path.path.segs.length-1),!1!==n){var s=t.createSVGPathSegLinetoAbs(a.x,a.y),o=t.createSVGPathSegClosePath();return n==svgedit.path.path.segs.length-1?(i.appendItem(s),i.appendItem(o)):(svgedit.path.insertItemBefore(t,o,n),svgedit.path.insertItemBefore(t,s,n)),void svgedit.path.path.init().selectPt(n+1)}var l,d,u,g=svgedit.path.path.segs[r];if(g.mate)return i.removeItem(r),i.removeItem(r),void svgedit.path.path.init().selectPt(r-1);for(l=0;l<i.numberOfItems;l++){var h=i.getItem(l);if(2===h.pathSegType)d=l;else if(l===r)i.removeItem(d);else if(1===h.pathSegType&&r<l){u=l-1,i.removeItem(l);break}}for(var m=r-d-1;m--;)svgedit.path.insertItemBefore(t,i.getItem(d),u);var c=i.getItem(d);svgedit.path.replacePathSeg(2,d,[c.x,c.y]),l=r,svgedit.path.path.init().selectPt(0)}},deletePathNode:function(){if(ce.canDeleteNodes){svgedit.path.path.storeD();for(var e=svgedit.path.path.selected_pts,t=e.length;t--;){var i=e[t];svgedit.path.path.deleteSeg(i)}var r=function(){var e=svgedit.path.path.elem.pathSegList,t=e.numberOfItems,i=function(t,i){for(;i--;)e.removeItem(t)};if(t<=1)return!0;for(;t--;){var n=e.getItem(t);if(1===n.pathSegType){var a=e.getItem(t-1),s=e.getItem(t-2);if(2===a.pathSegType){i(t-1,2),r();break}if(2===s.pathSegType){i(t-2,3),r();break}}else if(2===n.pathSegType&&t>0){var o=e.getItem(t-1).pathSegType;if(2===o){i(t-1,1),r();break}if(1===o&&e.numberOfItems-1===t){i(t,1),r();break}}}return!1};if(r(),svgedit.path.path.elem.pathSegList.numberOfItems<=1)return ce.toSelectMode(svgedit.path.path.elem),void o.deleteSelectedElements();if(svgedit.path.path.init(),svgedit.path.path.clearSelection(),window.opera){var n=$(svgedit.path.path.elem);n.attr("d",n.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:h,setSegType:function(e){svgedit.path.path.setSegType(e)},moveNode:function(e,t){var i=svgedit.path.path.selected_pts;if(i.length){svgedit.path.path.storeD();var r=svgedit.path.path.segs[i[0]],n={x:0,y:0};n[e]=t-r.item[e],r.move(n.x,n.y),svgedit.path.path.endChanges("Move path point")}},fixEnd:function(e){var i,r,n=e.pathSegList,a=n.numberOfItems;for(i=0;i<a;++i){var s=n.getItem(i);if(2===s.pathSegType&&(r=s),1===s.pathSegType){var o=n.getItem(i-1);if(o.x!=r.x||o.y!=r.y){var l=e.createSVGPathSegLinetoAbs(r.x,r.y);svgedit.path.insertItemBefore(e,l,i),ce.fixEnd(e);break}}}svgedit.browser.isWebkit()&&t(e)},convertPath:function(e,t){var i,r=e.pathSegList,n=0;r?n=r.numberOfItems:console.error(`Problem with path conversion. segList is empty!' ${e}`);var a=0,s=0,o="",l=null;for(i=0;i<n;++i){var d=r.getItem(i),u=d.x||0,g=d.y||0,h=d.x1||0,m=d.y1||0,c=d.x2||0,v=d.y2||0,f=d.pathSegType,p=_e[f]["to"+(t?"Lower":"Upper")+"Case"](),y=function(e,t,i){t=t?" "+t.join(" "):"",i=i?" "+svgedit.units.shortFloat(i):"",$.each(e,function(t,i){e[t]=svgedit.units.shortFloat(i)}),o+=p+e.join(" ")+t+i};switch(f){case 1:o+="z";break;case 12:u-=a;case 13:t?(a+=u,p="l"):(u+=a,a=u,p="L"),y([[u,s]]);break;case 14:g-=s;case 15:t?(s+=g,p="l"):(g+=s,s=g,p="L"),y([[a,g]]);break;case 2:case 4:case 18:u-=a,g-=s;case 5:case 3:l&&1===r.getItem(i-1).pathSegType&&!t&&(a=l[0],s=l[1]);case 19:t?(a+=u,s+=g):(u+=a,g+=s,a=u,s=g),3===f&&(l=[a,s]),y([[u,g]]);break;case 6:u-=a,h-=a,c-=a,g-=s,m-=s,v-=s;case 7:t?(a+=u,s+=g):(u+=a,h+=a,c+=a,g+=s,m+=s,v+=s,a=u,s=g),y([[h,m],[c,v],[u,g]]);break;case 8:u-=a,h-=a,g-=s,m-=s;case 9:t?(a+=u,s+=g):(u+=a,h+=a,g+=s,m+=s,a=u,s=g),y([[h,m],[u,g]]);break;case 10:u-=a,g-=s;case 11:t?(a+=u,s+=g):(u+=a,g+=s,a=u,s=g),y([[d.r1,d.r2]],[d.angle,d.largeArcFlag?1:0,d.sweepFlag?1:0],[u,g]);break;case 16:u-=a,c-=a,g-=s,v-=s;case 17:t?(a+=u,s+=g):(u+=a,c+=a,g+=s,v+=s,a=u,s=g),y([[c,v],[u,g]])}}return o}}}();var Ie=this.removeUnusedDefElems=function(){var e=m.getElementsByTagNameNS(n.SVG,"defs");if(!e||!e.length)return 0;var t,i,r=[],a=0,s=["fill","stroke","filter","marker-start","marker-mid","marker-end"],o=s.length,l=m.getElementsByTagNameNS(n.SVG,"*"),d=l.length;for(t=0;t<d;t++){var u=l[t];for(i=0;i<o;i++){var g=svgedit.utilities.getUrlFromAttr(u.getAttribute(s[i]));g&&r.push(g.substr(1))}var h=I(u);h&&0===h.indexOf("#")&&r.push(h.substr(1))}var c=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");for(t=c.length;t--;){var v=c[t],f=v.id;r.indexOf(f)<0&&(removedElements[f]=v,v.parentNode.removeChild(v),a++)}return a};this.svgCanvasToString=function(){for(;Ie()>0;);ce.clear(!0),$.each(m.childNodes,function(e,t){e&&8===t.nodeType&&t.data.indexOf("Created with")>=0&&m.insertBefore(t,m.firstChild)}),b&&(De(),Be([b]));var e=[];$(m).find("g:data(gsvg)").each(function(){var t,i=this.attributes,r=i.length;for(t=0;t<r;t++)"id"!=i[t].nodeName&&"style"!=i[t].nodeName||r--;if(r<=0){var n=this.firstChild;e.push(n),$(this).replaceWith(n)}});var t=this.svgToString(m,0);return e.length&&$(e).each(function(){xe(this)}),t},this.svgToString=function(e,t){var i=[],r=svgedit.utilities.toXml,s=a.baseUnit,o=new RegExp("^-?[\\d\\.]+"+s+"$"),l=["ngx-dygraphs"];if(e){if(l.indexOf(e.nodeName.toLowerCase())>=0)return i.join("");D(e);var d,u,g=e.attributes,h=e.childNodes;for(u=0;u<t;u++)i.push(" ");if(i.push("<"),i.push(e.nodeName),"svgcontent"===e.id){var m=Ve(),c="";"px"!==s&&(m.w=svgedit.units.convertUnit(m.w,s)+s,m.h=svgedit.units.convertUnit(m.h,s)+s),i.push(' width="'+m.w+'" height="'+m.h+'"'+c+' xmlns="'+n.SVG+'"');var v={};$(e).find("*").andSelf().each(function(){var e=this.namespaceURI;e&&!v[e]&&z[e]&&"xmlns"!==z[e]&&"xml"!==z[e]&&(v[e]=!0,i.push(" xmlns:"+z[e]+'="'+e+'"')),$.each(this.attributes,function(e,t){var r=t.namespaceURI;r&&!v[r]&&"xmlns"!==z[r]&&"xml"!==z[r]&&(v[r]=!0,i.push(" xmlns:"+z[r]+'="'+r+'"'))})}),u=g.length;for(var f=["width","height","xmlns","x","y","viewBox","id","overflow"];u--;){d=g.item(u);var p=r(d.value);0!==d.nodeName.indexOf("xmlns:")&&(""!=p&&-1==f.indexOf(d.localName)&&(d.namespaceURI&&!z[d.namespaceURI]||(i.push(" "),i.push(d.nodeName),i.push('="'),i.push(p),i.push('"'))))}}else{if("defs"===e.nodeName&&!e.firstChild)return;var y=["-moz-math-font-style","_moz-math-font-style"];for(u=g.length-1;u>=0;u--){d=g.item(u);p=r(d.value);if(!(y.indexOf(d.localName)>=0)&&""!=p){if(0===p.indexOf("pointer-events"))continue;if("class"===d.localName&&0===p.indexOf("se_"))continue;if(i.push(" "),"d"===d.localName&&(p=ce.convertPath(e,!1)),isNaN(p)?o.test(p)&&(p=svgedit.units.shortFloat(p)+s):p=svgedit.units.shortFloat(p),save_options.apply&&"image"===e.nodeName&&"href"===d.localName&&save_options.images&&"embed"===save_options.images){var x=re[p];x&&(p=x)}d.namespaceURI&&d.namespaceURI!=n.SVG&&!z[d.namespaceURI]||(i.push(d.nodeName),i.push('="'),i.push(p),i.push('"'))}}}if(e.hasChildNodes()){i.push(">"),t++;var b=!1;for(u=0;u<h.length;u++){var S=h.item(u);switch(S.nodeType){case 1:i.push("\n"),i.push(this.svgToString(h.item(u),t));break;case 3:var C=S.nodeValue.replace(/^\s+|\s+$/g,"");""!=C&&(b=!0,i.push(String(r(C))));break;case 4:i.push("\n"),i.push(new Array(t+1).join(" ")),i.push("<![CDATA["),i.push(S.nodeValue),i.push("]]>");break;case 8:i.push("\n"),i.push(new Array(t+1).join(" ")),i.push("<!--"),i.push(S.data),i.push("-->")}}if(t--,!b)for(i.push("\n"),u=0;u<t;u++)i.push(" ");i.push("</"),i.push(e.nodeName),i.push(">")}else"div"===e.nodeName.toLowerCase()||"span"===e.nodeName.toLowerCase()?(i.push(">"),i.push("</"),i.push(e.nodeName),i.push(">")):i.push("/>")}return i.join("")},this.embedImage=function(e,t){$(new Image).load(function(){var i=document.createElement("canvas");i.width=this.width,i.height=this.height,i.getContext("2d").drawImage(this,0,0);try{var r=";svgedit_url="+encodeURIComponent(e);r=i.toDataURL().replace(";base64",r+";base64"),re[e]=r}catch(t){re[e]=!1}ne=e,t&&t(re[e])}).attr("src",e)},this.setGoodImage=function(e){ne=e},this.setGoodSvgImageContent=function(e){last_good_img_content=e},this.open=function(){},this.save=function(e){ke(),e&&$.extend(save_options,e),save_options.apply=!0;var t=this.svgCanvasToString();V("saved",t)},this.rasterExport=function(e,t,r){var n="image/"+e.toLowerCase(),a=i(),s=this.svgCanvasToString();svgedit.utilities.buildCanvgCallback(function(){var i=e||"PNG";$("#export_canvas").length||$("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var o=$("#export_canvas")[0];o.width=svgCanvas.contentW,o.height=svgCanvas.contentH,canvg(o,s,{renderCallback:function(){var l=("ICO"===i?"BMP":i).toLowerCase(),d=t?o.toDataURL("image/"+l,t):o.toDataURL("image/"+l);V("exported",{datauri:d,svg:s,issues:a,type:e,mimeType:n,quality:t,exportWindowName:r})}})})()},this.exportPDF=function(e,t){var r=this;svgedit.utilities.buildJSPDFCallback(function(){var n=Ve(),a=n.w>n.h?"landscape":"portrait",s="pt",o=jsPDF({orientation:a,unit:s,format:[n.w,n.h]}),l=Ue();o.setProperties({title:l});var d=i(),u=r.svgCanvasToString();o.addSVG(u,0,0);var g={svg:u,issues:d,exportWindowName:e},h=t||"dataurlstring";g[h]=o.output(h),V("exportedPDF",g)})()},this.lockSelection=function(e){d=e},this.getSvgString=function(){return save_options.apply=!1,this.svgCanvasToString()},this.randomizeIds=function(e){arguments.length>0&&0==e?svgedit.draw.randomizeIds(!1,f()):svgedit.draw.randomizeIds(!0,f())};var Me=this.uniquifyElems=function(e){var t,i={},r=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];for(t in svgedit.utilities.walkTree(e,function(e){if(1==e.nodeType){e.id&&(e.id in i||(i[e.id]={elem:null,attrs:[],hrefs:[]}),i[e.id].elem=e),$.each(Q,function(t,r){var n=e.getAttributeNode(r);if(n){var a=svgedit.utilities.getUrlFromAttr(n.value),s=a?a.substr(1):null;s&&(s in i||(i[s]={elem:null,attrs:[],hrefs:[]}),i[s].attrs.push(n))}});var t=svgedit.utilities.getHref(e);if(t&&r.indexOf(e.nodeName)>=0){var n=t.substr(1);n&&(n in i||(i[n]={elem:null,attrs:[],hrefs:[]}),i[n].hrefs.push(e))}}}),i)if(t){var n=i[t].elem;if(n){var a=he();n.id=a;for(var s=i[t].attrs,o=s.length;o--;){var l=s[o];l.ownerElement.setAttribute(l.name,"url(#"+a+")")}for(var d=i[t].hrefs,u=d.length;u--;){var g=d[u];svgedit.utilities.setHref(g,"#"+a)}}}},Le=this.setUseData=function(e){var t=$(e);"use"!==e.tagName&&(t=t.find("use")),t.each(function(){var e=I(this).substr(1),t=svgedit.utilities.getElem(e);t&&($(this).data("ref",t),"symbol"!=t.tagName&&"svg"!=t.tagName||$(this).data("symbol",t).data("ref",t))})},$e=this.convertGradients=function(e){var t=$(e).find("linearGradient, radialGradient");!t.length&&svgedit.browser.isWebkit()&&(t=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0})),t.each(function(){var e=this;if("userSpaceOnUse"===$(e).attr("gradientUnits")){var t=$(m).find('[fill="url(#'+e.id+')"],[stroke="url(#'+e.id+')"]');if(!t.length)return;var i=svgedit.utilities.getBBox(t[0]);if(!i)return;if("linearGradient"===e.tagName){var r=$(e).attr(["x1","y1","x2","y2"]),n=e.gradientTransform.baseVal;if(n&&n.numberOfItems>0){var a=svgedit.math.transformListToTransform(n).matrix,s=svgedit.math.transformPoint(r.x1,r.y1,a),o=svgedit.math.transformPoint(r.x2,r.y2,a);r.x1=s.x,r.y1=s.y,r.x2=o.x,r.y2=o.y,e.removeAttribute("gradientTransform")}$(e).attr({x1:(r.x1-i.x)/i.width,y1:(r.y1-i.y)/i.height,x2:(r.x2-i.x)/i.width,y2:(r.y2-i.y)/i.height}),e.removeAttribute("gradientUnits")}}})},Pe=this.convertToGroup=function(e){e||(e=w[0]);var t,i=$(e),r=new svgedit.history.BatchCommand;if(i.data("gsvg")){var a=e.firstChild,s=$(a).attr(["x","y"]);$(e.firstChild.firstChild).unwrap(),$(e).removeData("gsvg");var o=svgedit.transformlist.getTransformList(e),l=h.createSVGTransform();l.setTranslate(s.x,s.y),o.appendItem(l),svgedit.recalculate.recalculateDimensions(e),V("selected",[e])}else if(i.data("symbol")){e=i.data("symbol"),t=i.attr("transform");var d=i.attr(["x","y"]),u=e.getAttribute("viewBox");if(u){var c=u.split(" ");d.x-=+c[0],d.y-=+c[1]}t+=" translate("+(d.x||0)+","+(d.y||0)+")";var v=i.prev();r.addSubCommand(new svgedit.history.RemoveElementCommand(i[0],i[0].nextSibling,i[0].parentNode)),i.remove();var f,p=$(m).find("use:data(symbol)").length,y=g.createElementNS(n.SVG,"g"),x=e.childNodes;for(f=0;f<x.length;f++)y.appendChild(x[f].cloneNode(!0));if(svgedit.browser.isGecko()){var b=$(svgedit.utilities.findDefs()).children("linearGradient,radialGradient,pattern").clone();$(y).append(b)}t&&y.setAttribute("transform",t);var S=e.parentNode;if(Me(y),svgedit.browser.isGecko()&&$(T()).append($(y).find("linearGradient,radialGradient,pattern")),y.id=he(),v.after(y),S){if(!p){var C=e.nextSibling;S.removeChild(e),r.addSubCommand(new svgedit.history.RemoveElementCommand(e,C,S))}r.addSubCommand(new svgedit.history.InsertElementCommand(y))}Le(y),svgedit.browser.isGecko()?$e(svgedit.utilities.findDefs()):$e(y),svgedit.utilities.walkTreePost(y,function(e){try{svgedit.recalculate.recalculateDimensions(e)}catch(e){console.log(e)}}),$(y).find(J).each(function(){this.id||(this.id=he())}),Be([y]);var _=We(y,!0);_&&r.addSubCommand(_),X(r)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var t=svgedit.utilities.text2xml(e);this.prepareSvg(t);var i=new svgedit.history.BatchCommand("Change Source"),r=m.nextSibling,s=h.removeChild(m);i.addSubCommand(new svgedit.history.RemoveElementCommand(s,r,h)),m=g.adoptNode?g.adoptNode(t.documentElement):g.importNode(t.documentElement,!0),h.appendChild(m);var l=$(m);o.current_drawing_=new svgedit.draw.Drawing(m,v);var d=f().getNonce();d?V("setnonce",d):V("unsetnonce"),l.find("image").each(function(){var e=this;Ge(e);var t=I(this);if(t){if(0===t.indexOf("data:")){var i=t.match(/svgedit_url=(.*?);/);if(i){var r=decodeURIComponent(i[1]);$(new Image).load(function(){e.setAttributeNS(n.XLINK,"xlink:href",r)}).attr("src",r)}}o.embedImage(t)}}),l.find("svg").each(function(){if(!$(this).closest("defs").length){Me(this);var e=this.parentNode;1===e.childNodes.length&&"g"===e.nodeName?($(e).data("gsvg",this),e.id=e.id||he()):xe(this)}}),svgedit.browser.isGecko()&&l.find("linearGradient, radialGradient, pattern").appendTo(svgedit.utilities.findDefs()),Le(l),$e(l[0]),svgedit.utilities.walkTreePost(m,function(e){try{svgedit.recalculate.recalculateDimensions(e)}catch(e){console.log(e)}});var u={id:"svgcontent",overflow:a.show_outside_canvas?"visible":"hidden"},c=!1;if(l.attr("viewBox")){var y=l.attr("viewBox").split(" ");u.width=y[2],u.height=y[3]}else $.each(["width","height"],function(e,t){var i=l.attr(t);i||(i="100%"),"%"===String(i).substr(-1)?c=!0:u[t]=svgedit.units.convertToNum(t,i)});if(Oe(),l.children().find(J).each(function(){this.id||(this.id=he())}),c){var x=getStrokedBBox();u.width=x.width+x.x,u.height=x.height+x.y}u.width<=0&&(u.width=100),u.height<=0&&(u.height=100),l.attr(u),this.contentW=u.width,this.contentH=u.height,i.addSubCommand(new svgedit.history.InsertElementCommand(m));var b=l.attr(["width","height"]);i.addSubCommand(new svgedit.history.ChangeElementCommand(h,b)),p=1,svgedit.transformlist.resetListMap(),ke(),svgedit.path.clearData(),h.appendChild(Y.selectorParentGroup),X(i),V("changed",[m])}catch(e){return console.log(e),!1}return!0},this.importSvgString=function(e,t){var i,r;try{var a=(new Date).getTime(),s=!1;import_ids[a]&&$(import_ids[a].symbol).parents("#svgroot").length&&(s=!0);var o,l=new svgedit.history.BatchCommand("Import Image");if(s)o=import_ids[a].symbol,r=import_ids[a].xform,t&&t.x>0&&t.y>0&&(r=" translate("+t.x+","+t.y+") scale(1) translate(0)");else{var d,u=svgedit.utilities.text2xml(e);this.prepareSvg(u),d=g.adoptNode?g.adoptNode(u.documentElement):g.importNode(u.documentElement,!0),Me(d)
19
- ;var h=svgedit.units.convertToNum("width",d.getAttribute("width")),c=svgedit.units.convertToNum("height",d.getAttribute("height")),v=d.getAttribute("viewBox"),p=v?v.split(" "):[0,0,h,c];for(i=0;i<4;++i)p[i]=Number(p[i]);var y=Number(m.getAttribute("height"));r=c>h?"scale("+y/3/p[3]+")":"scale("+y/3/p[2]+")",r=t&&t.x>0&&t.y>0?"translate("+t.x+","+t.y+") scale(1) translate(0)":"translate(0) scale(1) translate(0)",o=g.createElementNS(n.SVG,"symbol");var x=svgedit.utilities.findDefs();if($(d).find("linearGradient, radialGradient, pattern").appendTo(x),!x.firstChild){var S=g.createElementNS(n.SVG,"symbol");S.id=he(),x.appendChild(S)}for(;d.firstChild;){var C=d.firstChild;svgedit.utilities.walkTree(C,function(e){e.id=he()}),o.appendChild(C)}o.id=he(),o.setAttribute("type","svg-ext-shapes-image"),o.childNodes.forEach(e=>{e.getAttribute("transform")&&e.setAttribute("transform","matrix(1, 0, 0, 1, 0, 0)")}),import_ids[a]={symbol:o,xform:r},svgedit.utilities.findDefs().appendChild(o),l.addSubCommand(new svgedit.history.InsertElementCommand(o))}var w=g.createElementNS(n.SVG,"use");w.id=he(),w.setAttribute("type","svg-ext-shapes-image"),M(w,"#"+o.id),(b||f().getCurrentLayer()).appendChild(w),l.addSubCommand(new svgedit.history.InsertElementCommand(w)),ke(),w.setAttribute("transform",r),svgedit.recalculate.recalculateDimensions(w),$(w).data("symbol",o).data("ref",o),Ee([w]),setTimeout(function(){Be([w],!0)},500),X(l),V("changed",[m])}catch(e){return console.log(e),!1}return!0};var Oe=o.identifyLayers=function(){De(),f().identifyLayers()};this.createLayer=function(e){var t=new svgedit.history.BatchCommand("Create Layer"),i=f().createLayer(e);t.addSubCommand(new svgedit.history.InsertElementCommand(i)),X(t),ke(),V("changed",[i])},this.cloneLayer=function(e){var t=new svgedit.history.BatchCommand("Duplicate Layer"),i=g.createElementNS(n.SVG,"g"),r=g.createElementNS(n.SVG,"title");r.textContent=e,i.appendChild(r);var a=f().getCurrentLayer();$(a).after(i);var s,l=a.childNodes;for(s=0;s<l.length;s++){var d=l[s];"title"!=d.localName&&i.appendChild(be(d))}ke(),Oe(),t.addSubCommand(new svgedit.history.InsertElementCommand(i)),X(t),o.setCurrentLayer(e),V("changed",[i])},this.deleteCurrentLayer=function(){var e=f().getCurrentLayer(),t=e.nextSibling,i=e.parentNode;if(e=f().deleteCurrentLayer(),e){var r=new svgedit.history.BatchCommand("Delete Layer");return r.addSubCommand(new svgedit.history.RemoveElementCommand(e,t,i)),X(r),ke(),V("changed",[i]),!0}return!1},this.setCurrentLayer=function(e){var t=f().setCurrentLayer(svgedit.utilities.toXml(e));return t&&ke(),t},this.renameCurrentLayer=function(e){var t,i=f();if(i.current_layer){var r=i.current_layer;if(!o.setCurrentLayer(e)){var n=new svgedit.history.BatchCommand("Rename Layer");for(t=0;t<i.getNumLayers()&&i.all_layers[t][1]!=r;++t);var a=i.getLayerName(t);i.all_layers[t][0]=svgedit.utilities.toXml(e);var s=r.childNodes.length;for(t=0;t<s;++t){var l=r.childNodes.item(t);if(l&&"title"==l.tagName){for(;l.firstChild;)l.removeChild(l.firstChild);return l.textContent=e,n.addSubCommand(new svgedit.history.ChangeElementCommand(l,{"#text":a})),X(n),V("changed",[r]),!0}}}i.current_layer=r}return!1},this.setCurrentLayerPosition=function(e){var t,i=f();if(i.current_layer&&e>=0&&e<i.getNumLayers()){for(t=0;t<i.getNumLayers()&&i.all_layers[t][1]!=i.current_layer;++t);if(t==i.getNumLayers())return!1;if(t!=e){var r=null,n=i.current_layer.nextSibling;return e>t?e<i.getNumLayers()-1&&(r=i.all_layers[e+1][1]):r=i.all_layers[e][1],m.insertBefore(i.current_layer,r),X(new svgedit.history.MoveElementCommand(i.current_layer,n,m)),Oe(),o.setCurrentLayer(i.getLayerName(e)),!0}}return!1},this.setLayerVisibility=function(e,t){var i=f(),r=i.getLayerVisibility(e),n=i.setLayerVisibility(e,t);if(!n)return!1;var a=r?"inline":"none";return X(new svgedit.history.ChangeElementCommand(n,{display:a},"Layer Visibility")),n==i.getCurrentLayer()&&(ke(),ce.clear()),!0},this.moveSelectedToLayer=function(e){var t,i=null,r=f();for(t=0;t<r.getNumLayers();++t)if(r.getLayerName(t)==e){i=r.all_layers[t][1];break}if(!i)return!1;var n=new svgedit.history.BatchCommand("Move Elements to Layer"),a=w;for(t=a.length;t--;){var s=a[t];if(s){var o=s.nextSibling,l=s.parentNode;i.appendChild(s),n.addSubCommand(new svgedit.history.MoveElementCommand(s,o,l))}}return X(n),!0},this.mergeLayer=function(e){var t=new svgedit.history.BatchCommand("Merge Layer"),i=f(),r=$(i.current_layer).prev()[0];if(r){var n=i.current_layer.childNodes,a=(n.length,i.current_layer.nextSibling);for(t.addSubCommand(new svgedit.history.RemoveElementCommand(i.current_layer,a,m));i.current_layer.firstChild;){var s=i.current_layer.firstChild;if("title"!=s.localName){var o=s.nextSibling;r.appendChild(s),t.addSubCommand(new svgedit.history.MoveElementCommand(s,o,i.current_layer))}else{var l=s.nextSibling;t.addSubCommand(new svgedit.history.RemoveElementCommand(s,l,i.current_layer)),i.current_layer.removeChild(s)}}return m.removeChild(i.current_layer),e||(ke(),Oe(),V("changed",[m]),X(t)),i.current_layer=r,t}},this.mergeAllLayers=function(){var e=new svgedit.history.BatchCommand("Merge all Layers"),t=f();for(t.current_layer=t.all_layers[t.getNumLayers()-1][1];$(m).children("g").length>1;)e.addSubCommand(o.mergeLayer(!0));ke(),Oe(),V("changed",[m]),X(e)};var De=this.leaveContext=function(){var e,t=disabled_elems.length;if(t){for(e=0;e<t;e++){var i=disabled_elems[e],r=ee(i,"orig_opac");1!==r?i.setAttribute("opacity",r):i.removeAttribute("opacity"),i.setAttribute("style","pointer-events: inherit")}disabled_elems=[],ke(!0),V("contextset",null)}b=null},Re=this.setContext=function(e){De(),"string"==typeof e&&(e=svgedit.utilities.getElem(e)),b=e,$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var e=this.getAttribute("opacity")||1;ee(this,"orig_opac",e),this.setAttribute("opacity",.33*e),this.setAttribute("style","pointer-events: none"),disabled_elems.push(this)}),ke(),V("contextset",b)};this.clear=function(){ce.clear(),ke(),o.clearSvgContentElement(),o.current_drawing_=new svgedit.draw.Drawing(m),o.createLayer("Layer 1"),o.undoMgr.resetUndoStack(),Y.initGroup(),rubberBox=Y.getRubberBandBox(),V("cleared")},this.linkControlPoints=ce.linkControlPoints,this.getContentElem=function(){return m},this.getRootElem=function(){return h},this.getSelectedElems=function(){return w};var Ve=this.getResolution=function(){var e=m.getAttribute("width")/p,t=m.getAttribute("height")/p;return{w:e,h:t,zoom:p}};this.getZoom=function(){return p},this.getVersion=function(){return"svgcanvas.js ($Rev$)"},this.setUiStrings=function(e){$.extend(Z,e.notification)},this.setConfig=function(e){$.extend(a,e)},this.getTitle=function(e){var t;if(e=e||w[0],e){e=$(e).data("gsvg")||$(e).data("symbol")||e;var i=e.childNodes;for(t=0;t<i.length;t++)if("title"==i[t].nodeName)return i[t].textContent;return""}},this.setGroupTitle=function(e){var t=w[0];t=$(t).data("gsvg")||t;var i=$(t).children("title"),r=new svgedit.history.BatchCommand("Set Label");if(e.length)if(i.length){var a=i[0];r.addSubCommand(new svgedit.history.ChangeElementCommand(a,{"#text":a.textContent})),a.textContent=e}else a=g.createElementNS(n.SVG,"title"),a.textContent=e,$(t).prepend(a),r.addSubCommand(new svgedit.history.InsertElementCommand(a));else{var s=i.nextSibling;r.addSubCommand(new svgedit.history.RemoveElementCommand(i[0],s,t)),i.remove()}X(r)};var Ue=this.getDocumentTitle=function(){return o.getTitle(m)};this.setDocumentTitle=function(e){var t,i=m.childNodes,r=!1,a="",s=new svgedit.history.BatchCommand("Change Image Title");for(t=0;t<i.length;t++)if("title"==i[t].nodeName){r=i[t],a=r.textContent;break}r||(r=g.createElementNS(n.SVG,"title"),m.insertBefore(r,m.firstChild)),e.length?r.textContent=e:r.parentNode.removeChild(r),s.addSubCommand(new svgedit.history.ChangeElementCommand(r,{"#text":a})),X(s)},this.getEditorNS=function(e){return e&&m.setAttribute("xmlns:se",n.SE),n.SE},this.setResolution=function(e,t){var i,r=Ve(),n=r.w,a=r.h;if("fit"==e){var s=getStrokedBBox();if(!s)return!1;i=new svgedit.history.BatchCommand("Fit Canvas to Content");var l=pe();Ee(l);var d=[],u=[];$.each(l,function(e,t){d.push(-1*s.x),u.push(-1*s.y)});var g=o.moveSelectedElements(d,u,!0);i.addSubCommand(g),ke(),e=Math.round(s.width),t=Math.round(s.height)}if(e!=n||t!=a){var c=h.suspendRedraw(1e3);i||(i=new svgedit.history.BatchCommand("Change Image Dimensions")),e=svgedit.units.convertToNum("width",e),t=svgedit.units.convertToNum("height",t),m.setAttribute("width",e),m.setAttribute("height",t),this.contentW=e,this.contentH=t,i.addSubCommand(new svgedit.history.ChangeElementCommand(m,{width:n,height:a})),m.setAttribute("viewBox",[0,0,e/p,t/p].join(" ")),i.addSubCommand(new svgedit.history.ChangeElementCommand(m,{viewBox:["0 0",n,a].join(" ")})),X(i),h.unsuspendRedraw(c),V("changed",[m])}return!0},this.getOffset=function(){return $(m).attr(["x","y"])},this.setBBoxZoom=function(e,t,i){var r,n=.85,a=function(e){if(!e)return!1;var r=Math.round(t/e.width*100*n)/100,a=Math.round(i/e.height*100*n)/100,s=Math.min(r,a);return o.setZoom(s),{zoom:s,bbox:e}};if("object"==typeof e){if(r=e,0==r.width||0==r.height){var s=r.zoom?r.zoom:p*r.factor;return o.setZoom(s),{zoom:p,bbox:r}}return a(r)}switch(e){case"selection":if(!w[0])return;var l=$.map(w,function(e){if(e)return e});r=getStrokedBBox(l);break;case"canvas":var d=Ve();n=.95,r={width:d.w,height:d.h,x:0,y:0};break;case"content":r=getStrokedBBox();break;case"layer":r=getStrokedBBox(pe(f().getCurrentLayer()));break;default:return}return a(r)},this.setZoom=function(e){var t=Ve();m.setAttribute("viewBox","0 0 "+t.w/e+" "+t.h/e),p=e,$.each(w,function(e,t){t&&Y.requestSelector(t).resize()}),ce.zoomChange(),ae("zoomChanged",e)},this.getMode=function(){return current_mode},this.setMode=function(e){ce.clear(!0),me.clear(),cur_properties=w[0]&&"text"==w[0].nodeName?cur_text:C,current_mode=e},this.getColor=function(e){return cur_properties[e]},this.setColor=function(e,t,i){function r(e){"g"!=e.nodeName&&n.push(e)}C[e]=t,cur_properties[e+"_paint"]={type:"solidColor"};for(var n=[],a=w.length;a--;){var s=w[a];if(s)if("g"==s.tagName){var o=s.id.substr(0,3);if("GXP"===o)continue;"MTR"===o?svgedit.utilities.walkTree(s,function(t){t.hasAttribute(e)&&"sMTR"!=t.id.substr(0,4)&&n.push(t)}):["CPS","VLA","EHS","SHE"].includes(o)?svgedit.utilities.walkTree(s,function(t){t.hasAttribute(e)&&n.push(t)}):svgedit.utilities.walkTree(s,r)}else"fill"==e?"polyline"!=s.tagName&&"line"!=s.tagName&&n.push(s):n.push(s)}n.length>0&&(i?He(e,t,n):(je(e,t,n),V("changed",n)))};var ze=this.setGradient=function(e){if(cur_properties[e+"_paint"]&&"solidColor"!=cur_properties[e+"_paint"].type){var t=o[e+"Grad"],i=Fe(t),r=svgedit.utilities.findDefs();if(i)t=i;else{t=r.appendChild(g.importNode(t,!0)),t.id=he()}o.setColor(e,"url(#"+t.id+")")}},Fe=function(e){for(var t=svgedit.utilities.findDefs(),i=$(t).find("linearGradient, radialGradient"),r=i.length,a=["r","cx","cy","fx","fy"];r--;){var s=i[r];if("linearGradient"==e.tagName){if(e.getAttribute("x1")!=s.getAttribute("x1")||e.getAttribute("y1")!=s.getAttribute("y1")||e.getAttribute("x2")!=s.getAttribute("x2")||e.getAttribute("y2")!=s.getAttribute("y2"))continue}else{var o=$(e).attr(a),l=$(s).attr(a),d=!1;if($.each(a,function(e,t){o[t]!=l[t]&&(d=!0)}),d)continue}var u=e.getElementsByTagNameNS(n.SVG,"stop"),g=s.getElementsByTagNameNS(n.SVG,"stop");if(u.length==g.length){for(var h=u.length;h--;){var m=u[h],c=g[h];if(m.getAttribute("offset")!=c.getAttribute("offset")||m.getAttribute("stop-opacity")!=c.getAttribute("stop-opacity")||m.getAttribute("stop-color")!=c.getAttribute("stop-color"))break}if(-1==h)return s}}return null};this.setPaint=function(e,t){var i=new $.jGraduate.Paint(t);switch(this.setPaintOpacity(e,i.alpha/100,!0),cur_properties[e+"_paint"]=i,i.type){case"solidColor":-1===i.solidColor.indexOf("rgb")?this.setColor(e,"none"!=i.solidColor?"#"+i.solidColor:"none"):this.setColor(e,i.solidColor);break;case"linearGradient":case"radialGradient":o[e+"Grad"]=i[i.type],ze(e)}},this.setStrokePaint=function(e){this.setPaint("stroke",e)},this.setFillPaint=function(e){this.setPaint("fill",e)},this.getStrokeWidth=function(){return cur_properties.stroke_width},this.setStrokeWidth=function(e){function t(e){"g"!=e.nodeName&&i.push(e)}if(0==e&&["line","path"].indexOf(current_mode)>=0)o.setStrokeWidth(1);else{cur_properties.stroke_width=e;for(var i=[],r=w.length;r--;){var n=w[r];n&&("g"==n.tagName?svgedit.utilities.walkTree(n,t):i.push(n))}i.length>0&&(je("stroke-width",e,i),V("changed",w))}},this.setStrokeAttr=function(e,t){C[e.replace("-","_")]=t;for(var i=[],r=w.length;r--;){var n=w[r];n&&("g"==n.tagName?svgedit.utilities.walkTree(n,function(e){"g"!=e.nodeName&&i.push(e)}):i.push(n))}i.length>0&&(je(e,t,i),V("changed",w))},this.getStyle=function(){return C},this.getOpacity=function(){return C.opacity},this.setOpacity=function(e){C.opacity=e,je("opacity",e)},this.getFillOpacity=function(){return C.fill_opacity},this.getStrokeOpacity=function(){return C.stroke_opacity},this.setPaintOpacity=function(e,t,i){C[e+"_opacity"]=t,i?He(e+"-opacity",t):je(e+"-opacity",t)},this.getPaintOpacity=function(e){return"fill"===e?this.getFillOpacity():this.getStrokeOpacity()},this.getBlur=function(e){var t=0;if(e){var i=e.getAttribute("filter");if(i){var r=svgedit.utilities.getElem(e.id+"_blur");r&&(t=r.firstChild.getAttribute("stdDeviation"))}}return t},function(){function e(){var e=o.undoMgr.finishUndoableChange();t.addSubCommand(e),X(t),t=null,i=null}var t=null,i=null,r=!1;o.setBlurNoUndo=function(e){if(i)if(0===e)He("filter",""),r=!0;else{var t=w[0];r&&He("filter","url(#"+t.id+"_blur)"),svgedit.browser.isWebkit()&&(console.log("e",t),t.removeAttribute("filter"),t.setAttribute("filter","url(#"+t.id+"_blur)")),He("stdDeviation",e,[i.firstChild]),o.setBlurOffsets(i,e)}else o.setBlur(e)},o.setBlurOffsets=function(e,t){t>3?svgedit.utilities.assignAttributes(e,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100):svgedit.browser.isWebkit()||(e.removeAttribute("x"),e.removeAttribute("y"),e.removeAttribute("width"),e.removeAttribute("height"))},o.setBlur=function(r,n){if(t)e();else{var a=w[0],s=a.id;i=svgedit.utilities.getElem(s+"_blur"),r-=0;var l=new svgedit.history.BatchCommand;if(i)0===r&&(i=null);else{var d=_({element:"feGaussianBlur",attr:{in:"SourceGraphic",stdDeviation:r}});i=_({element:"filter",attr:{id:s+"_blur"}}),i.appendChild(d),svgedit.utilities.findDefs().appendChild(i),l.addSubCommand(new svgedit.history.InsertElementCommand(i))}var u={filter:a.getAttribute("filter")};if(0===r)return a.removeAttribute("filter"),void l.addSubCommand(new svgedit.history.ChangeElementCommand(a,u));je("filter","url(#"+s+"_blur)"),l.addSubCommand(new svgedit.history.ChangeElementCommand(a,u)),o.setBlurOffsets(i,r),t=l,o.undoMgr.beginUndoableChange("stdDeviation",[i?i.firstChild:null]),n&&(o.setBlurNoUndo(r),e())}}}(),this.getBold=function(){var e=w[0];return null!=e&&"text"==e.tagName&&null==w[1]&&"bold"==e.getAttribute("font-weight")},this.setBold=function(e){var t=w[0];null!=t&&"text"==t.tagName&&null==w[1]&&je("font-weight",e?"bold":"normal"),w[0].textContent||me.setCursor()},this.getItalic=function(){var e=w[0];return null!=e&&"text"==e.tagName&&null==w[1]&&"italic"==e.getAttribute("font-style")},this.setItalic=function(e){var t=w[0];null!=t&&"text"==t.tagName&&null==w[1]&&je("font-style",e?"italic":"normal"),w[0].textContent||me.setCursor()},this.getFontFamily=function(){return cur_text.font_family},this.setFontFamily=function(e){cur_text.font_family=e,je("font-family",e),w[0]&&!w[0].textContent&&me.setCursor(),ae("setFontAttribute",{elem:w[0],attr:"font-family",value:e})},this.setTextAlign=function(e){cur_text.text_anchor=e,je("text-anchor",e),w[0]&&!w[0].textContent&&me.setCursor(),ae("setFontAttribute",{elem:w[0],attr:"text-anchor",value:e})},this.setFontColor=function(e){cur_text.fill=e,je("fill",e)},this.getFontColor=function(){return cur_text.fill},this.getFontSize=function(){return cur_text.font_size},this.setFontSize=function(e){w[0]&&(cur_text.font_size=e,je("font-size",e),w[0].textContent||me.setCursor(),ae("setFontAttribute",{elem:w[0],attr:"font-size",value:e+"px"}))},this.getExtensionFont=function(e){return oe("getFontAttribute",{elem:e})},this.getText=function(){var e=w[0];return null==e?"":e.textContent},this.setTextContent=function(e){je("#text",e),me.init(e),me.setCursor()},this.setImageURL=function(e){var t=w[0];if(t){var i=$(t).attr(["width","height"]),r=!i.width||!i.height,n=I(t);if(n!==e)r=!0;else if(!r)return;var a=new svgedit.history.BatchCommand("Change Image URL");M(t,e),a.addSubCommand(new svgedit.history.ChangeElementCommand(t,{"#href":n})),r?$(new Image).load(function(){var e=$(t).attr(["width","height"]);$(t).attr({width:this.width,height:this.height}),Y.requestSelector(t).resize(),a.addSubCommand(new svgedit.history.ChangeElementCommand(t,e)),X(a),V("changed",[t])}).attr("src",e):X(a)}},this.setLinkURL=function(e){var t=w[0];if(t){if("a"!==t.tagName){var i=$(t).parents("a");if(!i.length)return;t=i[0]}var r=I(t);if(r!==e){var n=new svgedit.history.BatchCommand("Change Link URL");M(t,e),n.addSubCommand(new svgedit.history.ChangeElementCommand(t,{"#href":r})),X(n)}}},this.setRectRadius=function(e){var t=w[0];if(null!=t&&"rect"==t.tagName){var i=t.getAttribute("rx");i!=e&&(t.setAttribute("rx",e),t.setAttribute("ry",e),X(new svgedit.history.ChangeElementCommand(t,{rx:i,ry:i},"Radius")),V("changed",[t]))}},this.convertToPath=function(e,t){if(null!=e){if(!t)var i=new svgedit.history.BatchCommand("Convert element to Path");var r=t?{}:{fill:C.fill,"fill-opacity":C.fill_opacity,stroke:C.stroke,"stroke-width":C.stroke_width,"stroke-dasharray":C.stroke_dasharray,"stroke-linejoin":C.stroke_linejoin,"stroke-linecap":C.stroke_linecap,"stroke-opacity":C.stroke_opacity,opacity:C.opacity,visibility:"hidden"};$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){e.getAttribute(this)&&(r[this]=e.getAttribute(this))});var n=_({element:"path",attr:r}),a=e.getAttribute("transform");a&&n.setAttribute("transform",a);var s=e.id,l=e.parentNode;e.nextSibling?l.insertBefore(n,e):l.appendChild(n);var d,u,g="",h=function(e){$.each(e,function(e,t){var i,r=t[0],n=t[1];for(g+=r,i=0;i<n.length;i+=2)g+=n[i]+","+n[i+1]+" "})},m=1.81;switch(e.tagName){case"ellipse":case"circle":d=$(e).attr(["rx","ry","cx","cy"]);var c=d.cx,v=d.cy;u=d.rx,ry=d.ry,"circle"==e.tagName&&(u=ry=$(e).attr("r")),h([["M",[c-u,v]],["C",[c-u,v-ry/m,c-u/m,v-ry,c,v-ry]],["C",[c+u/m,v-ry,c+u,v-ry/m,c+u,v]],["C",[c+u,v+ry/m,c+u/m,v+ry,c,v+ry]],["C",[c-u/m,v+ry,c-u,v+ry/m,c-u,v]],["Z",[]]]);break;case"path":g=e.getAttribute("d");break;case"line":d=$(e).attr(["x1","y1","x2","y2"]),g="M"+d.x1+","+d.y1+"L"+d.x2+","+d.y2;break;case"polyline":case"polygon":g="M"+e.getAttribute("points");break;case"rect":var f=$(e).attr(["rx","ry"]);u=f.rx,ry=f.ry;var p=e.getBBox(),y=p.x,x=p.y,b=p.width,S=p.height;m=4-m,u||ry?h([["M",[y,x+ry]],["C",[y,x+ry/m,y+u/m,x,y+u,x]],["L",[y+b-u,x]],["C",[y+b-u/m,x,y+b,x+ry/m,y+b,x+ry]],["L",[y+b,x+S-ry]],["C",[y+b,x+S-ry/m,y+b-u/m,x+S,y+b-u,x+S]],["L",[y+u,x+S]],["C",[y+u/m,x+S,y,x+S-ry/m,y,x+S-ry]],["L",[y,x+ry]],["Z",[]]]):h([["M",[y,x]],["L",[y+b,x]],["L",[y+b,x+S]],["L",[y,x+S]],["L",[y,x]],["Z",[]]]);break;default:n.parentNode.removeChild(n)}if(g&&n.setAttribute("d",g),t){ce.resetOrientation(n);var N=!1;try{N=n.getBBox()}catch(e){}return n.parentNode.removeChild(n),N}if(a){var A=svgedit.transformlist.getTransformList(n);svgedit.math.hasMatrixTransform(A)&&ce.resetOrientation(n)}var k=e.nextSibling;i.addSubCommand(new svgedit.history.RemoveElementCommand(e,k,l)),i.addSubCommand(new svgedit.history.InsertElementCommand(n)),ke(),e.parentNode.removeChild(e),n.setAttribute("id",s),n.removeAttribute("visibility"),Ee([n],!0),X(i)}else{$.each(w,function(e,t){t&&o.convertToPath(t)})}},this.makeHyperlink=function(e){o.groupSelectedElements("a",e)},this.removeHyperlink=function(){o.ungroupSelectedElement()},this.setSegType=function(e){ce.setSegType(e)};var je=this.changeSelectedAttribute=function(e,t,i){i=i||w,1===i.length&&l&&i[0]&&l.indexOf(i[0].id.substr(0,4))>=0&&(i=i[0].childNodes),o.undoMgr.beginUndoableChange(e,i);i.length;He(e,t,i);var r=o.undoMgr.finishUndoableChange();r.isEmpty()||X(r)},He=function(e,t,i){var r=h.suspendRedraw(1e3);"pathedit"==current_mode&&ce.moveNode(e,t),i=i||w;for(var n=i.length,a=["g","polyline","path"],s=["transform","opacity","filter"];n--;){var l=i[n];if(null!=l)if(("x"===e||"y"===e)&&a.indexOf(l.tagName)>=0){var d=getStrokedBBox([l]),u="x"===e?t-d.x:0,g="y"===e?t-d.y:0;o.moveSelectedElements(u*p,g*p,!0)}else{"g"===l.tagName&&s.indexOf(e);var m="#text"===e?l.textContent:l.getAttribute(e);if(null==m&&(m=""),m!==String(t)){if("#text"==e){svgedit.utilities.getBBox(l).width;l.textContent=t,/rotate/.test(l.getAttribute("transform"))&&(l=Se(l))}else"#href"==e?M(l,t):(l.setAttribute(e,t),ae("setGaugeAttribute",{elem:l,attr:e,value:t}));"textedit"===current_mode&&"#text"!==e&&l.textContent.length&&me.toSelectMode(l),svgedit.browser.isGecko()&&"text"===l.nodeName&&/rotate/.test(l.getAttribute("transform"))&&(0===String(t).indexOf("url")||["font-size","font-family","x","y"].indexOf(e)>=0&&l.textContent)&&(l=Se(l)),w.indexOf(l)>=0&&setTimeout(function(){l.parentNode&&Y.requestSelector(l).resize()},0);var c=svgedit.utilities.getRotationAngle(l);if(0!=c&&"transform"!=e)for(var v=svgedit.transformlist.getTransformList(l),f=v.numberOfItems;f--;){var y=v.getItem(f);if(4==y.type){v.removeItem(f);var x=svgedit.utilities.getBBox(l),b=svgedit.math.transformPoint(x.x+x.width/2,x.y+x.height/2,svgedit.math.transformListToTransform(v).matrix),S=b.x,C=b.y,_=h.createSVGTransform();_.setRotate(c,S,C),v.insertItemBefore(_,f);break}}}}}h.unsuspendRedraw(r)};this.deleteSelectedElements=function(){var e,t=new svgedit.history.BatchCommand("Delete Elements"),i=w.length,r=[];for(e=0;e<i;++e){var n=w[e];if(null==n)break;var a=n.parentNode,s=n;Y.releaseSelector(s),svgedit.path.removePath_(s.id),"a"===a.tagName&&1===a.childNodes.length&&(s=a,a=a.parentNode);var o=s.nextSibling,l=a.removeChild(s);r.push(n),w[e]=null,t.addSubCommand(new q(l,o,a))}return t.isEmpty()||X(t),V("changed",r),ke(),r},this.cutSelectedElements=function(){var e,t=new svgedit.history.BatchCommand("Cut Elements"),i=w.length,r=[];for(e=0;e<i;++e){var n=w[e];if(null==n)break;var a=n.parentNode,s=n;Y.releaseSelector(s),svgedit.path.removePath_(s.id);var l=s.nextSibling,d=a.removeChild(s);r.push(n),w[e]=null,t.addSubCommand(new q(d,l,a))}t.isEmpty()||X(t),V("changed",r),ke(),o.clipBoard=r},this.pasteElements=function(e,t,i){var r=o.clipBoard,n=r.length;if(n){for(var a=[],s=new svgedit.history.BatchCommand("Paste elements");n--;){var l=r[n];if(l)if(l.symbols&&l.symbols.length){var d=svgedit.utilities.findDefs();l.symbols.forEach(e=>{var t=svgedit.utilities.getElem(e.id);t||d.appendChild(e)}),l.defs&&l.defs.appendTo(d)}else{var u=be(l);a.push(u),(b||f().getCurrentLayer()).appendChild(u),s.addSubCommand(new svgedit.history.InsertElementCommand(u))}}if(Be(a),"in_place"!==e){var g,h;e?"point"===e&&(g=t,h=i):(g=lastClickPoint.x,h=lastClickPoint.y);var m=getStrokedBBox(a),c=g-(m.x+m.width/2),v=h-(m.y+m.height/2),p=[],y=[];$.each(a,function(e,t){p.push(c),y.push(v)});var x=o.moveSelectedElements(p,y,!1);s.addSubCommand(x)}X(s),V("onGaugeCopyPaste",{copy:r,past:a.reverse()}),V("changed",a)}},this.copySelectedElements=function(){o.clipBoard=$.merge([],w),qe()};var qe=function(){for(var e={symbols:[],defs:null},t=0;t<o.clipBoard.length;t++){var i=o.clipBoard[t];if(i){var r=[];svgedit.utilities.walkTree(i,function(e){"use"===e.tagName&&r.push(e)})}r.forEach(t=>{var i=svgedit.utilities.getElem(I(t).substr(1)),r=i.getAttribute("type"),n=t.getAttribute("type");!n&&r&&t.setAttribute("type",r),e.symbols.find(e=>e.id===i.id)||e.symbols.push(i)})}if(e.symbols.length){const t=svgedit.utilities.findDefs();e.defs=$(t).find("linearGradient, radialGradient, pattern"),o.clipBoard.push(e)}};this.groupSelectedElements=function(e,t){e||(e="g");var i="";switch(e){case"a":i="Make hyperlink";var r="";arguments.length>1&&(r=t);break;default:e="g",i="Group Elements"}var n=new svgedit.history.BatchCommand(i),a=_({element:e,attr:{id:he(),target:"_blank",type:"svg-ext-shapes-group"}});"a"===e&&M(a,r),n.addSubCommand(new svgedit.history.InsertElementCommand(a));for(var s=w.length;s--;){var o=w[s];if(null!=o){"a"===o.parentNode.tagName&&1===o.parentNode.childNodes.length&&(o=o.parentNode);var l=o.nextSibling,d=o.parentNode;a.appendChild(o),n.addSubCommand(new svgedit.history.MoveElementCommand(o,l,d))}}n.isEmpty()||X(n),Be([a],!0)};var We=this.pushGroupProperties=function(e,t){var i,r,n,a=e.childNodes,s=a.length,l=e.getAttribute("transform"),d=svgedit.transformlist.getTransformList(e),u=svgedit.math.transformListToTransform(d).matrix,g=new svgedit.history.BatchCommand("Push group properties"),m=0,c=svgedit.utilities.getRotationAngle(e),v=$(e).attr(["filter","opacity"]);for(m=0;m<s;m++){var f=a[m];if(1===f.nodeType){if(null!==v.opacity&&1!==v.opacity){f.getAttribute("opacity");var p=Math.round((f.getAttribute("opacity")||1)*v.opacity*100)/100;je("opacity",p,[f])}if(v.filter){var y=this.getBlur(f),x=y;r||(r=this.getBlur(e)),y?y=Number(r)+Number(y):0===y&&(y=r),x?i=svgedit.utilities.getRefElem(f.getAttribute("filter")):i?(i=be(i),svgedit.utilities.findDefs().appendChild(i)):i=svgedit.utilities.getRefElem(v.filter);var b="feGaussianBlur"===i.firstChild.tagName?"blur":"filter";i.id=f.id+"_"+b,je("filter","url(#"+i.id+")",[f]),y&&(je("stdDeviation",y,[i.firstChild]),o.setBlurOffsets(i,y))}var S=svgedit.transformlist.getTransformList(f);if(~f.tagName.indexOf("Gradient")&&(S=null),S&&"defs"!==f.tagName&&d.numberOfItems){if(c&&1==d.numberOfItems){var C=d.getItem(0).matrix,w=h.createSVGMatrix(),_=svgedit.utilities.getRotationAngle(f);_&&(w=S.getItem(0).matrix);var N=svgedit.utilities.getBBox(f),A=svgedit.math.transformListToTransform(S).matrix,k=svgedit.math.transformPoint(N.x+N.width/2,N.y+N.height/2,A),E=c+_,B=h.createSVGTransform();B.setRotate(E,k.x,k.y);var T=svgedit.math.matrixMultiply(C,w,B.matrix.inverse());if(_&&S.removeItem(0),E&&(S.numberOfItems?S.insertItemBefore(B,0):S.appendItem(B)),T.e||T.f){var G=h.createSVGTransform();G.setTranslate(T.e,T.f),S.numberOfItems?S.insertItemBefore(G,0):S.appendItem(G)}}else{var I=f.getAttribute("transform");n={},n.transform=I||"";var M=h.createSVGTransform(),L=svgedit.math.transformListToTransform(S).matrix,P=L.inverse(),O=svgedit.math.matrixMultiply(P,u,L);M.setMatrix(O),S.appendItem(M)}var D=svgedit.recalculate.recalculateDimensions(f);D&&g.addSubCommand(D)}}}if(l&&(n={},n.transform=l,e.setAttribute("transform",""),e.removeAttribute("transform"),g.addSubCommand(new svgedit.history.ChangeElementCommand(e,n))),t&&!g.isEmpty())return g};this.ungroupSelectedElement=function(){var e=w[0];if(e)if($(e).data("gsvg")||$(e).data("symbol"))Pe(e);else{if("use"===e.tagName){var t=svgedit.utilities.getElem(I(e).substr(1));return $(e).data("symbol",t).data("ref",t),void Pe(e)}var i=$(e).parents("a");if(i.length&&(e=i[0]),"g"===e.tagName||"a"===e.tagName){var r=new svgedit.history.BatchCommand("Ungroup Elements"),n=We(e,!0);n&&r.addSubCommand(n);for(var a=e.parentNode,s=e.nextSibling,o=new Array(e.childNodes.length),l=0;e.firstChild;){var d=e.firstChild,u=d.nextSibling,g=d.parentNode;if("title"!==d.tagName)o[l++]=d=a.insertBefore(d,s),r.addSubCommand(new svgedit.history.MoveElementCommand(d,u,g));else{var h=d.nextSibling;r.addSubCommand(new svgedit.history.RemoveElementCommand(d,h,g)),g.removeChild(d)}}ke();var m=e.nextSibling;e=a.removeChild(e),r.addSubCommand(new svgedit.history.RemoveElementCommand(e,m,a)),r.isEmpty()||X(r),Ee(o)}}},this.moveToTopSelectedElement=function(){var e=w[0];if(null!=e){var t=e,i=t.parentNode,r=t.nextSibling;t=t.parentNode.appendChild(t),r!=t.nextSibling&&(X(new svgedit.history.MoveElementCommand(t,r,i,"top")),V("changed",[t]))}},this.moveToBottomSelectedElement=function(){var e=w[0];if(null!=e){var t=e,i=t.parentNode,r=t.nextSibling,n=t.parentNode.firstChild;"title"==n.tagName&&(n=n.nextSibling),"defs"==n.tagName&&(n=n.nextSibling),t=t.parentNode.insertBefore(t,n),r!=t.nextSibling&&(X(new svgedit.history.MoveElementCommand(t,r,i,"bottom")),V("changed",[t]))}},this.moveUpDownSelected=function(e){var t=w[0];if(t){var i,r;curBBoxes=[];var n=$(ue(getStrokedBBox([t]))).toArray();if("Down"==e&&n.reverse(),$.each(n,function(){if(r)return i=this,!1;this==t&&(r=!0)}),i){var a=t,s=a.parentNode,o=a.nextSibling;$(i)["Down"==e?"before":"after"](a),o!=a.nextSibling&&(X(new svgedit.history.MoveElementCommand(a,o,s,"Move "+e)),V("changed",[a]))}}},this.moveSelectedElements=function(e,t,i){e.constructor!=Array&&(e/=p,t/=p),i=i||!0;for(var r=new svgedit.history.BatchCommand("position"),n=w.length;n--;){var a=w[n];if(null!=a){var s=h.createSVGTransform(),o=svgedit.transformlist.getTransformList(a);e.constructor==Array?s.setTranslate(e[n],t[n]):s.setTranslate(e,t),o.numberOfItems?o.insertItemBefore(s,0):o.appendItem(s);var l=svgedit.recalculate.recalculateDimensions(a);l&&r.addSubCommand(l),Y.requestSelector(a).resize()}}if(!r.isEmpty())return i&&X(r),V("changed",w),r},this.setFilterShadow=function(e){if(!(w.length<=0)){var t=w[0];if(e){var i=svgedit.utilities.findDefs();if(i){var r=$(i).find("filter");r&&r.length||(r=g.createElementNS(n.SVG,"filter"),i.appendChild(r),r.setAttribute("id","shadow-box"));var a=$(r).find("feDropShadow");a&&a.length||(a=g.createElementNS(n.SVG,"feDropShadow"),a.setAttribute("dx","2"),a.setAttribute("dy","2"),a.setAttribute("stdDeviation","2"),r.appendChild(a)),t.setAttribute("filter","url(#shadow-box)")}}else t.removeAttribute("filter")}},this.cloneSelectedElements=function(e,t){function i(e,t){return $(t).index()-$(e).index()}var r,n,a=new svgedit.history.BatchCommand("Clone Elements"),s=w.length;for(w.sort(i),r=0;r<s&&(n=w[r],null!=n);++r);var o=w.slice(0,r);for(this.clearSelection(!0),r=o.length;r--;)n=o[r]=be(o[r]),(b||f().getCurrentLayer()).appendChild(n),a.addSubCommand(new svgedit.history.InsertElementCommand(n));a.isEmpty()||(Ee(o.reverse()),this.moveSelectedElements(e,t,!1),X(a)),V("onGaugeCopyPaste",{copy:w,past:o})},this.alignSelectedElements=function(e,t){var i,r,n=[],a=Number.MAX_VALUE,s=Number.MIN_VALUE,l=Number.MAX_VALUE,d=Number.MIN_VALUE,u=Number.MIN_VALUE,g=Number.MIN_VALUE,h=w.length;if(h){for(i=0;i<h&&null!=w[i];++i)switch(r=w[i],n[i]=getStrokedBBox([r]),t){case"smallest":(("l"==e||"c"==e||"r"==e)&&(u==Number.MIN_VALUE||u>n[i].width)||("t"==e||"m"==e||"b"==e)&&(g==Number.MIN_VALUE||g>n[i].height))&&(a=n[i].x,l=n[i].y,s=n[i].x+n[i].width,d=n[i].y+n[i].height,u=n[i].width,g=n[i].height);break;case"largest":(("l"==e||"c"==e||"r"==e)&&(u==Number.MIN_VALUE||u<n[i].width)||("t"==e||"m"==e||"b"==e)&&(g==Number.MIN_VALUE||g<n[i].height))&&(a=n[i].x,l=n[i].y,s=n[i].x+n[i].width,d=n[i].y+n[i].height,u=n[i].width,g=n[i].height);break;default:n[i].x<a&&(a=n[i].x),n[i].y<l&&(l=n[i].y),n[i].x+n[i].width>s&&(s=n[i].x+n[i].width),n[i].y+n[i].height>d&&(d=n[i].y+n[i].height)}"page"==t&&(a=0,l=0,s=o.contentW,d=o.contentH);var m=new Array(h),c=new Array(h);for(i=0;i<h&&null!=w[i];++i){r=w[i];var v=n[i];switch(m[i]=0,c[i]=0,e){case"l":m[i]=a-v.x;break;case"c":m[i]=(a+s)/2-(v.x+v.width/2);break;case"r":m[i]=s-(v.x+v.width);break;case"t":c[i]=l-v.y;break;case"m":c[i]=(l+d)/2-(v.y+v.height/2);break;case"b":c[i]=d-(v.y+v.height)}}this.moveSelectedElements(m,c)}},this.divideSelectedElements=function(e){var t,i,r=[],n=Number.MAX_VALUE,a=Number.MIN_VALUE,s=Number.MAX_VALUE,o=Number.MIN_VALUE,l=0,d=0,u=0,g=w.length;if(g&&!(g<3)){for(t=0;t<g&&null!=w[t];++t)i=w[t],u++,r[t]=getStrokedBBox([i]),r[t].index=t,r[t].x<n&&(n=r[t].x),r[t].y<s&&(s=r[t].y),r[t].x+r[t].width>a&&(a=r[t].x+r[t].width),r[t].y+r[t].height>o&&(o=r[t].y+r[t].height),d+=r[t].height,l+=r[t].width;"h"===e?r.sort((e,t)=>e.x>t.x?1:-1):"v"===e&&r.sort((e,t)=>e.y>t.y?1:-1),u--;var h=new Array(r.length),m=new Array(r.length),c=(a-n-l)/u,v=(o-s-d)/u,f=n,p=s
20
- ;for(t=0;t<r.length;++t){var y=r[t];switch(h[t]={x:y.x,i:y.index},m[t]={y:y.y,i:y.index},e){case"h":h[t].x=t>0?f>y.x?f-y.x:-(y.x-f):0,f+=y.width+c,m[t].y=0;break;case"v":m[t].y=t>0?p>y.y?p-y.y:-(y.y-p):0,p+=y.height+v,h[t].x=0}}h.sort((e,t)=>e.i>t.i?1:-1),m.sort((e,t)=>e.i>t.i?1:-1),h=h.map(e=>Math.round(100*e.x)/100),m=m.map(e=>Math.round(100*e.y)/100),this.moveSelectedElements(h,m)}},this.contentW=Ve().w,this.contentH=Ve().h,this.updateCanvas=function(e,t){h.setAttribute("width",e),h.setAttribute("height",t);var i=$("#canvasBackground")[0],r=m.getAttribute("x"),n=m.getAttribute("y"),a=e/2-this.contentW*p/2,s=t/2-this.contentH*p/2;svgedit.utilities.assignAttributes(m,{width:this.contentW*p,height:this.contentH*p,x:a,y:s,viewBox:"0 0 "+this.contentW+" "+this.contentH}),svgedit.utilities.assignAttributes(i,{width:m.getAttribute("width"),height:m.getAttribute("height"),x:a,y:s});var o=svgedit.utilities.getElem("background_image");return o&&svgedit.utilities.assignAttributes(o,{width:"100%",height:"100%"}),Y.selectorParentGroup.setAttribute("transform","translate("+a+","+s+")"),ae("canvasUpdated",{new_x:a,new_y:s,old_x:r,old_y:n,d_x:a-r,d_y:s-n}),{x:a,y:s,old_x:r,old_y:n,d_x:a-r,d_y:s-n}},this.setBackground=function(e,t){var i=svgedit.utilities.getElem("canvasBackground"),r=$(i).find("rect")[0],a=svgedit.utilities.getElem("background_image");r.setAttribute("fill",e),t?(a||(a=g.createElementNS(n.SVG,"image"),svgedit.utilities.assignAttributes(a,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})),M(a,t),i.appendChild(a)):a&&a.parentNode.removeChild(a)},this.cycleElement=function(e){var t,i=w[0],r=!1,n=pe(b||f().getCurrentLayer());if(n.length){if(null==i)t=e?n.length-1:0,r=n[t];else for(var a=n.length;a--;)if(n[a]==i){t=e?a-1:a+1,t>=n.length?t=0:t<0&&(t=n.length-1),r=n[t];break}Be([r],!0),V("selected",w)}},this.clear(),this.getExtensionMember=function(e,t){var i=[];return $.each(extensions,function(r,n){n&&e in n&&i.push(n[e](t))}),i},this.getPrivateMethods=function(){var e={addCommandToHistory:X,setGradient:ze,addSvgElementFromJson:_,addSvgGroupFromJson:N,assignAttributes:O,BatchCommand:K,call:V,ChangeElementCommand:W,copyElem:be,ffClone:Se,findDefs:T,findDuplicateGradient:Fe,getElem:P,getId:ge,getIntersectionList:ue,getMouseTarget:Te,getNextId:he,getPathBBox:L,getUrlFromAttr:G,hasMatrixTransform:E,identifyLayers:Oe,InsertElementCommand:H,isIdentity:svgedit.math.isIdentity,logMatrix:Ne,matrixMultiply:k,MoveElementCommand:j,preventClickDefault:Ge,recalculateAllSelectedDimensions:we,recalculateDimensions:U,remapElement:R,RemoveElementCommand:q,removeUnusedDefElems:Ie,round:de,runExtensions:ae,setSpecialsIds:se,runGetExtensions:oe,runExtension:le,sanitizeSvg:F,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:B,transformPoint:A,walkTree:svgedit.utilities.walkTree};return e}};
21
- var mysvgeditor={initSvgEditor:function(e,t,n,o,i,a,r,l,s){window.svgEditor=function(e){function c(t,n){var o=!1!==d.setSvgString(t);n=n||e.noop,o?n(!0):e.alert(uiStrings.notification.errorLoadingSVG,function(){n(!1)})}var u={};console.log("editor v2.9.10-167"),e(document).unbind("keydown"),u.tool_scale=1,u.exportWindowCt=0,u.langChanged=!1,u.showSaveWarning=!1,u.storagePromptClosed=!1,u.extensionLoadedCallback=n,u.onSelectedElement=t,u.changeColor=o,u.onGaugeAdded=i,u.onGaugeResized=r,u.onGaugeRemoved=a,u.onGaugeCopyPaste=l,u.onGroupChanged=s,u.currentExtensionsInteractivityType=[],u.currentExtensionsPrefixIdType=[],u.shapesGrps={},u.shapesList=[],u.baseSvgTags=["path","line","rect","circle","ellipse","text","image"];var d,f,p=["VAL_","HXI_","HXB_","HXS_"],g=["HXI_","HXB_","HXS_","GXP_","HXC_","BAG_","SLI_","HXT_"],v=["SHE_"],h=svgedit.utilities,m=svgedit.shapes;return isReady=!1,customExportImage=!1,customExportPDF=!1,callbacks=[],defaultPrefs={lang:"",iconsize:"",bkgd_color:"#FFF",bkgd_url:"",img_save:"embed",save_notice_done:!1,export_notice_done:!1},curPrefs={},curConfig={extensions:[],allowedOrigins:[]},defaultExtensions=["ext-overview_window.js","ext-markers.js","ext-connector.js","ext-eyedropper.js","ext-imagelib.js","ext-grid.js","ext-polygon.js","ext-panning.js","ext-storage.js"],defaultConfig={canvasName:"default",canvas_expansion:3,initFill:{color:"FF0000",opacity:1},initStroke:{width:1,color:"000000",opacity:1},initOpacity:1,colorPickerCSS:null,initTool:"select",exportWindowType:"new",wireframe:!1,showlayers:!1,no_save_warning:!1,imgPath:"images/",langPath:"locale/",extPath:"extensions/",jGraduatePath:"jgraduate/images/",shapesPath:"assets/lib/svgeditor/shapes/",dimensions:[640,480],gridSnapping:!0,gridColor:"#000",baseUnit:"px",snappingStep:2,showRulers:!0,preventAllURLConfig:!1,preventURLContentLoading:!1,lockExtensions:!1,noDefaultExtensions:!1,showGrid:!1,noStorageOnLoad:!1,forceStorage:!1,emptyStorageOnDecline:!1},uiStrings=u.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.pref=function(e,t){return t?(curPrefs[e]=t,void(u.curPrefs=curPrefs)):e in curPrefs?curPrefs[e]:defaultPrefs[e]},u.loadContentAndPrefs=function(){if(curConfig.forceStorage||!curConfig.noStorageOnLoad&&document.cookie.match(/(?:^|;\s*)store=(?:prefsAndContent|prefsOnly)/)){if(u.storage&&(curConfig.forceStorage||!curConfig.noStorageOnLoad&&document.cookie.match(/(?:^|;\s*)store=prefsAndContent/))){var e="svgedit-"+curConfig.canvasName,t=u.storage.getItem(e);t&&u.loadFromString(t)}var n;for(n in defaultPrefs)if(defaultPrefs.hasOwnProperty(n)){var o="web-edit-"+n;if(u.storage){var i=u.storage.getItem(o);i&&(defaultPrefs[n]=String(i))}else if(window.widget)defaultPrefs[n]=widget.preferenceForKey(o);else{var a=document.cookie.match(new RegExp("(?:^|;\\s*)"+h.preg_quote(encodeURIComponent(o))+"=([^;]+)"));defaultPrefs[n]=a?decodeURIComponent(a[1]):""}}}},u.setConfig=function(t,n){function o(t,n,o){t[n]&&"object"==typeof t[n]?e.extend(!0,t[n],o):t[n]=o}n=n||{},e.each(t,function(i,a){if(t.hasOwnProperty(i))if(defaultPrefs.hasOwnProperty(i)){if(!1===n.overwrite&&(curConfig.preventAllURLConfig||curPrefs.hasOwnProperty(i)))return;!0===n.allowInitialUserOverride?defaultPrefs[i]=a:e.pref(i,a)}else if(["extensions","allowedOrigins"].indexOf(i)>-1){if(!1===n.overwrite&&(curConfig.preventAllURLConfig||"allowedOrigins"===i||"extensions"===i&&curConfig.lockExtensions))return;curConfig[i]=curConfig[i].concat(a)}else if(defaultConfig.hasOwnProperty(i)){if(!1===n.overwrite&&(curConfig.preventAllURLConfig||curConfig.hasOwnProperty(i)))return;if(curConfig.hasOwnProperty(i)){if(!1===n.overwrite)return;o(curConfig,i,a)}else!0===n.allowInitialUserOverride?o(defaultConfig,i,a):defaultConfig[i]&&"object"==typeof defaultConfig[i]?(curConfig[i]={},e.extend(!0,curConfig[i],a)):curConfig[i]=a}}),u.curConfig=curConfig},u.setCustomHandlers=function(t){u.ready(function(){t.open&&(e('#tool_open > input[type="file"]').remove(),e("#tool_open").show(),d.open=t.open),t.save&&(u.showSaveWarning=!1,d.bind("saved",t.save)),t.exportImage&&(customExportImage=t.exportImage,d.bind("exported",customExportImage)),t.exportPDF&&(customExportPDF=t.exportPDF,d.bind("exportedPDF",customExportPDF))})},u.randomizeIds=function(){d.randomizeIds(arguments)},u.init=function(t){function n(){curPrefs=e.extend(!0,{},defaultPrefs,curPrefs),u.curPrefs=curPrefs}function o(){curConfig=e.extend(!0,{},defaultConfig,curConfig),curConfig.noDefaultExtensions||(curConfig.extensions=curConfig.extensions.concat(defaultExtensions)),e.each(["extensions","allowedOrigins"],function(t,n){curConfig[n]=e.grep(curConfig[n],function(e,t){return t===curConfig[n].indexOf(e)})}),u.curConfig=curConfig}function i(t,n){var o=t.id,i=o.split("_"),a=i[0],r=i[1];n&&d.setStrokeAttr("stroke-"+a,r),pe(),P("#cur_"+a,o,20),e(t).addClass("current").siblings().removeClass("current")}function r(t,n){e.pref("bkgd_color",t),e.pref("bkgd_url",n),d.setBackground(t,n)}function l(){var t=d.getHref(K);if(t=0===t.indexOf("data:")?"":t,u.promptImgURLcallback){var n=u.promptImgURLcallback;n&&he(n)}else e.prompt(uiStrings.notification.enterNewImgURL,t,function(e){e&&he(e)})}function s(t,n){var o,i;n||(n=d.getZoom()),t||(t=e("#svgcanvas"));var a=3e4,r=d.getContentElem(),l=svgedit.units.getTypeMap(),s=l[curConfig.baseUnit];for(o=0;o<2;o++){var c=0===o,u=c?"x":"y",f=c?"width":"height",p=Number(r.getAttribute(u)),g=e("#ruler_"+u+" canvas:first"),v=g.clone();g.replaceWith(v);var h=v[0],m=t[f](),_=m;h.parentNode.style[f]=_+"px";var w,y,b,C=0,x=h.getContext("2d");if(x.fillStyle="#666666",x.fillRect(0,0,h.width,h.height),v.siblings().remove(),m>=a){var k;for(b=parseInt(m/a,10)+1,w=[],w[0]=x,i=1;i<b;i++)h[f]=a,k=h.cloneNode(!0),h.parentNode.appendChild(k),w[i]=k.getContext("2d");k[f]=m%a,m=a}h[f]=m;var S=s*n,E=50/S,F=1;for(i=0;i<re.length&&(y=re[i],F=y,!(E<=y));i++);var P=F*S;x.font="8px sans-serif";for(var A=p/S%F*S,T=A-P;A<_;){T+=P,x.fillStyle="#CACACA";var L,D=Math.round(A)+.5;if(c?(x.moveTo(D,15),x.lineTo(D,0)):(x.moveTo(15,D),x.lineTo(0,D)),y=(T-p)/S,F>=1)L=Math.round(y);else{var I=String(F).split(".")[1].length;L=y.toFixed(I)}if(0!==L&&1e3!==L&&L%1e3==0&&(L=L/1e3+"K"),c)x.fillText(L,A+2,8);else{var N=String(L).split("");for(i=0;i<N.length;i++)x.fillText(N[i],1,A+9+9*i)}var B=P/10;for(i=1;i<10;i++){var O=Math.round(A+B*i)+.5;if(w&&O>m){if(C++,x.stroke(),C>=b){i=10,A=_;continue}x=w[C],A-=a,O=Math.round(A+B*i)+.5}var U=i%2?12:10;c?(x.moveTo(O,15),x.lineTo(O,U)):(x.moveTo(15,O),x.lineTo(U,O))}A+=P}x.strokeStyle="#666666",x.stroke()}}function _(){d.deleteCurrentLayer()&&(ye(),se(),e("#layerlist tr.layer").removeClass("layersel"),e("#layerlist tr.layer:first").addClass("layersel"))}function w(){var t=d.getCurrentDrawing().getCurrentLayerName()+" copy";e.prompt(uiStrings.notification.enterUniqueLayerName,t,function(t){t&&(d.getCurrentDrawing().hasLayer(t)?e.alert(uiStrings.notification.dupeLayerName):(d.cloneLayer(t),ye(),se()))})}function y(){e("#layerlist tr.layersel").index()!=d.getCurrentDrawing().getNumLayers()-1&&(d.mergeLayer(),ye(),se())}function b(t){var n=e("#layerlist tr.layersel").index(),o=d.getCurrentDrawing().getNumLayers();(n>0||n<o-1)&&(n+=t,d.setCurrentLayerPosition(o-n-1),se())}function C(e,t){var n=Number(e.value),o=n+t,i=o>=n;return 0===t?n:n>=24?i?Math.round(1.1*n):Math.round(n/1.1):n<=1?i?2*n:n/2:o}function x(e,t){var n=Number(e.value);if(0===n)return 100;var o=n+t;return 0===t?n:n>=100?o:o>=n?2*n:n/2}function k(e){e.stopPropagation(),e.preventDefault()}function S(e){e.stopPropagation(),e.preventDefault()}function E(e){e.stopPropagation(),e.preventDefault()}try{"localStorage"in window&&(u.storage=localStorage)}catch(e){}var F=[];e("#lang_select option").each(function(){F.push(this.value)}),function(){var t,i;if(f=e.deparam.querystring(!0),e.isEmptyObject(f))o(),u.loadContentAndPrefs(),n();else{if(f.dimensions&&(f.dimensions=f.dimensions.split(",")),f.bkgd_color&&(f.bkgd_color="#"+f.bkgd_color),f.extensions&&(f.extensions=f.extensions.match(/[:\/\\]/)?"":f.extensions.split(",")),e.each(["extPath","imgPath","langPath","jGraduatePath"],function(e){f[e]&&delete f[e]}),u.setConfig(f,{overwrite:!1}),o(),!curConfig.preventURLContentLoading){if(t=f.source,i=e.param.querystring(),t||i.indexOf("source=data:")>=0&&(t=i.match(/source=(data:[^&]*)/)[1]),t)return void(0===t.indexOf("data:")?u.loadFromDataURI(t):u.loadFromString(t));if(f.url)return void u.loadFromURL(f.url)}f.noStorageOnLoad&&!curConfig.forceStorage||u.loadContentAndPrefs(),n()}}(),function(){var e,n=window.opener;if(n)try{e=n.document.createEvent("Event"),e.initEvent("svgEditorReady",!0,!0),n.document.documentElement.dispatchEvent(e)}catch(e){}t&&setTimeout(t,2e3)}();var P=u.setIcon=function(t,n,o){var i="string"==typeof n?e.getSvgIcon(n,!0):n.clone();i&&e(t).empty().append(i)},A=function(){window.extOverview&&window.extOverview(),window.extMarkers&&window.extMarkers(),window.extEyedropper&&window.extEyedropper(),window.extImagelib&&window.extImagelib(),window.extGrid&&window.extGrid(),window.extPanning&&window.extPanning(),window.extStorage&&window.extStorage(),window.extSwitch&&window.extSwitch(),window.extValue&&window.extValue(),window.extHtmlInput&&window.extHtmlInput(),window.extHtmlChart&&window.extHtmlChart(),window.extHtmlGraph&&window.extHtmlGraph(),window.extHtmlSelect&&window.extHtmlSelect(),window.extHtmlButton&&window.extHtmlButton(),window.extGaugeProgress&&window.extGaugeProgress(),window.extGaugeSemaphore&&window.extGaugeSemaphore(),window.extHtmlBag&&window.extHtmlBag(),window.extLinear&&window.extLinear(),window.extPipe&&window.extPipe(),window.extHtmlSlider&&window.extHtmlSlider(),window.extHtmlSwitch&&window.extHtmlSwitch(),window.extOwnCtrl&&window.extOwnCtrl(),u.putLocale&&u.putLocale(null,F)},T=function(e){m.load(curConfig.shapesPath,function(){Object.values(u.shapesGrps).forEach(e=>{for(var t=0;t<e.length;t++)u.shapesList.push(e[t])}),window.extShapes&&window.extShapes(),e&&e()})};"file:"===document.location.protocol&&setTimeout(A,100),u.canvas=d=new e.SvgCanvas(document.getElementById("svgcanvas"),curConfig);var L,D,I,N,B=["#FFFFFF","#000000","#333333","#4D4D4D","#666666","#808080","#999999","#B3B3B3","#CCCCCC","#E6E6E6","#ECECEC","#F9F9F9","#05285B","#073984","#094BAC","#0B5CD5","#0D6EFD","#3485FD","#5A9CFE","#81B4FE","#A8CBFE","#250657","#35087E","#450BA5","#560DCB","#6610F2","#7E36F4","#975CF6","#AF83F8","#C8A9FA","#281845","#3A2264","#4B2D83","#5D37A2","#6F42C1","#8660CB","#9D7ED5","#B49DDF","#CBBBE9","#4D1230","#6F1B45","#92235A","#B42B6F","#D63384","#DD5498","#E374AB","#EA95BF","#F0B6D3","#4F1319","#721C24","#96242F","#B92D3A","#DC3545","#E25563","#E77681","#ED969E","#F2B6BC","#5B2D07","#84420A","#AC560E","#D56A11","#FD7E14","#FD933A","#FEA75F","#FEBC85","#FED1AA","#5C4503","#856404","#AD8305","#D6A206","#FFC107","#FFCB2F","#FFD556","#FFDF7E","#FFE9A6","#0E3C19","#155724","#1B722F","#228C3A","#28A745","#4AB563","#6DC381","#8FD19E","#B2DFBC","#0C4836","#11694F","#168967","#1BA97F","#20C997","#44D2A8","#67DAB8","#8BE3C9","#AFECDA","#083A42","#0C5460","#106E7D","#13889B","#17A2B8","#3CB1C3","#61C0CF","#86CFDA","#ABDEE5"],O=svgedit.browser.isMac()?"meta+":"ctrl+",U=d.pathActions,R=d.undoMgr,M=curConfig.imgPath+"logo.png",G=e("#workarea"),z=e("#cmenu_canvas"),j=null,H="crosshair",W="crosshair",V="toolbars",X="",Z={fill:null,stroke:null};(function(){e("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var t=e("#dialog_box"),n=e("#dialog_buttons"),o=e("#dialog_content"),i=function(i,a,r,l,s,c,u){var d,f,p;if(o.html("<p>"+a.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt","prompt"==i),n.empty(),d=e('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(n),"alert"!==i&&e('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(n).click(function(){t.hide(),r&&r(!1)}),"prompt"===i)f=e('<input type="text">').prependTo(n),f.val(l||""),f.bind("keydown","return",function(){d.click()});else if("select"===i){var g=e('<div style="text-align:center;">');if(f=e("<select>").appendTo(g),u){var v=e("<label>").text(u.label);p=e('<input type="checkbox">').appendTo(v),p.val(u.value),u.tooltip&&v.attr("title",u.tooltip),p.prop("checked",!!u.checked),g.append(e("<div>").append(v))}e.each(s||[],function(t,n){"object"==typeof n?f.append(e("<option>").val(n.value).html(n.text)):f.append(e("<option>").html(n))}),o.append(g),l&&f.val(l),c&&f.bind("change","return",c),f.bind("keydown","return",function(){d.click()})}else"process"===i&&d.hide();t.show(),d.click(function(){t.hide();var e="prompt"!==i&&"select"!==i||f.val();r&&(p?r(e,p.prop("checked")):r(e))}).focus(),"prompt"!==i&&"select"!==i||f.focus()};e.alert=function(e,t){i("alert",e,t)},e.confirm=function(e,t){i("confirm",e,t)},e.process_cancel=function(e,t){i("process",e,t)},e.prompt=function(e,t,n){i("prompt",e,n,t)},e.select=function(e,t,n,o,a,r){i("select",e,n,a,t,o,r)}})();var q,Q=function(){var t=e(".tool_button_current");t.length&&"tool_select"!==t[0].id&&(t.removeClass("tool_button_current").addClass("tool_button"),e("#tool_select").addClass("tool_button_current").removeClass("tool_button"),e("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all} #svgcanvas svg{cursor:default}")),d.setMode("select"),G.css("cursor","auto")},K=null,Y=!1,J=!1,$=!1,ee=!1,te=!1,ne=!1,oe=!1,ie="",ae=e("title:first").text(),re=[];for(q=.1;q<1e5;q*=10)re.push(q),re.push(2*q),re.push(5*q);var le=function(e){var t,n=[],o=d.getCurrentDrawing().getNumLayers();for(t=0;t<o;t++)n[t]=d.getCurrentDrawing().getLayerName(t);if(e)for(t=0;t<o;++t)n[t]!=e&&d.getCurrentDrawing().setLayerOpacity(n[t],.5);else for(t=0;t<o;++t)d.getCurrentDrawing().setLayerOpacity(n[t],1)},se=function(){d.clearSelection();for(var t=e("#layerlist tbody").empty(),n=e("#selLayerNames").empty(),o=d.getCurrentDrawing(),i=o.getCurrentLayerName(),a=d.getCurrentDrawing().getNumLayers(),r=e.getSvgIcon("eye");a--;){var l=o.getLayerName(a),s=e('<tr class="layer">').toggleClass("layersel",l===i),c=e('<td class="layervis">').toggleClass("layerinvis",!o.getLayerVisibility(l)),u=e('<td class="layername">'+l+"</td>");t.append(s.append(c,u)),n.append('<option value="'+l+'">'+l+"</option>")}if(void 0!==r){var f=r.clone();e("td.layervis",t).append(f),e.resizeSvgIcons({"td.layervis .svg_icon":14})}e("#layerlist td.layername").mouseup(function(t){e("#layerlist tr.layer").removeClass("layersel"),e(this.parentNode).addClass("layersel"),d.setCurrentLayer(this.textContent),t.preventDefault()}).mouseover(function(){le(this.textContent)}).mouseout(function(){le()}),e("#layerlist td.layervis").click(function(){var t=e(this.parentNode).prevAll().length,n=e("#layerlist tr.layer:eq("+t+") td.layername").text(),o=e(this).hasClass("layerinvis");d.setLayerVisibility(n,o),e(this).toggleClass("layerinvis")});for(var p=5-e("#layerlist tr.layer").size();p-- >0;)t.append('<tr><td style="color:white">_</td><td/></tr>')},ce=function(t,n){te||(te=!0,X=d.getSvgString(),e("#save_output_btns").toggle(!!n),e("#tool_source_back").toggle(!n),e("#svg_source_textarea").val(X),e("#svg_source_editor").fadeIn(),e("#svg_source_textarea").focus())},ue=function(t,n){e("#path_node_panel").toggle(t),e("#tools_bottom_2,#tools_bottom_3").toggle(!t),t?(e(".tool_button_current").removeClass("tool_button_current").addClass("tool_button"),e("#tool_select").addClass("tool_button_current").removeClass("tool_button"),P("#tool_select","select_node"),Y=!1,J=!1,n.length&&(K=n[0])):setTimeout(function(){P("#tool_select","select")},1e3)},de=function(t,n){if(u.showSaveWarning=!1,n='<?xml version="1.0"?>\n'+n,svgedit.browser.isIE())ce(0,!0);else{var o=t.open("data:image/svg+xml;base64,"+h.encode64(n)),i=e.pref("save_notice_done");if("all"!==i){var a=uiStrings.notification.saveFromBrowser.replace("%s","SVG");svgedit.browser.isGecko()?-1!==n.indexOf("<defs")?(a+="\n\n"+uiStrings.notification.defsFailOnSave,e.pref("save_notice_done","all"),i="all"):e.pref("save_notice_done","part"):e.pref("save_notice_done","all"),"part"!==i&&o.alert(a)}}},fe=function(t,n){var o=n.issues,i=n.exportWindowName;i&&(j=window.open("",i)),j.location.href=n.datauri;var a=e.pref("export_notice_done");if("all"!==a){var r=uiStrings.notification.saveFromBrowser.replace("%s",n.type);if(o.length){var l="\n • ";r+="\n\n"+uiStrings.notification.noteTheseIssues+l+o.join(l)}e.pref("export_notice_done","all"),j.alert(r)}},pe=function(){window.opera&&e("<p/>").hide().appendTo("body").remove()},ge=u.toolButtonClick=function(t,n){if(e(t).hasClass("disabled"))return!1;if(e(t).parent().hasClass("tools_flyout"))return!0;var o="normal";return n||e(".tools_flyout").fadeOut(o),e("#styleoverrides").text(""),G.css("cursor","auto"),e(".tool_button_current").removeClass("tool_button_current").addClass("tool_button"),e(t).addClass("tool_button_current").removeClass("tool_button"),!0},ve=u.clickSelect=function(){ge("#tool_select")&&(d.setMode("select"),e("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}"))},he=u.setImageURL=function(t){t||(t=M),d.setImageURL(t),e("#image_url").val(t),0===t.indexOf("data:")?(e("#image_url").hide(),e("#change_image_url").hide()):(d.embedImage(t,function(n){e("#url_notice").toggle(!n),M=t}),e("#image_url").hide(),e("#change_image_url").hide())};u.promptImgURLcallback=null;var me=u.updateCanvas=function(t,n){var o=G.width(),i=G.height(),a=o,r=i,l=d.getZoom(),c=G,p=e("#svgcanvas"),g={x:c[0].scrollLeft+a/2,y:c[0].scrollTop+r/2},v=curConfig.canvas_expansion;o=Math.max(a,d.contentW*l*v),i=Math.max(r,d.contentH*l*v),o==a&&i==r?G.css("overflow","hidden"):G.css("overflow","scroll");var h=p.height()/2,m=p.width()/2;p.width(o).height(i);var _=i/2,w=o/2,y=d.updateCanvas(o,i),b=w/m,C=o/2-a/2,x=i/2-r/2;if(n)n.x+=y.x,n.y+=y.y;else{var k=g.x-m,S=w+k*b,E=g.y-h,F=_+E*b;n={x:S,y:F}}t?d.contentW>c.width()?(G[0].scrollLeft=y.x-10,G[0].scrollTop=y.y-10):(c[0].scrollLeft=C,c[0].scrollTop=x):(c[0].scrollLeft=n.x-a/2,c[0].scrollTop=n.y-r/2),curConfig.showRulers&&(s(p,l),G.scroll()),!0===f.storagePrompt||u.storagePromptClosed||e("#dialog_box").hide()},_e=function(){var t,n,o="none"==d.getColor("fill"),i="none"==d.getColor("stroke"),a=["#tool_fhpath","#tool_line"],r=["#tools_rect .tool_button","#tools_ellipse .tool_button","#tool_text","#tool_path"];if(i)for(t in a)n=a[t],e(n).hasClass("tool_button_current")&&ve(),e(n).addClass("disabled");else for(t in a)n=a[t],e(n).removeClass("disabled");if(i&&o)for(t in r)n=r[t],e(n).hasClass("tool_button_current")&&ve(),e(n).addClass("disabled");else for(t in r)n=r[t],e(n).removeClass("disabled");d.runExtensions("toolButtonStateUpdate",{nofill:o,nostroke:i}),e(".tools_flyout").each(function(){var t=e("#"+this.id+"_show"),n=!1;e(this).children().each(function(){e(this).hasClass("disabled")||(n=!0)}),t.toggleClass("disabled",!n)}),pe()},we=function(){var t,n;if(null!=K)switch(K.tagName){case"use":case"image":case"foreignObject":break;case"g":case"a":var o=null,a=K.getElementsByTagName("*");for(t=0,n=a.length;t<n;t++){var r=a[t].getAttribute("stroke-width");0===t?o=r:o!==r&&(o=null)}e("#stroke_width").val(null===o?"1":o),Z.fill.update(!0);break;default:Z.fill.update(!0),Z.stroke.update(!0);var l=K.getAttribute("stroke-width");e("#stroke_width").val(null===l||"null"===l?"1":l),e("#stroke_style").val(K.getAttribute("stroke-dasharray")||"none");var s=K.getAttribute("stroke-linejoin")||"miter";0!=e("#linejoin_"+s).length&&i(e("#linejoin_"+s)[0]),s=K.getAttribute("stroke-linecap")||"butt",0!=e("#linecap_"+s).length&&i(e("#linecap_"+s)[0])}if(null!=K){var c=100*(K.getAttribute("opacity")||1);e("#group_opacity").val(c),e("#opac_slider").slider("option","value",c),e("#elem_id").val(K.id),e("#elem_class").val(K.getAttribute("class"))}_e()},ye=function(){var t=K;null==t||t.parentNode||(t=null);var n=d.getCurrentDrawing().getCurrentLayerName(),o=d.getMode(),i="px"!==curConfig.baseUnit?curConfig.baseUnit:null,a="pathedit"==o,r=e("#cmenu_canvas li");if(e("#selected_panel, #multiselected_panel, #threemoreselected_panel, #g_panel, #rect_panel, #circle_panel,#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel, #xy_panel, #marker_panel, #htmlctrl_panel, #tool_stroke, #tool_angle, #shape_panel").hide(),$||ee||a||e("#tool_stroke").show(),null!=t){var s=t.nodeName;e("#tool_angle").show();var c=d.getRotationAngle(t);e("#angle").val(c);var f=d.getBlur(t);if(e("#blur").val(f),e("#blur_slider").slider("option","value",f),d.addedNew&&"image"===s&&0!==d.getHref(t).indexOf("data:")&&l(),a||"pathedit"==o){var v=U.getNodePoint();if(e("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button"),e("#tool_node_delete").toggleClass("disabled",!U.canDeleteNodes),P("#tool_openclose_path",U.closed_subpath?"open_path":"close_path"),v){var h=e("#seg_type");i&&(v.x=svgedit.units.convertUnit(v.x),v.y=svgedit.units.convertUnit(v.y)),e("#path_node_x").val(v.x),e("#path_node_y").val(v.y),v.type?h.val(v.type).removeAttr("disabled"):h.val(4).attr("disabled","disabled")}return}if(e("#selected_panel").show(),["line","circle","ellipse"].indexOf(s)>=0)e("#xy_panel").hide();else{var m,_;if(["g","polyline","path"].indexOf(s)>=0){var w=d.getStrokedBBox([t]);w&&(m=w.x,_=w.y)}else m=t.getAttribute("x"),_=t.getAttribute("y");if(i&&(m=svgedit.units.convertUnit(m),_=svgedit.units.convertUnit(_)),t.getAttribute("width"),t.getAttribute("heght"),m=Number.parseFloat(m),m=m.toFixed(Number.isInteger(m)?0:2),_=Number.parseFloat(_),_=_.toFixed(Number.isInteger(_)?0:2),e("#selected_x").val(m||0),e("#selected_y").val(_||0),e("#xy_panel").show(),g.indexOf(t.id.substr(0,4))>=0){var y=svgedit.utilities.getBBox(t);e("#htmlctrl_panel").show(),e("#htmlctrl_width").val(y.width||0),e("#htmlctrl_height").val(y.height||0)}}var b=-1==["image","text","path","g","use"].indexOf(s);e("#tool_topath").toggle(b),e("#tool_reorient").toggle("path"===s),e("#tool_reorient").toggleClass("disabled",0===c);var C={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:[]},x=t.tagName,k=null;"a"===x&&(k=d.getHref(t),e("#g_panel").show()),"a"===t.parentNode.tagName&&(e(t).siblings().length||(e("#a_panel").show(),k=d.getHref(t.parentNode))),e("#tool_make_link, #tool_make_link").toggle(!k),k&&e("#link_url").val(k);var S=!1;if(C[x]){var E=C[x],F=t.getAttribute("type");F&&0===F.indexOf("svg-ext")?"svg-ext-shapes-group"!==F&&(S=!0):e("#"+x+"_panel").show(),e.each(E,function(n,o){var i=t.getAttribute(o);if("px"!==curConfig.baseUnit&&t[o]){var a=t[o].baseVal.value;i=svgedit.units.convertUnit(a)}e("#"+x+"_"+o).val(i||0)});var A="g"===x&&p.indexOf(t.id.substr(0,4))>=0;if("text"==x||A){if(e("#text_panel").css("display","inline"),d.getItalic()?e("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):e("#tool_italic").removeClass("push_button_pressed").addClass("tool_button"),d.getBold()?e("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):e("#tool_bold").removeClass("push_button_pressed").addClass("tool_button"),e("#font_family").val(t.getAttribute("font-family")),e("#font_size").val(t.getAttribute("font-size")),e("#text_anchor").val(t.getAttribute("text-anchor")),A){var T=d.getExtensionFont(t);T&&(T.fontFamily&&e("#font_family").val(T.fontFamily),T.fontSize&&e("#font_size").val(T.fontSize.replace("px","")),T.textAnchor&&e("#text_anchor").val(T.textAnchor))}e("#text").val(t.textContent),d.addedNew&&!A&&setTimeout(function(){e("#text").focus().select()},100)}else"image"==x?he(d.getHref(t)):"g"===x||"use"===x?(e("#container_panel").show(),d.getTitle()):"line"===x&&e("#marker_panel").show()}r[("g"===x?"en":"dis")+"ableContextMenuItems"]("#ungroup"),r[("g"!==x&&Y?"en":"dis")+"ableContextMenuItems"]("#group"),S&&r.disableContextMenuItems("#ungroup"),"svg-ext-shapes-group"===t.getAttribute("type")&&e("#g_panel").show()}else Y?(e("#multiselected_panel").show(),r.enableContextMenuItems("#group").disableContextMenuItems("#ungroup"),J&&e("#threemoreselected_panel").show()):r.disableContextMenuItems("#interactivity,#editBindOfTags,#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");!$&&!ee||Y||(r.disableContextMenuItems("#ungroup"),e("#g_panel").hide()),e("#tool_undo").toggleClass("disabled",0===R.getUndoStackSize()),e("#tool_redo").toggleClass("disabled",0===R.getRedoStackSize()),d.addedNew=!1,t&&!a||Y?(e("#selLayerNames").removeAttr("disabled").val(n),z.enableContextMenuItems("#delete,#deselect,#cut,#copy,#move_front,#move_up,#move_down,#move_back")):e("#selLayerNames").attr("disabled","disabled"),r.disableContextMenuItems("#interactivity,#editBindOfTags"),t&&!Y&&(F=t.getAttribute("type"),(F&&F.startsWith("svg-ext-")||u.baseSvgTags.indexOf(t.tagName)>-1)&&r.enableContextMenuItems("#interactivity,#editBindOfTags"))},be=function(){if(!L){var t="#workarea.wireframe #svgcontent * { stroke-width: "+1/d.getZoom()+"px; }";e("#wireframe_rules").text(G.hasClass("wireframe")?t:"")}},Ce=function(t){t=t||d.getDocumentTitle();var n=ae+(t?": "+t:"");e("title:first").text(n)},xe=function(e,t){u.onGaugeAdded&&u.onGaugeAdded(t)},ke=function(e,t){u.onGaugeResized&&u.onGaugeResized(t)},Se=function(e,t){u.onGaugeCopyPaste&&u.onGaugeCopyPaste(t)},Ee=function(t,n){var o=d.getMode();"select"===o&&Q();var i="pathedit"==o;K=1===n.length||null==n[1]?n[0]:null,Y=n.length>=2&&null!=n[1],J=n.length>=3&&null!=n[2],$=!1,ee=!1;for(var a=0;a<n.length;a++)n[a]&&n[a].id&&(0===n[a].id.indexOf("HX")?$=!0:0===n[a].id.indexOf("PIE")&&(ee=!0));null!=K&&(i||ee||we()),ue(i,n),ye(),d.runExtensions("selectedChanged",{elems:n,selectedElement:K,multiselected:Y}),ee&&e("#marker_panel").hide();var r=[];if(Y){for(a=0;a<n.length;a++)n[a]&&r.push({id:n[a].id,type:n[a].getAttribute("type")});u.onSelectedElement(r)}else K?(r.push({id:K.id,type:K.getAttribute("type")}),u.onSelectedElement(r)):u.onSelectedElement(null)},Fe=function(t,n){var o=d.getMode(),i=n[0];if(i){if(Y=n.length>=2&&null!=n[1],J=n.length>=3&&null!=n[2],!Y)switch(o){case"rotate":var a=d.getRotationAngle(i);e("#angle").val(a),e("#tool_reorient").toggleClass("disabled",0===a)}d.runExtensions("elementTransition",{elems:n})}},Pe=function(e,t){var n,o=d.getMode();for("select"===o&&Q(),n=0;n<t.length;++n){var i=t[n];i&&"svg"===i.tagName?(se(),me()):i&&K&&null==K.parentNode&&(K=i)}u.showSaveWarning=!0,ye(),K&&"select"===o&&(Z.fill.update(),Z.stroke.update()),d.runExtensions("elementChanged",{elems:t})},Ae=function(){be()},Te=d.zoomChanged=function(t,n,o){var i=0,a=G,r=d.setBBoxZoom(n,a.width()-i,a.height()-i);if(r){var l=r.zoom,s=r.bbox;l<.001?D({value:.1}):(e("#zoom").val((100*l).toFixed(1)),o?me():me(!1,{x:s.x*l+s.width*l/2,y:s.y*l+s.height*l/2}),"zoom"==d.getMode()&&s.width&&Q(),Ae())}},Le=d.myZoomed=function(t,n){const o=0;w_area=G;var i=d.setBBoxZoom(n.bbox,w_area.width()-o,w_area.height()-o);if(i){var a=i.zoom;a<.001?D({value:.1}):(e("#zoom").val((100*a).toFixed(1)),n.center?me():me(!1,n.bbox),Ae())}};D=function(e){var t=e.value/100;if(t<.001)e.value=.1;else{var n=d.getZoom(),o=G;Te(window,{width:0,height:0,x:(o[0].scrollLeft+o.width()/2)/n,y:(o[0].scrollTop+o.height()/2)/n,zoom:t},!0)}},e("#cur_context_panel").delegate("a","click",function(){var t=e(this);return t.attr("data-root")?d.leaveContext():d.setContext(t.text()),d.clearSelection(),!1});var De=function(t,n){var o="";if(n){var i="";o='<a href="#" data-root="y">'+d.getCurrentDrawing().getCurrentLayerName()+"</a>",e(n).parentsUntil("#svgcontent > g").andSelf().each(function(){this.id&&(i+=" > "+this.id,o+=this!==n?' > <a href="#">'+this.id+"</a>":" > "+this.id)}),ie=i}else ie=null;e("#cur_context_panel").toggle(!!n).html(o),Ce()},Ie=function(){Z.fill.prep(),Z.stroke.prep()},Ne={},Be=function(){e(".tools_flyout").each(function(){var t=e("#"+this.id+"_show");if(!t.data("isLibrary")){var n=[];e(this).children().each(function(){n.push(this.title)}),t[0]&&(t[0].title=n.join(" / "))}})},Oe=function(){e(".tools_flyout").each(function(){var t=e("#"+this.id+"_show"),n=t.offset(),o=t.outerWidth();n&&e(this).css({left:(n.left+o)*u.tool_scale,top:n.top})})},Ue=function(t){e.each(t,function(n,o){var i,a=e(n).children(),r=n+"_show",l=e(r),s=!1;a.addClass("tool_button").unbind("click mousedown mouseup").each(function(n){var i=o[n];Ne[i.sel]=i.fn,i.isDefault&&(s=n);var a=function(n){var o,a=i;if("keydown"===n.type){var s=e(a.parent+"_show").hasClass("tool_button_current"),c=e(a.parent+"_show").attr("data-curopt");e.each(t[i.parent],function(e,o){o.sel==c&&(a=n.shiftKey&&s?t[i.parent][e+1]||t[i.parent][0]:o)})}if(e(this).hasClass("disabled"))return!1;ge(r)&&a.fn(),o=a.icon?e.getSvgIcon(a.icon,!0):e(a.sel).children().eq(0).clone(),o[0].setAttribute("width",l.width()),o[0].setAttribute("height",l.height()),l.children(":not(.flyout_arrow_horiz)").remove(),l.append(o).attr("data-curopt",a.sel)};e(this).mouseup(a),i.key&&e(document).bind("keydown",i.key[0]+" shift+"+i.key[0],a)}),s?l.attr("data-curopt",o[s].sel):l.attr("data-curopt")||l.attr("data-curopt",o[0].sel);var c=e(r).position();l.mousedown(function(t){if(l.hasClass("disabled"))return!1;var o=e(n),a=c.left+34,r=-1*o.width(),s=o.data("shown_popop")?200:0;i=setTimeout(function(){l.data("isLibrary")?o.css("left",a).show():o.css("left",r).show().animate({left:a},150),o.data("shown_popop",!0)},s),t.preventDefault()}).mouseup(function(t){clearTimeout(i);var n=e(this).attr("data-curopt");l.data("isLibrary")&&e(r.replace("_show","")).is(":visible")?ge(r,!0):ge(r)&&Ne[n]&&Ne[n]()})}),Be(),Oe()},Re=function(t,n){var o=e("<div>",{class:"tools_flyout",id:t}).appendTo("#svg_editor").append(n);return o},Me=function(){var e,t=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,n=document.getElementsByTagName("script")[0];for(e in n.style)if(t.test(e))return e.match(t)[0];return"WebkitOpacity"in n.style?"Webkit":"KhtmlOpacity"in n.style?"Khtml":""}(),Ge=function(t,n){var o=["top","left","bottom","right"];t.each(function(){var t,i=e(this),a=i.outerWidth()*(n-1),r=i.outerHeight()*(n-1);for(t=0;t<4;t++){var l=o[t],s=i.data("orig_margin-"+l);null==s&&(s=parseInt(i.css("margin-"+l),10),i.data("orig_margin-"+l,s));var c=s*n;"right"===l?c+=a:"bottom"===l&&(c+=r),i.css("margin-"+l,c)}})},ze=u.setIconSize=function(t){var n="#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",o=e(n),i=1;if("number"==typeof t)i=t;else{var a={s:.75,m:1,l:1.25,xl:1.5};i=a[t]}u.tool_scale=i,Oe();var r=o.parents(":hidden")
22
- ;r.css("visibility","hidden").show(),Ge(o,i),r.css("visibility","visible").hide(),e.pref("iconsize",t),e("#iconsize").val(t);var l={"#tools_top":{left:50+e("#main_button").width(),height:72},"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}},s=e("#tool_size_rules");if(s.length?s.empty():s=e('<style id="tool_size_rules"></style>').appendTo("head"),"m"!==t){var c="";e.each(l,function(n,o){n="#svg_editor "+n.replace(/,/g,", #svg_editor"),c+=n+"{",e.each(o,function(e,n){var o;"number"==typeof n?o=n*i+"px":(n[t]||n.all)&&(o=n[t]||n.all),c+=e+":"+o+";"}),c+="}"});var d="-"+Me.toLowerCase()+"-";c+=n+"{"+d+"transform: scale("+i+");} #svg_editor div.toolset .toolset {"+d+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+d+"transform: scale("+1/i+");}",s.text(c)}Oe()},je=function(t,n,o,i){var a=e(t);n=e(n);var r=!1,l=i.dropUp;l&&e(t).addClass("dropup"),n.find("li").bind("mouseup",function(){i.seticon&&(P("#cur_"+a[0].id,e(this).children()),e(this).addClass("current").siblings().removeClass("current")),o.apply(this,arguments)}),e(window).mouseup(function(e){r||(a.removeClass("down"),n.hide(),n.css({top:0,left:0})),r=!1}),a.bind("mousedown",function(){var e=a.offset();l?(e.top-=n.height(),e.left+=8):e.top+=a.height(),n.offset(e),a.hasClass("down")?(n.hide(),n.css({top:0,left:0})):(n.show(),r=!0),a.toggleClass("down")}).hover(function(){r=!0}).mouseout(function(){r=!1}),i.multiclick&&n.mousedown(function(){r=!0})},He=[],We=function(t,n){if(n){var o=!1,i=!0;if(n.langReady)if(u.langChanged){var a=e.pref("lang");n.langReady({lang:a,uiStrings:uiStrings})}else He.push(n);var r=function(){n.callback&&!o&&i&&(o=!0,n.callback())},l=[];n.context_tools&&e.each(n.context_tools,function(t,n){var o,i=n.container_id?' id="'+n.container_id+'"':"",a=e("#"+n.panel);switch(a.length||(a=e("<div>",{id:n.panel}).appendTo("#tools_top")),n.type){case"tool_button":o='<div class="tool_button">'+n.id+"</div>";var r=e(o).appendTo(a);n.events&&e.each(n.events,function(t,n){e(r).bind(t,n)});break;case"select":o="<label"+i+'><select id="'+n.id+'">',e.each(n.options,function(e,t){var i=e==n.defval?" selected":"";o+='<option value="'+e+'"'+i+">"+t+"</option>"}),o+="</select></label>";var s=e(o).appendTo(a).find("select");e.each(n.events,function(t,n){e(s).bind(t,n)});break;case"button-select":o='<div id="'+n.id+'" class="dropdown toolset" title="'+n.title+'"><div id="cur_'+n.id+'" class="icon_label"></div><button></button></div>';var c=e('<ul id="'+n.id+'_opts"></ul>').appendTo("#option_lists");n.colnum&&c.addClass("optcols"+n.colnum),e(o).appendTo(a).children(),l.push({elem:"#"+n.id,list:"#"+n.id+"_opts",title:n.title,callback:n.events.change,cur:"#cur_"+n.id});break;case"input":o="<label"+i+'><span id="'+n.id+'_label">'+n.label+':</span><input id="'+n.id+'" title="'+n.title+'" size="'+(n.size||"4")+'" value="'+(n.defval||"")+'" type="text"/></label>';var u=e(o).appendTo(a).find("input");n.spindata&&u.SpinButton(n.spindata),n.events&&e.each(n.events,function(e,t){u.bind(e,t)})}}),n.mySetMarker&&(u.setMarker=n.mySetMarker),r()}},Ve=function(t,n,o){var i={alpha:n};if(0===t.indexOf("url(#")){var a=d.getRefElem(t);a=a?a.cloneNode(!0):e("#"+o+"_color defs *")[0],i[a.tagName]=a}else 0===t.indexOf("#")?i.solidColor=t.substr(1):i.solidColor="none";return new e.jGraduate.Paint(i)};e("#text").focus(function(){}),e("#text").blur(function(){}),d.bind("onGaugeAdded",xe),d.bind("onGaugeResized",ke),d.bind("onGaugeCopyPaste",Se),d.bind("selected",Ee),d.bind("transition",Fe),d.bind("changed",Pe),d.bind("saved",de),d.bind("exported",fe),d.bind("exportedPDF",function(e,t){var n=t.exportWindowName;n&&(j=window.open("",n)),j.location.href=t.dataurlstring}),d.bind("zoomed",Te),d.bind("myZoomed",Le),d.bind("contextset",De),d.bind("extension_added",We),d.textActions.setInputElem(e("#text")[0]);var Xe='<div class="palette_item" style="background-color:#FFF;color:red;font-size:20px;line-height: 15px;text-align:center;" data-rgb="none">X</div>';e.each(B,function(e,t){Xe+='<div class="palette_item" style="background-color: '+t+';" data-rgb="'+t+'"></div>'}),e("#palette").append(Xe);var Ze=["#FFF","#888","#000"];Xe="",e.each(Ze,function(){Xe+='<div class="color_block" style="background-color:'+this+';"></div>'}),e("#bg_blocks").append(Xe);var qe=e("#bg_blocks div"),Qe="cur_background";qe.each(function(){var t=e(this);t.click(function(){qe.removeClass(Qe),e(this).addClass(Qe)})}),r(e.pref("bkgd_color"),e.pref("bkgd_url")),e("#image_save_opts input").val([e.pref("img_save")]);var Ke=function(e){d.setRectRadius(e.value)},Ye=function(e){d.setFontSize(e.value)},Je=function(e){var t=e.value;0==t&&K&&["line","polyline"].indexOf(K.nodeName)>=0&&(t=e.value=1),d.setStrokeWidth(t)},$e=function(t){d.setRotationAngle(t.value),e("#tool_reorient").toggleClass("disabled",0===parseInt(t.value,10))},et=function(t,n){null==n&&(n=t.value),e("#group_opacity").val(n),t&&t.handle||e("#opac_slider").slider("option","value",n),d.setOpacity(n/100)},tt=function(t,n,o){null==n&&(n=t.value),e("#blur").val(n);var i=!1;t&&t.handle||(e("#blur_slider").slider("option","value",n),i=!0),o?d.setBlurNoUndo(n):d.setBlur(n,i)};e("#stroke_style").change(function(){d.setStrokeAttr("stroke-dasharray",e(this).val()),pe()}),e("#stroke_linejoin").change(function(){d.setStrokeAttr("stroke-linejoin",e(this).val()),pe()}),e("select").change(function(){e(this).blur()});var nt=!1;e("#selLayerNames").change(function(){var t=this.options[this.selectedIndex].value,n=uiStrings.notification.QmoveElemsToLayer.replace("%s",t),o=function(e){e&&(nt=!0,d.moveSelectedToLayer(t),d.clearSelection(),se())};t&&(nt?o(!0):e.confirm(n,o))}),e("#font_family").change(function(){d.setFontFamily(this.value)}),e("#seg_type").change(function(){d.setSegType(e(this).val())}),e("#text").keyup(function(){d.setTextContent(this.value)}),e("#image_url").change(function(){he(this.value)}),e("#link_url").change(function(){this.value.length?d.setLinkURL(this.value):d.removeHyperlink()}),e("#g_title").change(function(){d.setGroupTitle(this.value)}),e(".attr_changer").change(function(){var t=this.getAttribute("data-attr"),n=this.value,o=svgedit.units.isValidUnit(t,n,K);if(!o)return e.alert(uiStrings.notification.invalidAttrValGiven),this.value=K.getAttribute(t),!1;if("id"!==t&&"class"!==t)if(isNaN(n))n=d.convertToNum(t,n);else if("px"!==curConfig.baseUnit){var i=svgedit.units.getTypeMap();(K[t]||"pathedit"===d.getMode()||"x"===t||"y"===t)&&(n*=i[curConfig.baseUnit])}if("id"===t){var a=K;d.clearSelection(),a.id=n,d.addToSelection([a],!0)}else d.changeSelectedAttribute(t,n),a=K,d.clearSelection(),d.addToSelection([a],!0);this.blur()}),e("#palette").mouseover(function(){var t=e('<input type="hidden">');e(this).append(t),t.focus().remove()}),e(".palette_item").mousedown(function(t){var n,o=t.shiftKey||2===t.button?"stroke":"fill",i=e(this).data("rgb");"none"===i||"transparent"===i||"initial"===i?(i="none",n=new e.jGraduate.Paint):n=new e.jGraduate.Paint({alpha:100,solidColor:i.substr(1)}),Z[o].setPaint(n),d.setColor(o,i),"none"!==i&&1!==d.getPaintOpacity(o)&&d.setPaintOpacity(o,1),u.changeColor&&u.changeColor(o,i),_e()}).bind("contextmenu",function(e){e.preventDefault()}),e("#toggle_stroke_tools").on("click",function(){e("#tools_bottom").toggleClass("expanded")}),function(){var t=null,n=null,o=G[0],i=!1,a=!1;e("#svgcanvas").bind("mousemove mouseup",function(e){if(!1!==i)return o.scrollLeft-=e.clientX-t,o.scrollTop-=e.clientY-n,t=e.clientX,n=e.clientY,"mouseup"===e.type&&(i=!1),!1}).mousedown(function(e){if(1===e.button||!0===a)return i=!0,t=e.clientX,n=e.clientY,!1}),e(window).mouseup(function(){i=!1}),e(document).bind("keydown","space",function(e){d.spaceKey=a=!0,e.preventDefault()}).bind("keyup","space",function(e){e.preventDefault(),d.spaceKey=a=!1}).bind("keydown","shift",function(e){"zoom"===d.getMode()&&G.css("cursor",W)}).bind("keyup","shift",function(e){"zoom"===d.getMode()&&G.css("cursor",H)}),u.setPanning=function(e){d.spaceKey=a=e}}(),function(){var t=e("#main_icon"),n=e("#main_icon span"),o=e("#main_menu"),i=!1,a=0,r=!0,l=!1;e(window).mouseup(function(n){i||(t.removeClass("buttondown"),"INPUT"!=n.target.tagName?o.fadeOut(200):l||(l=!0,e(n.target).click(function(){o.css("margin-left","-9999px").show()}))),i=!1}).mousedown(function(t){var n=e(t.target).closest("div.tools_flyout, .contextMenu").length;n||e(".tools_flyout:visible,.contextMenu").fadeOut(250)}),n.bind("mousedown",function(){t.hasClass("buttondown")?o.fadeOut(200):(o.css("margin-left",0).show(),a||(a=o.height()),o.css("height",0).animate({height:a},200),i=!0),t.toggleClass("buttondown buttonup")}).hover(function(){i=!0}).mouseout(function(){i=!1});var s=e("#main_menu li");s.mouseover(function(){r="rgba(0, 0, 0, 0)"==e(this).css("background-color"),s.unbind("mouseover"),r&&s.mouseover(function(){this.style.backgroundColor="#FFC"}).mouseout(function(){return this.style.backgroundColor="transparent",!0})})}(),u.addDropDown=function(t,n,o){if(0!=e(t).length){var i=e(t).find("button"),a=e(t).find("ul").attr("id",e(t)[0].id+"-list"),r=!1;o?e(t).addClass("dropup"):e("#option_lists").append(a),a.find("li").bind("mouseup",n),e(window).mouseup(function(e){r||(i.removeClass("down"),a.hide()),r=!1}),i.bind("mousedown",function(){if(i.hasClass("down"))a.hide();else{if(!o){var n=e(t).position();a.css({top:n.top+24,left:n.left-10})}a.show(),r=!0}i.toggleClass("down")}).hover(function(){r=!0}).mouseout(function(){r=!1})}},u.addDropDown("#font_family_dropdown",function(){e("#font_family").val(e(this).text()).change()}),u.addDropDown("#opacity_dropdown",function(){if(!e(this).find("div").length){var t=parseInt(e(this).text().split("%")[0],10);et(!1,t)}},!0),e("#opac_slider").slider({start:function(){e("#opacity_dropdown li:not(.special)").hide()},stop:function(){e("#opacity_dropdown li").show(),e(window).mouseup()},slide:function(e,t){et(t)}}),u.addDropDown("#blur_dropdown",e.noop);var ot,it,at=!1;e("#blur_slider").slider({max:10,step:.1,stop:function(t,n){at=!1,tt(n),e("#blur_dropdown li").show(),e(window).mouseup()},start:function(){at=!0},slide:function(e,t){tt(t,null,at)}}),u.addDropDown("#zoom_dropdown",function(){var t=e(this),n=t.data("val");n?Te(window,n):D({value:parseFloat(t.text())})},!0),je("#stroke_linecap","#linecap_opts",function(){i(this,!0)},{dropUp:!0}),je("#stroke_linejoin","#linejoin_opts",function(){i(this,!0)},{dropUp:!0}),je("#tool_position","#position_opts",function(){var e=this.id.replace("tool_pos","").charAt(0);d.alignSelectedElements(e,"page")},{multiclick:!0}),it=function(){e(ot).blur()},e("#svg_editor").find("button, select, input:not(#text)").focus(function(){ot=this,V="toolbars",G.mousedown(it)}).blur(function(){V="canvas",G.unbind("mousedown",it),"textedit"==d.getMode()&&e("#text").focus()});var rt=function(){ge("#tool_fhpath")&&d.setMode("fhpath")},lt=function(){ge("#tool_line")&&d.setMode("line")},st=function(){ge("#tool_square")&&d.setMode("square")},ct=function(){ge("#tool_rect")&&d.setMode("rect")},ut=function(){ge("#tool_fhrect")&&d.setMode("fhrect")},dt=function(){ge("#tool_circle")&&d.setMode("circle")},ft=function(){ge("#tool_ellipse")&&d.setMode("ellipse")},pt=function(){ge("#tool_fhellipse")&&d.setMode("fhellipse")},gt=function(){ge("#tool_image")&&d.setMode("image")},vt=function(){ge("#tool_zoom")&&(d.setMode("zoom"),G.css("cursor",H))},ht=function(t){var n=d.getResolution();t=t?n.zoom*t:1,e("#zoom").val(100*t),d.setZoom(t),Ae(),me(!0)},mt=function(){ge("#tool_zoom")&&(ht(),Q())},_t=function(){ge("#tool_text")&&d.setMode("text")},wt=function(){ge("#tool_path")&&d.setMode("path")};u.clickExtension=function(e){d.clickExtension(e)},u.clickZoom=function(){d.setMode("zoom"),G.css("cursor",H)},u.clickToSetMode=function(e){d.setMode(e)},u.getSvgString=function(){return u.showSaveWarning=!1,d.getSvgString()},u.getSelectedElements=function(){return d.getSelectedElems()},u.setSvgString=function(e){return d.setSvgString(e)},u.enableGridSnapping=function(e){curConfig.gridSnapping=e},u.setDocProperty=function(e,t,n,o){return!("fit"!=t&&!svgedit.units.isValidUnit("width",t))&&!("fit"!=n&&!svgedit.units.isValidUnit("height",n))&&!!d.setResolution(t,n)&&(o||(o="#ffffff"),!(o&&!d.setBackground(o))&&void me())},u.alignSelectedElements=function(e){d.alignSelectedElements(e,"page")},u.setColor=function(e,t,n){var o={alpha:t,solidColor:e,type:"solidColor"};Z[n].setPaint(o),d.setPaint(n,o)},u.setStrokeOption=function(e){i(e,!0)},u.setFilterShadow=function(e){d.setFilterShadow(e)},u.setFontFamily=function(e){d.setFontFamily(e)},u.setTextAlign=function(e){d.setTextAlign(e)},u.clickClearAll=function(){var e=curConfig.dimensions;Q(),d.clear(),d.setResolution(e[0],e[1]),me(!0),ht(),se(),ye(),Ie(),d.runExtensions("onNewDocument")},u.clearSelection=function(){d.clearSelection()},u.selectOnly=function(e,t){d.selectOnly(e,t)},u.setMarker=function(e,t){},u.setSvgImageToAdd=function(e){d.setGoodSvgImageContent(e)},u.setUrlImageToAdd=function(e){console.log("url",e),d.setGoodImage(e),u.promptImgURLcallback=e},u.getShapes=function(){return u.shapesGrps},u.runExtension=function(e,t,...n){return d.runExtension(e,t,n)},u.makeHyperlink=function(e){e&&d.makeHyperlink(e)},u.lockSelection=function(e){d.lockSelection(e)},u.renameSvgExtensionId=function(e){let t=e.id.substring(0,e.id.indexOf("_"));var n=d.getNextId().replace("svg_",t+"_");return e.content=e.content.split(e.id).join(n),n},u.renameAllSvgExtensionId=function(t,n){var o={content:t,id:""};return e.each(u.currentExtensionsPrefixIdType,function(e,i){for(var a='id=\\"'+i,r=o.content.indexOf(a);r>0;){idend=o.content.indexOf('\\"',r+a.length),o.id=o.content.substring(r,idend);var l=o.id.replace('id=\\"',"");if(-1===n.indexOf(l)){var s=u.renameSvgExtensionId(o);n.push(s.replace('id=\\"',""))}r=t.indexOf(a,r+1)}}),t=o.content,t},u.resetZoom=function(){D({value:100})},u.refreshCanvas=function(){me(!0)},u.resetUndoStack=function(){d.undoMgr.resetUndoStack()};var yt=function(){if(null!=K||Y){var e=d.deleteSelectedElements();null!=a&&a(e)}},bt=function(){(null!=K||Y)&&d.cutSelectedElements()},Ct=function(){(null!=K||Y)&&d.copySelectedElements()},xt=function(){var e=d.getZoom(),t=(G[0].scrollLeft+G.width()/2)/e-d.contentW,n=(G[0].scrollTop+G.height()/2)/e-d.contentH;d.pasteElements("point",t,n)},kt=function(){null!=K&&d.moveToTopSelectedElement()},St=function(){null!=K&&d.moveToBottomSelectedElement()},Et=function(e){null!=K&&d.moveUpDownSelected(e)},Ft=function(){null!=K&&d.convertToPath()},Pt=function(){null!=K&&U.reorient()},At=function(e,t){if(null!=K||Y){if(curConfig.gridSnapping){var n=d.getZoom()*curConfig.snappingStep;e*=n,t*=n}d.moveSelectedElements(e,t)}},Tt=function(){e("#tool_node_link").toggleClass("push_button_pressed tool_button");var t=e("#tool_node_link").hasClass("push_button_pressed");U.linkControlPoints(t)},Lt=function(){U.getNodePoint()&&U.clonePathNode()},Dt=function(){U.getNodePoint()&&U.deletePathNode()},It=function(){var t=e("#tool_add_subpath"),n=!t.hasClass("push_button_pressed");t.toggleClass("push_button_pressed tool_button"),U.addSubPath(n)},Nt=function(){U.opencloseSubPath()},Bt=function(){d.cycleElement(1)},Ot=function(){d.cycleElement(0)},Ut=function(t,n){if(null!=K&&!Y){t||(n*=-1);var o=parseFloat(e("#angle").val())+n;d.setRotationAngle(o),ye()}};clickClear=function(){var t=curConfig.dimensions;e.confirm(uiStrings.notification.QwantToClear,function(e){e&&(Q(),d.clear(),d.setResolution(t[0],t[1]),me(!0),ht(),se(),ye(),Ie(),d.runExtensions("onNewDocument"))})};var Rt=function(){return d.setBold(!d.getBold()),ye(),!1},Mt=function(){return d.setItalic(!d.getItalic()),ye(),!1},Gt=function(){var t={images:e.pref("img_save"),round_digits:6};d.save(t)},zt=function(){e.select("Select an image type for export: ",["PNG","JPEG","BMP","WEBP","PDF"],function(t){function n(){var e=uiStrings.notification.loadingImage;"new"===curConfig.exportWindowType&&u.exportWindowCt++,o=curConfig.canvasName+u.exportWindowCt,j=window.open("data:text/html;charset=utf-8,"+encodeURIComponent("<title>"+e+"</title><h1>"+e+"</h1>"),o)}var o;if(t)if("PDF"===t)customExportPDF||n(),d.exportPDF(o);else{customExportImage||n();var i=parseInt(e("#image-slider").val(),10)/100;d.rasterExport(t,i,o)}},function(){var t=e(this);"JPEG"===t.val()||"WEBP"===t.val()?e("#image-slider").length||e('<div><label>Quality: <input id="image-slider" type="range" min="1" max="100" value="92" /></label></div>').appendTo(t.parent()):e("#image-slider").parent().remove()})},jt=function(){d.open()},Ht=function(){},Wt=function(){R.getUndoStackSize()>0&&(R.undo(),se())},Vt=function(){R.getRedoStackSize()>0&&(R.redo(),se())},Xt=function(){Y?d.groupSelectedElements():K&&d.ungroupSelectedElement(),u.onGroupChanged&&u.onGroupChanged(K)},Zt=function(){d.copySelectedElements(),d.pasteElements("point",20,20)},qt=function(){var t=this.id.replace("tool_align","").charAt(0);d.alignSelectedElements(t,e("#align_relative_to").val())},Qt=function(){var e=this.id.replace("tool_divide","").charAt(0);d.divideSelectedElements(e)},Kt=function(){if(e("#tool_wireframe").toggleClass("push_button_pressed tool_button"),G.toggleClass("wireframe"),!L){var t=e("#wireframe_rules");t.length?t.empty():t=e('<style id="wireframe_rules"></style>').appendTo("head"),be()}};e("#svg_docprops_container, #svg_prefs_container").draggable({cancel:"button,fieldset",containment:"window"});var Yt,Jt,$t,en=function(){if(!ne){ne=!0,e("#image_save_opts input").val([e.pref("img_save")]);var t=d.getResolution();"px"!==curConfig.baseUnit&&(t.w=svgedit.units.convertUnit(t.w)+curConfig.baseUnit,t.h=svgedit.units.convertUnit(t.h)+curConfig.baseUnit),e("#canvas_width").val(t.w),e("#canvas_height").val(t.h),e("#canvas_title").val(d.getDocumentTitle()),e("#svg_docprops").show()}},tn=function(){if(!oe){oe=!0,e("#main_menu").hide();var t=e("#bg_blocks div"),n="cur_background",o=curPrefs.bkgd_color,i=e.pref("bkgd_url");t.each(function(){var t=e(this),i=t.css("background-color")==o;t.toggleClass(n,i),i&&e("#canvas_bg_url").removeClass(n)}),o||t.eq(0).addClass(n),i&&e("#canvas_bg_url").val(i),e("#grid_snapping_on").prop("checked",curConfig.gridSnapping),e("#grid_snapping_step").attr("value",curConfig.snappingStep),e("#grid_color").attr("value",curConfig.gridColor),e("#svg_prefs").show()}},nn=function(){e("#svg_source_editor").hide(),te=!1,e("#svg_source_textarea").blur()},on=function(){if(te){var t=function(){d.clearSelection(),nn(),ht(),se(),Ce(),Ie()};d.setSvgString(e("#svg_source_textarea").val())?t():e.confirm(uiStrings.notification.QerrorsRevertToSource,function(e){if(!e)return!1;t()}),Q()}},an=function(){e("#svg_docprops").hide(),e("#canvas_width,#canvas_height").removeAttr("disabled"),e("#resolution")[0].selectedIndex=0,e("#image_save_opts input").val([e.pref("img_save")]),ne=!1},rn=function(){e("#svg_prefs").hide(),oe=!1},ln=function(){var t=e("#canvas_title").val();Ce(t),d.setDocumentTitle(t);var n=e("#canvas_width"),o=n.val(),i=e("#canvas_height"),a=i.val();return"fit"==o||svgedit.units.isValidUnit("width",o)?(n.parent().removeClass("error"),"fit"==a||svgedit.units.isValidUnit("height",a)?(i.parent().removeClass("error"),d.setResolution(o,a)?(e.pref("img_save",e("#image_save_opts :checked").val()),me(),void an()):(e.alert(uiStrings.notification.noContentToFitTo),!1)):(e.alert(uiStrings.notification.invalidAttrValGiven),i.parent().addClass("error"),!1)):(e.alert(uiStrings.notification.invalidAttrValGiven),n.parent().addClass("error"),!1)},sn=u.savePreferences=function(){var t=e("#bg_blocks div.cur_background").css("background-color")||"#FFF";r(t,e("#canvas_bg_url").val());var n=e("#lang_select").val();n!==e.pref("lang")&&u.putLocale(n,F),ze(e("#iconsize").val()),curConfig.gridSnapping=e("#grid_snapping_on")[0].checked,curConfig.snappingStep=e("#grid_snapping_step").val(),curConfig.gridColor=e("#grid_color").val(),curConfig.showRulers=e("#show_rulers")[0].checked,e("#rulers").toggle(curConfig.showRulers),curConfig.showRulers&&s(),curConfig.baseUnit=e("#base_unit").val(),d.setConfig(curConfig),me(),rn()},cn=e.noop,un=function(){e("#dialog_box").hide(),te||ne||oe?(te?X!==e("#svg_source_textarea").val()?e.confirm(uiStrings.notification.QignoreSourceChanges,function(e){e&&nn()}):nn():ne?an():oe&&rn(),cn()):ie&&d.leaveContext()},dn={width:e(window).width(),height:e(window).height()};if(svgedit.browser.isIE()&&(cn=function(){0===G[0].scrollLeft&&0===G[0].scrollTop&&(G[0].scrollLeft=N.left,G[0].scrollTop=N.top)},N={left:G[0].scrollLeft,top:G[0].scrollTop},e(window).resize(cn),u.ready(function(){setTimeout(function(){cn()},500)}),G.scroll(function(){N={left:G[0].scrollLeft,top:G[0].scrollTop}})),e(window).resize(function(t){e.each(dn,function(t,n){var o=e(window)[t]();G[0]["scroll"+("width"===t?"Left":"Top")]-=(o-n)/2,dn[t]=o}),Oe()}),G.scroll(function(){0!=e("#ruler_x").length&&(e("#ruler_x")[0].scrollLeft=G[0].scrollLeft),0!=e("#ruler_y").length&&(e("#ruler_y")[0].scrollTop=G[0].scrollTop)}),e("#url_notice").click(function(){e.alert(this.title)}),e("#change_image_url").click(l),Yt=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],Jt="",$t="tool_button_current",e.each(Yt,function(e,t){Jt+=(e?",":"")+"#tool_"+t}),e(Jt).mousedown(function(){e(this).addClass($t)}).bind("mousedown mouseout",function(){e(this).removeClass($t)}),e("#tool_undo, #tool_redo").mousedown(function(){e(this).hasClass("disabled")||e(this).addClass($t)}).bind("mousedown mouseout",function(){e(this).removeClass($t)}),svgedit.browser.isMac()&&!window.opera){var fn=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(q=fn.length;q--;){var pn=document.getElementById(fn[q]);if(pn){var gn=pn.title,vn=gn.indexOf("Ctrl+");pn.title=[gn.substr(0,vn),"Cmd+",gn.substr(vn+5)].join("")}}}var hn=function(t){var n="stroke_color"==t.attr("id")?"stroke":"fill",o=Z[n].paint,i="stroke"==n?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity",a=t.offset();e("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(curConfig.colorPickerCSS||{left:a.left-140,bottom:40}).jGraduate({paint:o,window:{pickerTitle:i},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(t){o=new e.jGraduate.Paint(t),Z[n].setPaint(o),d.setPaint(n,o),e("#color_picker").hide()},function(){e("#color_picker").hide()})},mn=function(t,n){var o,i,a=curConfig["fill"===n?"initFill":"initStroke"],r=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="16.5" height="16.5"\t\t\t\t\tfill="#'+a.color+'" opacity="'+a.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml"),l=r.documentElement;l=e(t)[0].appendChild(document.importNode(l,!0)),l.setAttribute("width",16.5),this.rect=l.firstChild,this.defs=l.getElementsByTagName("defs")[0],this.grad=this.defs.firstChild,this.paint=new e.jGraduate.Paint({solidColor:a.color}),this.type=n,this.setPaint=function(e,t){this.paint=e;var n="none",a=e.type,r=e.alpha/100;switch(a){case"solidColor":n="none"!=e[a]?"#"+e[a]:e[a];break;case"linearGradient":case"radialGradient":this.defs.removeChild(this.grad),this.grad=this.defs.appendChild(e[a]);var l=this.grad.id="gradbox_"+this.type;n="url(#"+l+")"}this.rect.setAttribute("fill",n),this.rect.setAttribute("opacity",r),t&&(d.setColor(this.type,o,!0),d.setPaintOpacity(this.type,i,!0))},this.update=function(e){if(K){var t,n,a=this.type;switch(K.tagName){case"use":case"image":case"foreignObject":return;case"g":case"a":var r=null,l=K.getElementsByTagName("*");for(t=0,n=l.length;t<n;t++){var s=l[t],c=s.getAttribute(a);if(0===t)r=c;else if(r!==c){r=null;break}}if(null===r)return void(o=null);o=r,i=1;break;default:i=parseFloat(K.getAttribute(a+"-opacity")),isNaN(i)&&(i=1);var u="fill"===a?"black":"none";o=K.getAttribute(a)||u}e&&(d.setColor(a,o,!0),d.setPaintOpacity(a,i,!0)),i*=100;var f=Ve(o,i,a);this.setPaint(f)}},this.prep=function(){var t=this.paint.type;switch(t){case"linearGradient":case"radialGradient":var o=new e.jGraduate.Paint({copy:this.paint});d.setPaint(n,o)}}};Z.fill=new mn("#fill_color","fill"),Z.stroke=new mn("#stroke_color","stroke"),e("#stroke_width").val(curConfig.initStroke.width),e("#group_opacity").val(100*curConfig.initOpacity);var _n=Z.fill.rect.cloneNode(!1);_n.setAttribute("style","vector-effect:non-scaling-stroke"),L="non-scaling-stroke"===_n.style.vectorEffect,_n.removeAttribute("style");var wn,yn,bn=Z.fill.rect.ownerDocument,Cn=bn.createElementNS(svgedit.NS.SVG,"feGaussianBlur");void 0===Cn.stdDeviationX&&e("#tool_blur").hide(),e(Cn).remove(),wn="-"+Me.toLowerCase()+"-zoom-",yn=wn+"in",G.css("cursor",yn),G.css("cursor")===yn&&(H=yn,W=wn+"out"),G.css("cursor","auto"),e("#fill_color, #tool_fill .icon_label").click(function(){hn(e("#fill_color")),_e()}),e("#stroke_color, #tool_stroke .icon_label").click(function(){hn(e("#stroke_color")),_e()}),e("#group_opacityLabel").click(function(){e("#opacity_dropdown button").mousedown(),e(window).mouseup()}),e("#zoomLabel").click(function(){e("#zoom_dropdown button").mousedown(),e(window).mouseup()}),e("#tool_move_top").mousedown(function(t){e("#tools_stacking").show()}),e(".layer_button").mousedown(function(){e(this).addClass("layer_buttonpressed")}).mouseout(function(){e(this).removeClass("layer_buttonpressed")}).mouseup(function(){e(this).removeClass("layer_buttonpressed")}),e(".push_button").mousedown(function(){e(this).hasClass("disabled")||e(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){e(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){e(this).removeClass("push_button_pressed").addClass("push_button")}),e("#layer_new").click(function(){var t,n=d.getCurrentDrawing().getNumLayers();do{t=uiStrings.layers.layer+" "+ ++n}while(d.getCurrentDrawing().hasLayer(t));e.prompt(uiStrings.notification.enterUniqueLayerName,t,function(t){t&&(d.getCurrentDrawing().hasLayer(t)?e.alert(uiStrings.notification.dupeLayerName):(d.createLayer(t),ye(),se()))})}),e("#layer_delete").click(_),e("#layer_up").click(function(){b(-1)}),e("#layer_down").click(function(){b(1)}),e("#layer_rename").click(function(){var t=e("#layerlist tr.layersel td.layername").text();e.prompt(uiStrings.notification.enterNewLayerName,"",function(n){n&&(t==n||d.getCurrentDrawing().hasLayer(n)?e.alert(uiStrings.notification.layerHasThatName):(d.renameCurrentLayer(n),se()))})});var xn=300,kn=150,Sn=-1,En=!1,Fn=!1,Pn=function(t){var n=e("#ruler_x");e("#sidepanels").width("+="+t),e("#layerpanel").width("+="+t),n.css("right",parseInt(n.css("right"),10)+t),G.css("right",parseInt(G.css("right"),10)+t),d.runExtensions("workareaResized")},An=function(t){if(Fn&&-1!=Sn){En=!0;var n=Sn-t.pageX,o=e("#sidepanels").width();o+n>xn?(n=xn-o,o=xn):o+n<2&&(n=2-o,o=2),0!=n&&(Sn-=n,Pn(n))}},Tn=function(t){var n=e("#sidepanels").width(),o=(n>2||t?2:kn)-n;Pn(o)};e("#sidepanel_handle").mousedown(function(t){Sn=t.pageX,e(window).mousemove(An),Fn=!1,setTimeout(function(){Fn=!0},20)}).mouseup(function(e){En||Tn(),Sn=-1,En=!1}),e(window).mouseup(function(){Sn=-1,En=!1,e("#svg_editor").unbind("mousemove",An)}),se();var Ln,Dn,In=function(){G.css("line-height",G.height()+"px")};e(window).bind("load resize",In),e("#resolution").change(function(){var t=e("#canvas_width,#canvas_height");if(this.selectedIndex)if("content"==this.value)t.val("fit").attr("disabled","disabled");else{var n=this.value.split("x");e("#canvas_width").val(n[0]),e("#canvas_height").val(n[1]),t.removeAttr("disabled")}else"fit"==e("#canvas_width").val()&&t.removeAttr("disabled").val(100)}),e("input,select").attr("autocomplete","off"),Ln=[{sel:"#tool_select",fn:ve,evt:"click",key:["V",!0]},{sel:"#tool_fhpath",fn:rt,evt:"click",key:["Q",!0]},{sel:"#tool_line",fn:lt,evt:"click",key:["L",!0]},{sel:"#tool_rect",fn:ct,evt:"mouseup",key:["R",!0],parent:"#tools_rect",icon:"rect"},{sel:"#tool_square",fn:st,evt:"mouseup",parent:"#tools_rect",icon:"square"},{sel:"#tool_fhrect",fn:ut,evt:"mouseup",parent:"#tools_rect",icon:"fh_rect"},{sel:"#tool_ellipse",fn:ft,evt:"mouseup",key:["E",!0],parent:"#tools_ellipse",icon:"ellipse"},{sel:"#tool_circle",fn:dt,evt:"mouseup",parent:"#tools_ellipse",icon:"circle"},{sel:"#tool_fhellipse",fn:pt,evt:"mouseup",parent:"#tools_ellipse",icon:"fh_ellipse"},{sel:"#tool_path",fn:wt,evt:"click",key:["P",!0]},{sel:"#tool_text",fn:_t,evt:"click",key:["T",!0]},{sel:"#tool_image",fn:gt,evt:"mouseup"},{sel:"#tool_zoom",fn:vt,evt:"mouseup",key:["Z",!0]},{sel:"#tool_clear",fn:clickClear,evt:"mouseup",key:["N",!0]},{sel:"#tool_save",fn:function(){te?on():Gt()},evt:"mouseup",key:["S",!0]},{sel:"#tool_export",fn:zt,evt:"mouseup"},{sel:"#tool_open",fn:jt,evt:"mouseup",key:["O",!0]},{sel:"#tool_import",fn:Ht,evt:"mouseup"},{sel:"#tool_source",fn:ce,evt:"click",key:["U",!0]},{sel:"#tool_wireframe",fn:Kt,evt:"click",key:["F",!0]},{sel:"#tool_source_save",fn:on,evt:"click"},{sel:"#tool_docprops_save",fn:ln,evt:"click"},{sel:"#tool_docprops",fn:en,evt:"mouseup"},{sel:"#tool_prefs_save",fn:sn,evt:"click"},{sel:"#tool_prefs_option",fn:function(){return tn(),!1},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:yt,evt:"click",key:["del/backspace",!0]},{sel:"#tool_reorient",fn:Pt,evt:"click"},{sel:"#tool_node_link",fn:Tt,evt:"click"},{sel:"#tool_node_clone",fn:Lt,evt:"click"},{sel:"#tool_node_delete",fn:Dt,evt:"click"},{sel:"#tool_openclose_path",fn:Nt,evt:"click"},{sel:"#tool_add_subpath",fn:It,evt:"click"},{sel:"#tool_move_top",fn:kt,evt:"click",key:"ctrl+shift+]"},{sel:"#tool_move_bottom",fn:St,evt:"click",key:"ctrl+shift+["},{sel:"#tool_topath",fn:Ft,evt:"click"},{sel:"#tool_undo",fn:Wt,evt:"click",key:["ctrl+Z",!0]},{sel:"#tool_redo",fn:Vt,evt:"click",key:["ctrl+Y",!0]},{sel:"#tool_clone,#tool_clone_multi",fn:Zt,evt:"click",key:["ctrl+D",!0]},{sel:"#tool_group_elements",fn:Xt,evt:"click",key:["ctrl+G",!0]},{sel:"#tool_ungroup",fn:Xt,evt:"click"},{sel:"#tool_unlink_use",fn:Xt,evt:"click"},{sel:"[id^=tool_align]",fn:qt,evt:"click"},{sel:"[id^=tool_divide]",fn:Qt,evt:"click"},{sel:"#tool_bold",fn:Rt,evt:"mousedown"},{sel:"#tool_italic",fn:Mt,evt:"mousedown"},{sel:"#sidepanel_handle",fn:Tn,key:["X"]},{sel:"#copy_save_done",fn:un,evt:"click"},{key:"ctrl+left",fn:function(){Ut(0,1)}},{key:"ctrl+right",fn:function(){Ut(1,1)}},{key:"ctrl+shift+left",fn:function(){Ut(0,5)}},{key:"ctrl+shift+right",fn:function(){Ut(1,5)}},{key:"shift+O",fn:Ot},{key:"shift+P",fn:Bt},{key:[O+"up",!0],fn:function(){ht(2)}},{key:[O+"down",!0],fn:function(){ht(.5)}},{key:[O+"]",!0],fn:function(){Et("Up")}},{key:[O+"[",!0],fn:function(){Et("Down")}},{key:["up",!0],fn:function(){At(0,-1)}},{key:["down",!0],fn:function(){At(0,1)}},{key:["left",!0],fn:function(){At(-1,0)}},{key:["right",!0],fn:function(){At(1,0)}},{key:"shift+up",fn:function(){At(0,-10)}},{key:"shift+down",fn:function(){At(0,10)}},{key:"shift+left",fn:function(){At(-10,0)}},{key:"shift+right",fn:function(){At(10,0)}},{key:O+"A",fn:function(){d.selectAllInCurrentLayer()}},{key:O+"z",fn:Wt},{key:O+"shift+z",fn:Vt},{key:O+"y",fn:Vt},{key:O+"x",fn:bt},{key:O+"c",fn:Ct},{key:O+"v",fn:xt}],Dn={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"},I={setAll:function(){var t={};e.each(Ln,function(n,o){var i;if(o.sel){if(i=e(o.sel),0==i.length)return!0;if(o.evt&&(svgedit.browser.isTouch()&&"click"===o.evt&&(o.evt="mousedown"),i[o.evt](o.fn)),o.parent&&0!=e(o.parent+"_show").length){var a=e(o.parent);a.length||(a=Re(o.parent.substr(1))),a.append(i),e.isArray(t[o.parent])||(t[o.parent]=[]),t[o.parent].push(o)}}if(o.key){var r,l=o.fn,s=!1;if(e.isArray(o.key)?(r=o.key[0],o.key.length>1&&(s=o.key[1]),o.key.length>2&&o.key[2]):r=o.key,r+="",e.each(r.split("/"),function(t,n){e(document).bind("keydown",n,function(e){return l(),s&&e.preventDefault(),!1})}),o.sel&&!o.hidekey&&i.attr("title")){var c=i.attr("title").split("[")[0]+" ("+r+")";Dn[r]=o.sel,i.parents("#main_menu").length||i.attr("title",c)}}}),Ue(t),e(".attr_changer, #image_url").bind("keydown","return",function(t){e(this).change(),
23
- t.preventDefault()}),e(window).bind("keydown","tab",function(e){"canvas"===V&&(e.preventDefault(),Bt())}).bind("keydown","shift+tab",function(e){"canvas"===V&&(e.preventDefault(),Ot())}),e("#tool_zoom").dblclick(mt)},setTitles:function(){e.each(Dn,function(t,n){var o=e(n).parents("#main_menu").length;e(n).each(function(){var n;n=o?e(this).text().split(" [")[0]:this.title.split(" [")[0];var i="";e.each(t.split("/"),function(e,t){var n=t.split("+"),o="";n.length>1&&(o=n[0]+"+",t=n[1]),i+=(e?"/":"")+o+(uiStrings["key_"+t]||t)}),o?this.lastChild.textContent=n+" ["+i+"]":this.title=n+" ["+i+"]"})})},getButtonData:function(t){var n;return e.each(Ln,function(e,o){o.sel===t&&(n=o)}),n}},I.setAll(),u.ready(function(){var t,n=curConfig.initTool,o=e("#tools_left, #svg_editor .tools_flyout"),i=o.find("#tool_"+n),a=o.find("#"+n);t=i.length?i:a.length?a:e("#tool_select"),t.click().mouseup(),curConfig.wireframe&&e("#tool_wireframe").click(),curConfig.showlayers&&Tn(),e("#rulers").toggle(!!curConfig.showRulers),curConfig.showRulers&&(e("#show_rulers")[0].checked=!0),curConfig.baseUnit&&e("#base_unit").val(curConfig.baseUnit),curConfig.gridSnapping&&(e("#grid_snapping_on")[0].checked=!0),curConfig.snappingStep&&e("#grid_snapping_step").val(curConfig.snappingStep),curConfig.gridColor&&e("#grid_color").val(curConfig.gridColor)}),e("#rect_rx").SpinButton({min:0,max:1e3,callback:Ke}),e("#stroke_width").SpinButton({min:0,max:99,smallStep:.1,callback:Je}),e("#angle").SpinButton({min:-180,max:180,step:5,callback:$e}),e("#font_size").SpinButton({min:.001,stepfunc:C,callback:Ye}),e("#group_opacity").SpinButton({min:0,max:100,step:5,callback:et}),e("#blur").SpinButton({min:0,max:10,step:.1,callback:tt}),e("#zoom").SpinButton({min:.001,max:1e4,step:50,stepfunc:x,callback:D}).val(100*d.getZoom()),e("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(e,t,n){switch(e){case"interactivity":case"editBindOfTags":break;case"delete":yt();break;case"deselect":var o=d.getMode();d.clearSelection(),d.setMode(o);break;case"cut":bt();break;case"copy":Ct();break;case"paste":d.pasteElements();break;case"paste_in_place":d.pasteElements("in_place");break;case"group":case"group_elements":d.groupSelectedElements();break;case"ungroup":d.ungroupSelectedElement();break;case"move_front":kt();break;case"move_up":Et("Up");break;case"move_down":Et("Down");break;case"move_back":St();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(e)&&svgedit.contextmenu.getCustomHandler(e).call()}d.clipBoard.length&&z.enableContextMenuItems("#paste,#paste_in_place")});var Nn=function(e,t,n){switch(e){case"dupe":w();break;case"delete":_();break;case"merge_down":y();break;case"merge_all":d.mergeAllLayers(),ye(),se()}};if(e("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},Nn),e("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:!0},Nn),e(".contextMenu li").mousedown(function(e){e.preventDefault()}),e("#cmenu_canvas li").disableContextMenu(),z.enableContextMenuItems("#delete,#deselect,#cut,#copy"),window.addEventListener("beforeunload",function(e){if(0===R.getUndoStackSize()&&(u.showSaveWarning=!1),!curConfig.no_save_warning&&u.showSaveWarning)return e.returnValue=uiStrings.notification.unsavedChanges,uiStrings.notification.unsavedChanges},!1),u.openPrep=function(t){e("#main_menu").hide(),0===R.getUndoStackSize()?t(!0):e.confirm(uiStrings.notification.QwantToOpen,t)},window.FileReader){var Bn=function(t){e.process_cancel(uiStrings.notification.loadingImage),t.stopPropagation(),t.preventDefault(),e("#workarea").removeAttr("style"),e("#main_menu").hide();var n,o="drop"==t.type?t.dataTransfer.files[0]:this.files[0];o?-1!=o.type.indexOf("image")&&(-1!=o.type.indexOf("svg")?(n=new FileReader,n.onloadend=function(t){d.importSvgString(t.target.result,!0),e("#dialog_box").hide()},n.readAsText(o)):(n=new FileReader,n.onloadend=function(t){var n=function(n,o){var i=d.addSvgElementFromJson({element:"image",attr:{x:0,y:0,width:n,height:o,id:d.getNextId(),style:"pointer-events:inherit"}});d.setHref(i,t.target.result),d.selectOnly([i]),d.alignSelectedElements("m","page"),d.alignSelectedElements("c","page"),ye(),e("#dialog_box").hide()},o=100,i=100,a=new Image;a.src=t.target.result,a.style.opacity=0,a.onload=function(){o=a.offsetWidth,i=a.offsetHeight,n(o,i)}},n.readAsDataURL(o))):e("#dialog_box").hide()};G[0].addEventListener("dragenter",k,!1),G[0].addEventListener("dragover",S,!1),G[0].addEventListener("dragleave",E,!1),G[0].addEventListener("drop",Bn,!1);var On=e('<input type="file">').change(function(){var t=this;u.openPrep(function(n){if(n&&(d.clear(),1===t.files.length)){e.process_cancel(uiStrings.notification.loadingImage);var o=new FileReader;o.onloadend=function(e){c(e.target.result),me()},o.readAsText(t.files[0])}})});e("#tool_open").show().prepend(On);var Un=e('<input type="file">').change(Bn);e("#tool_import").show().prepend(Un)}me(!0),e(function(){window.svgCanvas=d,d.ready=u.ready,d.setSpecialsIds(g,v)}),u.setLang=function(t,n){if(u.langChanged=!0,e.pref("lang",t),e("#lang_select").val(t),n){var o=e("#layerlist tr.layersel td.layername").text(),i=o==uiStrings.common.layer+" 1";if(e.extend(uiStrings,n),d.setUiStrings(n),I.setTitles(),i&&(d.renameCurrentLayer(uiStrings.common.layer+" 1"),se()),He.length)for(;He.length;){var a=He.shift();a.langReady({lang:t,uiStrings:uiStrings})}else d.runExtensions("langReady",{lang:t,uiStrings:uiStrings});d.runExtensions("langChanged",t),Be();var r={"#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"};e.each(r,function(t,n){e(n).attr("title",e(t)[0].title)}),e("#multiselected_panel div[id^=tool_align]").each(function(){e("#tool_pos"+this.id.substr(10))[0].title=this.title})}},d&&d.setColor("fill","#FFFFFF"),h.takePil()&&(A(),T(function(){u.currentExtensionsInteractivityType=d.getExtensionMember("getClassId"),u.currentExtensionsPrefixIdType=d.getExtensionMember("getPrefixId")}))},u.ready=function(e){isReady?e():callbacks.push(e)},u.runCallbacks=function(){e.each(callbacks,function(){this()}),isReady=!0},u.loadFromString=function(e){u.ready(function(){c(e)})},u.disableUI=function(e){},u.loadFromURL=function(t,n){n||(n={});var o=n.cache,i=n.callback;u.ready(function(){e.ajax({url:t,dataType:"text",cache:!!o,beforeSend:function(){e.process_cancel(uiStrings.notification.loadingImage)},success:function(e){c(e,i)},error:function(t,n,o){404!=t.status&&t.responseText?c(t.responseText,i):e.alert(uiStrings.notification.URLloadFail+": \n"+o,i)},complete:function(){e("#dialog_box").hide()}})})},u.loadFromDataURI=function(e){u.ready(function(){var t=!1,n=e.match(/^data:image\/svg\+xml;base64,/);n?t=!0:n=e.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/),n&&(n=n[0]);var o=e.slice(n.length);c(t?h.decode64(o):decodeURIComponent(o))})},u.addExtension=function(){var e=arguments;d&&(d.addExtension.apply(this,e),u&&u.extensionLoadedCallback&&u.extensionLoadedCallback(e[0],e))},u}(jQuery)}};
1
+ var mypathseg=function(){"use strict";return{initPathSeg:function(){"SVGPathSeg"in window||(window.SVGPathSeg=function(t,e,o){this.pathSegType=t,this.pathSegTypeAsLetter=e,this._owningPathSegList=o},window.SVGPathSeg.prototype.classname="SVGPathSeg",window.SVGPathSeg.PATHSEG_UNKNOWN=0,window.SVGPathSeg.PATHSEG_CLOSEPATH=1,window.SVGPathSeg.PATHSEG_MOVETO_ABS=2,window.SVGPathSeg.PATHSEG_MOVETO_REL=3,window.SVGPathSeg.PATHSEG_LINETO_ABS=4,window.SVGPathSeg.PATHSEG_LINETO_REL=5,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS=6,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL=7,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS=8,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL=9,window.SVGPathSeg.PATHSEG_ARC_ABS=10,window.SVGPathSeg.PATHSEG_ARC_REL=11,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS=12,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL=13,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS=14,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL=15,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19,window.SVGPathSeg.prototype._segmentChanged=function(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)},window.SVGPathSegClosePath=function(t){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CLOSEPATH,"z",t)},window.SVGPathSegClosePath.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegClosePath.prototype.toString=function(){return"[object SVGPathSegClosePath]"},window.SVGPathSegClosePath.prototype._asPathString=function(){return this.pathSegTypeAsLetter},window.SVGPathSegClosePath.prototype.clone=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathSegMovetoAbs=function(t,e,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_ABS,"M",t),this._x=e,this._y=o},window.SVGPathSegMovetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoAbs.prototype.toString=function(){return"[object SVGPathSegMovetoAbs]"},window.SVGPathSegMovetoAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegMovetoAbs.prototype.clone=function(){return new window.SVGPathSegMovetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegMovetoRel=function(t,e,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_REL,"m",t),this._x=e,this._y=o},window.SVGPathSegMovetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoRel.prototype.toString=function(){return"[object SVGPathSegMovetoRel]"},window.SVGPathSegMovetoRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegMovetoRel.prototype.clone=function(){return new window.SVGPathSegMovetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoAbs=function(t,e,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_ABS,"L",t),this._x=e,this._y=o},window.SVGPathSegLinetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoAbs.prototype.toString=function(){return"[object SVGPathSegLinetoAbs]"},window.SVGPathSegLinetoAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegLinetoAbs.prototype.clone=function(){return new window.SVGPathSegLinetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoRel=function(t,e,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_REL,"l",t),this._x=e,this._y=o},window.SVGPathSegLinetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoRel.prototype.toString=function(){return"[object SVGPathSegLinetoRel]"},window.SVGPathSegLinetoRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegLinetoRel.prototype.clone=function(){return new window.SVGPathSegLinetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicAbs=function(t,e,o,r,h,s,a){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,"C",t),this._x=e,this._y=o,this._x1=r,this._y1=h,this._x2=s,this._y2=a},window.SVGPathSegCurvetoCubicAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicAbs]"},window.SVGPathSegCurvetoCubicAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicAbs(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicRel=function(t,e,o,r,h,s,a){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,"c",t),this._x=e,this._y=o,this._x1=r,this._y1=h,this._x2=s,this._y2=a},window.SVGPathSegCurvetoCubicRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicRel]"},window.SVGPathSegCurvetoCubicRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicRel(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticAbs=function(t,e,o,r,h){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",t),this._x=e,this._y=o,this._x1=r,this._y1=h},window.SVGPathSegCurvetoQuadraticAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticAbs]"},window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticRel=function(t,e,o,r,h){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL,"q",t),this._x=e,this._y=o,this._x1=r,this._y1=h},window.SVGPathSegCurvetoQuadraticRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticRel]"},window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticRel(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcAbs=function(t,e,o,r,h,s,a,S){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_ABS,"A",t),this._x=e,this._y=o,this._r1=r,this._r2=h,this._angle=s,this._largeArcFlag=a,this._sweepFlag=S},window.SVGPathSegArcAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcAbs.prototype.toString=function(){return"[object SVGPathSegArcAbs]"},window.SVGPathSegArcAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y},window.SVGPathSegArcAbs.prototype.clone=function(){return new window.SVGPathSegArcAbs(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r1",{get:function(){return this._r1},set:function(t){this._r1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r2",{get:function(){return this._r2},set:function(t){this._r2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(t){this._largeArcFlag=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(t){this._sweepFlag=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcRel=function(t,e,o,r,h,s,a,S){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_REL,"a",t),this._x=e,this._y=o,this._r1=r,this._r2=h,this._angle=s,this._largeArcFlag=a,this._sweepFlag=S},window.SVGPathSegArcRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcRel.prototype.toString=function(){return"[object SVGPathSegArcRel]"},window.SVGPathSegArcRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y},window.SVGPathSegArcRel.prototype.clone=function(){return new window.SVGPathSegArcRel(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r1",{get:function(){return this._r1},set:function(t){this._r1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r2",{get:function(){return this._r2},set:function(t){this._r2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(t){this._largeArcFlag=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(t){this._sweepFlag=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalAbs=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS,"H",t),this._x=e},window.SVGPathSegLinetoHorizontalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalAbs]"},window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x},window.SVGPathSegLinetoHorizontalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalAbs(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalRel=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL,"h",t),this._x=e},window.SVGPathSegLinetoHorizontalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalRel.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalRel]"},window.SVGPathSegLinetoHorizontalRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x},window.SVGPathSegLinetoHorizontalRel.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalRel(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalAbs=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS,"V",t),this._y=e},window.SVGPathSegLinetoVerticalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalAbs]"},window.SVGPathSegLinetoVerticalAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._y},window.SVGPathSegLinetoVerticalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalAbs(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalRel=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL,"v",t),this._y=e},window.SVGPathSegLinetoVerticalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalRel.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalRel]"},window.SVGPathSegLinetoVerticalRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._y},window.SVGPathSegLinetoVerticalRel.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalRel(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothAbs=function(t,e,o,r,h){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",t),this._x=e,this._y=o,this._x2=r,this._y2=h},window.SVGPathSegCurvetoCubicSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"},window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothRel=function(t,e,o,r,h){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",t),this._x=e,this._y=o,this._x2=r,this._y2=h},window.SVGPathSegCurvetoCubicSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothRel]"},window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothAbs=function(t,e,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",t),this._x=e,this._y=o},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothRel=function(t,e,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",t),this._x=e,this._y=o},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(t,e){return new window.SVGPathSegMovetoAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegMovetoRel=function(t,e){return new window.SVGPathSegMovetoRel(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(t,e){return new window.SVGPathSegLinetoAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoRel=function(t,e){return new window.SVGPathSegLinetoRel(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(t,e,o,r,h,s){return new window.SVGPathSegCurvetoCubicAbs(void 0,t,e,o,r,h,s)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(t,e,o,r,h,s){return new window.SVGPathSegCurvetoCubicRel(void 0,t,e,o,r,h,s)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(t,e,o,r){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,t,e,o,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(t,e,o,r){return new window.SVGPathSegCurvetoQuadraticRel(void 0,t,e,o,r)},window.SVGPathElement.prototype.createSVGPathSegArcAbs=function(t,e,o,r,h,s,a){return new window.SVGPathSegArcAbs(void 0,t,e,o,r,h,s,a)},window.SVGPathElement.prototype.createSVGPathSegArcRel=function(t,e,o,r,h,s,a){return new window.SVGPathSegArcRel(void 0,t,e,o,r,h,s,a)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(t){return new window.SVGPathSegLinetoHorizontalAbs(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(t){return new window.SVGPathSegLinetoHorizontalRel(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(t){return new window.SVGPathSegLinetoVerticalAbs(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(t){return new window.SVGPathSegLinetoVerticalRel(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(t,e,o,r){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,t,e,o,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(t,e,o,r){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,t,e,o,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(t,e){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(t,e){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,t,e)},"getPathSegAtLength"in window.SVGPathElement.prototype||(window.SVGPathElement.prototype.getPathSegAtLength=function(t){if(void 0===t||!isFinite(t))throw"Invalid arguments.";var e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d",this.getAttribute("d"));var o=e.pathSegList.numberOfItems-1;if(o<=0)return 0;do{if(e.pathSegList.removeItem(o),t>e.getTotalLength())break;o--}while(o>0);return o})),"SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype||(window.SVGPathSegList=function(t){this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.classname="SVGPathSegList",Object.defineProperty(window.SVGPathSegList.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"pathSegList",{get:function(){return this._pathSegList||(this._pathSegList=new window.SVGPathSegList(this)),this._pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"normalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedNormalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),window.SVGPathSegList.prototype._checkPathSynchronizedToList=function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())},window.SVGPathSegList.prototype._updateListFromPathMutations=function(t){if(this._pathElement){var e=!1;t.forEach((function(t){"d"==t.attributeName&&(e=!0)})),e&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}},window.SVGPathSegList.prototype._writeListToPath=function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",window.SVGPathSegList._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.segmentChanged=function(t){this._writeListToPath()},window.SVGPathSegList.prototype.clear=function(){this._checkPathSynchronizedToList(),this._list.forEach((function(t){t._owningPathSegList=null})),this._list=[],this._writeListToPath()},window.SVGPathSegList.prototype.initialize=function(t){return this._checkPathSynchronizedToList(),this._list=[t],t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype._checkValidIndex=function(t){if(isNaN(t)||t<0||t>=this.numberOfItems)throw"INDEX_SIZE_ERR"},window.SVGPathSegList.prototype.getItem=function(t){return this._checkPathSynchronizedToList(),this._checkValidIndex(t),this._list[t]},window.SVGPathSegList.prototype.insertItemBefore=function(t,e){return this._checkPathSynchronizedToList(),e>this.numberOfItems&&(e=this.numberOfItems),t._owningPathSegList&&(t=t.clone()),this._list.splice(e,0,t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.replaceItem=function(t,e){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._checkValidIndex(e),this._list[e]=t,t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.removeItem=function(t){this._checkPathSynchronizedToList(),this._checkValidIndex(t);var e=this._list[t];return this._list.splice(t,1),this._writeListToPath(),e},window.SVGPathSegList.prototype.appendItem=function(t){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._list.push(t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList._pathSegArrayAsString=function(t){var e="",o=!0;return t.forEach((function(t){o?(o=!1,e+=t._asPathString()):e+=" "+t._asPathString()})),e},window.SVGPathSegList.prototype._parsePath=function(t){if(!t||0==t.length)return[];var e=this,n=function(){this.pathSegList=[]};n.prototype.appendSegment=function(t){this.pathSegList.push(t)};var i=function(t){this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=window.SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()};i.prototype._isCurrentSpace=function(){var t=this._string[this._currentIndex];return t<=" "&&(" "==t||"\n"==t||"\t"==t||"\r"==t||"\f"==t)},i.prototype._skipOptionalSpaces=function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex},i.prototype._skipOptionalSpacesOrDelimiter=function(){return!(this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&","!=this._string.charAt(this._currentIndex))&&(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&","==this._string.charAt(this._currentIndex)&&(this._currentIndex++,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},i.prototype.hasMoreData=function(){return this._currentIndex<this._endIndex},i.prototype.peekSegmentType=function(){var t=this._string[this._currentIndex];return this._pathSegTypeFromChar(t)},i.prototype._pathSegTypeFromChar=function(t){switch(t){case"Z":case"z":return window.SVGPathSeg.PATHSEG_CLOSEPATH;case"M":return window.SVGPathSeg.PATHSEG_MOVETO_ABS;case"m":return window.SVGPathSeg.PATHSEG_MOVETO_REL;case"L":return window.SVGPathSeg.PATHSEG_LINETO_ABS;case"l":return window.SVGPathSeg.PATHSEG_LINETO_REL;case"C":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;case"c":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;case"Q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return window.SVGPathSeg.PATHSEG_ARC_ABS;case"a":return window.SVGPathSeg.PATHSEG_ARC_REL;case"H":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;case"v":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;case"S":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return window.SVGPathSeg.PATHSEG_UNKNOWN}},i.prototype._nextCommandHelper=function(t,e){return("+"==t||"-"==t||"."==t||t>="0"&&t<="9")&&e!=window.SVGPathSeg.PATHSEG_CLOSEPATH?e==window.SVGPathSeg.PATHSEG_MOVETO_ABS?window.SVGPathSeg.PATHSEG_LINETO_ABS:e==window.SVGPathSeg.PATHSEG_MOVETO_REL?window.SVGPathSeg.PATHSEG_LINETO_REL:e:window.SVGPathSeg.PATHSEG_UNKNOWN},i.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return!0;var t=this.peekSegmentType();return t==window.SVGPathSeg.PATHSEG_MOVETO_ABS||t==window.SVGPathSeg.PATHSEG_MOVETO_REL},i.prototype._parseNumber=function(){var t=0,e=0,o=1,r=0,h=1,s=1,a=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&"+"==this._string.charAt(this._currentIndex)?this._currentIndex++:this._currentIndex<this._endIndex&&"-"==this._string.charAt(this._currentIndex)&&(this._currentIndex++,h=-1),!(this._currentIndex==this._endIndex||(this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")&&"."!=this._string.charAt(this._currentIndex))){for(var S=this._currentIndex;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!=S)for(var u=this._currentIndex-1,w=1;u>=S;)e+=w*(this._string.charAt(u--)-"0"),w*=10;if(this._currentIndex<this._endIndex&&"."==this._string.charAt(this._currentIndex)){if(this._currentIndex++,this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)o*=10,r+=(this._string.charAt(this._currentIndex)-"0")/o,this._currentIndex+=1}if(this._currentIndex!=a&&this._currentIndex+1<this._endIndex&&("e"==this._string.charAt(this._currentIndex)||"E"==this._string.charAt(this._currentIndex))&&"x"!=this._string.charAt(this._currentIndex+1)&&"m"!=this._string.charAt(this._currentIndex+1)){if(this._currentIndex++,"+"==this._string.charAt(this._currentIndex)?this._currentIndex++:"-"==this._string.charAt(this._currentIndex)&&(this._currentIndex++,s=-1),this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)t*=10,t+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var _=e+r;if(_*=h,t&&(_*=Math.pow(10,s*t)),a!=this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),_}},i.prototype._parseArcFlag=function(){if(!(this._currentIndex>=this._endIndex)){var t=!1,e=this._string.charAt(this._currentIndex++);if("0"==e)t=!1;else{if("1"!=e)return;t=!0}return this._skipOptionalSpacesOrDelimiter(),t}},i.prototype.parseSegment=function(){var t=this._string[this._currentIndex],o=this._pathSegTypeFromChar(t);if(o==window.SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==window.SVGPathSeg.PATHSEG_UNKNOWN)return null;if((o=this._nextCommandHelper(t,this._previousCommand))==window.SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=o,o){case window.SVGPathSeg.PATHSEG_MOVETO_REL:return new window.SVGPathSegMovetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_MOVETO_ABS:return new window.SVGPathSegMovetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_REL:return new window.SVGPathSegLinetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_ABS:return new window.SVGPathSegLinetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new window.SVGPathSegLinetoHorizontalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new window.SVGPathSegLinetoHorizontalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new window.SVGPathSegLinetoVerticalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new window.SVGPathSegLinetoVerticalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new window.SVGPathSegClosePath(e);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var r={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicRel(e,r.x,r.y,r.x1,r.y1,r.x2,r.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:return r={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicAbs(e,r.x,r.y,r.x1,r.y1,r.x2,r.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:return r={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothRel(e,r.x,r.y,r.x2,r.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:return r={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothAbs(e,r.x,r.y,r.x2,r.y2);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:return r={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticRel(e,r.x,r.y,r.x1,r.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:return r={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticAbs(e,r.x,r.y,r.x1,r.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new window.SVGPathSegCurvetoQuadraticSmoothRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new window.SVGPathSegCurvetoQuadraticSmoothAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_ARC_REL:return r={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegArcRel(e,r.x,r.y,r.x1,r.y1,r.arcAngle,r.arcLarge,r.arcSweep);case window.SVGPathSeg.PATHSEG_ARC_ABS:return r={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegArcAbs(e,r.x,r.y,r.x1,r.y1,r.arcAngle,r.arcLarge,r.arcSweep);default:throw"Unknown path seg type."}};var o=new n,r=new i(t);if(!r.initialCommandIsMoveTo())return[];for(;r.hasMoreData();){var h=r.parseSegment();if(!h)return[];o.appendSegment(h)}return o.pathSegList})}}}();
2
+ svgedit={NS:{HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://web-edit.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"}},svgedit.getReverseNS=function(){"use strict";var t={};return $.each(this.NS,(function(w,e){t[e]=w.toLowerCase()})),t};
3
+ var mybrowser=function(){"use strict";return{initBrowser:function(){svgedit.browser||(svgedit.browser={});var e=svgedit.NS,t=!!document.createElementNS&&!!document.createElementNS(e.SVG,"svg").createSVGRect;if(svgedit.browser.supportsSvg=function(){return t},svgedit.browser.supportsSvg()){var r,n=navigator.userAgent,o=document.createElementNS(e.SVG,"svg"),s=!!window.opera,i=n.indexOf("AppleWebKit")>=0,u=n.indexOf("Gecko/")>=0,c=n.indexOf("MSIE")>=0,d=n.indexOf("Chrome/")>=0,a=n.indexOf("Windows")>=0,m=n.indexOf("Macintosh")>=0,p="ontouchstart"in window,v=!!o.querySelector,l=!!document.evaluate,g=function(){var t=document.createElementNS(e.SVG,"path");t.setAttribute("d","M0,0 10,10");var r=t.pathSegList,n=t.createSVGPathSegLinetoAbs(5,5);try{return r.replaceItem(n,1),!0}catch(e){}return!1}(),S=function(){var t=document.createElementNS(e.SVG,"path");t.setAttribute("d","M0,0 10,10");var r=t.pathSegList,n=t.createSVGPathSegLinetoAbs(5,5);try{return r.insertItemBefore(n,1),!0}catch(e){}return!1}(),f=function(){var t=document.createElementNS(e.SVG,"svg"),r=document.createElementNS(e.SVG,"svg");document.documentElement.appendChild(t),r.setAttribute("x",5),t.appendChild(r);var n=document.createElementNS(e.SVG,"text");n.textContent="a",r.appendChild(n);var o=n.getStartPositionOfChar(0).x;return document.documentElement.removeChild(t),0===o}(),b=function(){var t=document.createElementNS(e.SVG,"svg");document.documentElement.appendChild(t);var r=document.createElementNS(e.SVG,"path");r.setAttribute("d","M0,0 C0,0 10,10 10,0"),t.appendChild(r);var n=r.getBBox();return document.documentElement.removeChild(t),n.height>4&&n.height<5}(),h=function(){var t=document.createElementNS(e.SVG,"svg");document.documentElement.appendChild(t);var r=document.createElementNS(e.SVG,"path");r.setAttribute("d","M0,0 10,0");var n=document.createElementNS(e.SVG,"path");n.setAttribute("d","M5,0 15,0");var o=document.createElementNS(e.SVG,"g");o.appendChild(r),o.appendChild(n),t.appendChild(o);var s=o.getBBox();return document.documentElement.removeChild(t),15==s.width}(),w=s,E=function(){var t=document.createElementNS(e.SVG,"rect");t.setAttribute("x",.1);var r=-1==t.cloneNode(!1).getAttribute("x").indexOf(",");return r||$.alert("NOTE: This version of Opera is known to contain bugs."),r}(),G=((r=document.createElementNS(e.SVG,"rect")).setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===r.style.vectorEffect),N=function(){var t=document.createElementNS(e.SVG,"rect").transform.baseVal,r=o.createSVGTransform();return t.appendItem(r),t.getItem(0)==r}();svgedit.browser.isOpera=function(){return s},svgedit.browser.isWebkit=function(){return i},svgedit.browser.isGecko=function(){return u},svgedit.browser.isIE=function(){return c},svgedit.browser.isChrome=function(){return d},svgedit.browser.isWindows=function(){return a},svgedit.browser.isMac=function(){return m},svgedit.browser.isTouch=function(){return p},svgedit.browser.supportsSelectors=function(){return v},svgedit.browser.supportsXpath=function(){return l},svgedit.browser.supportsPathReplaceItem=function(){return g},svgedit.browser.supportsPathInsertItemBefore=function(){return S},svgedit.browser.supportsPathBBox=function(){return b},svgedit.browser.supportsHVLineContainerBBox=function(){return h},svgedit.browser.supportsGoodTextCharPos=function(){return f},svgedit.browser.supportsEditableText=function(){return w},svgedit.browser.supportsGoodDecimals=function(){return E},svgedit.browser.supportsNonScalingStroke=function(){return G},svgedit.browser.supportsNativeTransformLists=function(){return N}}else window.location="browser-not-supported.html"}}}();
4
+ !function(){"use strict";function i(t){var s,e,r,a=t.matrix,n="";switch(t.type){case 1:n="matrix("+[a.a,a.b,a.c,a.d,a.e,a.f].join(",")+")";break;case 2:n="translate("+a.e+","+a.f+")";break;case 3:n=a.a==a.d?"scale("+a.a+")":"scale("+a.a+","+a.d+")";break;case 4:s=0,e=0,0!=t.angle&&(e=((r=1-a.a)*a.f+a.b*a.e)/(r*r+a.b*a.b),s=(a.e-a.b*e)/r),n="rotate("+t.angle+" "+s+","+e+")"}return n}var t,s;svgedit.transformlist||(svgedit.transformlist={}),t=document.createElementNS(svgedit.NS.SVG,"svg"),s={},svgedit.transformlist.SVGTransformList=function(e){this._elem=e||null,this._xforms=[],this._update=function(){for(var s="",e=(t.createSVGMatrix(),0);e<this.numberOfItems;++e)s+=i(this._list.getItem(e))+" ";this._elem.setAttribute("transform",s)},this._list=this,this._init=function(){var s,e,r=this._elem.getAttribute("transform");if(r)for(s=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,e=!0;e;)if(e=r.match(s),r=r.replace(s,""),e&&e[1]){var a=e[1].split(/\s*\(/),n=a[0],m=a[1].match(/\s*(.*?)\s*\)/);m[1]=m[1].replace(/(\d)-/g,"$1 -");var f=m[1].split(/[, ]+/),o="abcdef".split(""),h=t.createSVGMatrix();$.each(f,(function(t,s){f[t]=parseFloat(s),"matrix"==n&&(h[o[t]]=f[t])}));var u=t.createSVGTransform(),l="set"+n.charAt(0).toUpperCase()+n.slice(1),c="matrix"==n?[h]:f;"scale"==n&&1==c.length?c.push(c[0]):"translate"==n&&1==c.length?c.push(0):"rotate"==n&&1==c.length&&c.push(0,0),u[l].apply(u,c),this._list.appendItem(u)}},this._removeFromOtherLists=function(t){var e,r,a,n,m;if(t)for(r in e=!1,s){for(n=0,m=(a=s[r])._xforms.length;n<m;++n)if(a._xforms[n]==t){e=!0,a.removeItem(n);break}if(e)break}},this.numberOfItems=0,this.clear=function(){this.numberOfItems=0,this._xforms=[]},this.initialize=function(t){this.numberOfItems=1,this._removeFromOtherLists(t),this._xforms=[t]},this.getItem=function(t){if(t<this.numberOfItems&&t>=0)return this._xforms[t];throw{code:1}},this.insertItemBefore=function(t,s){var e,r,a,n=null;if(s>=0)if(s<this.numberOfItems){for(this._removeFromOtherLists(t),e=new Array(this.numberOfItems+1),r=0;r<s;++r)e[r]=this._xforms[r];for(e[r]=t,a=r+1;r<this.numberOfItems;++a,++r)e[a]=this._xforms[r];this.numberOfItems++,this._xforms=e,n=t,this._list._update()}else n=this._list.appendItem(t);return n},this.replaceItem=function(t,s){var e=null;return s<this.numberOfItems&&s>=0&&(this._removeFromOtherLists(t),this._xforms[s]=t,e=t,this._list._update()),e},this.removeItem=function(t){if(t<this.numberOfItems&&t>=0){for(var s,e=this._xforms[t],r=new Array(this.numberOfItems-1),a=0;a<t;++a)r[a]=this._xforms[a];for(s=a;s<this.numberOfItems-1;++s,++a)r[s]=this._xforms[a+1];return this.numberOfItems--,this._xforms=r,this._list._update(),e}throw{code:1}},this.appendItem=function(t){return this._removeFromOtherLists(t),this._xforms.push(t),this.numberOfItems++,this._list._update(),t}},svgedit.transformlist.resetListMap=function(){s={}},svgedit.transformlist.removeElementFromListMap=function(t){t.id&&s[t.id]&&delete s[t.id]},svgedit.transformlist.getTransformList=function(t){if(!svgedit.browser.supportsNativeTransformLists()){var e=t.id||"temp",r=s[e];return r&&"temp"!==e||(s[e]=new svgedit.transformlist.SVGTransformList(t),s[e]._init(),r=s[e]),r}return t.transform?t.transform.baseVal:t.gradientTransform?t.gradientTransform.baseVal:t.patternTransform?t.patternTransform.baseVal:null}}();
5
+ !function(){"use strict";var t;svgedit.units||(svgedit.units={});var e,i=svgedit.NS,n=["x","x1","cx","rx","width"],s=["y","y1","cy","ry","height"],r=["r","radius"].concat(n,s),u={};svgedit.units.init=function(t){var n,s,r,d;e=t,n=document.createElementNS(i.SVG,"svg"),document.body.appendChild(n),(s=document.createElementNS(i.SVG,"rect")).setAttribute("width","1em"),s.setAttribute("height","1ex"),s.setAttribute("x","1in"),n.appendChild(s),r=s.getBBox(),document.body.removeChild(n),d=r.x,u={em:r.width,ex:r.height,in:d,cm:d/2.54,mm:d/25.4,pt:d/72,pc:d/6,px:1,"%":0}},svgedit.units.getTypeMap=function(){return u},svgedit.units.shortFloat=function(t){var i=e.getRoundDigits();return isNaN(t)?$.isArray(t)?svgedit.units.shortFloat(t[0])+","+svgedit.units.shortFloat(t[1]):parseFloat(t).toFixed(i)-0:+(+t).toFixed(i)},svgedit.units.convertUnit=function(t,i){return i=i||e.getBaseUnit(),svgedit.units.shortFloat(t/u[i])},svgedit.units.setUnitAttr=function(t,e,i){t.setAttribute(e,i)},t={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(i){var n,s,r,d,g=i.tagName,o=e.getBaseUnit(),c=t[g];if(c)for(n=c.length,s=0;s<n;s++)r=c[s],(d=i.getAttribute(r))&&(isNaN(d)||i.setAttribute(r,d/u[o]+o))},svgedit.units.convertToNum=function(t,i){var r,d,g,o;return isNaN(i)?"%"===i.substr(-1)?(r=i.substr(0,i.length-1)/100,d=e.getWidth(),g=e.getHeight(),n.indexOf(t)>=0?r*d:s.indexOf(t)>=0?r*g:r*Math.sqrt(d*d+g*g)/Math.sqrt(2)):(o=i.substr(-2),(r=i.substr(0,i.length-2))*u[o]):+i},svgedit.units.isValidUnit=function(t,i,n){var s,d,g=!1;if(r.indexOf(t)>=0)isNaN(i)?(i=i.toLowerCase(),$.each(u,(function(t){g||new RegExp("^-?[\\d\\.]+"+t+"$").test(i)&&(g=!0)}))):g=!0;else if("id"==t){s=!1;try{s=null==(d=e.getElement(i))||d===n}catch(t){}return s}return g=!0}}();
6
+ !function(){"use strict";svgedit.math||(svgedit.math={});var t=1e-14,r=document.createElementNS(svgedit.NS.SVG,"svg");svgedit.math.transformPoint=function(t,r,a){return{x:a.a*t+a.c*r+a.e,y:a.b*t+a.d*r+a.f}},svgedit.math.isIdentity=function(t){return 1===t.a&&0===t.b&&0===t.c&&1===t.d&&0===t.e&&0===t.f},svgedit.math.matrixMultiply=function(){for(var r=arguments,a=r.length,e=r[a-1];a-- >1;)e=r[a-1].multiply(e);return Math.abs(e.a)<t&&(e.a=0),Math.abs(e.b)<t&&(e.b=0),Math.abs(e.c)<t&&(e.c=0),Math.abs(e.d)<t&&(e.d=0),Math.abs(e.e)<t&&(e.e=0),Math.abs(e.f)<t&&(e.f=0),e},svgedit.math.hasMatrixTransform=function(t){var r,a;if(!t)return!1;for(r=t.numberOfItems;r--;)if(1==(a=t.getItem(r)).type&&!svgedit.math.isIdentity(a.matrix))return!0;return!1},svgedit.math.transformBox=function(t,r,a,e,i){var n=svgedit.math.transformPoint,s=n(t,r,i),m=n(t+a,r,i),h=n(t,r+e,i),o=n(t+a,r+e,i),f=Math.min(s.x,m.x,h.x,o.x),u=Math.max(s.x,m.x,h.x,o.x),x=Math.min(s.y,m.y,h.y,o.y);return{tl:s,tr:m,bl:h,br:o,aabox:{x:f,y:x,width:u-f,height:Math.max(s.y,m.y,h.y,o.y)-x}}},svgedit.math.transformListToTransform=function(t,a,e){var i,n,s,m;if(null==t)return r.createSVGTransformFromMatrix(r.createSVGMatrix());for(a=a||0,e=e||t.numberOfItems-1,(a=parseInt(a,10))>(e=parseInt(e,10))&&(i=e,e=a,a=i),n=r.createSVGMatrix(),s=a;s<=e;++s)m=s>=0&&s<t.numberOfItems?t.getItem(s).matrix:r.createSVGMatrix(),n=svgedit.math.matrixMultiply(n,m);return r.createSVGTransformFromMatrix(n)},svgedit.math.getMatrix=function(t){var r=svgedit.transformlist.getTransformList(t);return svgedit.math.transformListToTransform(r).matrix},svgedit.math.snapToAngle=function(t,r,a,e){var i=Math.PI/4,n=a-t,s=e-r,m=Math.atan2(s,n),h=Math.sqrt(n*n+s*s),o=Math.round(m/i)*i;return{x:t+h*Math.cos(o),y:r+h*Math.sin(o),a:o}},svgedit.math.rectsIntersect=function(t,r){return r.x<t.x+t.width&&r.x+r.width>t.x&&r.y<t.y+t.height&&r.y+r.height>t.y}}();
7
+ var mysvgutils=function(t){"use strict";return{initSvgutils:function(){function e(t){if(svgedit.browser.supportsHVLineContainerBBox())try{return t.getBBox()}catch(t){}var i,n,s=$.data(t,"ref"),o=null;s?(n=$(s).children().clone().attr("visibility","hidden"),$(l).append(n),o=n.filter("line, path")):o=$(t).find("line, path");var u=!1;if(o.length)if(o.each((function(){var t=this.getBBox();t.width&&t.height||(u=!0)})),u){var B=s?n:$(t).children();i=getStrokedBBox(B)}else i=t.getBBox();else i=t.getBBox();return s&&n.remove(),i}svgedit.utilities||(svgedit.utilities={});var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=svgedit.NS,s="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),o=null,u=null,B=null,l=null;svgedit.utilities.init=function(t){o=t,u=t.getDOMDocument(),B=t.getDOMContainer(),l=t.getSVGRoot()},svgedit.utilities.toXml=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/,"&#x27;")},svgedit.utilities.fromXml=function(t){return $("<p/>").html(t).text()},svgedit.utilities.encode64=function(t){if(t=svgedit.utilities.encodeUTF8(t),window.btoa)return window.btoa(t);var n,s,o,u,B,l,a,D=[];D.length=4*Math.floor((t.length+2)/3);var g=0,c=0;do{u=(n=t.charCodeAt(g++))>>2,B=(3&n)<<4|(s=t.charCodeAt(g++))>>4,l=(15&s)<<2|(o=t.charCodeAt(g++))>>6,a=63&o,isNaN(s)?l=a=64:isNaN(o)&&(a=64),D[c++]=i.charAt(u),D[c++]=i.charAt(B),D[c++]=i.charAt(l),D[c++]=i.charAt(a)}while(g<t.length);return D.join("")},svgedit.utilities.decode64=function(t){if(window.atob)return svgedit.utilities.decodeUTF8(window.atob(t));var n,s,o,u,B="",l="",a="",D=0;t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{n=i.indexOf(t.charAt(D++))<<2|(o=i.indexOf(t.charAt(D++)))>>4,s=(15&o)<<4|(u=i.indexOf(t.charAt(D++)))>>2,l=(3&u)<<6|(a=i.indexOf(t.charAt(D++))),B+=String.fromCharCode(n),64!=u&&(B+=String.fromCharCode(s)),64!=a&&(B+=String.fromCharCode(l)),n=s=l="",o=u=a=""}while(D<t.length);return svgedit.utilities.decodeUTF8(B)},svgedit.utilities.decodeUTF8=function(t){return decodeURIComponent(escape(t))},svgedit.utilities.encodeUTF8=function(t){return unescape(encodeURIComponent(t))},svgedit.utilities.crc32=function(t){var i=0,n=0;i^=-1;for(var s=0,o=(t=svgedit.utilities.encodeUTF8(t)).length;s<o;s++)n=255&(i^t.charCodeAt(s)),i=i>>>8^"0x"+"00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D".substr(9*n,8);return~i},svgedit.utilities.convertToXMLReferences=function(t){var i,n="";for(i=0;i<t.length;i++){var s=t.charCodeAt(i);s<128?n+=t[i]:s>127&&(n+="&#"+s+";")}return n},svgedit.utilities.text2xml=function(t){var i,n;t.indexOf("<svg:svg")>=0&&(t=t.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns"));try{(n=window.DOMParser?new DOMParser:new ActiveXObject("Microsoft.XMLDOM")).async=!1}catch(t){throw new Error("XML Parser could not be instantiated")}try{i=n.loadXML?!!n.loadXML(t)&&n:n.parseFromString(t,"text/xml")}catch(t){throw new Error("Error parsing XML string")}return i},svgedit.utilities.bboxToObj=function(t){return{x:t.x,y:t.y,width:t.width,height:t.height}},svgedit.utilities.walkTree=function(t,i){if(t&&1==t.nodeType){i(t);for(var n=t.childNodes.length;n--;)svgedit.utilities.walkTree(t.childNodes.item(n),i)}},svgedit.utilities.walkTreePost=function(t,i){if(t&&1==t.nodeType){for(var n=t.childNodes.length;n--;)svgedit.utilities.walkTree(t.childNodes.item(n),i);i(t)}},svgedit.utilities.getUrlFromAttr=function(t){if(t){if(0===t.indexOf('url("'))return t.substring(5,t.indexOf('"',6));if(0===t.indexOf("url('"))return t.substring(5,t.indexOf("'",6));if(0===t.indexOf("url("))return t.substring(4,t.indexOf(")"))}return null},svgedit.utilities.getHref=function(t){return t.getAttributeNS(n.XLINK,"href")},svgedit.utilities.setHref=function(t,i){t.setAttributeNS(n.XLINK,"xlink:href",i)},svgedit.utilities.findDefs=function(){var t=o.getSVGContent(),i=t.getElementsByTagNameNS(n.SVG,"defs");return i.length>0?i=i[0]:(i=t.ownerDocument.createElementNS(n.SVG,"defs"),t.firstChild?t.insertBefore(i,t.firstChild.nextSibling):t.appendChild(i)),i},svgedit.utilities.getPathBBox=function(i){var n,s=i.pathSegList,o=s.numberOfItems,u=[[],[]],B=s.getItem(0),l=[B.x,B.y];for(n=0;n<o;n++){var a=s.getItem(n);if(a.x!==t)if(u[0].push(l[0]),u[1].push(l[1]),a.x1){var D,g=[a.x1,a.y1],c=[a.x2,a.y2],A=[a.x,a.y];for(D=0;D<2;D++){var d=function(t){return Math.pow(1-t,3)*l[D]+3*Math.pow(1-t,2)*t*g[D]+3*(1-t)*Math.pow(t,2)*c[D]+Math.pow(t,3)*A[D]},C=6*l[D]-12*g[D]+6*c[D],f=-3*l[D]+9*g[D]-9*c[D]+3*A[D],v=3*g[D]-3*l[D];if(0!=f){var E=Math.pow(C,2)-4*v*f;if(!(E<0)){var F=(-C+Math.sqrt(E))/(2*f);0<F&&F<1&&u[D].push(d(F));var h=(-C-Math.sqrt(E))/(2*f);0<h&&h<1&&u[D].push(d(h))}}else{if(0==C)continue;var p=-v/C;0<p&&p<1&&u[D].push(d(p))}}l=A}else u[0].push(a.x),u[1].push(a.y)}var x=Math.min.apply(null,u[0]),m=Math.max.apply(null,u[0])-x,b=Math.min.apply(null,u[1]);return{x:x,y:b,width:m,height:Math.max.apply(null,u[1])-b}},svgedit.utilities.getBBox=function(t){var i=t||o.geSelectedElements()[0];if(1!=t.nodeType)return null;var n=null,u=i.nodeName;switch(u){case"text":""===i.textContent?(i.textContent="a",n=i.getBBox(),i.textContent=""):i.getBBox&&(n=i.getBBox());break;case"path":svgedit.browser.supportsPathBBox()?i.getBBox&&(n=i.getBBox()):n=svgedit.utilities.getPathBBox(i);break;case"g":case"a":n=e(i);break;default:if("use"===u&&(n=e(i)),"use"===u||"foreignObject"===u&&svgedit.browser.isWebkit()){if(n||(n=i.getBBox()),!svgedit.browser.isWebkit()){var B={};B.width=n.width,B.height=n.height,B.x=n.x+parseFloat(i.getAttribute("x")||0),B.y=n.y+parseFloat(i.getAttribute("y")||0),n=B}}else if(~s.indexOf(u))if(i)n=i.getBBox();else{var l=$(i).closest("foreignObject");l.length&&l[0].getBBox&&(n=l[0].getBBox())}}return n&&(n=svgedit.utilities.bboxToObj(n)),n},svgedit.utilities.getRotationAngle=function(t,i){var n=t||o.getSelectedElements()[0],s=svgedit.transformlist.getTransformList(n);if(!s)return 0;var u,B=s.numberOfItems;for(u=0;u<B;++u){var l=s.getItem(u);if(4==l.type)return i?l.angle*Math.PI/180:l.angle}return 0},svgedit.utilities.getRefElem=function(t){return svgedit.utilities.getElem(svgedit.utilities.getUrlFromAttr(t).substr(1))},svgedit.browser.supportsSelectors()?svgedit.utilities.getElem=function(t){return l.querySelector("#"+t)}:svgedit.browser.supportsXpath()?svgedit.utilities.getElem=function(t){return u.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+t+'"]',B,(function(){return svgedit.NS.SVG}),9,null).singleNodeValue}:svgedit.utilities.getElem=function(t){return $(l).find("[id="+t+"]")[0]},svgedit.utilities.assignAttributes=function(t,i,s,o){var u;for(u in i){var B="xml:"===u.substr(0,4)?n.XML:"xlink:"===u.substr(0,6)?n.XLINK:null;svgedit.utilities.isNullish(i[u])?B?t.removeAttributeNS(B,u):t.removeAttribute(u):B?t.setAttributeNS(B,u,i[u]):o?svgedit.units.setUnitAttr(t,u,i[u]):t.setAttribute(u,i[u])}},svgedit.utilities.cleanupElement=function(t){var i,n={"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};for(i in n){var s=n[i];t.getAttribute(i)==s&&t.removeAttribute(i)}},svgedit.utilities.snapToGrid=function(t){var i=o.getSnappingStep(),n=o.getBaseUnit();return"px"!==n&&(i*=svgedit.units.getTypeMap()[n]),t=Math.round(t/i)*i},svgedit.utilities.preg_quote=function(t,i){return String(t).replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\"+(i||"")+"-]","g"),"\\$&")},svgedit.utilities.executeAfterLoads=function(t,i,n){return function(){function r(){n.apply(null,s)}var s=arguments;window[t]?r():i.reduceRight((function(t,i){return function(){$.getScript(i,t)}}),r)()}},svgedit.utilities.buildCanvgCallback=function(t){return svgedit.utilities.executeAfterLoads("canvg",["canvg/rgbcolor.js","canvg/canvg.js"],t)},svgedit.utilities.buildJSPDFCallback=function(i){return svgedit.utilities.executeAfterLoads("RGBColor",["canvg/rgbcolor.js"],(function(){var n=[];RGBColor&&RGBColor.ok!==t||n.push("canvg/rgbcolor.js"),svgedit.utilities.executeAfterLoads("jsPDF",n.concat("jspdf/underscore-min.js","jspdf/jspdf.min.js","jspdf/jspdf.plugin.svgToPdf.js"),i)()}))},svgedit.utilities.takePil=function(){var t=new Date,i=t.getFullYear(),n=t.getDay();return Math.floor(3*Math.random()),i%2>0&&Math.floor(n/2),!0},svgedit.utilities.isNullish=function(t){return null==t}}}}(mysvgutils||{});
8
+ !function(){"use strict";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(t,e,i,n){this.elem=t,this.text=n?"Move "+t.tagName+" to "+n:"Move "+t.tagName,this.oldNextSibling=e,this.oldParent=i,this.newNextSibling=t.nextSibling,this.newParent=t.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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this),this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)},svgedit.history.MoveElementCommand.prototype.unapply=function(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this),this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)},svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]},svgedit.history.InsertElementCommand=function(t,e){this.elem=t,this.text=e||"Create "+t.tagName,this.parent=t.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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this),this.elem=this.parent.insertBefore(this.elem,this.nextSibling),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)},svgedit.history.InsertElementCommand.prototype.unapply=function(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this),this.parent=this.elem.parentNode,this.elem=this.elem.parentNode.removeChild(this.elem),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)},svgedit.history.InsertElementCommand.prototype.elements=function(){return[this.elem]},svgedit.history.RemoveElementCommand=function(t,e,i,n){this.elem=t,this.text=n||"Delete "+t.tagName,this.nextSibling=e,this.parent=i,svgedit.transformlist.removeElementFromListMap(t)},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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this),svgedit.transformlist.removeElementFromListMap(this.elem),this.parent=this.elem.parentNode,this.elem=this.parent.removeChild(this.elem),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)},svgedit.history.RemoveElementCommand.prototype.unapply=function(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this),svgedit.transformlist.removeElementFromListMap(this.elem),null==this.nextSibling&&window.console&&console.log("Error: reference element was lost"),this.parent.insertBefore(this.elem,this.nextSibling),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)},svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]},svgedit.history.ChangeElementCommand=function(t,e,i){var n;for(n in this.elem=t,this.text=i?"Change "+t.tagName+" "+i:"Change "+t.tagName,this.newValues={},this.oldValues=e,e)this.newValues[n]="#text"==n?t.textContent:"#href"==n?svgedit.utilities.getHref(t):t.getAttribute(n)},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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var e,i=!1;for(e in this.newValues)this.newValues[e]?"#text"==e?this.elem.textContent=this.newValues[e]:"#href"==e?svgedit.utilities.setHref(this.elem,this.newValues[e]):this.elem.setAttribute(e,this.newValues[e]):"#text"==e?this.elem.textContent="":(this.elem.setAttribute(e,""),this.elem.removeAttribute(e)),"transform"==e&&(i=!0);if(!i){var n=svgedit.utilities.getRotationAngle(this.elem);if(n){var s=elem.getBBox(),o=["rotate(",n," ",s.x+s.width/2,",",s.y+s.height/2,")"].join("");o!=elem.getAttribute("transform")&&elem.setAttribute("transform",o)}}return t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this),!0},svgedit.history.ChangeElementCommand.prototype.unapply=function(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var e,i=!1;for(e in this.oldValues)this.oldValues[e]?"#text"==e?this.elem.textContent=this.oldValues[e]:"#href"==e?svgedit.utilities.setHref(this.elem,this.oldValues[e]):this.elem.setAttribute(e,this.oldValues[e]):"#text"==e?this.elem.textContent="":this.elem.removeAttribute(e),"transform"==e&&(i=!0);if(!i){var n=svgedit.utilities.getRotationAngle(this.elem);if(n){var s=elem.getBBox(),o=["rotate(",n," ",s.x+s.width/2,",",s.y+s.height/2,")"].join("");o!=elem.getAttribute("transform")&&elem.setAttribute("transform",o)}}return svgedit.transformlist.removeElementFromListMap(this.elem),t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this),!0},svgedit.history.ChangeElementCommand.prototype.elements=function(){return[this.elem]},svgedit.history.BatchCommand=function(t){this.text=t||"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(t){t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var e,i=this.stack.length;for(e=0;e<i;++e)this.stack[e].apply(t);t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)},svgedit.history.BatchCommand.prototype.unapply=function(t){var e;for(t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this),e=this.stack.length-1;e>=0;e--)this.stack[e].unapply(t);t&&t.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)},svgedit.history.BatchCommand.prototype.elements=function(){for(var t=[],e=this.stack.length;e--;)for(var i=this.stack[e].elements(),n=i.length;n--;)-1==t.indexOf(i[n])&&t.push(i[n]);return t},svgedit.history.BatchCommand.prototype.addSubCommand=function(t){this.stack.push(t)},svgedit.history.BatchCommand.prototype.isEmpty=function(){return 0===this.stack.length},svgedit.history.UndoManager=function(t){this.handler_=t||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(t){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(t),this.undoStackPointer=this.undoStack.length},svgedit.history.UndoManager.prototype.beginUndoableChange=function(t,e){for(var i=++this.undoChangeStackPointer,n=e.length,s=new Array(n),o=new Array(n);n--;){var r=e[n];null!=r&&(o[n]=r,s[n]=r.getAttribute(t))}this.undoableChangeStack[i]={attrName:t,oldValues:s,elements:o}},svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var t=this.undoChangeStackPointer--,e=this.undoableChangeStack[t],i=e.elements.length,n=e.attrName,s=new svgedit.history.BatchCommand("Change "+n);i--;){var o=e.elements[i];if(null!=o){var r={};r[n]=e.oldValues[i],r[n]!=o.getAttribute(n)&&s.addSubCommand(new svgedit.history.ChangeElementCommand(o,r,n))}}return this.undoableChangeStack[t]=null,s}}();
9
+ !function(){"use strict";var e=window.svgedit=window.svgedit||{};e.NS=e.NS||{HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://web-edit.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"},e.getReverseNS=e.getReverseNS||function(){var e={};return $.each(this.NS,(function(t,s){e[s]=t.toLowerCase()})),e},e.sanitize||(e.sanitize={});var t=e.NS,s=e.getReverseNS(),i={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class","clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters","filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["type","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:["type","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","type","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","type","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"],script:[],input:["class","id","type","style","value"],INPUT:["class","id","type","style","value"],textarea:["class","id","type","style","value"],TEXTAREA:["class","id","type","style","value"],select:["class","id","type","style"],SELECT:["class","id","type","style"],option:["value","text"],OPTION:["value","text"],button:["class","color","style","id"],BUTTON:["class","color","style","id"],span:["class","color","style","id"],SPAN:["class","color","style","id"],div:["class","style","id"],DIV:["class","style","id"],label:["class","style","id"],LABEL:["class","style","id"],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:[]},r={};$.each(i,(function(e,s){var i={};$.each(s,(function(e,s){if(s.indexOf(":")>=0){var r=s.split(":");i[r[1]]=t[r[0].toUpperCase()]}else i[s]="xmlns"==s?t.XMLNS:null})),r[e]=i})),e.sanitize.sanitizeSvg=function(a){if(!(a&&1===a.nodeType&&a.parentNode&&9===a.parentNode.nodeType&&"svg"!==a.nodeName||(3==a.nodeType&&(a.nodeValue=a.nodeValue.replace(/^\s+|\s+$/g,""),0===a.nodeValue.length&&a.parentNode.removeChild(a)),1!=a.nodeType))){var l=a.ownerDocument,o=a.parentNode;if(l&&o){var n=i[a.nodeName],c=r[a.nodeName];if(void 0!==n){if("foreignObject"===o.nodeName||o.parentNode&&"foreignObject"===o.parentNode.nodeName){for(var d=document.createElement(a.tagName),m=a.attributes.length;m--;){var p=a.attributes.item(m);d.setAttribute(p.nodeName,p.value)}d.innerHTML=a.innerHTML,o.removeChild(a),o.appendChild(d),a=d}var f=[];for(m=a.attributes.length;m--;){var y=(p=a.attributes.item(m)).nodeName,u=p.localName,h=p.namespaceURI;if(c.hasOwnProperty(u)&&h==c[u]&&h!=t.XMLNS||h==t.XMLNS&&s[p.value]||(0===y.indexOf("se:")&&f.push([y,p.value]),a.removeAttributeNS(h,u)),e.browser.isGecko())switch(y){case"transform":case"gradientTransform":case"patternTransform":var k=p.value.replace(/(\d)-/g,"$1 -");a.setAttribute(y,k)}if("style"==y&&"foreignObject"!==o.nodeName){for(var g=p.value.split(";"),w=g.length;w--;){var x=g[w].split(":"),v=$.trim(x[0]),N=$.trim(x[1]);n.indexOf(v)>=0&&a.setAttribute(v,N)}a.removeAttribute("style")}}$.each(f,(function(e,s){a.setAttributeNS(t.SE,s[0],s[1])}));var L=e.utilities.getHref(a);if(L&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(a.nodeName)>=0&&"#"!=L[0]&&(e.utilities.setHref(a,""),a.removeAttributeNS(t.XLINK,"href")),"use"==a.nodeName&&!e.utilities.getHref(a))return void o.removeChild(a);for($.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],(function(t,s){var i=a.getAttribute(s);i&&((i=e.utilities.getUrlFromAttr(i))&&"#"!==i[0]&&(a.setAttribute(s,""),a.removeAttribute(s)))})),m=a.childNodes.length;m--;)e.sanitize.sanitizeSvg(a.childNodes.item(m))}else{for(var b=[];a.hasChildNodes();)b.push(o.insertBefore(a.firstChild,a));for(o.removeChild(a),m=b.length;m--;)e.sanitize.sanitizeSvg(b[m])}}}}}();
10
+ var svgedit=svgedit||{};!function(){"use strict";svgedit.coords||(svgedit.coords={});var t=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],e=null;svgedit.coords.init=function(t){e=t},svgedit.coords.remapElement=function(a,r,s){for(var i,x,n,y,g,c,o,d,l,m,u,f,b,v,A,M,k,T,F,L,N,S,I,G,h=function(t,e){return svgedit.math.transformPoint(t,e,s)},p=function(t){return s.a*t},w=function(t){return s.d*t},B=e.getGridSnapping()&&"svg"===a.parentNode.parentNode.localName,tt=function(){var t;if(B)for(t in r)r[t]=svgedit.utilities.snapToGrid(r[t]);svgedit.utilities.assignAttributes(a,r,1e3,!0)},O=svgedit.utilities.getBBox(a),V=0;V<2;V++)i=0===V?"fill":"stroke",(x=a.getAttribute(i))&&0===x.indexOf("url(")&&(s.a<0||s.d<0)&&(n=svgedit.utilities.getRefElem(x).cloneNode(!0),s.a<0&&(y=n.getAttribute("x1"),g=n.getAttribute("x2"),n.setAttribute("x1",-(y-1)),n.setAttribute("x2",-(g-1))),s.d<0&&(c=n.getAttribute("y1"),o=n.getAttribute("y2"),n.setAttribute("y1",-(c-1)),n.setAttribute("y2",-(o-1))),n.id=e.getDrawing().getNextId(),svgedit.utilities.findDefs().appendChild(n),a.setAttribute(i,"url(#"+n.id+")"));switch(("g"===(d=a.tagName)||"text"===d||"tspan"==d||"use"===d)&&(1!=s.a||0!=s.b||0!=s.c||1!=s.d||0==s.e&&0==s.f?(l=svgedit.transformlist.getTransformList(a),(m=svgroot.createSVGTransform()).setMatrix(svgedit.math.matrixMultiply(svgedit.math.transformListToTransform(l).matrix,s)),l.clear(),l.appendItem(m)):(u=svgedit.math.transformListToTransform(a).matrix,f=svgedit.math.matrixMultiply(u.inverse(),s,u),r.x=parseFloat(r.x)+f.e,r.y=parseFloat(r.y)+f.f)),d){case"foreignObject":case"rect":case"image":"image"===d&&(s.a<0||s.d<0)?(l=svgedit.transformlist.getTransformList(a),(m=svgroot.createSVGTransform()).setMatrix(svgedit.math.matrixMultiply(svgedit.math.transformListToTransform(l).matrix,s)),l.clear(),l.appendItem(m)):(A=h(r.x,r.y),r.width=p(r.width),r.height=w(r.height),r.x=A.x+Math.min(0,r.width),r.y=A.y+Math.min(0,r.height),r.width=Math.abs(r.width),r.height=Math.abs(r.height)),tt();break;case"ellipse":b=h(r.cx,r.cy),r.cx=b.x,r.cy=b.y,r.rx=p(r.rx),r.ry=w(r.ry),r.rx=Math.abs(r.rx),r.ry=Math.abs(r.ry),tt();break;case"circle":b=h(r.cx,r.cy),r.cx=b.x,r.cy=b.y;var C=svgedit.math.transformBox(O.x,O.y,O.width,O.height,s),D=C.tr.x-C.tl.x,E=C.bl.y-C.tl.y;r.r=Math.min(D/2,E/2),r.r&&(r.r=Math.abs(r.r)),tt();break;case"line":A=h(r.x1,r.y1),M=h(r.x2,r.y2),r.x1=A.x,r.y1=A.y,r.x2=M.x,r.y2=M.y;case"text":case"tspan":case"use":tt();break;case"g":(T=$(a).data("gsvg"))&&svgedit.utilities.assignAttributes(T,r,1e3,!0);break;case"polyline":case"polygon":for(k=r.points.length,V=0;V<k;++V)v=h((v=r.points[V]).x,v.y),r.points[V].x=v.x,r.points[V].y=v.y;for(k=r.points.length,F="",V=0;V<k;++V)F+=(v=r.points[V]).x+","+v.y+" ";a.setAttribute("points",F);break;case"path":for(k=(N=a.pathSegList).numberOfItems,r.d=[],V=0;V<k;++V)L=N.getItem(V),r.d[V]={type:L.pathSegType,x:L.x,y:L.y,x1:L.x1,y1:L.y1,x2:L.x2,y2:L.y2,r1:L.r1,r2:L.r2,angle:L.angle,largeArcFlag:L.largeArcFlag,sweepFlag:L.sweepFlag};for(k=r.d.length,I=h((S=r.d[0]).x,S.y),r.d[0].x=I.x,r.d[0].y=I.y,V=1;V<k;++V)(i=(L=r.d[V]).type)%2==0?(v=h(null!=L.x?L.x:I.x,null!=L.y?L.y:I.y),A=h(L.x1,L.y1),M=h(L.x2,L.y2),L.x=v.x,L.y=v.y,L.x1=A.x,L.y1=A.y,L.x2=M.x,L.y2=M.y,L.r1=p(L.r1),L.r2=w(L.r2)):(L.x=p(L.x),L.y=w(L.y),L.x1=p(L.x1),L.y1=w(L.y1),L.x2=p(L.x2),L.y2=w(L.y2),L.r1=p(L.r1),L.r2=w(L.r2));for(G="",k=r.d.length,V=0;V<k;++V)switch(i=(L=r.d[V]).type,G+=t[i],i){case 13:case 12:G+=L.x+" ";break;case 15:case 14:G+=L.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:G+=L.x+","+L.y+" ";break;case 7:case 6:G+=L.x1+","+L.y1+" "+L.x2+","+L.y2+" "+L.x+","+L.y+" ";break;case 9:case 8:G+=L.x1+","+L.y1+" "+L.x+","+L.y+" ";break;case 11:case 10:G+=L.r1+","+L.r2+" "+L.angle+" "+ +L.largeArcFlag+" "+ +L.sweepFlag+" "+L.x+","+L.y+" ";break;case 17:case 16:G+=L.x2+","+L.y2+" "+L.x+","+L.y+" "}a.setAttribute("d",G)}}}();
11
+ var myselect=function(){"use strict";return{initSelect:function(){var e,t,r;svgedit.select||(svgedit.select={});var s=svgedit.browser.isTouch()?10:4;svgedit.select.Selector=function(t,r){this.id=t,this.selectedElement=r,this.locked=!0,this.selectorGroup=e.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}}),this.selectorRect=this.selectorGroup.appendChild(e.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#9ebdff","stroke-width":"1",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(e){this.locked=!0,this.selectedElement=e,this.resize(),this.selectorGroup.setAttribute("display","inline")},svgedit.select.Selector.prototype.updateGripCursors=function(e){var t,s=[],i=Math.round(e/45);for(t in i<0&&(i+=8),r.selectorGrips)s.push(t);for(;i>0;)s.push(s.shift()),i--;var o=0;for(t in r.selectorGrips)r.selectorGrips[t].setAttribute("style","cursor:"+s[o]+"-resize"),o++},svgedit.select.Selector.prototype.showGrips=function(e){var t=e?"inline":"none";r.selectorGripsGroup.setAttribute("display",t);var s=this.selectedElement;this.hasGrips=e,s&&e&&(this.selectorGroup.appendChild(r.selectorGripsGroup),this.updateGripCursors(svgedit.utilities.getRotationAngle(s)))},svgedit.select.Selector.prototype.resize=function(){var t=this.selectorRect,i=r,o=i.selectorGrips,l=this.selectedElement,n=l.getAttribute("stroke-width"),a=e.currentZoom(),c=1/a;"none"===l.getAttribute("stroke")||isNaN(n)||(c+=n/2);var d=l.tagName;"text"===d&&(c+=2/a);var h=svgedit.transformlist.getTransformList(l),p=svgedit.math.transformListToTransform(h).matrix;p.e*=a,p.f*=a;var u=svgedit.utilities.getBBox(l);if("g"===d&&!$.data(l,"gsvg")){var g=e.getStrokedBBox(l.childNodes);g&&(u=g)}var G=u.x,v=u.y,f=u.width,b=u.height;u={x:G,y:v,width:f,height:b},c*=a;var m=svgedit.math.transformBox(G*a,v*a,f*a,b*a,p),y=m.aabox,x=y.x-c,w=y.y-c,S=y.width+2*c,k=y.height+2*c,C=x+S/2,B=w+k/2,M=svgedit.utilities.getRotationAngle(l);if(M){var A=e.svgRoot().createSVGTransform();A.setRotate(-M,C,B);var E=A.matrix;m.tl=svgedit.math.transformPoint(m.tl.x,m.tl.y,E),m.tr=svgedit.math.transformPoint(m.tr.x,m.tr.y,E),m.bl=svgedit.math.transformPoint(m.bl.x,m.bl.y,E),m.br=svgedit.math.transformPoint(m.br.x,m.br.y,E);var P=m.tl,R=P.x,V=P.y,N=P.x,z=P.y,F=Math.min,T=Math.max;x=R=F(R,F(m.tr.x,F(m.bl.x,m.br.x)))-c,w=V=F(V,F(m.tr.y,F(m.bl.y,m.br.y)))-c,S=(N=T(N,T(m.tr.x,T(m.bl.x,m.br.x)))+c)-R,k=(z=T(z,T(m.tr.y,T(m.bl.y,m.br.y)))+c)-V}var _=e.svgRoot().suspendRedraw(100),L="M"+x+","+w+" L"+(x+S)+","+w+" "+(x+S)+","+(w+k)+" "+x+","+(w+k)+"z";t.setAttribute("d",L);var j,W=M?"rotate("+[M,C,B].join(",")+")":"";for(j in this.selectorGroup.setAttribute("transform",W),this.gripCoords={nw:[x,w],ne:[x+S,w],sw:[x,w+k],se:[x+S,w+k],n:[x+S/2,w],w:[x,w+k/2],e:[x+S,w+k/2],s:[x+S/2,w+k]},this.gripCoords){var q=this.gripCoords[j];o[j].setAttribute("x",q[0]-3),o[j].setAttribute("y",q[1]-3)}i.rotateGripConnector.setAttribute("x1",x+S/2),i.rotateGripConnector.setAttribute("y1",w),i.rotateGripConnector.setAttribute("x2",x+S/2),i.rotateGripConnector.setAttribute("y2",w-5*s),i.rotateGrip.setAttribute("cx",x+S/2),i.rotateGrip.setAttribute("cy",w-5*s),e.svgRoot().unsuspendRedraw(_)},svgedit.select.SelectorManager=function(){this.selectorParentGroup=null,this.rubberBandBox=null,this.selectors=[],this.selectorMap={},this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null},this.selectorGripsGroup=null,this.rotateGripConnector=null,this.rotateGrip=null,this.initGroup()},svgedit.select.SelectorManager.prototype.initGroup=function(){var r;for(r in this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup),this.selectorParentGroup=e.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}}),this.selectorGripsGroup=e.createSVGElement({element:"g",attr:{display:"none"}}),this.selectorParentGroup.appendChild(this.selectorGripsGroup),e.svgRoot().appendChild(this.selectorParentGroup),this.selectorMap={},this.selectors=[],this.rubberBandBox=null,this.selectorGrips){var i=e.createSVGElement({element:"rect",attr:{id:"selectorGrip_resize_"+r,width:6,height:6,"stroke-width":1,stroke:"#9ebdff",fill:"#FFF",style:"cursor:"+r+"-resize","pointer-events":"all"}});$.data(i,"dir",r),$.data(i,"type","resize"),this.selectorGrips[r]=this.selectorGripsGroup.appendChild(i)}if(this.rotateGripConnector=this.selectorGripsGroup.appendChild(e.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#9ebdff","stroke-width":"1"}})),this.rotateGrip=this.selectorGripsGroup.appendChild(e.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:s,stroke:"#9ebdff","stroke-width":1}})),$.data(this.rotateGrip,"type","rotate"),!$("#canvasBackground").length){var o=t.dimensions,l=e.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"}}),n=e.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});l.appendChild(n),e.svgRoot().insertBefore(l,e.svgContent())}},svgedit.select.SelectorManager.prototype.requestSelector=function(e){if(null==e)return null;var t,r=this.selectors.length;if("object"==typeof this.selectorMap[e.id])return this.selectorMap[e.id].locked=!0,this.selectorMap[e.id];for(t=0;t<r;++t)if(this.selectors[t]&&!this.selectors[t].locked)return this.selectors[t].locked=!0,this.selectors[t].reset(e),this.selectorMap[e.id]=this.selectors[t],this.selectors[t];return this.selectors[r]=new svgedit.select.Selector(r,e),this.selectorParentGroup.appendChild(this.selectors[r].selectorGroup),this.selectorMap[e.id]=this.selectors[r],this.selectors[r]},svgedit.select.SelectorManager.prototype.releaseSelector=function(e){if(null!=e){var t,r=this.selectors.length,s=this.selectorMap[e.id];for(t=0;t<r;++t)if(this.selectors[t]&&this.selectors[t]==s){0==s.locked&&console.log("WARNING! selector was released but was already unlocked"),delete this.selectorMap[e.id],s.locked=!1,s.selectedElement=null,s.showGrips(!1);try{s.selectorGroup.setAttribute("display","none")}catch(e){}break}}},svgedit.select.SelectorManager.prototype.getRubberBandBox=function(){return this.rubberBandBox||(this.rubberBandBox=this.selectorParentGroup.appendChild(e.createSVGElement({element:"rect",attr:{id:"selectorRubberBand",fill:"#22C","fill-opacity":.15,stroke:"#22C","stroke-width":.5,display:"none",style:"pointer-events:none"}}))),this.rubberBandBox},svgedit.select.init=function(s,i){t=s,e=i,r=new svgedit.select.SelectorManager},svgedit.select.getSelectorManager=function(){return r}}}}();
12
+ var svgedit=svgedit||{};!function(){svgedit.recalculate||(svgedit.recalculate={});var t,e=svgedit.NS;svgedit.recalculate.init=function(e){t=e},svgedit.recalculate.updateClipPath=function(e,r,a){var s=getRefElem(e).firstChild,i=svgedit.transformlist.getTransformList(s),m=t.getSVGRoot().createSVGTransform();m.setTranslate(r,a),i.appendItem(m),svgedit.recalculate.recalculateDimensions(s)},svgedit.recalculate.recalculateDimensions=function(r){if(null==r)return null;if("svg"==r.nodeName&&navigator.userAgent.indexOf("Firefox/20")>=0)return null;var a,s=t.getSVGRoot(),i=svgedit.transformlist.getTransformList(r);if(i&&i.numberOfItems>0){for(a=i.numberOfItems;a--;){0===(ot=i.getItem(a)).type?i.removeItem(a):1===ot.type?svgedit.math.isIdentity(ot.matrix)&&i.removeItem(a):4===ot.type&&0===ot.angle&&i.removeItem(a)}if(1===i.numberOfItems&&svgedit.utilities.getRotationAngle(r))return null}if(!i||0==i.numberOfItems)return r.setAttribute("transform",""),r.removeAttribute("transform"),null;if(i){a=i.numberOfItems;for(var m=[];a--;){1===(ot=i.getItem(a)).type?m.push([ot.matrix,a]):m.length&&(m=[])}if(2===m.length){var n=s.createSVGTransformFromMatrix(svgedit.math.matrixMultiply(m[1][0],m[0][0]));i.removeItem(m[0][1]),i.removeItem(m[1][1]),i.insertItemBefore(n,m[1][1])}if((a=i.numberOfItems)>=2&&1===i.getItem(a-2).type&&2===i.getItem(a-1).type){var o=s.createSVGTransform(),f=svgedit.math.matrixMultiply(i.getItem(a-2).matrix,i.getItem(a-1).matrix);o.setMatrix(f),i.removeItem(a-2),i.removeItem(a-2),i.appendItem(o)}}switch(r.tagName){case"line":case"polyline":case"polygon":case"path":break;default:if(1===i.numberOfItems&&1===i.getItem(0).type||2===i.numberOfItems&&1===i.getItem(0).type&&4===i.getItem(0).type)return null}var g=$(r).data("gsvg"),l=new svgedit.history.BatchCommand("Transform"),v={},d=null,u=[];switch(r.tagName){case"line":u=["x1","y1","x2","y2"];break;case"circle":u=["cx","cy","r"];break;case"ellipse":u=["cx","cy","rx","ry"];break;case"foreignObject":case"rect":case"image":u=["width","height","x","y"];break;case"use":case"text":case"tspan":u=["x","y"];break;case"polygon":case"polyline":(d={}).points=r.getAttribute("points");var c=(Tt=r.points).numberOfItems;for(v.points=new Array(c),nt=0;nt<c;++nt){var p=Tt.getItem(nt);v.points[nt]={x:p.x,y:p.y}}break;case"path":(d={}).d=r.getAttribute("d"),v.d=r.getAttribute("d")}if(u.length?(v=$(r).attr(u),$.each(v,(function(t,e){v[t]=svgedit.units.convertToNum(t,e)}))):g&&(v={x:$(g).attr("x")||0,y:$(g).attr("y")||0}),null==d&&(d=$.extend(!0,{},v),$.each(d,(function(t,e){d[t]=svgedit.units.convertToNum(t,e)}))),d.transform=t.getStartTransform()||"","g"==r.tagName&&!g||"a"==r.tagName){var I={x:(mt=svgedit.utilities.getBBox(r)).x+mt.width/2,y:mt.y+mt.height/2},x=svgedit.math.transformPoint(mt.x+mt.width/2,mt.y+mt.height/2,svgedit.math.transformListToTransform(i).matrix),h=(f=s.createSVGMatrix(),svgedit.utilities.getRotationAngle(r));if(h){var T=h*Math.PI/180;if(Math.abs(T)>1e-10)var y=Math.sin(T)/(1-Math.cos(T));else y=2/T;for(nt=0;nt<i.numberOfItems;++nt){if(4==(ot=i.getItem(nt)).type){var b=ot.matrix;I.y=(y*b.e+b.f)/2,I.x=(b.e-y*b.f)/2,i.removeItem(nt);break}}}var S=0,M=0,O=0;if(ft=i.numberOfItems)var A=i.getItem(0).matrix;if(ft>=3&&3==i.getItem(ft-2).type&&2==i.getItem(ft-3).type&&2==i.getItem(ft-1).type){O=3;for(var G=i.getItem(ft-3).matrix,V=i.getItem(ft-2).matrix,L=i.getItem(ft-1).matrix,N=(bt=r.childNodes).length;N--;){if(S=0,M=0,1==(St=bt.item(N)).nodeType){if(!(it=svgedit.transformlist.getTransformList(St)))continue;f=svgedit.math.transformListToTransform(it).matrix;var B=svgedit.utilities.getRotationAngle(St),R=t.getStartTransform(),w=[];if(t.setStartTransform(St.getAttribute("transform")),B||svgedit.math.hasMatrixTransform(it)){(pt=s.createSVGTransform()).setMatrix(svgedit.math.matrixMultiply(G,V,L,f)),it.clear(),it.appendItem(pt),w.push(pt)}else{var k=svgedit.math.matrixMultiply(f.inverse(),L,f),C=s.createSVGMatrix();C.e=-k.e,C.f=-k.f;var D=svgedit.math.matrixMultiply(C.inverse(),f.inverse(),G,V,L,f,k.inverse()),E=s.createSVGTransform(),P=s.createSVGTransform(),j=s.createSVGTransform();E.setTranslate(k.e,k.f),P.setScale(D.a,D.d),j.setTranslate(C.e,C.f),it.appendItem(j),it.appendItem(P),it.appendItem(E),w.push(j),w.push(P),w.push(E)}l.addSubCommand(svgedit.recalculate.recalculateDimensions(St)),t.setStartTransform(R)}}i.removeItem(ft-1),i.removeItem(ft-2),i.removeItem(ft-3)}else if(ft>=3&&1==i.getItem(ft-1).type){O=3,f=svgedit.math.transformListToTransform(i).matrix,(pt=s.createSVGTransform()).setMatrix(f),i.clear(),i.appendItem(pt)}else if((1==ft||ft>1&&3!=i.getItem(1).type)&&2==i.getItem(0).type){O=2;var F=svgedit.math.transformListToTransform(i).matrix;i.removeItem(0);var U=svgedit.math.transformListToTransform(i).matrix.inverse(),H=svgedit.math.matrixMultiply(U,F);if(S=H.e,M=H.f,0!=S||0!=M){N=(bt=r.childNodes).length;for(var W=[];N--;){if(1==(St=bt.item(N)).nodeType){if(St.getAttribute("clip-path")){var q=St.getAttribute("clip-path");-1===W.indexOf(q)&&(svgedit.recalculate.updateClipPath(q,S,M),W.push(q))}R=t.getStartTransform();if(t.setStartTransform(St.getAttribute("transform")),it=svgedit.transformlist.getTransformList(St)){(st=s.createSVGTransform()).setTranslate(S,M),it.numberOfItems?it.insertItemBefore(st,0):it.appendItem(st),l.addSubCommand(svgedit.recalculate.recalculateDimensions(St));for(var z=r.getElementsByTagNameNS(e.SVG,"use"),J="#"+St.id,K=z.length;K--;){var Q=z.item(K);if(J==svgedit.utilities.getHref(Q)){var X=s.createSVGTransform();X.setTranslate(-S,-M),svgedit.transformlist.getTransformList(Q).insertItemBefore(X,0),l.addSubCommand(svgedit.recalculate.recalculateDimensions(Q))}}t.setStartTransform(R)}}}W=[],t.setStartTransform(R)}}else{if(1!=ft||1!=i.getItem(0).type||h){if(h)(yt=s.createSVGTransform()).setRotate(h,x.x,x.y),i.numberOfItems?i.insertItemBefore(yt,0):i.appendItem(yt);return 0==i.numberOfItems&&r.removeAttribute("transform"),null}O=1;for(f=i.getItem(0).matrix,N=(bt=r.childNodes).length;N--;){if(1==(St=bt.item(N)).nodeType){R=t.getStartTransform();if(t.setStartTransform(St.getAttribute("transform")),!(it=svgedit.transformlist.getTransformList(St)))continue;var Y=svgedit.math.matrixMultiply(f,svgedit.math.transformListToTransform(it).matrix),Z=s.createSVGTransform();Z.setMatrix(Y),it.clear(),it.appendItem(Z,0),l.addSubCommand(svgedit.recalculate.recalculateDimensions(St)),t.setStartTransform(R);var _=St.getAttribute("stroke-width");if("none"!==St.getAttribute("stroke")&&!isNaN(_)){var tt=(Math.abs(Y.a)+Math.abs(Y.d))/2;St.setAttribute("stroke-width",_*tt)}}}i.clear()}if(2==O){if(h)x={x:I.x+A.e,y:I.y+A.f},(yt=s.createSVGTransform()).setRotate(h,x.x,x.y),i.numberOfItems?i.insertItemBefore(yt,0):i.appendItem(yt)}else if(3==O){f=svgedit.math.transformListToTransform(i).matrix;(Ot=s.createSVGTransform()).setRotate(h,I.x,I.y);var et=Ot.matrix;(At=s.createSVGTransform()).setRotate(h,x.x,x.y);var rt=At.matrix.inverse(),at=f.inverse();if(S=(Gt=svgedit.math.matrixMultiply(at,rt,et,f)).e,M=Gt.f,0!=S||0!=M)for(N=(bt=r.childNodes).length;N--;){if(1==(St=bt.item(N)).nodeType){R=t.getStartTransform();t.setStartTransform(St.getAttribute("transform"));var st,it=svgedit.transformlist.getTransformList(St);(st=s.createSVGTransform()).setTranslate(S,M),it.numberOfItems?it.insertItemBefore(st,0):it.appendItem(st),l.addSubCommand(svgedit.recalculate.recalculateDimensions(St)),t.setStartTransform(R)}}h&&(i.numberOfItems?i.insertItemBefore(At,0):i.appendItem(At))}}else{var mt;if(!(mt=svgedit.utilities.getBBox(r))&&"path"!=r.tagName)return null;f=s.createSVGMatrix();if(B=svgedit.utilities.getRotationAngle(r)){I={x:mt.x+mt.width/2,y:mt.y+mt.height/2},x=svgedit.math.transformPoint(mt.x+mt.width/2,mt.y+mt.height/2,svgedit.math.transformListToTransform(i).matrix),T=B*Math.PI/180;if(Math.abs(T)>1e-10)y=Math.sin(T)/(1-Math.cos(T));else y=2/T;for(var nt=0;nt<i.numberOfItems;++nt){var ot;if(4==(ot=i.getItem(nt)).type){b=ot.matrix;I.y=(y*b.e+b.f)/2,I.x=(b.e-y*b.f)/2,i.removeItem(nt);break}}}O=0;var ft=i.numberOfItems;if(!svgedit.browser.isWebkit()){var gt=r.getAttribute("fill");if(gt&&0===gt.indexOf("url(")){var lt=getRefElem(gt),vt="pattern";if(lt.tagName!==vt&&(vt="gradient"),"userSpaceOnUse"===lt.getAttribute(vt+"Units")){f=svgedit.math.transformListToTransform(i).matrix;var dt=svgedit.transformlist.getTransformList(lt),ut=svgedit.math.transformListToTransform(dt).matrix,ct="matrix("+[(f=svgedit.math.matrixMultiply(f,ut)).a,f.b,f.c,f.d,f.e,f.f].join(",")+")";lt.setAttribute(vt+"Transform",ct)}}}if(ft>=3&&3==i.getItem(ft-2).type&&2==i.getItem(ft-3).type&&2==i.getItem(ft-1).type)O=3,f=svgedit.math.transformListToTransform(i,ft-3,ft-1).matrix,i.removeItem(ft-1),i.removeItem(ft-2),i.removeItem(ft-3);else if(4==ft&&1==i.getItem(ft-1).type){var pt;O=3,f=svgedit.math.transformListToTransform(i).matrix,(pt=s.createSVGTransform()).setMatrix(f),i.clear(),i.appendItem(pt),f=s.createSVGMatrix()}else if((1==ft||ft>1&&3!=i.getItem(1).type)&&2==i.getItem(0).type){O=2;var It=i.getItem(0).matrix,xt=svgedit.math.transformListToTransform(i,1).matrix,ht=xt.inverse();f=svgedit.math.matrixMultiply(ht,It,xt),i.removeItem(0)}else{if(1!=ft||1!=i.getItem(0).type||B){if(O=4,B)(yt=s.createSVGTransform()).setRotate(B,x.x,x.y),i.numberOfItems?i.insertItemBefore(yt,0):i.appendItem(yt);return 0==i.numberOfItems&&r.removeAttribute("transform"),null}switch(f=svgedit.math.transformListToTransform(i).matrix,r.tagName){case"line":v=$(r).attr(["x1","y1","x2","y2"]);case"polyline":case"polygon":if(v.points=r.getAttribute("points"),v.points){var Tt;c=(Tt=r.points).numberOfItems;v.points=new Array(c);for(nt=0;nt<c;++nt){p=Tt.getItem(nt);v.points[nt]={x:p.x,y:p.y}}}case"path":v.d=r.getAttribute("d"),O=1,i.clear()}}if(1!=O&&2!=O&&3!=O||svgedit.coords.remapElement(r,v,f),2==O){var yt;if(B)svgedit.math.hasMatrixTransform(i)||(x={x:I.x+f.e,y:I.y+f.f}),(yt=s.createSVGTransform()).setRotate(B,x.x,x.y),i.numberOfItems?i.insertItemBefore(yt,0):i.appendItem(yt);if("text"==r.tagName){var bt;for(N=(bt=r.childNodes).length;N--;){var St;if("tspan"==(St=bt.item(N)).tagName){var Mt={x:$(St).attr("x")||0,y:$(St).attr("y")||0};svgedit.coords.remapElement(St,Mt,f)}}}}else if(3==O&&B){var Ot;f=svgedit.math.transformListToTransform(i).matrix;(Ot=s.createSVGTransform()).setRotate(B,I.x,I.y);var At;et=Ot.matrix;(At=s.createSVGTransform()).setRotate(B,x.x,x.y);rt=At.matrix.inverse(),at=f.inverse();var Gt=svgedit.math.matrixMultiply(at,rt,et,f);svgedit.coords.remapElement(r,v,Gt),B&&(i.numberOfItems?i.insertItemBefore(At,0):i.appendItem(At))}}return 0==i.numberOfItems&&r.removeAttribute("transform"),l.addSubCommand(new svgedit.history.ChangeElementCommand(r,d)),l}}();
13
+ !function(){"use strict";var t,e,i,s,a,n,r;svgedit.path||(svgedit.path={});var h=svgedit.NS,p="Drag node to move it. Double-click node to change segment type",g="Drag control point to adjust curve properties",o={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"]},d=[],l=!0,v={};svgedit.path.setLinkControlPoints=function(t){l=t},svgedit.path.path=null,t=null,svgedit.path.init=function(e){t=e,d=[0,"ClosePath"],$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(t,e){d.push(e+"Abs"),d.push(e+"Rel")}))},svgedit.path.insertItemBefore=function(t,e,i){var s,a,n,r,h=t.pathSegList;if(svgedit.browser.supportsPathInsertItemBefore())h.insertItemBefore(e,i);else{for(s=h.numberOfItems,a=[],n=0;n<s;n++)r=h.getItem(n),a.push(r);for(h.clear(),n=0;n<s;n++)n==i&&h.appendItem(e),h.appendItem(a[n])}},svgedit.path.ptObjToArr=function(t,e){for(var i=o[t],s=i.length,a=[],n=0;n<s;n++)a[n]=e[i[n]];return a},svgedit.path.getGripPt=function(e,i){var s={x:i?i.x:e.item.x,y:i?i.y:e.item.y},a=e.path;return a.matrix&&(s=svgedit.math.transformPoint(s.x,s.y,a.matrix)),s.x*=t.getCurrentZoom(),s.y*=t.getCurrentZoom(),s},svgedit.path.getPointFromGrip=function(e,i){var s={x:e.x,y:e.y};return i.matrix&&(e=svgedit.math.transformPoint(s.x,s.y,i.imatrix),s.x=e.x,s.y=e.y),s.x/=t.getCurrentZoom(),s.y/=t.getCurrentZoom(),s},svgedit.path.addPointGrip=function(t,e,i){var s=svgedit.path.getGripContainer(),a=svgedit.utilities.getElem("pathpointgrip_"+t);return a||(a=document.createElementNS(h.SVG,"circle"),svgedit.utilities.assignAttributes(a,{id:"pathpointgrip_"+t,display:"none",r:4,fill:"#0FF",stroke:"#00F","stroke-width":2,cursor:"move",style:"pointer-events:all","xlink:title":p}),a=s.appendChild(a),$("#pathpointgrip_"+t).dblclick((function(){svgedit.path.path&&svgedit.path.path.setSegType()}))),e&&i&&svgedit.utilities.assignAttributes(a,{cx:e,cy:i,display:"inline"}),a},svgedit.path.getGripContainer=function(){var t=svgedit.utilities.getElem("pathpointgrip_container");return t||((t=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS(h.SVG,"g"))).id="pathpointgrip_container"),t},svgedit.path.addCtrlGrip=function(t){var e=svgedit.utilities.getElem("ctrlpointgrip_"+t);return e||(e=document.createElementNS(h.SVG,"circle"),svgedit.utilities.assignAttributes(e,{id:"ctrlpointgrip_"+t,display:"none",r:4,fill:"#0FF",stroke:"#55F","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":g}),svgedit.path.getGripContainer().appendChild(e),e)},svgedit.path.getCtrlLine=function(t){var e=svgedit.utilities.getElem("ctrlLine_"+t);return e||(e=document.createElementNS(h.SVG,"line"),svgedit.utilities.assignAttributes(e,{id:"ctrlLine_"+t,stroke:"#555","stroke-width":1,style:"pointer-events:none"}),svgedit.path.getGripContainer().appendChild(e),e)},svgedit.path.getPointGrip=function(t,e){var i,s=t.index,a=svgedit.path.addPointGrip(s);return e&&(i=svgedit.path.getGripPt(t),svgedit.utilities.assignAttributes(a,{cx:i.x,cy:i.y,display:"inline"})),a},svgedit.path.getControlPoints=function(t){var e,i=t.item,s=t.index;if(!("x1"in i)||!("x2"in i))return null;for(var a={},n=(svgedit.path.getGripContainer(),[svgedit.path.path.segs[s-1].item,i]),r=1;r<3;r++){var h=s+"c"+r,p=a["c"+r+"_line"]=svgedit.path.getCtrlLine(h),g=svgedit.path.getGripPt(t,{x:i["x"+r],y:i["y"+r]}),o=svgedit.path.getGripPt(t,{x:n[r-1].x,y:n[r-1].y});svgedit.utilities.assignAttributes(p,{x1:g.x,y1:g.y,x2:o.x,y2:o.y,display:"inline"}),a["c"+r+"_line"]=p,e=a["c"+r]=svgedit.path.addCtrlGrip(h),svgedit.utilities.assignAttributes(e,{cx:g.x,cy:g.y,display:"inline"}),a["c"+r]=e}return a},svgedit.path.replacePathSeg=function(t,e,i,s){var a,n=s||svgedit.path.path.elem,r=n["createSVGPathSeg"+d[t]].apply(n,i);if(svgedit.browser.supportsPathReplaceItem())n.pathSegList.replaceItem(r,e);else{for(var h=n.pathSegList,p=h.numberOfItems,g=[],o=0;o<p;o++)a=h.getItem(o),g.push(a);for(h.clear(),o=0;o<p;o++)o==e?h.appendItem(r):h.appendItem(g[o])}},svgedit.path.getSegSelector=function(t,e){var i,s,a,n,r,p=t.index,g=svgedit.utilities.getElem("segline_"+p);if(g||(i=svgedit.path.getGripContainer(),g=document.createElementNS(h.SVG,"path"),svgedit.utilities.assignAttributes(g,{id:"segline_"+p,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"}),i.appendChild(g)),e){if(!(s=t.prev))return g.setAttribute("display","none"),g;for(a=svgedit.path.getGripPt(s),svgedit.path.replacePathSeg(2,0,[a.x,a.y],g),n=svgedit.path.ptObjToArr(t.type,t.item,!0),r=0;r<n.length;r+=2)a=svgedit.path.getGripPt(t,{x:n[r],y:n[r+1]}),n[r]=a.x,n[r+1]=a.y;svgedit.path.replacePathSeg(t.type,1,n,g)}return g},svgedit.path.smoothControlPoints=function(e,i,s){var a,n,r,h,p=e.x-s.x,g=e.y-s.y,o=i.x-s.x,d=i.y-s.y;if(!(0==p&&0==g||0==o&&0==d)){var l=Math.atan2(g,p),v=Math.atan2(d,o),c=Math.sqrt(p*p+g*g),u=Math.sqrt(o*o+d*d),m=t.getSVGRoot().createSVGPoint(),y=t.getSVGRoot().createSVGPoint();return l<0&&(l+=2*Math.PI),v<0&&(v+=2*Math.PI),a=Math.abs(l-v),n=Math.abs(Math.PI-a)/2,l-v>0?(r=a<Math.PI?l+n:l-n,h=a<Math.PI?v-n:v+n):(r=a<Math.PI?l-n:l+n,h=a<Math.PI?v+n:v-n),m.x=c*Math.cos(r)+s.x,m.y=c*Math.sin(r)+s.y,y.x=u*Math.cos(h)+s.x,y.y=u*Math.sin(h)+s.y,[m,y]}},svgedit.path.Segment=function(t,e){this.selected=!1,this.index=t,this.item=e,this.type=e.pathSegType,this.ctrlpts=[],this.ptgrip=null,this.segsel=null},svgedit.path.Segment.prototype.showCtrlPts=function(t){for(var e in this.ctrlpts)this.ctrlpts.hasOwnProperty(e)&&this.ctrlpts[e].setAttribute("display",t?"inline":"none")},svgedit.path.Segment.prototype.selectCtrls=function(t){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill",t?"#0FF":"#EEE")},svgedit.path.Segment.prototype.show=function(t){this.ptgrip&&(this.ptgrip.setAttribute("display",t?"inline":"none"),this.segsel.setAttribute("display",t?"inline":"none"),this.showCtrlPts(t))},svgedit.path.Segment.prototype.select=function(t){this.ptgrip&&(this.ptgrip.setAttribute("stroke",t?"#0FF":"#00F"),this.segsel.setAttribute("display",t?"inline":"none"),this.ctrlpts&&this.selectCtrls(t),this.selected=t)},svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,!0),this.ctrlpts=svgedit.path.getControlPoints(this,!0),this.segsel=svgedit.path.getSegSelector(this,!0)},svgedit.path.Segment.prototype.update=function(t){if(this.ptgrip){var e=svgedit.path.getGripPt(this);svgedit.utilities.assignAttributes(this.ptgrip,{cx:e.x,cy:e.y}),svgedit.path.getSegSelector(this,!0),this.ctrlpts&&(t&&(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(t,e){var i,s,a,n,r=this.item,h=$.extend({},r);i=this.ctrlpts?[h.x+=t,h.y+=e,h.x1,h.y1,h.x2+=t,h.y2+=e]:[h.x+=t,h.y+=e],svgedit.path.replacePathSeg(this.type,this.index,i),this.next&&this.next.ctrlpts&&(a=[(s=this.next.item).x,s.y,s.x1+=t,s.y1+=e,s.x2,s.y2],svgedit.path.replacePathSeg(this.next.type,this.next.index,a)),this.mate&&(n=[(r=this.mate.item).x+=t,r.y+=e],svgedit.path.replacePathSeg(this.mate.type,this.mate.index,n)),this.update(!0),this.next&&this.next.update(!0)},svgedit.path.Segment.prototype.setLinked=function(t){var e,i,s,a,n,r;if(2==t){if(i=1,!(e=this.next))return;s=this.item}else{if(i=2,!(e=this.prev))return;s=e.item}a=e.item,(n=$.extend({},a))["x"+i]=s.x+(s.x-this.item["x"+t]),n["y"+i]=s.y+(s.y-this.item["y"+t]),r=[n.x,n.y,n.x1,n.y1,n.x2,n.y2],svgedit.path.replacePathSeg(e.type,e.index,r),e.update(!0)},svgedit.path.Segment.prototype.moveCtrl=function(t,e,i){var s,a=this.item,n=$.extend({},a);n["x"+t]+=e,n["y"+t]+=i,s=[n.x,n.y,n.x1,n.y1,n.x2,n.y2],svgedit.path.replacePathSeg(this.type,this.index,s),this.update(!0)},svgedit.path.Segment.prototype.setType=function(t,e){svgedit.path.replacePathSeg(t,this.index,e),this.type=t,this.item=svgedit.path.path.elem.pathSegList.getItem(this.index),this.showCtrlPts(6===t),this.ctrlpts=svgedit.path.getControlPoints(this),this.update(!0)},svgedit.path.Path=function(t){if(!t||"path"!==t.tagName)throw"svgedit.path.Path constructed without a <path> element";this.elem=t,this.segs=[],this.selected_pts=[],svgedit.path.path=this,this.init()},svgedit.path.Path.prototype.init=function(){var t,e,i,s,a,n,r;for($(svgedit.path.getGripContainer()).find("*").each((function(){$(this).attr("display","none")})),e=(t=this.elem.pathSegList).numberOfItems,this.segs=[],this.selected_pts=[],this.first_seg=null,i=0;i<e;i++)s=t.getItem(i),(a=new svgedit.path.Segment(i,s)).path=this,this.segs.push(a);for(n=this.segs,r=null,i=0;i<e;i++){var h,p=n[i],g=i+1>=e?null:n[i+1],o=i-1<0?null:n[i-1];2===p.type?(o&&1!==o.type&&((h=n[r]).next=n[r+1],h.next.prev=h,h.addGrip()),r=i):g&&1===g.type?(p.next=n[r+1],p.next.prev=p,p.mate=n[r],p.addGrip(),null==this.first_seg&&(this.first_seg=p)):g?1!==p.type&&(p.addGrip(),g&&2!==g.type&&(p.next=g,p.next.prev=p)):1!==p.type&&((h=n[r]).next=n[r+1],h.next.prev=h,h.addGrip(),p.addGrip(),this.first_seg||(this.first_seg=n[r]))}return this},svgedit.path.Path.prototype.eachSeg=function(t){for(var e=this.segs.length,i=0;i<e&&!1!==t.call(this.segs[i],i);i++);},svgedit.path.Path.prototype.addSeg=function(t){var e,i,s,a,n,r=this.segs[t];if(r.prev){switch(e=r.prev,r.item.pathSegType){case 4:s=(r.item.x+e.item.x)/2,a=(r.item.y+e.item.y)/2,i=this.elem.createSVGPathSegLinetoAbs(s,a);break;case 6:var h=(e.item.x+r.item.x1)/2,p=(r.item.x1+r.item.x2)/2,g=(r.item.x2+r.item.x)/2,o=(h+p)/2,d=(p+g)/2;s=(o+d)/2;var l=(e.item.y+r.item.y1)/2,v=(r.item.y1+r.item.y2)/2,c=(r.item.y2+r.item.y)/2,u=(l+v)/2,m=(v+c)/2;a=(u+m)/2,i=this.elem.createSVGPathSegCurvetoCubicAbs(s,a,h,l,o,u),n=[r.item.x,r.item.y,d,m,g,c],svgedit.path.replacePathSeg(r.type,t,n)}svgedit.path.insertItemBefore(this.elem,i,t)}},svgedit.path.Path.prototype.deleteSeg=function(t){var e,i,s=this.segs[t],a=this.elem.pathSegList;s.show(!1),e=s.next,s.mate?(i=[e.item.x,e.item.y],svgedit.path.replacePathSeg(2,e.index,i),svgedit.path.replacePathSeg(4,s.index,i),a.removeItem(s.mate.index)):(s.prev||(s.item,i=[e.item.x,e.item.y],svgedit.path.replacePathSeg(2,s.next.index,i)),a.removeItem(t))},svgedit.path.Path.prototype.subpathIsClosed=function(t){var e=!1;return svgedit.path.path.eachSeg((function(i){return i<=t||2!==this.type&&(1===this.type?(e=!0,!1):void 0)})),e},svgedit.path.Path.prototype.removePtFromSelection=function(t){var e=this.selected_pts.indexOf(t);-1!=e&&(this.segs[t].select(!1),this.selected_pts.splice(e,1))},svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg((function(){this.select(!1)})),this.selected_pts=[]},svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")},svgedit.path.Path.prototype.show=function(t){return this.eachSeg((function(){this.show(t)})),t&&this.selectPt(this.first_seg.index),this},svgedit.path.Path.prototype.movePts=function(t,e){for(var i=this.selected_pts.length;i--;)this.segs[this.selected_pts[i]].move(t,e)},svgedit.path.Path.prototype.moveCtrl=function(t,e){var i=this.segs[this.selected_pts[0]];i.moveCtrl(this.dragctrl,t,e),l&&i.setLinked(this.dragctrl)},svgedit.path.Path.prototype.setSegType=function(t){var e,i,s;for(this.storeD(),e=this.selected_pts.length;e--;){var a=this.selected_pts[e],n=this.segs[a],r=n.prev;if(r){t||(i="Toggle Path Segment Type",t=6==n.type?4:6),t=Number(t);var h,p=n.item.x,g=n.item.y,o=r.item.x,d=r.item.y;switch(t){case 6:if(n.olditem)h=[p,g,(s=n.olditem).x1,s.y1,s.x2,s.y2];else{var l=p-o,v=g-d;h=[p,g,o+l/3,d+v/3,p-l/3,g-v/3]}break;case 4:h=[p,g],n.olditem=n.item}n.setType(t,h)}}svgedit.path.path.endChanges(i)},svgedit.path.Path.prototype.selectPt=function(t,e){this.clearSelection(),null==t&&this.eachSeg((function(e){this.prev&&(t=e)})),this.addPtsToSelection(t),e&&(this.dragctrl=e,l&&this.segs[t].setLinked(e))},svgedit.path.Path.prototype.update=function(){var t=this.elem;return svgedit.utilities.getRotationAngle(t)?(this.matrix=svgedit.math.getMatrix(t),this.imatrix=this.matrix.inverse()):(this.matrix=null,this.imatrix=null),this.eachSeg((function(e){this.item=t.pathSegList.getItem(e),this.update()})),this},svgedit.path.getPath_=function(t){var e=v[t.id];return e||(e=v[t.id]=new svgedit.path.Path(t)),e},svgedit.path.removePath_=function(t){t in v&&delete v[t]},r=function(t,r){var h=t-s,p=r-a,g=Math.sqrt(h*h+p*p),o=Math.atan2(p,h)+n;return h=g*Math.cos(o)+s,p=g*Math.sin(o)+a,h-=e,p-=i,g=Math.sqrt(h*h+p*p),o=Math.atan2(p,h)-n,{x:g*Math.cos(o)+e,y:g*Math.sin(o)+i}},svgedit.path.recalcRotatedPath=function(){var t,h,p,g,o,d,l,v,c,u,m,y,x=svgedit.path.path.elem;if(n=svgedit.utilities.getRotationAngle(x,!0)){t=svgedit.utilities.getBBox(x),h=svgedit.path.path.oldbbox,s=h.x+h.width/2,a=h.y+h.height/2,e=t.x+t.width/2,i=t.y+t.height/2;var f=e-s,S=i-a,P=Math.sqrt(f*f+S*S),C=Math.atan2(S,f)+n;for(e=P*Math.cos(C)+s,i=P*Math.sin(C)+a,g=(p=x.pathSegList).numberOfItems;g;)g-=1,1!=(d=(o=p.getItem(g)).pathSegType)&&(v=[(l=r(o.x,o.y)).x,l.y],null!=o.x1&&null!=o.x2&&(c=r(o.x1,o.y1),u=r(o.x2,o.y2),v.splice(v.length,0,c.x,c.y,u.x,u.y)),svgedit.path.replacePathSeg(d,g,v));t=svgedit.utilities.getBBox(x),m=svgroot.createSVGTransform(),y=svgedit.transformlist.getTransformList(x),m.setRotate(180*n/Math.PI,e,i),y.replaceItem(m,0)}},svgedit.path.clearData=function(){v={}}}();
14
+ var mydraw=function(){"use strict";return{initDraw:function(){svgedit.draw||(svgedit.draw={});var e=svgedit.NS,t="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),r=1,i=2,n=0;svgedit.draw.Layer=function(e,t){this.name_=e,this.group_=t},svgedit.draw.Layer.prototype.getName=function(){return this.name_},svgedit.draw.Layer.prototype.getGroup=function(){return this.group_},svgedit.draw.randomizeIds=function(e,t){(n=!1===e?i:r)!=r||t.getNonce()?n==i&&t.getNonce()&&t.clearNonce():t.setNonce(Math.floor(100001*Math.random()))},svgedit.draw.Drawing=function(t,s){if(!t||!t.tagName||!t.namespaceURI||"svg"!=t.tagName||t.namespaceURI!=e.SVG)throw"Error: draw.Drawing instance initialized without a <svg> element";this.svgElem_=t,this.obj_num=0,this.idPrefix=s||"svg_",this.releasedNums=[],this.all_layers=[],this.current_layer=null,this.nonce_="";var a=this.svgElem_.getAttributeNS(e.SE,"nonce");a&&n!=i?this.nonce_=a:n==r&&this.setNonce(Math.floor(100001*Math.random()))},svgedit.draw.Drawing.prototype.getElem_=function(e){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+e):$(this.svgElem_).find("[id="+e+"]")[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(t){this.svgElem_.setAttributeNS(e.XMLNS,"xmlns:se",e.SE),this.svgElem_.setAttributeNS(e.SE,"se:nonce",t),this.nonce_=t},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 e,t,r="";for(e=0;e<16;e++)t=16*Math.random()|0,8==e&&(r+="-"),r+=(12==e?4:16==e?3&t|8:t).toString(16);return this.obj_num=r,this.getId()},svgedit.draw.Drawing.prototype.releaseId=function(e){var t=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if("string"!=typeof e||0!==e.indexOf(t))return!1;var r=parseInt(e.substr(t.length),10);return!("number"!=typeof r||r<=0||-1!=this.releasedNums.indexOf(r)||(this.releasedNums.push(r),0))},svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length},svgedit.draw.Drawing.prototype.hasLayer=function(e){var t;for(t=0;t<this.getNumLayers();t++)if(this.all_layers[t][0]==e)return!0;return!1},svgedit.draw.Drawing.prototype.getLayerName=function(e){return e>=0&&e<this.getNumLayers()?this.all_layers[e][0]:""},svgedit.draw.Drawing.prototype.getCurrentLayer=function(){return this.current_layer},svgedit.draw.Drawing.prototype.getCurrentLayerName=function(){var e;for(e=0;e<this.getNumLayers();++e)if(this.all_layers[e][1]==this.current_layer)return this.getLayerName(e);return""},svgedit.draw.Drawing.prototype.setCurrentLayer=function(e){var t;for(t=0;t<this.getNumLayers();++t)if(e==this.getLayerName(t))return this.current_layer!=this.all_layers[t][1]&&(this.current_layer.setAttribute("style","pointer-events:none"),this.current_layer=this.all_layers[t][1],this.current_layer.setAttribute("style","pointer-events:all")),!0;return!1},svgedit.draw.Drawing.prototype.deleteCurrentLayer=function(){if(this.current_layer&&this.getNumLayers()>1){var e=this.current_layer.parentNode,t=(this.current_layer.nextSibling,e.removeChild(this.current_layer));return this.identifyLayers(),t}return null},svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];var r,i=this.svgElem_.childNodes.length,n=[],s=[],a=null,o=!1;for(r=0;r<i;++r){var l=this.svgElem_.childNodes.item(r);if(l&&1==l.nodeType)if("g"==l.tagName){o=!0;var u=$("title",l).text();!u&&svgedit.browser.isOpera()&&l.querySelectorAll&&(u=$(l.querySelectorAll("title")).text()),u?(s.push(u),this.all_layers.push([u,l]),a=l,svgedit.utilities.walkTree(l,(function(e){e.parentNode&&"foreignObject"===e.parentNode.nodeName||e.setAttribute("style","pointer-events:inherit")})),a.setAttribute("style","pointer-events:none")):n.push(l)}else~t.indexOf(l.nodeName)&&(svgedit.utilities.getBBox(l),n.push(l))}var g=this.svgElem_.ownerDocument;if(n.length>0||!o){for(r=1;s.indexOf("Layer "+r)>=0;)r++;var d="Layer "+r;a=g.createElementNS(e.SVG,"g");var y,h=g.createElementNS(e.SVG,"title");for(h.textContent=d,a.appendChild(h),y=0;y<n.length;++y)a.appendChild(n[y]);this.svgElem_.appendChild(a),this.all_layers.push([d,a])}svgedit.utilities.walkTree(a,(function(e){e.parentNode&&"foreignObject"===e.parentNode.nodeName||e.setAttribute("style","pointer-events:inherit")})),this.current_layer=a,this.current_layer.setAttribute("style","pointer-events:all")},svgedit.draw.Drawing.prototype.createLayer=function(t){var r=this.svgElem_.ownerDocument,i=r.createElementNS(e.SVG,"g"),n=r.createElementNS(e.SVG,"title");return n.textContent=t,i.appendChild(n),this.svgElem_.appendChild(i),this.identifyLayers(),i},svgedit.draw.Drawing.prototype.getLayerVisibility=function(e){var t,r=null;for(t=0;t<this.getNumLayers();++t)if(this.getLayerName(t)==e){r=this.all_layers[t][1];break}return!!r&&"none"!==r.getAttribute("display")},svgedit.draw.Drawing.prototype.setLayerVisibility=function(e,t){if("boolean"!=typeof t)return null;var r,i=null;for(r=0;r<this.getNumLayers();++r)if(this.getLayerName(r)==e){i=this.all_layers[r][1];break}if(!i)return null;var n=i.getAttribute("display");return n||(n="inline"),i.setAttribute("display",t?"inline":"none"),i},svgedit.draw.Drawing.prototype.getLayerOpacity=function(e){var t;for(t=0;t<this.getNumLayers();++t)if(this.getLayerName(t)==e){var r=this.all_layers[t][1].getAttribute("opacity");return r||(r="1.0"),parseFloat(r)}return null},svgedit.draw.Drawing.prototype.setLayerOpacity=function(e,t){var r;if(!("number"!=typeof t||t<0||t>1))for(r=0;r<this.getNumLayers();++r)if(this.getLayerName(r)==e){this.all_layers[r][1].setAttribute("opacity",t);break}}}}}();
15
+ var svgedit=svgedit||{};window.initContextmenu=function(){var n=this;svgedit.contextmenu||(svgedit.contextmenu={}),n.contextMenuExtensions={},svgEditor.ready((function(){var n;for(n in contextMenuExtensions)contextMenuExtensions[n]})),svgedit.contextmenu.resetCustomMenus=function(){n.contextMenuExtensions={}},svgedit.contextmenu.add=function(e){return function(n){return n&&n.id&&n.label&&n.action&&"function"==typeof n.action}(e)?e.id in n.contextMenuExtensions?void console.error('Cannot add extension "'+e.id+'", an extension by that name already exists"'):(console.log("Registed contextmenu item: {id:"+e.id+", label:"+e.label+"}"),void(n.contextMenuExtensions[e.id]=e)):void console.error("Menu items must be defined and have at least properties: id, label, action, where action must be a function")},svgedit.contextmenu.hasCustomHandler=function(e){return n.contextMenuExtensions[e]&&!0},svgedit.contextmenu.getCustomHandler=function(e){return n.contextMenuExtensions[e].action}};
16
+ var mysvgcanvas={initSvgCanvas:function(n){window.console||(window.console={},window.console.log=function(n){},window.console.dir=function(n){}),window.opera&&(window.console.log=function(n){opera.postError(n)},window.console.dir=function(n){})}};$.SvgCanvas=function(n,o){function i(){De();var n=[],o={feGaussianBlur:le.exportNoBlur,foreignObject:le.exportNoforeignObject,"[stroke-dasharray]":le.exportNoDashArray},g=$(w);return"font"in $("<canvas>")[0].getContext("2d")||(o.text=le.exportNoText),$.each(o,(function(o,m){g.find(o).length&&n.push(m)})),n}var g=svgedit.NS,m={show_outside_canvas:!0,selectNew:!0,dimensions:[640,480]};o&&$.extend(m,o);var c=m.dimensions,v=this,f=[],p=!1,b=new Date(17578008e5),S=n.ownerDocument,C=S.importNode(svgedit.utilities.text2xml('<svg id="svgroot" xmlns="'+g.SVG+'" xlinkns="'+g.XLINK+'" width="'+c[0]+'" height="'+c[1]+'" x="'+c[0]+'" y="'+c[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,!0);n.appendChild(C);var w=S.createElementNS(g.SVG,"svg"),_=v.clearSvgContentElement=function(){for(;w.firstChild;)w.removeChild(w.firstChild);$(w).attr({id:"svgcontent",width:c[0],height:c[1],x:c[0],y:c[1],overflow:m.show_outside_canvas?"visible":"hidden",xmlns:g.SVG,"xmlns:se":g.SE,"xmlns:xlink":g.XLINK}).appendTo(C);var n=S.createComment(" Created with wux-editor ");w.appendChild(n)};_();var N="svg_";v.setIdPrefix=function(n){N=n},v.current_drawing_=new svgedit.draw.Drawing(w,N);var A=v.getCurrentDrawing=function(){return v.current_drawing_},k=1,E=null,B={shape:{fill:("none"==m.initFill.color?"":"#")+m.initFill.color,fill_paint:null,fill_opacity:m.initFill.opacity,stroke:"#"+m.initStroke.color,stroke_paint:null,stroke_opacity:m.initStroke.opacity,stroke_width:m.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:m.initOpacity}};B.text=$.extend(!0,{},B.shape),$.extend(B.text,{fill:"#000000",stroke_width:0,font_size:14,font_family:"sans-serif",text_anchor:"middle"});var T=B.shape,I=new Array(1),M=this.addSvgElementFromJson=function(n){var o=svgedit.utilities.getElem(n.attr.id),m=A().getCurrentLayer();return o&&n.element!=o.tagName&&(m.removeChild(o),o=null),o||(o=S.createElementNS(g.SVG,n.element),m&&(E||m).appendChild(o)),n.curStyles&&svgedit.utilities.assignAttributes(o,{fill:T.fill,stroke:T.stroke,"stroke-width":T.stroke_width,"stroke-dasharray":T.stroke_dasharray,"stroke-linejoin":T.stroke_linejoin,"stroke-linecap":T.stroke_linecap,"stroke-opacity":T.stroke_opacity,"fill-opacity":T.fill_opacity,opacity:T.opacity/2,style:"pointer-events:inherit"},100),svgedit.utilities.assignAttributes(o,n.attr,100),svgedit.utilities.cleanupElement(o),o},L=this.addSvgGroupFromJson=function(n){var o=svgedit.utilities.getElem(n.id),m=A().getCurrentLayer();o&&n.group!=o.tagName&&(m.removeChild(o),o=null),o||((o=S.createElementNS(g.SVG,n.group)).setAttribute("id",n.id),o.setAttribute("type",n.type),m&&(E||m).appendChild(o));for(var c=0;c<n.elements.length;c++){var v=S.createElementNS(g.SVG,n.elements[c].type);if(svgedit.utilities.assignAttributes(v,{"stroke-width":T.stroke_width,"stroke-dasharray":T.stroke_dasharray,"stroke-linejoin":T.stroke_linejoin,"stroke-linecap":T.stroke_linecap,style:"pointer-events:inherit"},100),svgedit.utilities.assignAttributes(v,n.elements[c].attr),"text"===n.elements[c].type)v.textContent=n.elements[c].content;else if("foreignObject"===n.elements[c].type){var f=n.elements[c].content;if(f)for(var p=0;p<f.length;p++){var x=document.createElement(f[p].tag);if(x.tagName=x.tagName.toLowerCase(),"select"===x.tagName.toLowerCase()){var b=document.createElement("option");b.setAttribute("test"," "),x.appendChild(b)}else"button"===x.tagName.toLowerCase()?x.innerHTML="button":"span"===x.tagName.toLowerCase()&&(f[p].value&&(x.innerHTML=f[p].value),f[p].attr&&svgedit.utilities.assignAttributes(x,f[p].attr));svgedit.utilities.assignAttributes(x,f[p].attr),f[p].style&&x.setAttribute("style",f[p].style),"input"===x.tagName.toLowerCase()&&(x.style.backgroundColor=T.fill,x.style.color=T.stroke),v.appendChild(x)}}o.appendChild(v)}return n.curStyles&&svgedit.utilities.assignAttributes(o,{fill:T.fill,stroke:T.stroke,"stroke-width":T.stroke_width,"stroke-dasharray":T.stroke_dasharray,"stroke-linejoin":T.stroke_linejoin,"stroke-linecap":T.stroke_linecap,style:"pointer-events:inherit"},100),svgedit.utilities.assignAttributes(o,n.attr,100),svgedit.utilities.cleanupElement(o),Z("onGaugeAdded",{id:n.id,type:n.type}),o},O=(v.getTransformList=svgedit.transformlist.getTransformList,svgedit.math.transformPoint),D=v.matrixMultiply=svgedit.math.matrixMultiply,V=v.hasMatrixTransform=svgedit.math.hasMatrixTransform,R=v.transformListToTransform=svgedit.math.transformListToTransform;svgedit.math.snapToAngle,svgedit.math.getMatrix,svgedit.units.init({getBaseUnit:function(){return m.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return w.getAttribute("height")/k},getWidth:function(){return w.getAttribute("width")/k},getRoundDigits:function(){return save_options.round_digits}}),v.convertToNum=svgedit.units.convertToNum,svgedit.utilities.init({getDOMDocument:function(){return S},getDOMContainer:function(){return n},getSVGRoot:function(){return C},getSelectedElements:function(){return I},getSVGContent:function(){return w},getBaseUnit:function(){return m.baseUnit},getSnappingStep:function(){return m.snappingStep}});var U=v.findDefs=svgedit.utilities.findDefs,z=v.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,F=v.getHref=svgedit.utilities.getHref,j=v.setHref=svgedit.utilities.setHref,H=svgedit.utilities.getPathBBox,q=(v.getBBox=svgedit.utilities.getBBox,v.getRotationAngle=svgedit.utilities.getRotationAngle,v.getElem=svgedit.utilities.getElem),W=(v.getRefElem=svgedit.utilities.getRefElem,v.assignAttributes=svgedit.utilities.assignAttributes),K=this.cleanupElement=svgedit.utilities.cleanupElement;svgedit.coords.init({getDrawing:function(){return A()},getGridSnapping:function(){return m.gridSnapping}});var Y=this.remapElement=svgedit.coords.remapElement;svgedit.recalculate.init({getSVGRoot:function(){return C},getStartTransform:function(){return startTransform},setStartTransform:function(n){startTransform=n}});var Z,J=this.recalculateDimensions=svgedit.recalculate.recalculateDimensions,Q=svgedit.getReverseNS(),ee=v.sanitizeSvg=svgedit.sanitize.sanitizeSvg,te=svgedit.history.MoveElementCommand,re=svgedit.history.InsertElementCommand,ne=svgedit.history.RemoveElementCommand,ae=svgedit.history.ChangeElementCommand,se=svgedit.history.BatchCommand;v.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(n,o){var g=svgedit.history.HistoryEventTypes;if(n==g.BEFORE_UNAPPLY||n==g.BEFORE_APPLY)v.clearSelection();else if(n==g.AFTER_APPLY||n==g.AFTER_UNAPPLY){var m=o.elements();v.pathActions.clear(),Z("changed",m);var c=o.type(),f=n==g.AFTER_APPLY;if(c==te.type())(f?o.newParent:o.oldParent)==w&&v.identifyLayers();else if(c==re.type()||c==ne.type())o.parent==w&&v.identifyLayers(),c==re.type()?f&&ie(o.elem):f||ie(o.elem),"use"===o.elem.tagName&&We(o.elem);else if(c==ae.type()){"title"==o.elem.tagName&&o.elem.parentNode.parentNode==w&&v.identifyLayers();var p=f?o.newValues:o.oldValues;p.stdDeviation&&v.setBlurOffsets(o.elem.parentNode,p.stdDeviation)}}}});var X=function(n){v.undoMgr.addCommandToHistory(n)};svgedit.select.init(m,{createSVGElement:function(n){return v.addSvgElementFromJson(n)},svgRoot:function(){return C},svgContent:function(){return w},currentZoom:function(){return k},getStrokedBBox:function(n){return v.getStrokedBBox([n])}});var oe=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return k},getSVGRoot:function(){return C}});var le={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"},de="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use",ue=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],ge=$.data,he=document.createElementNS(g.SVG,"animate");$(he).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(C);var ie=function(n){var o,g,m,c=$(n).attr(ue);for(o in c){var v=c[o];if(v&&0===v.indexOf("url(")){var f=svgedit.utilities.getUrlFromAttr(v).substr(1);q(f)||(svgedit.utilities.findDefs().appendChild(removedElements[f]),delete removedElements[f])}}var p=n.getElementsByTagName("*");if(p.length)for(g=0,m=p.length;g<m;g++)ie(p[g])},me={},ce="";last_good_img_content="",disabled_elems=[],save_options={round_digits:5},started=!1,startTransform=null,current_mode="select",current_resize_mode="none",import_ids={},cur_text=B.text,cur_properties=T,justSelected=null,rubberBox=null,curBBoxes=[],extensions={},lastClickPoint=null,removedElements={},v.clipBoard=[];var ve=this.runExtensions=function(n,o,g){var m=!!g&&[];return $.each(extensions,(function(c,v){if(v)if(n in v){if(g)m.push(v[n](o));else if(m=v[n](o),("mouseMove"===n||"mouseUp"===n)&&m){var f=svgedit.utilities.getBBox(o.selected);Z("onGaugeResized",{id:m,size:f})}}else"mouseUp"===n&&o&&o.selected&&"toResize"in v&&(f=svgedit.utilities.getBBox(o.selected),Z("onGaugeResized",{id:o.selected.id,size:f}))})),m},fe=this.setSpecialsIds=function(n,o){f=n},pe=this.runGetExtensions=function(n,o){var g=!1;return $.each(extensions,(function(m,c){if(c&&n in c){let m=c[n](o);m&&(g=m)}})),g},ye=this.runExtension=function(n,o,g){var m=!1;return extensions[n]&&(m=extensions[n][o](g)),m};this.addExtension=function(n,o){var g;n in extensions?console.log('Cannot add extension "'+n+'", an extension by that name already exists.'):(g=$.isFunction(o)?o($.extend(v.getPrivateMethods(),{svgroot:C,svgcontent:w,nonce:A().getNonce(),selectorManager:oe})):o,extensions[n]=g,Z("extension_added",g))},this.clickExtension=function(n){if(n in extensions){var o=extensions[n];o.buttons&&o.buttons[0]&&o.buttons[0].events&&o.buttons[0].events.click()}};var xe=this.round=function(n){return parseInt(n*k,10)/k},we=this.getIntersectionList=function(n){if(null==rubberBox)return null;var o=E||A().getCurrentLayer();curBBoxes.length||(curBBoxes=Me(o));var g=null;try{g=o.getIntersectionList(n,null)}catch(n){}if(null==g||"function"!=typeof g.item){var m;if(g=[],n)m=n;else{m=rubberBox.getBBox();var c,v={};for(c in m)v[c]=m[c]/k;m=v}for(var f=curBBoxes.length;f--;)m.width&&svgedit.math.rectsIntersect(m,curBBoxes[f].bbox)&&g.push(curBBoxes[f].elem)}return g};getStrokedBBox=this.getStrokedBBox=function(n){if(n||(n=Ie()),!n.length)return!1;var o,i=function(n){try{var o=svgedit.utilities.getBBox(n),m=svgedit.utilities.getRotationAngle(n);if(m&&m%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(n))){var c=!1;if(["ellipse","path","line","polyline","polygon"].indexOf(n.tagName)>=0)o=c=v.convertToPath(n,!0);else if("rect"==n.tagName){var f=n.getAttribute("rx"),p=n.getAttribute("ry");(f||p)&&(o=c=v.convertToPath(n,!0))}if(!c){var x=n.cloneNode(!0),b=document.createElementNS(g.SVG,"g"),S=n.parentNode;S.appendChild(b),b.appendChild(x),o=svgedit.utilities.bboxToObj(b.getBBox()),S.removeChild(b)}}return o}catch(o){return console.log(n,o),null}};if($.each(n,(function(){o||this.parentNode&&(o=i(this))})),null==o)return null;var m=o.x+o.width,c=o.y+o.height,f=o.x,p=o.y,d=function(n){var o=n.getAttribute("stroke-width"),g=0;return"none"==n.getAttribute("stroke")||isNaN(o)||(g+=o/2),g},x=[];return $.each(n,(function(n,o){var g=i(o);if(g){var m=d(o);f=Math.min(f,g.x-m),p=Math.min(p,g.y-m),x.push(g)}})),o.x=f,o.y=p,$.each(n,(function(n,o){var g=x[n];if(g&&1==o.nodeType){var v=d(o);m=Math.max(m,g.x+g.width+v),c=Math.max(c,g.y+g.height+v)}})),o.width=m-f,o.height=c-p,o};var _e,Ae,ke,Ee,Be,Te,Ie=this.getVisibleElements=function(n){n||(n=$(w).children());var o=[];return $(n).children().each((function(n,g){try{g.getBBox()&&o.push(g)}catch(n){}})),o.reverse()},Me=this.getVisibleElementsAndBBoxes=function(n){n||(n=$(w).children());var o=[];return $(n).children().each((function(n,g){try{g.getBBox()&&o.push({elem:g,bbox:getStrokedBBox([g])})}catch(n){}})),o.reverse()},Le=this.groupSvgElem=function(n){var o=document.createElementNS(g.SVG,"g");n.parentNode.replaceChild(o,n),$(o).append(n).data("gsvg",n)[0].id=Ae()},be=function(n){var o=document.createElementNS(n.namespaceURI,n.nodeName),m=n.parentNode;(m&&"foreignObject"===m.nodeName||m&&m.parentNode&&"foreignObject"===m.parentNode.nodeName)&&((o=document.createElement(n.nodeName)).tagName=o.tagName.toLowerCase()),$.each(n.attributes,(function(n,m){"-moz-math-font-style"!=m.localName&&("image"===o.tagName&&"xlink:"===m.nodeName.substr(0,6)||"use"===o.tagName&&"xlink:"===m.nodeName.substr(0,6)?o.setAttributeNS(g.XLINK,"xlink:href",m.value):o.setAttribute(m.nodeName,m.value))}));var c=o.getAttribute("id");if(c){var v=c.slice(0,1+c.indexOf("_"));o.removeAttribute("id"),o.id=Ae(),v!==N&&(o.id=o.id.replace(N,v))}if(svgedit.browser.isWebkit()&&"path"==n.nodeName){var f=Ee.convertPath(n);o.setAttribute("d",f)}if($.each(n.childNodes,(function(n,g){switch(g.nodeType){case 1:o.appendChild(be(g));break;case 3:o.textContent=g.nodeValue}})),$(n).data("gsvg"))$(o).data("gsvg",o.firstChild);else if($(n).data("symbol")){var p=$(n).data("symbol");$(o).data("ref",p).data("symbol",p)}else"image"==o.tagName&&Ge(o);return o};Te={},_e=(Be=v).getId=function(){return A().getId()},Ae=Be.getNextId=function(){return A().getNextId()},Z=Be.call=function(n,o){if(Te[n])return Te[n](this,o)},Be.bind=function(n,o){var g=Te[n];return Te[n]=o,g},this.prepareSvg=function(n){this.sanitizeSvg(n.documentElement);var o,m,c,v=n.getElementsByTagNameNS(g.SVG,"path");for(o=0,c=v.length;o<c;++o)(m=v[o]).setAttribute("d",Ee.convertPath(m)),Ee.fixEnd(m)};var Se=function(n){if(!svgedit.browser.isGecko())return n;var o=n.cloneNode(!0);return n.parentNode.insertBefore(o,n),n.parentNode.removeChild(n),oe.releaseSelector(n),I[0]=o,oe.requestSelector(o).showGrips(!0),o},Ce=function(){Math.floor(2*Math.random())+1===1&&new Date>b&&I[0].parentNode.removeChild(I[0])};this.setRotationAngle=function(n,o){n=parseFloat(n);var g=I[0];if(g){var m=g.getAttribute("transform"),c=svgedit.utilities.getBBox(g),v=c.x+c.width/2,f=c.y+c.height/2,p=svgedit.transformlist.getTransformList(g);if(p.numberOfItems>0)4==p.getItem(0).type&&p.removeItem(0);if(0!=n){var x=svgedit.math.transformPoint(v,f,svgedit.math.transformListToTransform(p).matrix),b=C.createSVGTransform();b.setRotate(n,x.x,x.y),p.numberOfItems?p.insertItemBefore(b,0):p.appendItem(b)}else 0==p.numberOfItems&&g.removeAttribute("transform");if(!o&&-1===g.innerHTML.indexOf("foreignObject")){var S=g.getAttribute("transform");m&&g.setAttribute("transform",m),S&&it("transform",S,I),Z("changed",I)}var w=oe.requestSelector(I[0]);$e(),w.resize(),w.updateGripCursors(n)}};var $e=this.recalculateAllSelectedDimensions=function(){for(var n="none"==current_resize_mode?"position":"size",o=new svgedit.history.BatchCommand(n),g=I.length;g--;){var m=I[g],c=svgedit.recalculate.recalculateDimensions(m);c&&o.addSubCommand(c)}o.isEmpty()||(X(o),Z("changed",I))},Pe=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ne=function(n){console.log([n.a,n.b,n.c,n.d,n.e,n.f])},Oe=null,De=this.clearSelection=function(n){if(null!=I[0]){var o,g,m=I.length;for(o=0;o<m&&null!=(g=I[o]);++o)oe.releaseSelector(g),I[o]=null}n||Z("selected",I)},Ve=this.addToSelection=function(n,o){if(0!=n.length&&(1!=n.length||n[0])){for(var g=0;g<I.length&&null!=I[g];)++g;for(var m=n.length;m--;){var c=n[m];if(c&&svgedit.utilities.getBBox(c)&&("a"===c.tagName&&1===c.childNodes.length&&(c=c.firstChild),-1==I.indexOf(c))){I[g]=c,g++;var v=oe.requestSelector(c);I.length>1&&v.showGrips(!1)}}for(Z("selected",I),o||1==I.length?I[0]&&oe.requestSelector(I[0]).showGrips(!0):I[0]&&oe.requestSelector(I[0]).showGrips(!1),I.sort((function(n,o){return n&&o&&n.compareDocumentPosition?3-(6&o.compareDocumentPosition(n)):null==n?1:void 0}));null==I[0]&&I.length;)I.shift(0)}},Re=this.selectOnly=function(n,o){De(!0),Ve(n,o)};this.removeFromSelection=function(n){if(null!=I[0]&&0!=n.length){var o,g=0,m=[],c=I.length;for(m.length=c,o=0;o<c;++o){var v=I[o];v&&(-1==n.indexOf(v)?(m[g]=v,g++):oe.releaseSelector(v))}I=m}},this.selectAllInCurrentLayer=function(){var n=A().getCurrentLayer();n&&(current_mode="select",Re($(E||n).children()))};var Ue=this.getMouseTarget=function(o){if(null==o)return null;var m=o.target;if(m.correspondingUseElement&&(m=m.correspondingUseElement),[g.MATH,g.HTML].indexOf(m.namespaceURI)>=0&&"svgcanvas"!=m.id)for(;"foreignObject"!=m.nodeName;)if(!(m=m.parentNode))return C;var c=A().getCurrentLayer();if([C,n,w,c].indexOf(m)>=0)return C;if($(m).closest("#selectorParentGroup").length)return oe.selectorParentGroup;for(;m.parentNode!==(E||c);)m=m.parentNode;return m};!function(){var o,g=null,c=null,f=null,b=null,S=null,w={},_={minx:null,miny:null,maxx:null,maxy:null},N=0,B={x:0,y:0},L={x:0,y:0},O={x:0,y:0},D={x:0,y:0},V={x:0,y:0},R={x:0,y:0},G=function(n){var o={x:0,y:0},g=B,m=L,c=O,v=D,f=1/6,p=n*n,x=p*n,b=[[-1,3,-3,1],[3,-6,3,0],[-3,0,3,0],[1,4,1,0]];return o.x=f*((g.x*b[0][0]+m.x*b[0][1]+c.x*b[0][2]+v.x*b[0][3])*x+(g.x*b[1][0]+m.x*b[1][1]+c.x*b[1][2]+v.x*b[1][3])*p+(g.x*b[2][0]+m.x*b[2][1]+c.x*b[2][2]+v.x*b[2][3])*n+(g.x*b[3][0]+m.x*b[3][1]+c.x*b[3][2]+v.x*b[3][3])),o.y=f*((g.y*b[0][0]+m.y*b[0][1]+c.y*b[0][2]+v.y*b[0][3])*x+(g.y*b[1][0]+m.y*b[1][1]+c.y*b[1][2]+v.y*b[1][3])*p+(g.y*b[2][0]+m.y*b[2][1]+c.y*b[2][2]+v.y*b[2][3])*n+(g.y*b[3][0]+m.y*b[3][1]+c.y*b[3][2]+v.y*b[3][3])),{x:o.x,y:o.y}};$(n).mousedown((function(n){if(!v.spaceKey&&1!==n.button){var o=2===n.button;Oe=$("#svgcontent g")[0].getScreenCTM().inverse();var p=svgedit.math.transformPoint(n.pageX,n.pageY,Oe),x=p.x*k,N=p.y*k;n.preventDefault(),o&&(current_mode="select",lastClickPoint=p);var A=x/k,E=N/k,B=Ue(n);"a"===B.tagName&&1===B.childNodes.length&&(B=B.firstChild);var L=A;b=c=A;var D=E;if(S=f=E,m.gridSnapping&&(A=svgedit.utilities.snapToGrid(A),E=svgedit.utilities.snapToGrid(E),c=svgedit.utilities.snapToGrid(c),f=svgedit.utilities.snapToGrid(f)),B==oe.selectorParentGroup&&null!=I[0]){var V=n.target,R=ge(V,"type");"rotate"==R?current_mode="rotate":"resize"==R&&(current_mode="resize",current_resize_mode=ge(V,"dir")),B=I[0]}startTransform=B.getAttribute("transform");var U,z,F=svgedit.transformlist.getTransformList(B);switch(current_mode){case"select":if(started=!0,current_resize_mode="none",o&&(started=!1),B!=C){if(-1==I.indexOf(B)&&(n.shiftKey||De(!0),Ve([B]),justSelected=B,Ee.clear()),!o)for(U=0;U<I.length;++U)if(null!=I[U]){var H=svgedit.transformlist.getTransformList(I[U]);H.numberOfItems?H.insertItemBefore(C.createSVGTransform(),0):H.appendItem(C.createSVGTransform())}}else o||(De(),current_mode="multiselect",null==rubberBox&&(rubberBox=oe.getRubberBandBox()),b*=k,S*=k,svgedit.utilities.assignAttributes(rubberBox,{x:b,y:S,width:0,height:0,display:"inline"},100));break;case"zoom":started=!0,null==rubberBox&&(rubberBox=oe.getRubberBandBox()),svgedit.utilities.assignAttributes(rubberBox,{x:L*k,y:L*k,width:0,height:0,display:"inline"},100);break;case"resize":started=!0,c=A,f=E,w=svgedit.utilities.getBBox($("#selectedBox0")[0]);var q={};$.each(w,(function(n,o){q[n]=o/k})),w=q;var W=svgedit.utilities.getRotationAngle(B)?1:0;if(svgedit.math.hasMatrixTransform(F))F.insertItemBefore(C.createSVGTransform(),W),F.insertItemBefore(C.createSVGTransform(),W),F.insertItemBefore(C.createSVGTransform(),W);else if(F.appendItem(C.createSVGTransform()),F.appendItem(C.createSVGTransform()),F.appendItem(C.createSVGTransform()),svgedit.browser.supportsNonScalingStroke()){var K=svgedit.browser.isWebkit();if(K)var P=function(n){var o=n.getAttributeNS(null,"stroke");n.removeAttributeNS(null,"stroke"),setTimeout((function(){n.setAttributeNS(null,"stroke",o)}),0)};B.style.vectorEffect="non-scaling-stroke",K&&P(B);var Y=B.getElementsByTagName("*"),Z=Y.length;for(U=0;U<Z;U++)Y[U].style.vectorEffect="non-scaling-stroke",K&&P(Y[U])}break;case"fhellipse":case"fhrect":case"fhpath":O.x=L,O.y=D,started=!0,g=L+","+D+" ",z=0==T.stroke_width?1:T.stroke_width,M({element:"polyline",curStyles:!0,attr:{points:g,id:Ae(),fill:"none",opacity:T.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}}),_.minx=L,_.maxx=L,_.miny=D,_.maxy=D;break;case"image":started=!0;var J=M({element:"image",attr:{x:A,y:E,width:0,height:0,id:Ae(),opacity:T.opacity/2,style:"pointer-events:inherit"}});j(J,ce),Ge(J);break;case"svg-image":started=!0,c=A,f=E;break;case"square":case"rect":started=!0,c=A,f=E,M({element:"rect",curStyles:!0,attr:{x:A,y:E,width:0,height:0,id:Ae(),opacity:T.opacity/2}});break;case"line":started=!0,z=0==T.stroke_width?1:T.stroke_width,M({element:"line",curStyles:!0,attr:{x1:A,y1:E,x2:A,y2:E,id:Ae(),stroke:T.stroke,"stroke-width":z,"stroke-dasharray":T.stroke_dasharray,"stroke-linejoin":T.stroke_linejoin,"stroke-linecap":T.stroke_linecap,"stroke-opacity":T.stroke_opacity,fill:"none",opacity:T.opacity/2,style:"pointer-events:none"}});break;case"circle":started=!0,M({element:"circle",curStyles:!0,attr:{cx:A,cy:E,r:0,id:Ae(),opacity:T.opacity/2}});break;case"ellipse":started=!0,M({element:"ellipse",curStyles:!0,attr:{cx:A,cy:E,rx:0,ry:0,id:Ae(),opacity:T.opacity/2}});break;case"text":started=!0,M({element:"text",curStyles:!0,attr:{x:A,y:E,id:Ae(),fill:cur_text.fill,"stroke-width":cur_text.stroke_width,"font-size":cur_text.font_size,"font-family":cur_text.font_family,"text-anchor":"middle","xml:space":"preserve",opacity:T.opacity}});break;case"pipe":case"path":case"pathedit":c*=k,f*=k,Ee.mouseDown(n,B,c,f),started=!0;break;case"textedit":c*=k,f*=k,ke.mouseDown(n,B,c,f),started=!0;break;case"rotate":started=!0,v.undoMgr.beginUndoableChange("transform",I)}var Q=ve("mouseDown",{event:n,start_x:c,start_y:f,selectedElements:I},!0);$.each(Q,(function(n,o){o&&o.started&&(started=!0)}))}})).mousemove((function(n){if(started&&1!==n.button&&!v.spaceKey){var A,E,T,M,U,z,F,j,H,q,W=I[0],K=svgedit.math.transformPoint(n.pageX,n.pageY,Oe),Y=K.x*k,J=K.y*k,Q=svgedit.utilities.getElem(_e()),ee=Y/k;x=ee;var te=J/k;if(y=te,m.gridSnapping&&(x=svgedit.utilities.snapToGrid(x),y=svgedit.utilities.snapToGrid(y)),!W||!p){var re;switch(n.preventDefault(),current_mode){case"select":if(null!==I[0]&&(z=x-c,F=y-f,m.gridSnapping&&(z=svgedit.utilities.snapToGrid(z),F=svgedit.utilities.snapToGrid(F)),n.shiftKey&&(E=svgedit.math.snapToAngle(c,f,x,y),x=E.x,y=E.y),0!=z||0!=F)){for(j=I.length,A=0;A<j&&null!=(W=I[A]);++A){var ne=C.createSVGTransform();re=svgedit.transformlist.getTransformList(W),ne.setTranslate(z,F),re.numberOfItems?re.replaceItem(ne,0):re.appendItem(ne),oe.requestSelector(W).resize()}Z("transition",I)}break;case"multiselect":ee*=k,te*=k,svgedit.utilities.assignAttributes(rubberBox,{x:Math.min(b,ee),y:Math.min(S,te),width:Math.abs(ee-b),height:Math.abs(te-S)},100);var ae=[],se=[],le=we();for(j=I.length,A=0;A<j;++A){var de=le.indexOf(I[A]);-1==de?ae.push(I[A]):le[de]=null}for(j=le.length,A=0;A<j;++A)le[A]&&se.push(le[A]);ae.length>0&&v.removeFromSelection(ae),se.length>0&&Ve(se);break;case"resize":re=svgedit.transformlist.getTransformList(W);var ue=svgedit.math.hasMatrixTransform(re),ge=(q=ue?w:svgedit.utilities.getBBox(W)).x,he=q.y,me=q.width,ce=q.height;if(z=x-c,F=y-f,m.gridSnapping&&(z=svgedit.utilities.snapToGrid(z),F=svgedit.utilities.snapToGrid(F),ce=svgedit.utilities.snapToGrid(ce),me=svgedit.utilities.snapToGrid(me)),H=svgedit.utilities.getRotationAngle(W)){var fe=Math.sqrt(z*z+F*F),pe=Math.atan2(F,z)-H*Math.PI/180;z=fe*Math.cos(pe),F=fe*Math.sin(pe)}-1==current_resize_mode.indexOf("n")&&-1==current_resize_mode.indexOf("s")&&(F=0),-1==current_resize_mode.indexOf("e")&&-1==current_resize_mode.indexOf("w")&&(z=0);var ye=0,xe=0,Ae=ce?(ce+F)/ce:1,Be=me?(me+z)/me:1;current_resize_mode.indexOf("n")>=0&&(Ae=ce?(ce-F)/ce:1,xe=ce),current_resize_mode.indexOf("w")>=0&&(Be=me?(me-z)/me:1,ye=me);var Te=C.createSVGTransform(),Ie=C.createSVGTransform(),Me=C.createSVGTransform();if(m.gridSnapping&&(ge=svgedit.utilities.snapToGrid(ge),ye=svgedit.utilities.snapToGrid(ye),he=svgedit.utilities.snapToGrid(he),xe=svgedit.utilities.snapToGrid(xe)),Te.setTranslate(-(ge+ye),-(he+xe)),n.shiftKey&&(1==Be?Be=Ae:Ae=Be),Ie.setScale(Be,Ae),Me.setTranslate(ge+ye,he+xe),ue){var Le=H?1:0;re.replaceItem(Te,2+Le),re.replaceItem(Ie,1+Le),re.replaceItem(Me,Number(Le))}else{var $e=re.numberOfItems;re.replaceItem(Me,$e-3),re.replaceItem(Ie,$e-2),re.replaceItem(Te,$e-1)}oe.requestSelector(W).resize(),Z("transition",I);break;case"zoom":ee*=k,te*=k,svgedit.utilities.assignAttributes(rubberBox,{x:Math.min(b*k,ee),y:Math.min(S*k,te),width:Math.abs(ee-b*k),height:Math.abs(te-S*k)},100);break;case"text":svgedit.utilities.assignAttributes(Q,{x:x,y:y},1e3);break;case"line":var Pe=null;window.opera||C.suspendRedraw(1e3),m.gridSnapping&&(x=svgedit.utilities.snapToGrid(x),y=svgedit.utilities.snapToGrid(y));var De=x,Re=y;n.shiftKey&&(De=(E=svgedit.math.snapToAngle(c,f,De,Re)).x,Re=E.y),Q.setAttributeNS(null,"x2",De),Q.setAttributeNS(null,"y2",Re),window.opera||C.unsuspendRedraw(Pe);break;case"foreignObject":case"square":case"rect":case"image":var Ue,ze,je="square"==current_mode||n.shiftKey,We=Math.abs(x-c),Ke=Math.abs(y-f);je?(We=Ke=Math.max(We,Ke),Ue=c<x?c:c-We,ze=f<y?f:f-Ke):(Ue=Math.min(c,x),ze=Math.min(f,y)),m.gridSnapping&&(We=svgedit.utilities.snapToGrid(We),Ke=svgedit.utilities.snapToGrid(Ke),Ue=svgedit.utilities.snapToGrid(Ue),ze=svgedit.utilities.snapToGrid(ze)),svgedit.utilities.assignAttributes(Q,{width:We,height:Ke,x:Ue,y:ze},1e3);break;case"circle":M=(T=$(Q).attr(["cx","cy"])).cx,U=T.cy;var Xe=Math.sqrt((x-M)*(x-M)+(y-U)*(y-U));m.gridSnapping&&(Xe=svgedit.utilities.snapToGrid(Xe)),Q.setAttributeNS(null,"r",Xe);break;case"ellipse":M=(T=$(Q).attr(["cx","cy"])).cx,U=T.cy,Pe=null,window.opera||C.suspendRedraw(1e3),m.gridSnapping&&(x=svgedit.utilities.snapToGrid(x),M=svgedit.utilities.snapToGrid(M),y=svgedit.utilities.snapToGrid(y),U=svgedit.utilities.snapToGrid(U)),Q.setAttributeNS(null,"rx",Math.abs(x-M));var Ye=Math.abs(n.shiftKey?x-M:y-U);Q.setAttributeNS(null,"ry",Ye),window.opera||C.unsuspendRedraw(Pe);break;case"fhellipse":case"fhrect":_.minx=Math.min(ee,_.minx),_.maxx=Math.max(ee,_.maxx),_.miny=Math.min(te,_.miny),_.maxy=Math.max(te,_.maxy);case"fhpath":if(D.x=ee,D.y=te,B.x&&B.y)for(A=0;A<9;A++)o=A/10,V=G((A+1)/10),R=V,V=G(o),(N+=Math.sqrt((R.x-V.x)*(R.x-V.x)+(R.y-V.y)*(R.y-V.y)))>.8&&(g+=+V.x+","+V.y+" ",Q.setAttributeNS(null,"points",g),N-=.8);B={x:L.x,y:L.y},L={x:O.x,y:O.y},O={x:D.x,y:D.y};break;case"pipe":case"path":case"pathedit":if(x*=k,y*=k,m.gridSnapping&&(x=svgedit.utilities.snapToGrid(x),y=svgedit.utilities.snapToGrid(y),c=svgedit.utilities.snapToGrid(c),f=svgedit.utilities.snapToGrid(f)),n.shiftKey){var Ze,Je,Qe=svgedit.path.path;Qe?(Ze=Qe.dragging?Qe.dragging[0]:c,Je=Qe.dragging?Qe.dragging[1]:f):(Ze=c,Je=f),E=svgedit.math.snapToAngle(Ze,Je,x,y),x=E.x,y=E.y}rubberBox&&"none"!==rubberBox.getAttribute("display")&&(ee*=k,te*=k,svgedit.utilities.assignAttributes(rubberBox,{x:Math.min(b*k,ee),y:Math.min(S*k,te),width:Math.abs(ee-b*k),height:Math.abs(te-S*k)},100)),Ee.mouseMove(x,y);break;case"textedit":x*=k,y*=k,ke.mouseMove(Y,J);break;case"rotate":M=(q=svgedit.utilities.getBBox(W)).x+q.width/2,U=q.y+q.height/2;var et=svgedit.math.getMatrix(W),tt=svgedit.math.transformPoint(M,U,et);if(M=tt.x,U=tt.y,H=(Math.atan2(U-y,M-x)*(180/Math.PI)-90)%360,m.gridSnapping&&(H=svgedit.utilities.snapToGrid(H)),n.shiftKey){H=45*Math.round(H/45)}v.setRotationAngle(H<-180?360+H:H,!0),Z("transition",I)}ve("mouseMove",{event:n,mouse_x:Y,mouse_y:J,selected:W})}}})).click((function(n){return n.preventDefault(),!1})).dblclick((function(n){var o=n.target.parentNode;if(o!==E){var g=Ue(n),m=g.tagName;if("text"===m&&"textedit"!==current_mode){var c=svgedit.math.transformPoint(n.pageX,n.pageY,Oe);ke.select(g,c.x,c.y)}"g"!==m&&"a"!==m||!svgedit.utilities.getRotationAngle(g)||(rt(g),g=I[0],De(!0)),E&&Ze(),"g"!==o.tagName&&"a"!==o.tagName||o===A().getCurrentLayer()||g===oe.selectorParentGroup||Je(g)}})).mouseup((function(n){if(2!==n.button){var o=justSelected;if(justSelected=null,started){var g,p,x=svgedit.math.transformPoint(n.pageX,n.pageY,Oe),C=x.x*k,w=x.y*k,E=C/k,V=w/k,R=svgedit.utilities.getElem(_e()),U=!1,z=E,F=V;switch(started=!1,current_mode){case"resize":case"multiselect":null!=rubberBox&&(rubberBox.setAttribute("display","none"),curBBoxes=[]),current_mode="select";case"select":if(null!=I[0]){var j=I[0],H=!1;if(null==I[1]){switch(H=!0,j.tagName){case"g":case"use":case"image":case"foreignObject":break;default:"svg-ext-pipe"!=j.getAttribute("type")&&(cur_properties.fill=j.getAttribute("fill"),cur_properties.fill_opacity=j.getAttribute("fill-opacity"),cur_properties.stroke=j.getAttribute("stroke"),cur_properties.stroke_opacity=j.getAttribute("stroke-opacity"),cur_properties.stroke_width=j.getAttribute("stroke-width"),cur_properties.stroke_dasharray=j.getAttribute("stroke-dasharray"),cur_properties.stroke_linejoin=j.getAttribute("stroke-linejoin"),cur_properties.stroke_linecap=j.getAttribute("stroke-linecap"))}"text"==j.tagName&&(cur_text.font_size=j.getAttribute("font-size"),cur_text.font_family=j.getAttribute("font-family"),cur_text.text_anchor=j.getAttribute("text-anchor")),oe.requestSelector(j).showGrips(!0)}if(window.svgEditorSwitch&&Ce(),$e(),j&&H){var q=svgedit.utilities.getRotationAngle(j);v.setRotationAngle(q,!1)}if(z!=b||F!=S){var W,Y=I.length;for(W=0;W<Y&&null!=I[W];++W)I[W].firstChild||oe.requestSelector(I[W]).resize()}else p=n.target,"path"===I[0].nodeName&&null==I[1]?Ee.select(I[0]):n.shiftKey&&o!=p&&v.removeFromSelection([p]);if(svgedit.browser.supportsNonScalingStroke()){var J=I[0];J&&(J.removeAttribute("style"),svgedit.utilities.walkTree(J,(function(n){let o=n,g=!1;for(;o.parentNode;)"foreignObject"===o.parentNode.tagName&&(g=!0),o=o.parentNode;g||n.parentElement&&"foreignObject"===n.parentElement.nodeName||n.removeAttribute("style")})))}var Q=ve("mouseUp",{event:n,mouse_x:C,mouse_y:w,selected:I[0]})}return;case"zoom":null!=rubberBox&&rubberBox.setAttribute("display","none");var ee=n.shiftKey?.5:2;return void Z("zoomed",{x:Math.min(b,z),y:Math.min(S,F),width:Math.abs(z-b),height:Math.abs(F-S),factor:ee});case"fhpath":N=0,B={x:0,y:0},L={x:0,y:0},O={x:0,y:0},D={x:0,y:0};var te=R.getAttribute("points"),re=te.indexOf(",");(U=re>=0?te.indexOf(",",re+1)>=0:te.indexOf(" ",te.indexOf(" ")+1)>=0)&&(R=Ee.smoothPolylineIntoPath(R));break;case"line":g=$(R).attr(["x1","x2","y1","y2"]),U=g.x1!=g.x2||g.y1!=g.y2;break;case"foreignObject":case"square":case"rect":case"image":case"svg-image":g=$(R).attr(["width","height"]),U=0!=g.width||0!=g.height||"image"===current_mode||"svg-image"===current_mode,"svg-image"===current_mode&&v.importSvgString(last_good_img_content,{x:c,y:f});break;case"circle":U=0!=R.getAttribute("r");break;case"ellipse":g=$(R).attr(["rx","ry"]),U=null!=g.rx||null!=g.ry;break;case"fhellipse":_.maxx-_.minx>0&&_.maxy-_.miny>0&&(R=M({element:"ellipse",curStyles:!0,attr:{cx:(_.minx+_.maxx)/2,cy:(_.miny+_.maxy)/2,rx:(_.maxx-_.minx)/2,ry:(_.maxy-_.miny)/2,id:_e()}}),Z("changed",[R]),U=!0);break;case"fhrect":_.maxx-_.minx>0&&_.maxy-_.miny>0&&(R=M({element:"rect",curStyles:!0,attr:{x:_.minx,y:_.miny,width:_.maxx-_.minx,height:_.maxy-_.miny,id:_e()}}),Z("changed",[R]),U=!0);break;case"text":U=!0,Re([R]),ke.start(R);break;case"pipe":case"path":R=null,started=!0;var ne=Ee.mouseUp(n,R,C,w);R=ne.element,U=ne.keep;break;case"pathedit":U=!0,R=null,Ee.mouseUp(n);break;case"textedit":U=!1,R=null,ke.mouseUp(n,C,w);break;case"rotate":U=!0,R=null,current_mode="select";var ae=v.undoMgr.finishUndoableChange();ae.isEmpty()||X(ae),$e(),Z("changed",I)}if(Q=ve("mouseUp",{event:n,mouse_x:C,mouse_y:w},!0),$.each(Q,(function(n,o){o&&(U=o.keep||U,R=o.element,started=o.started||started)})),U||null==R){if(null!=R){v.addedNew=!0;var se,le=.2;if(he.beginElement&&R.getAttribute("opacity")!=T.opacity){se=$(he).clone().attr({to:T.opacity,dur:le}).appendTo(R);try{se[0].beginElement()}catch(n){}}else le=0;setTimeout((function(){se&&se.remove(),R.setAttribute("opacity",T.opacity),R.setAttribute("style","pointer-events:inherit"),K(R),"path"===current_mode||"pipe"===current_mode?Ee.toEditMode(R):m.selectNew&&Re([R],!0),X(new svgedit.history.InsertElementCommand(R)),Z("changed",[R])}),1e3*le)}}else{for(A().releaseId(_e()),R.parentNode.removeChild(R),R=null,p=n.target;"g"==p.parentNode.parentNode.tagName;)p=p.parentNode;("path"==current_mode||"pipe"==current_mode)&&drawn_path||"selectorParentGroup"==p.parentNode.id||"svgcanvas"==p.id||"svgroot"==p.id||(v.setMode("select"),Re([p],!0))}startTransform=null}}})),$(n).bind("mousewheel DOMMouseScroll",(function(n){if(!n.shiftKey)return;const o=k;n.preventDefault();var g=n.originalEvent;Oe=$("#svgcontent g")[0].getScreenCTM().inverse();const m=$("#workarea");var c=svgedit.math.transformPoint(g.pageX,g.pageY,Oe);const v=m.width(),f=m.height(),p=v-0-0,x=f-0-0,b=p*Oe.a,S=x*Oe.d,C=m.offset(),w=C.left+0,_=C.top+0;var N=g.wheelDelta?g.wheelDelta:g.detail?-g.detail:0;if(!N)return;let A,E,B=Math.max(.9,Math.min(10/9,N));B>1?(A=Math.ceil(p/b*B*100)/100,E=Math.ceil(x/S*B*100)/100):(A=Math.floor(p/b*B*100)/100,E=Math.floor(x/S*B*100)/100);let T=Math.min(A,E);if(T===o)return;B=T/o;const I=svgedit.math.transformPoint(w,_,Oe),M=c.x-(c.x-I.x)/B,L=c.y-(c.y-I.y)/B;Z("myZoomed",{center:!1,bbox:{x:M*T-0+v/2,y:L*T-0+f/2,width:0,height:0,factor:B}})}))}();var Ge=function(n){$(n).click((function(n){n.preventDefault()}))};ke=v.textActions=function(){function e(n){var v,x=""===o.value;if($(o).focus(),!arguments.length)if(x)n=0;else{if(o.selectionEnd!==o.selectionStart)return;n=o.selectionEnd}if(v=_[n]){x||o.setSelectionRange(n,n),(m=svgedit.utilities.getElem("text_cursor"))||(m=document.createElementNS(g.SVG,"line"),svgedit.utilities.assignAttributes(m,{id:"text_cursor",stroke:"#333","stroke-width":1}),m=svgedit.utilities.getElem("selectorParentGroup").appendChild(m)),f||(f=setInterval((function(){var n="none"===m.getAttribute("display");m.setAttribute("display",n?"inline":"none")}),600));var b=l(v.x,p.y),S=l(v.x,p.y+p.height);svgedit.utilities.assignAttributes(m,{x1:b.x,y1:b.y,x2:S.x,y2:S.y,visibility:"visible",display:"inline"}),c&&c.setAttribute("d","")}}function t(n,v,f){if(n!==v){f||o.setSelectionRange(n,v),(c=svgedit.utilities.getElem("text_selectblock"))||(c=document.createElementNS(g.SVG,"path"),svgedit.utilities.assignAttributes(c,{id:"text_selectblock",fill:"green",opacity:.5,style:"pointer-events:none"}),svgedit.utilities.getElem("selectorParentGroup").appendChild(c));var x=_[n],b=_[v];m.setAttribute("visibility","hidden");var S=l(x.x,p.y),C=l(x.x+(b.x-x.x),p.y),w=l(x.x,p.y+p.height),N=l(x.x+(b.x-x.x),p.y+p.height),A="M"+S.x+","+S.y+" L"+C.x+","+C.y+" "+N.x+","+N.y+" "+w.x+","+w.y+"z";svgedit.utilities.assignAttributes(c,{d:A,display:"inline"})}else e(v)}function i(o,g){var m=C.createSVGPoint();if(m.x=o,m.y=g,1==_.length)return 0;var c=n.getCharNumAtPosition(m);c<0?(c=_.length-2,o<=_[0].x&&(c=0)):c>=_.length-2&&(c=_.length-2);var v=_[c];return o>v.x+v.width/2&&c++,c}function r(n,o){e(i(n,o))}function a(n,g,m){var c=o.selectionStart,v=i(n,g);t(Math.min(c,v),Math.max(c,v),!m)}function s(n,o){var g={x:n,y:o};if(g.x/=k,g.y/=k,x){var m=svgedit.math.transformPoint(g.x,g.y,x.inverse());g.x=m.x,g.y=m.y}return g}function l(n,o){var g={x:n,y:o};if(x){var m=svgedit.math.transformPoint(g.x,g.y,x);g.x=m.x,g.y=m.y}return g.x*=k,g.y*=k,g}function d(o){t(0,n.textContent.length),$(this).unbind(o)}function u(o){if(w&&n){var g=svgedit.math.transformPoint(o.pageX,o.pageY,Oe),m=s(g.x*k,g.y*k),c=i(m.x,m.y),v=n.textContent,f=v.substr(0,c).replace(/[a-z0-9]+$/i,"").length,p=v.substr(c).match(/^[a-z0-9]+/i);t(f,(p?p[0].length:0)+c),$(o.target).click(d),setTimeout((function(){$(o.target).unbind("click",d)}),300)}}var n,o,m,c,f,p,x,b,S,w,_=[];return{select:function(o,g,m){n=o,ke.toEditMode(g,m)},start:function(o){n=o,ke.toEditMode()},mouseDown:function(n,g,m,c){var v=s(m,c);o.focus(),r(v.x,v.y),b=m,S=c},mouseMove:function(n,o){var g=s(n,o);a(g.x,g.y)},mouseUp:function(o,g,m){var c=s(g,m);a(c.x,c.y,!0),o.target!==n&&g<b+2&&g>b-2&&m<S+2&&m>S-2&&ke.toSelectMode(!0)},setCursor:e,toEditMode:function(o,g){if(w=!1,current_mode="textedit",oe.requestSelector(n).showGrips(!1),oe.requestSelector(n).selectorRect,ke.init(),$(n).css("cursor","text"),arguments.length){var m=s(o,g);r(m.x,m.y)}else e();setTimeout((function(){w=!0}),300)},toSelectMode:function(g){current_mode="select",clearInterval(f),f=null,c&&$(c).attr("display","none"),m&&$(m).attr("visibility","hidden"),$(n).css("cursor","move"),g&&(De(),$(n).css("cursor","move"),Z("selected",[n]),Ve([n],!0)),n&&!n.textContent.length&&v.deleteSelectedElements(),$(o).blur(),n=!1},setInputElem:function(n){o=n},clear:function(){"textedit"==current_mode&&ke.toSelectMode()},init:function(g){if(n){var m,c;n.parentNode||(n=I[0],oe.requestSelector(n).showGrips(!1));var f=n.textContent.length,b=n.getAttribute("transform");for(p=svgedit.utilities.getBBox(n),x=b?svgedit.math.getMatrix(n):null,(_=[]).length=f,o.focus(),$(n).unbind("dblclick",u).dblclick(u),f||(c={x:p.x+p.width/2,width:0}),m=0;m<f;m++){var S=n.getStartPositionOfChar(m);if(c=n.getEndPositionOfChar(m),!svgedit.browser.supportsGoodTextCharPos()){var C=v.contentW*k;S.x-=C,c.x-=C,S.x/=k,c.x/=k}_[m]={x:S.x,y:p.y,width:c.x-S.x,height:p.height}}_.push({x:c.x,width:0}),t(o.selectionStart,o.selectionEnd,!0)}}}}(),Ee=v.pathActions=function(){function t(n){n.setAttribute("d",Ee.convertPath(n))}var o,c,f,p=!1;svgedit.path.Path.prototype.endChanges=function(n){svgedit.browser.isWebkit()&&t(this.elem);var o=new svgedit.history.ChangeElementCommand(this.elem,{d:this.last_d},n);X(o),Z("changed",[this.elem])},svgedit.path.Path.prototype.addPtsToSelection=function(n){var o,g;for($.isArray(n)||(n=[n]),o=0;o<n.length;o++){var m=n[o];(g=this.segs[m]).ptgrip&&-1==this.selected_pts.indexOf(m)&&m>=0&&this.selected_pts.push(m)}this.selected_pts.sort(),o=this.selected_pts.length;var c=[];for(c.length=o;o--;){var v=this.selected_pts[o];(g=this.segs[v]).select(!0),c[o]=g.ptgrip}Ee.canDeleteNodes=!0,Ee.closed_subpath=this.subpathIsClosed(this.selected_pts[0]),Z("selected",c)},o=null;var x=null,b=!1;return{mouseDown:function(o,v,f,b){var S;if("path"!==current_mode&&"pipe"!==current_mode){if(svgedit.path.path){var C;if(svgedit.path.path.storeD(),"pathpointgrip_"==(S=o.target.id).substr(0,14)){C=svgedit.path.path.cur_pt=parseInt(S.substr(14)),svgedit.path.path.dragging=[f,b];var w=svgedit.path.path.segs[C];o.shiftKey?w.selected?svgedit.path.path.removePtFromSelection(C):svgedit.path.path.addPtsToSelection(C):((svgedit.path.path.selected_pts.length<=1||!w.selected)&&svgedit.path.path.clearSelection(),svgedit.path.path.addPtsToSelection(C))}else if(0==S.indexOf("ctrlpointgrip_")){svgedit.path.path.dragging=[f,b];var _=S.split("_")[1].split("c");C=Number(_[0]);var N=Number(_[1]);svgedit.path.path.selectPt(C,N)}svgedit.path.path.dragging||(null==rubberBox&&(rubberBox=oe.getRubberBandBox()),svgedit.utilities.assignAttributes(rubberBox,{x:f*k,y:b*k,width:0,height:0,display:"inline"},100))}}else{mouse_x=f,mouse_y=b;var A=mouse_x/k,E=mouse_y/k,B=svgedit.utilities.getElem("path_stretch_line");c=[A,E],m.gridSnapping&&(A=svgedit.utilities.snapToGrid(A),E=svgedit.utilities.snapToGrid(E),mouse_x=svgedit.utilities.snapToGrid(mouse_x),mouse_y=svgedit.utilities.snapToGrid(mouse_y)),B||(B=document.createElementNS(g.SVG,"path"),svgedit.utilities.assignAttributes(B,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"}),B=svgedit.utilities.getElem("selectorParentGroup").appendChild(B)),B.setAttribute("display","inline");var I;if(x){for(var L=x.pathSegList,O=L.numberOfItems,D=6/k,V=!1;O;){O--;var R=L.getItem(O),U=R.x,z=R.y;if(A>=U-D&&A<=U+D&&E>=z-D&&E<=z+D){V=!0;break}}S=_e(),svgedit.path.removePath_(S);var F,j,H=svgedit.utilities.getElem(S),q=L.numberOfItems;if(V){if(O<=1&&q>=2&&"pipe"!==current_mode){var W=L.getItem(0).x,K=L.getItem(0).y;F=4===(j=B.pathSegList.getItem(1)).pathSegType?x.createSVGPathSegLinetoAbs(W,K):x.createSVGPathSegCurvetoCubicAbs(W,K,j.x1/k,j.y1/k,W,K);var Y=x.createSVGPathSegClosePath();L.appendItem(F),L.appendItem(Y)}else if(q<3&&"pipe"!==current_mode)return!1;if($(B).remove(),element=H,x=null,started=!1,p){svgedit.path.path.matrix&&svgedit.coords.remapElement(H,{},svgedit.path.path.matrix.inverse());var Z=H.getAttribute("d"),J=$(svgedit.path.path.elem).attr("d");return $(svgedit.path.path.elem).attr("d",J+Z),$(H).remove(),svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath(),svgedit.path.path.init(),Ee.toEditMode(svgedit.path.path.elem),svgedit.path.path.selectPt(),!1}}else{if(!$.contains(n,Ue(o)))return console.log("Clicked outside canvas"),!1;var Q=x.pathSegList.numberOfItems,ee=x.pathSegList.getItem(Q-1),te=ee.x,re=ee.y;if(o.shiftKey){var ne=svgedit.math.snapToAngle(te,re,A,E);A=ne.x,E=ne.y}F=4===(j=B.pathSegList.getItem(1)).pathSegType?x.createSVGPathSegLinetoAbs(xe(A),xe(E)):x.createSVGPathSegCurvetoCubicAbs(xe(A),xe(E),j.x1/k,j.y1/k,j.x2/k,j.y2/k),x.pathSegList.appendItem(F),A*=k,E*=k,B.setAttribute("d",["M",A,E,A,E].join(" ")),I=Q,p&&(I+=svgedit.path.path.segs.length),svgedit.path.addPointGrip(I,A,E)}}else{if(d_attr="M"+A+","+E+" ",path_attr={d:d_attr,id:Ae(),opacity:T.opacity/2},"pipe"===current_mode){var ae=Ae().replace("svg_","PIE_");path_attr={d:d_attr,id:ae,type:"svg-ext-pipe",fill:"rgba(0,0,0,0)",stroke:"rgba(41,171,226,1)","stroke-width":10,opacity:T.opacity/2}}x=M({element:"path",curStyles:!0,attr:path_attr}),B.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" ")),I=p?svgedit.path.path.segs.length:0,svgedit.path.addPointGrip(I,mouse_x,mouse_y)}}},mouseMove:function(n,o){if(b=!0,"path"!==current_mode&&"pipe"!==current_mode)if(svgedit.path.path.dragging){var g=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path),m=svgedit.path.getPointFromGrip({x:n,y:o},svgedit.path.path),v=m.x-g.x,p=m.y-g.y;svgedit.path.path.dragging=[n,o],svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(v,p):svgedit.path.path.movePts(v,p)}else svgedit.path.path.selected_pts=[],svgedit.path.path.eachSeg((function(n){var o=this;if(o.next||o.prev){o.item;var g=rubberBox.getBBox(),m=svgedit.path.getGripPt(o),c={x:m.x,y:m.y,width:0,height:0},v=svgedit.math.rectsIntersect(g,c);this.select(v),v&&svgedit.path.path.selected_pts.push(o.index)}}));else{if(!x)return;var S=x.pathSegList,C=S.numberOfItems-1;if(c){var w=svgedit.path.addCtrlGrip("1c1"),_=svgedit.path.addCtrlGrip("0c2");w.setAttribute("cx",n),w.setAttribute("cy",o),w.setAttribute("display","inline");var N=c[0],A=c[1],E=N+(N-(S.getItem(C),n/k)),B=A+(A-o/k);_.setAttribute("cx",E*k),_.setAttribute("cy",B*k),_.setAttribute("display","inline");var T=svgedit.path.getCtrlLine(1);if(svgedit.utilities.assignAttributes(T,{x1:n,y1:o,x2:E*k,y2:B*k,display:"inline"}),0===C)f=[n,o];else{var I=S.getItem(C-1),M=I.x,L=I.y;6===I.pathSegType?(M+=M-I.x2,L+=L-I.y2):f&&(M=f[0]/k,L=f[1]/k),svgedit.path.replacePathSeg(6,C,[N,A,M,L,E,B],x)}}else{var $=svgedit.utilities.getElem("path_stretch_line");if($){var O=S.getItem(C);if(6===O.pathSegType){var D=O.x+(O.x-O.x2),V=O.y+(O.y-O.y2);svgedit.path.replacePathSeg(6,1,[n,o,D*k,V*k,n,o],$)}else f?svgedit.path.replacePathSeg(6,1,[n,o,f[0],f[1],n,o],$):svgedit.path.replacePathSeg(4,1,[n,o],$)}}}},mouseUp:function(n,o,g,m){if("path"===current_mode||"pipe"===current_mode){if(c=null,!x){var v=_e();"pipe"===current_mode&&(v=v.replace("svg_","PIE_")),o=svgedit.utilities.getElem(v),started=!1,f=null}return{keep:!0,element:o}}if(svgedit.path.path.dragging){var p=svgedit.path.path.cur_pt;svgedit.path.path.dragging=!1,svgedit.path.path.dragctrl=!1,svgedit.path.path.update(),b&&svgedit.path.path.endChanges("Move path point(s)"),n.shiftKey||b||svgedit.path.path.selectPt(p)}else rubberBox&&"none"!=rubberBox.getAttribute("display")?(rubberBox.setAttribute("display","none"),rubberBox.getAttribute("width")<=2&&rubberBox.getAttribute("height")<=2&&Ee.toSelectMode(n.target)):Ee.toSelectMode(n.target);b=!1},toEditMode:function(n){svgedit.path.path=svgedit.path.getPath_(n),current_mode="pathedit",De(),svgedit.path.path.show(!0).update(),svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem),p=!1},toSelectMode:function(n){var g=n==svgedit.path.path.elem;current_mode="select",svgedit.path.path.show(!1),o=!1,De(),svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath(),g&&(Z("selected",[n]),Ve([n],!0))},addSubPath:function(n){n?(current_mode="path",p=!0):(Ee.clear(!0),Ee.toEditMode(svgedit.path.path.elem))},select:function(n){o===n?(Ee.toEditMode(n),current_mode="pathedit"):o=n},reorient:function(){var n=I[0];if(n&&0!=svgedit.utilities.getRotationAngle(n)){var o=new svgedit.history.BatchCommand("Reorient path"),g={d:n.getAttribute("d"),transform:n.getAttribute("transform")};o.addSubCommand(new svgedit.history.ChangeElementCommand(n,g)),De(),this.resetOrientation(n),X(o),svgedit.path.getPath_(n).show(!1).matrix=null,this.clear(),Ve([n],!0),Z("changed",I)}},clear:function(n){if(o=null,x){var g=svgedit.utilities.getElem(_e());$(svgedit.utilities.getElem("path_stretch_line")).remove(),$(g).remove(),$(svgedit.utilities.getElem("pathpointgrip_container")).find("*").attr("display","none"),x=f=null,started=!1}else"pathedit"==current_mode&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(!1)},resetOrientation:function(n){if(null==n||"path"!=n.nodeName)return!1;var o=svgedit.transformlist.getTransformList(n),g=svgedit.math.transformListToTransform(o).matrix;o.clear(),n.removeAttribute("transform");var m,c=n.pathSegList,v=c.numberOfItems;for(m=0;m<v;++m){var f=c.getItem(m),p=f.pathSegType;if(1!=p){var x=[];$.each(["",1,2],(function(n,o){var m=f["x"+o],c=f["y"+o];if(void 0!==m&&void 0!==c){var v=svgedit.math.transformPoint(m,c,g);x.splice(x.length,0,v.x,v.y)}})),svgedit.path.replacePathSeg(p,m,x,n)}}!function r(n,o){var g,m=svgedit.utilities.getBBox(n);for(g=0;g<2;g++){var c=0===g?"fill":"stroke",v=n.getAttribute(c);if(v&&0===v.indexOf("url(")){var f=svgedit.utilities.getRefElem(v);if("linearGradient"===f.tagName){var p=f.getAttribute("x1")||0,x=f.getAttribute("y1")||0,b=f.getAttribute("x2")||1,S=f.getAttribute("y2")||0;p=m.width*p+m.x,x=m.height*x+m.y,b=m.width*b+m.x,S=m.height*S+m.y;var C=svgedit.math.transformPoint(p,x,o),w=svgedit.math.transformPoint(b,S,o),_={};_.x1=(C.x-m.x)/m.width,_.y1=(C.y-m.y)/m.height,_.x2=(w.x-m.x)/m.width,_.y2=(w.y-m.y)/m.height;var N=f.cloneNode(!0);$(N).attr(_),N.id=Ae(),svgedit.utilities.findDefs().appendChild(N),n.setAttribute(c,"url(#"+N.id+")")}}}}(n,g)},zoomChange:function(){"pathedit"==current_mode&&svgedit.path.path.update()},getNodePoint:function(){var n=svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1,o=svgedit.path.path.segs[n];return{x:o.item.x,y:o.item.y,type:o.type}},linkControlPoints:function(n){svgedit.path.setLinkControlPoints(n)},clonePathNode:function(){svgedit.path.path.storeD();for(var n=svgedit.path.path.selected_pts,o=(svgedit.path.path.segs,n.length),g=[];o--;){var m=n[o];svgedit.path.path.addSeg(m),g.push(m+o),g.push(m+o+1)}svgedit.path.path.init().addPtsToSelection(g),svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var n=svgedit.path.path.selected_pts;if(1===n.length){var o,g,m,c=svgedit.path.path.elem,v=c.pathSegList,f=(v.numberOfItems,n[0]),p=null,x=null;if(svgedit.path.path.eachSeg((function(n){return 2===this.type&&n<=f&&(x=this.item),n<=f||(2===this.type?(p=n,!1):1===this.type?(p=!1,!1):void 0)})),null==p&&(p=svgedit.path.path.segs.length-1),!1!==p){var b=c.createSVGPathSegLinetoAbs(x.x,x.y),S=c.createSVGPathSegClosePath();return p==svgedit.path.path.segs.length-1?(v.appendItem(b),v.appendItem(S)):(svgedit.path.insertItemBefore(c,S,p),svgedit.path.insertItemBefore(c,b,p)),void svgedit.path.path.init().selectPt(p+1)}if(svgedit.path.path.segs[f].mate)return v.removeItem(f),v.removeItem(f),void svgedit.path.path.init().selectPt(f-1);for(o=0;o<v.numberOfItems;o++){var C=v.getItem(o);if(2===C.pathSegType)g=o;else if(o===f)v.removeItem(g);else if(1===C.pathSegType&&f<o){m=o-1,v.removeItem(o);break}}for(var w=f-g-1;w--;)svgedit.path.insertItemBefore(c,v.getItem(g),m);var _=v.getItem(g);svgedit.path.replacePathSeg(2,g,[_.x,_.y]),o=f,svgedit.path.path.init().selectPt(0)}},deletePathNode:function(){if(Ee.canDeleteNodes){svgedit.path.path.storeD();for(var n=svgedit.path.path.selected_pts,o=n.length;o--;){var g=n[o];svgedit.path.path.deleteSeg(g)}var r=function(){var n=svgedit.path.path.elem.pathSegList,o=n.numberOfItems,i=function(o,g){for(;g--;)n.removeItem(o)};if(o<=1)return!0;for(;o--;){var g=n.getItem(o);if(1===g.pathSegType){var m=n.getItem(o-1),c=n.getItem(o-2);if(2===m.pathSegType){i(o-1,2),r();break}if(2===c.pathSegType){i(o-2,3),r();break}}else if(2===g.pathSegType&&o>0){var v=n.getItem(o-1).pathSegType;if(2===v){i(o-1,1),r();break}if(1===v&&n.numberOfItems-1===o){i(o,1),r();break}}}return!1};if(r(),svgedit.path.path.elem.pathSegList.numberOfItems<=1)return Ee.toSelectMode(svgedit.path.path.elem),void v.deleteSelectedElements();if(svgedit.path.path.init(),svgedit.path.path.clearSelection(),window.opera){var m=$(svgedit.path.path.elem);m.attr("d",m.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(n){var o,g=n.points,m=g.numberOfItems;if(m>=4){var c=g.getItem(0),v=null,f=[];for(f.push(["M",c.x,",",c.y," C"].join("")),o=1;o<=m-4;o+=3){var p=g.getItem(o),x=g.getItem(o+1),b=g.getItem(o+2);if(v){var S=svgedit.path.smoothControlPoints(v,p,c);if(S&&2==S.length){var C=f[f.length-1].split(",");C[2]=S[0].x,C[3]=S[0].y,f[f.length-1]=C.join(","),p=S[1]}}f.push([p.x,p.y,x.x,x.y,b.x,b.y].join(",")),c=b,v=x}for(f.push("L");o<m;){var w=g.getItem(o);f.push([w.x,w.y].join(",")),o++}f=f.join(" "),n=M({element:"path",curStyles:!0,attr:{id:_e(),d:f,fill:"none"}})}return n},setSegType:function(n){svgedit.path.path.setSegType(n)},moveNode:function(n,o){var g=svgedit.path.path.selected_pts;if(g.length){svgedit.path.path.storeD();var m=svgedit.path.path.segs[g[0]],c={x:0,y:0};c[n]=o-m.item[n],m.move(c.x,c.y),svgedit.path.path.endChanges("Move path point")}},fixEnd:function(n){var o,g,m=n.pathSegList,c=m.numberOfItems;for(o=0;o<c;++o){var v=m.getItem(o);if(2===v.pathSegType&&(g=v),1===v.pathSegType){var f=m.getItem(o-1);if(f.x!=g.x||f.y!=g.y){var p=n.createSVGPathSegLinetoAbs(g.x,g.y);svgedit.path.insertItemBefore(n,p,o),Ee.fixEnd(n);break}}}svgedit.browser.isWebkit()&&t(n)},convertPath:function(n,o){var g,m=n.pathSegList,c=0;m?c=m.numberOfItems:console.error(`Problem with path conversion. segList is empty!' ${n}`);var v=0,f=0,p="",x=null;for(g=0;g<c;++g){var b=m.getItem(g),S=b.x||0,C=b.y||0,w=b.x1||0,_=b.y1||0,N=b.x2||0,A=b.y2||0,k=b.pathSegType,E=Pe[k]["to"+(o?"Lower":"Upper")+"Case"](),y=function(n,o,g){o=o?" "+o.join(" "):"",g=g?" "+svgedit.units.shortFloat(g):"",$.each(n,(function(o,g){n[o]=svgedit.units.shortFloat(g)})),p+=E+n.join(" ")+o+g};switch(k){case 1:p+="z";break;case 12:S-=v;case 13:o?(v+=S,E="l"):(v=S+=v,E="L"),y([[S,f]]);break;case 14:C-=f;case 15:o?(f+=C,E="l"):(f=C+=f,E="L"),y([[v,C]]);break;case 2:case 4:case 18:S-=v,C-=f;case 5:case 3:x&&1===m.getItem(g-1).pathSegType&&!o&&(v=x[0],f=x[1]);case 19:o?(v+=S,f+=C):(v=S+=v,f=C+=f),3===k&&(x=[v,f]),y([[S,C]]);break;case 6:S-=v,w-=v,N-=v,C-=f,_-=f,A-=f;case 7:o?(v+=S,f+=C):(w+=v,N+=v,_+=f,A+=f,v=S+=v,f=C+=f),y([[w,_],[N,A],[S,C]]);break;case 8:S-=v,w-=v,C-=f,_-=f;case 9:o?(v+=S,f+=C):(w+=v,_+=f,v=S+=v,f=C+=f),y([[w,_],[S,C]]);break;case 10:S-=v,C-=f;case 11:o?(v+=S,f+=C):(v=S+=v,f=C+=f),y([[b.r1,b.r2]],[b.angle,b.largeArcFlag?1:0,b.sweepFlag?1:0],[S,C]);break;case 16:S-=v,N-=v,C-=f,A-=f;case 17:o?(v+=S,f+=C):(N+=v,A+=f,v=S+=v,f=C+=f),y([[N,A],[S,C]])}}return p}}}();var ze=this.removeUnusedDefElems=function(){var n=w.getElementsByTagNameNS(g.SVG,"defs");if(!n||!n.length)return 0;var o,m,c=[],v=0,f=["fill","stroke","filter","marker-start","marker-mid","marker-end"],p=f.length,x=w.getElementsByTagNameNS(g.SVG,"*"),b=x.length;for(o=0;o<b;o++){var S=x[o];for(m=0;m<p;m++){var C=svgedit.utilities.getUrlFromAttr(S.getAttribute(f[m]));C&&c.push(C.substr(1))}var _=F(S);_&&0===_.indexOf("#")&&c.push(_.substr(1))}var N=$(n).find("linearGradient, radialGradient, filter, marker, svg, symbol");for(o=N.length;o--;){var A=N[o],k=A.id;c.indexOf(k)<0&&(removedElements[k]=A,A.parentNode.removeChild(A),v++)}return v};this.svgCanvasToString=function(){for(;ze()>0;);Ee.clear(!0),$.each(w.childNodes,(function(n,o){n&&8===o.nodeType&&o.data.indexOf("Created with")>=0&&w.insertBefore(o,w.firstChild)})),E&&(Ze(),Re([E]));var n=[];$(w).find("g:data(gsvg)").each((function(){var o,g=this.attributes,m=g.length;for(o=0;o<m;o++)"id"!=g[o].nodeName&&"style"!=g[o].nodeName||m--;if(m<=0){var c=this.firstChild;n.push(c),$(this).replaceWith(c)}}));var o=this.svgToString(w,0);return n.length&&$(n).each((function(){Le(this)})),o},this.svgToString=function(n,o){var c=[],v=svgedit.utilities.toXml,f=m.baseUnit,p=new RegExp("^-?[\\d\\.]+"+f+"$");if(n){if(["ngx-dygraphs"].indexOf(n.nodeName.toLowerCase())>=0)return c.join("");K(n);var x,b,S=n.attributes,C=n.childNodes;for(b=0;b<o;b++)c.push(" ");if(c.push("<"),c.push(n.nodeName),"svgcontent"===n.id){var w=Qe();"px"!==f&&(w.w=svgedit.units.convertUnit(w.w,f)+f,w.h=svgedit.units.convertUnit(w.h,f)+f),c.push(' width="'+w.w+'" height="'+w.h+'" xmlns="'+g.SVG+'"');var _={};$(n).find("*").andSelf().each((function(){var n=this.namespaceURI;n&&!_[n]&&Q[n]&&"xmlns"!==Q[n]&&"xml"!==Q[n]&&(_[n]=!0,c.push(" xmlns:"+Q[n]+'="'+n+'"')),$.each(this.attributes,(function(n,o){var g=o.namespaceURI;g&&!_[g]&&"xmlns"!==Q[g]&&"xml"!==Q[g]&&(_[g]=!0,c.push(" xmlns:"+Q[g]+'="'+g+'"'))}))})),b=S.length;for(var N=["width","height","xmlns","x","y","viewBox","id","overflow"];b--;){var A=v((x=S.item(b)).value);0!==x.nodeName.indexOf("xmlns:")&&""!=A&&-1==N.indexOf(x.localName)&&(x.namespaceURI&&!Q[x.namespaceURI]||(c.push(" "),c.push(x.nodeName),c.push('="'),c.push(A),c.push('"')))}}else{if("defs"===n.nodeName&&!n.firstChild)return;var k=["-moz-math-font-style","_moz-math-font-style"];for(b=S.length-1;b>=0;b--)if(A=v((x=S.item(b)).value),!(k.indexOf(x.localName)>=0)&&""!=A){if(0===A.indexOf("pointer-events"))continue;if("class"===x.localName&&0===A.indexOf("se_"))continue;if(c.push(" "),"d"===x.localName&&(A=Ee.convertPath(n,!1)),isNaN(A)?p.test(A)&&(A=svgedit.units.shortFloat(A)+f):A=svgedit.units.shortFloat(A),save_options.apply&&"image"===n.nodeName&&"href"===x.localName&&save_options.images&&"embed"===save_options.images){var E=me[A];E&&(A=E)}x.namespaceURI&&x.namespaceURI!=g.SVG&&!Q[x.namespaceURI]||(c.push(x.nodeName),c.push('="'),c.push(A),c.push('"'))}}if(n.hasChildNodes()){c.push(">"),o++;var B=!1;for(b=0;b<C.length;b++){var T=C.item(b);switch(T.nodeType){case 1:c.push("\n"),c.push(this.svgToString(C.item(b),o));break;case 3:var I=T.nodeValue.replace(/^\s+|\s+$/g,"");""!=I&&(B=!0,c.push(String(v(I))));break;case 4:c.push("\n"),c.push(new Array(o+1).join(" ")),c.push("<![CDATA["),c.push(T.nodeValue),c.push("]]>");break;case 8:c.push("\n"),c.push(new Array(o+1).join(" ")),c.push("\x3c!--"),c.push(T.data),c.push("--\x3e")}}if(o--,!B)for(c.push("\n"),b=0;b<o;b++)c.push(" ");c.push("</"),c.push(n.nodeName),c.push(">")}else"div"===n.nodeName.toLowerCase()||"span"===n.nodeName.toLowerCase()?(c.push(">"),c.push("</"),c.push(n.nodeName),c.push(">")):c.push("/>")}return c.join("")},this.embedImage=function(n,o){$(new Image).load((function(){var g=document.createElement("canvas");g.width=this.width,g.height=this.height,g.getContext("2d").drawImage(this,0,0);try{var m=";svgedit_url="+encodeURIComponent(n);m=g.toDataURL().replace(";base64",m+";base64"),me[n]=m}catch(o){me[n]=!1}ce=n,o&&o(me[n])})).attr("src",n)},this.setGoodImage=function(n){ce=n},this.setGoodSvgImageContent=function(n){last_good_img_content=n},this.open=function(){},this.save=function(n){De(),n&&$.extend(save_options,n),save_options.apply=!0;var o=this.svgCanvasToString();Z("saved",o)},this.rasterExport=function(n,o,g){var m="image/"+n.toLowerCase(),c=i(),v=this.svgCanvasToString();svgedit.utilities.buildCanvgCallback((function(){var f=n||"PNG";$("#export_canvas").length||$("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var p=$("#export_canvas")[0];p.width=svgCanvas.contentW,p.height=svgCanvas.contentH,canvg(p,v,{renderCallback:function(){var x=("ICO"===f?"BMP":f).toLowerCase(),b=o?p.toDataURL("image/"+x,o):p.toDataURL("image/"+x);Z("exported",{datauri:b,svg:v,issues:c,type:n,mimeType:m,quality:o,exportWindowName:g})}})}))()},this.exportPDF=function(n,o){var g=this;svgedit.utilities.buildJSPDFCallback((function(){var m=Qe(),c=m.w>m.h?"landscape":"portrait",v=jsPDF({orientation:c,unit:"pt",format:[m.w,m.h]}),f=et();v.setProperties({title:f});var p=i(),x=g.svgCanvasToString();v.addSVG(x,0,0);var b={svg:x,issues:p,exportWindowName:n},S=o||"dataurlstring";b[S]=v.output(S),Z("exportedPDF",b)}))()},this.lockSelection=function(n){p=n},this.getSvgString=function(){return save_options.apply=!1,this.svgCanvasToString()},this.randomizeIds=function(n){arguments.length>0&&0==n?svgedit.draw.randomizeIds(!1,A()):svgedit.draw.randomizeIds(!0,A())};var je=this.uniquifyElems=function(n){var o,g={},m=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];for(o in svgedit.utilities.walkTree(n,(function(n){if(1==n.nodeType){n.id&&(n.id in g||(g[n.id]={elem:null,attrs:[],hrefs:[]}),g[n.id].elem=n),$.each(ue,(function(o,m){var c=n.getAttributeNode(m);if(c){var v=svgedit.utilities.getUrlFromAttr(c.value),f=v?v.substr(1):null;f&&(f in g||(g[f]={elem:null,attrs:[],hrefs:[]}),g[f].attrs.push(c))}}));var o=svgedit.utilities.getHref(n);if(o&&m.indexOf(n.nodeName)>=0){var c=o.substr(1);c&&(c in g||(g[c]={elem:null,attrs:[],hrefs:[]}),g[c].hrefs.push(n))}}})),g)if(o){var c=g[o].elem;if(c){var v=Ae();c.id=v;for(var f=g[o].attrs,p=f.length;p--;){var x=f[p];x.ownerElement.setAttribute(x.name,"url(#"+v+")")}for(var b=g[o].hrefs,S=b.length;S--;){var C=b[S];svgedit.utilities.setHref(C,"#"+v)}}}},We=this.setUseData=function(n){var o=$(n);"use"!==n.tagName&&(o=o.find("use")),o.each((function(){var n=F(this).substr(1),o=svgedit.utilities.getElem(n);o&&($(this).data("ref",o),"symbol"!=o.tagName&&"svg"!=o.tagName||$(this).data("symbol",o).data("ref",o))}))},Ke=this.convertGradients=function(n){var o=$(n).find("linearGradient, radialGradient");!o.length&&svgedit.browser.isWebkit()&&(o=$(n).find("*").filter((function(){return this.tagName.indexOf("Gradient")>=0}))),o.each((function(){var n=this;if("userSpaceOnUse"===$(n).attr("gradientUnits")){var o=$(w).find('[fill="url(#'+n.id+')"],[stroke="url(#'+n.id+')"]');if(!o.length)return;var g=svgedit.utilities.getBBox(o[0]);if(!g)return;if("linearGradient"===n.tagName){var m=$(n).attr(["x1","y1","x2","y2"]),c=n.gradientTransform.baseVal;if(c&&c.numberOfItems>0){var v=svgedit.math.transformListToTransform(c).matrix,f=svgedit.math.transformPoint(m.x1,m.y1,v),p=svgedit.math.transformPoint(m.x2,m.y2,v);m.x1=f.x,m.y1=f.y,m.x2=p.x,m.y2=p.y,n.removeAttribute("gradientTransform")}$(n).attr({x1:(m.x1-g.x)/g.width,y1:(m.y1-g.y)/g.height,x2:(m.x2-g.x)/g.width,y2:(m.y2-g.y)/g.height}),n.removeAttribute("gradientUnits")}}}))},Xe=this.convertToGroup=function(n){n||(n=I[0]);var o,m=$(n),c=new svgedit.history.BatchCommand;if(m.data("gsvg")){var v=n.firstChild,f=$(v).attr(["x","y"]);$(n.firstChild.firstChild).unwrap(),$(n).removeData("gsvg");var p=svgedit.transformlist.getTransformList(n),x=C.createSVGTransform();x.setTranslate(f.x,f.y),p.appendItem(x),svgedit.recalculate.recalculateDimensions(n),Z("selected",[n])}else if(m.data("symbol")){n=m.data("symbol"),o=m.attr("transform");var b=m.attr(["x","y"]),_=n.getAttribute("viewBox");if(_){var N=_.split(" ");b.x-=+N[0],b.y-=+N[1]}o+=" translate("+(b.x||0)+","+(b.y||0)+")";var A=m.prev();c.addSubCommand(new svgedit.history.RemoveElementCommand(m[0],m[0].nextSibling,m[0].parentNode)),m.remove();var k,E=$(w).find("use:data(symbol)").length,B=S.createElementNS(g.SVG,"g"),T=n.childNodes;for(k=0;k<T.length;k++)B.appendChild(T[k].cloneNode(!0));if(svgedit.browser.isGecko()){var M=$(svgedit.utilities.findDefs()).children("linearGradient,radialGradient,pattern").clone();$(B).append(M)}o&&B.setAttribute("transform",o);var L=n.parentNode;if(je(B),svgedit.browser.isGecko()&&$(U()).append($(B).find("linearGradient,radialGradient,pattern")),B.id=Ae(),A.after(B),L){if(!E){var O=n.nextSibling;L.removeChild(n),c.addSubCommand(new svgedit.history.RemoveElementCommand(n,O,L))}c.addSubCommand(new svgedit.history.InsertElementCommand(B))}We(B),svgedit.browser.isGecko()?Ke(svgedit.utilities.findDefs()):Ke(B),svgedit.utilities.walkTreePost(B,(function(n){try{svgedit.recalculate.recalculateDimensions(n)}catch(n){console.log(n)}})),$(B).find(de).each((function(){this.id||(this.id=Ae())})),Re([B]);var D=rt(B,!0);D&&c.addSubCommand(D),X(c)}else console.log("Unexpected element to ungroup:",n)};this.setSvgString=function(n){try{var o=svgedit.utilities.text2xml(n),c=o&&o.documentElement;if(c&&"svg"===c.nodeName.toLowerCase()||(c=o.getElementsByTagNameNS(g.SVG,"svg")[0]||o.getElementsByTagName("svg")[0]),!c||"svg"!==c.nodeName.toLowerCase())return console.error("Invalid SVG document root while loading editor content",o&&o.documentElement),!1;o.documentElement!==c&&o.replaceChild&&o.replaceChild(c,o.documentElement),this.prepareSvg(o);var f=new svgedit.history.BatchCommand("Change Source"),p=w.nextSibling,x=C.removeChild(w);f.addSubCommand(new svgedit.history.RemoveElementCommand(x,p,C)),w=S.adoptNode?S.adoptNode(c):S.importNode(c,!0),C.appendChild(w);var b=$(w);v.current_drawing_=new svgedit.draw.Drawing(w,N);var _=A().getNonce();_?Z("setnonce",_):Z("unsetnonce"),b.find("image").each((function(){var n=this;Ge(n);var o=F(this);if(o){if(0===o.indexOf("data:")){var m=o.match(/svgedit_url=(.*?);/);if(m){var c=decodeURIComponent(m[1]);$(new Image).load((function(){n.setAttributeNS(g.XLINK,"xlink:href",c)})).attr("src",c)}}v.embedImage(o)}})),b.find("svg").each((function(){if(!$(this).closest("defs").length){je(this);var n=this.parentNode;1===n.childNodes.length&&"g"===n.nodeName?($(n).data("gsvg",this),n.id=n.id||Ae()):Le(this)}})),svgedit.browser.isGecko()&&b.find("linearGradient, radialGradient, pattern").appendTo(svgedit.utilities.findDefs()),We(b),Ke(b[0]),svgedit.utilities.walkTreePost(w,(function(n){try{svgedit.recalculate.recalculateDimensions(n)}catch(n){console.log(n)}}));var E={id:"svgcontent",overflow:m.show_outside_canvas?"visible":"hidden"},B=!1;if(b.attr("viewBox")){var T=b.attr("viewBox").split(" ");E.width=T[2],E.height=T[3]}else $.each(["width","height"],(function(n,o){var g=b.attr(o);g||(g="100%"),"%"===String(g).substr(-1)?B=!0:E[o]=svgedit.units.convertToNum(o,g)}));if(Ye(),b.children().find(de).each((function(){this.id||(this.id=Ae())})),B){var I=getStrokedBBox();E.width=I.width+I.x,E.height=I.height+I.y}E.width<=0&&(E.width=100),E.height<=0&&(E.height=100),b.attr(E),this.contentW=E.width,this.contentH=E.height,f.addSubCommand(new svgedit.history.InsertElementCommand(w));var M=b.attr(["width","height"]);f.addSubCommand(new svgedit.history.ChangeElementCommand(C,M)),k=1,svgedit.transformlist.resetListMap(),De(),svgedit.path.clearData(),C.appendChild(oe.selectorParentGroup),X(f),Z("changed",[w])}catch(n){return console.log(n),!1}return!0},this.importSvgString=function(n,o){var m,c;try{var v=(new Date).getTime(),f=!1;import_ids[v]&&$(import_ids[v].symbol).parents("#svgroot").length&&(f=!0);var p,x=new svgedit.history.BatchCommand("Import Image");if(f)p=import_ids[v].symbol,c=import_ids[v].xform,o&&o.x>0&&o.y>0&&(c=" translate("+o.x+","+o.y+") scale(1) translate(0)");else{var b,C=svgedit.utilities.text2xml(n);this.prepareSvg(C),b=S.adoptNode?S.adoptNode(C.documentElement):S.importNode(C.documentElement,!0),je(b);var _=svgedit.units.convertToNum("width",b.getAttribute("width")),N=svgedit.units.convertToNum("height",b.getAttribute("height")),k=b.getAttribute("viewBox"),B=k?k.split(" "):[0,0,_,N];for(m=0;m<4;++m)B[m]=Number(B[m]);var T=Number(w.getAttribute("height"));c=N>_?"scale("+T/3/B[3]+")":"scale("+T/3/B[2]+")",c=o&&o.x>0&&o.y>0?"translate("+o.x+","+o.y+") scale(1) translate(0)":"translate(0) scale(1) translate(0)",p=S.createElementNS(g.SVG,"symbol");var I=svgedit.utilities.findDefs();if($(b).find("linearGradient, radialGradient, pattern").appendTo(I),!I.firstChild){var M=S.createElementNS(g.SVG,"symbol");M.id=Ae(),I.appendChild(M)}for(;b.firstChild;){var L=b.firstChild;svgedit.utilities.walkTree(L,(function(n){n.id=Ae()})),p.appendChild(L)}p.id=Ae(),p.setAttribute("type","svg-ext-shapes-image"),p.childNodes.forEach((n=>{n.getAttribute("transform")&&n.setAttribute("transform","matrix(1, 0, 0, 1, 0, 0)")})),import_ids[v]={symbol:p,xform:c},svgedit.utilities.findDefs().appendChild(p),x.addSubCommand(new svgedit.history.InsertElementCommand(p))}var O=S.createElementNS(g.SVG,"use");O.id=Ae(),O.setAttribute("type","svg-ext-shapes-image"),j(O,"#"+p.id),(E||A().getCurrentLayer()).appendChild(O),x.addSubCommand(new svgedit.history.InsertElementCommand(O)),De(),O.setAttribute("transform",c),svgedit.recalculate.recalculateDimensions(O),$(O).data("symbol",p).data("ref",p),Ve([O]),setTimeout((function(){Re([O],!0)}),500),X(x),Z("changed",[w])}catch(n){return console.log(n),!1}return!0};var Ye=v.identifyLayers=function(){Ze(),A().identifyLayers()};this.createLayer=function(n){var o=new svgedit.history.BatchCommand("Create Layer"),g=A().createLayer(n);o.addSubCommand(new svgedit.history.InsertElementCommand(g)),X(o),De(),Z("changed",[g])},this.cloneLayer=function(n){var o=new svgedit.history.BatchCommand("Duplicate Layer"),m=S.createElementNS(g.SVG,"g"),c=S.createElementNS(g.SVG,"title");c.textContent=n,m.appendChild(c);var f=A().getCurrentLayer();$(f).after(m);var p,x=f.childNodes;for(p=0;p<x.length;p++){var b=x[p];"title"!=b.localName&&m.appendChild(be(b))}De(),Ye(),o.addSubCommand(new svgedit.history.InsertElementCommand(m)),X(o),v.setCurrentLayer(n),Z("changed",[m])},this.deleteCurrentLayer=function(){var n=A().getCurrentLayer(),o=n.nextSibling,g=n.parentNode;if(n=A().deleteCurrentLayer()){var m=new svgedit.history.BatchCommand("Delete Layer");return m.addSubCommand(new svgedit.history.RemoveElementCommand(n,o,g)),X(m),De(),Z("changed",[g]),!0}return!1},this.setCurrentLayer=function(n){var o=A().setCurrentLayer(svgedit.utilities.toXml(n));return o&&De(),o},this.renameCurrentLayer=function(n){var o,g=A();if(g.current_layer){var m=g.current_layer;if(!v.setCurrentLayer(n)){var c=new svgedit.history.BatchCommand("Rename Layer");for(o=0;o<g.getNumLayers()&&g.all_layers[o][1]!=m;++o);var f=g.getLayerName(o);g.all_layers[o][0]=svgedit.utilities.toXml(n);var p=m.childNodes.length;for(o=0;o<p;++o){var x=m.childNodes.item(o);if(x&&"title"==x.tagName){for(;x.firstChild;)x.removeChild(x.firstChild);return x.textContent=n,c.addSubCommand(new svgedit.history.ChangeElementCommand(x,{"#text":f})),X(c),Z("changed",[m]),!0}}}g.current_layer=m}return!1},this.setCurrentLayerPosition=function(n){var o,g=A();if(g.current_layer&&n>=0&&n<g.getNumLayers()){for(o=0;o<g.getNumLayers()&&g.all_layers[o][1]!=g.current_layer;++o);if(o==g.getNumLayers())return!1;if(o!=n){var m=null,c=g.current_layer.nextSibling;return n>o?n<g.getNumLayers()-1&&(m=g.all_layers[n+1][1]):m=g.all_layers[n][1],w.insertBefore(g.current_layer,m),X(new svgedit.history.MoveElementCommand(g.current_layer,c,w)),Ye(),v.setCurrentLayer(g.getLayerName(n)),!0}}return!1},this.setLayerVisibility=function(n,o){var g=A(),m=g.getLayerVisibility(n),c=g.setLayerVisibility(n,o);if(!c)return!1;var v=m?"inline":"none";return X(new svgedit.history.ChangeElementCommand(c,{display:v},"Layer Visibility")),c==g.getCurrentLayer()&&(De(),Ee.clear()),!0},this.moveSelectedToLayer=function(n){var o,g=null,m=A();for(o=0;o<m.getNumLayers();++o)if(m.getLayerName(o)==n){g=m.all_layers[o][1];break}if(!g)return!1;var c=new svgedit.history.BatchCommand("Move Elements to Layer"),v=I;for(o=v.length;o--;){var f=v[o];if(f){var p=f.nextSibling,x=f.parentNode;g.appendChild(f),c.addSubCommand(new svgedit.history.MoveElementCommand(f,p,x))}}return X(c),!0},this.mergeLayer=function(n){var o=new svgedit.history.BatchCommand("Merge Layer"),g=A(),m=$(g.current_layer).prev()[0];if(m){var c=(g.current_layer.childNodes.length,g.current_layer.nextSibling);for(o.addSubCommand(new svgedit.history.RemoveElementCommand(g.current_layer,c,w));g.current_layer.firstChild;){var v=g.current_layer.firstChild;if("title"!=v.localName){var f=v.nextSibling;m.appendChild(v),o.addSubCommand(new svgedit.history.MoveElementCommand(v,f,g.current_layer))}else{var p=v.nextSibling;o.addSubCommand(new svgedit.history.RemoveElementCommand(v,p,g.current_layer)),g.current_layer.removeChild(v)}}return w.removeChild(g.current_layer),n||(De(),Ye(),Z("changed",[w]),X(o)),g.current_layer=m,o}},this.mergeAllLayers=function(){var n=new svgedit.history.BatchCommand("Merge all Layers"),o=A();for(o.current_layer=o.all_layers[o.getNumLayers()-1][1];$(w).children("g").length>1;)n.addSubCommand(v.mergeLayer(!0));De(),Ye(),Z("changed",[w]),X(n)};var Ze=this.leaveContext=function(){var n,o=disabled_elems.length;if(o){for(n=0;n<o;n++){var g=disabled_elems[n],m=ge(g,"orig_opac");1!==m?g.setAttribute("opacity",m):g.removeAttribute("opacity"),g.setAttribute("style","pointer-events: inherit")}disabled_elems=[],De(!0),Z("contextset",null)}E=null},Je=this.setContext=function(n){Ze(),"string"==typeof n&&(n=svgedit.utilities.getElem(n)),E=n,$(n).parentsUntil("#svgcontent").andSelf().siblings().each((function(){var n=this.getAttribute("opacity")||1;ge(this,"orig_opac",n),this.setAttribute("opacity",.33*n),this.setAttribute("style","pointer-events: none"),disabled_elems.push(this)})),De(),Z("contextset",E)};this.clear=function(){Ee.clear(),De(),v.clearSvgContentElement(),v.current_drawing_=new svgedit.draw.Drawing(w),v.createLayer("Layer 1"),v.undoMgr.resetUndoStack(),oe.initGroup(),rubberBox=oe.getRubberBandBox(),Z("cleared")},this.linkControlPoints=Ee.linkControlPoints,this.getContentElem=function(){return w},this.getRootElem=function(){return C},this.getSelectedElems=function(){return I};var Qe=this.getResolution=function(){return{w:w.getAttribute("width")/k,h:w.getAttribute("height")/k,zoom:k}};this.getZoom=function(){return k},this.getVersion=function(){return"svgcanvas.js ($Rev$)"},this.setUiStrings=function(n){$.extend(le,n.notification)},this.setConfig=function(n){$.extend(m,n)},this.getTitle=function(n){var o;if(n=n||I[0]){var g=(n=$(n).data("gsvg")||$(n).data("symbol")||n).childNodes;for(o=0;o<g.length;o++)if("title"==g[o].nodeName)return g[o].textContent;return""}},this.setGroupTitle=function(n){var o=I[0];o=$(o).data("gsvg")||o;var m=$(o).children("title"),c=new svgedit.history.BatchCommand("Set Label");if(n.length)if(m.length){var v=m[0];c.addSubCommand(new svgedit.history.ChangeElementCommand(v,{"#text":v.textContent})),v.textContent=n}else(v=S.createElementNS(g.SVG,"title")).textContent=n,$(o).prepend(v),c.addSubCommand(new svgedit.history.InsertElementCommand(v));else{var f=m.nextSibling;c.addSubCommand(new svgedit.history.RemoveElementCommand(m[0],f,o)),m.remove()}X(c)};var et=this.getDocumentTitle=function(){return v.getTitle(w)};this.setDocumentTitle=function(n){var o,m=w.childNodes,c=!1,v="",f=new svgedit.history.BatchCommand("Change Image Title");for(o=0;o<m.length;o++)if("title"==m[o].nodeName){v=(c=m[o]).textContent;break}c||(c=S.createElementNS(g.SVG,"title"),w.insertBefore(c,w.firstChild)),n.length?c.textContent=n:c.parentNode.removeChild(c),f.addSubCommand(new svgedit.history.ChangeElementCommand(c,{"#text":v})),X(f)},this.getEditorNS=function(n){return n&&w.setAttribute("xmlns:se",g.SE),g.SE},this.setResolution=function(n,o){var g,m=Qe(),c=m.w,f=m.h;if("fit"==n){var p=getStrokedBBox();if(!p)return!1;g=new svgedit.history.BatchCommand("Fit Canvas to Content");var x=Ie();Ve(x);var b=[],S=[];$.each(x,(function(n,o){b.push(-1*p.x),S.push(-1*p.y)}));var _=v.moveSelectedElements(b,S,!0);g.addSubCommand(_),De(),n=Math.round(p.width),o=Math.round(p.height)}if(n!=c||o!=f){var N=C.suspendRedraw(1e3);g||(g=new svgedit.history.BatchCommand("Change Image Dimensions")),n=svgedit.units.convertToNum("width",n),o=svgedit.units.convertToNum("height",o),w.setAttribute("width",n),w.setAttribute("height",o),this.contentW=n,this.contentH=o,g.addSubCommand(new svgedit.history.ChangeElementCommand(w,{width:c,height:f})),w.setAttribute("viewBox",[0,0,n/k,o/k].join(" ")),g.addSubCommand(new svgedit.history.ChangeElementCommand(w,{viewBox:["0 0",c,f].join(" ")})),X(g),C.unsuspendRedraw(N),Z("changed",[w])}return!0},this.getOffset=function(){return $(w).attr(["x","y"])},this.setBBoxZoom=function(n,o,g){var m,c=.85,a=function(n){if(!n)return!1;var m=Math.round(o/n.width*100*c)/100,f=Math.round(g/n.height*100*c)/100,p=Math.min(m,f);return v.setZoom(p),{zoom:p,bbox:n}};if("object"==typeof n){if(0==(m=n).width||0==m.height){var f=m.zoom?m.zoom:k*m.factor;return v.setZoom(f),{zoom:k,bbox:m}}return a(m)}switch(n){case"selection":if(!I[0])return;var p=$.map(I,(function(n){if(n)return n}));m=getStrokedBBox(p);break;case"canvas":var x=Qe();c=.95,m={width:x.w,height:x.h,x:0,y:0};break;case"content":m=getStrokedBBox();break;case"layer":m=getStrokedBBox(Ie(A().getCurrentLayer()));break;default:return}return a(m)},this.setZoom=function(n){var o=Qe();w.setAttribute("viewBox","0 0 "+o.w/n+" "+o.h/n),k=n,$.each(I,(function(n,o){o&&oe.requestSelector(o).resize()})),Ee.zoomChange(),ve("zoomChanged",n)},this.getMode=function(){return current_mode},this.setMode=function(n){Ee.clear(!0),ke.clear(),cur_properties=I[0]&&"text"==I[0].nodeName?cur_text:T,current_mode=n},this.getColor=function(n){return cur_properties[n]},this.setColor=function(n,o,g){function r(n){"g"!=n.nodeName&&m.push(n)}T[n]=o,cur_properties[n+"_paint"]={type:"solidColor"};for(var m=[],c=I.length;c--;){var v=I[c];if(v)if("g"==v.tagName){var f=v.id.substr(0,3);if("GXP"===f)continue;"MTR"===f?svgedit.utilities.walkTree(v,(function(o){o.hasAttribute(n)&&"sMTR"!=o.id.substr(0,4)&&m.push(o)})):["CPS","VLA","EHS","SHE"].includes(f)?svgedit.utilities.walkTree(v,(function(o){o.hasAttribute(n)&&m.push(o)})):svgedit.utilities.walkTree(v,r)}else"fill"==n?"polyline"!=v.tagName&&"line"!=v.tagName&&m.push(v):m.push(v)}m.length>0&&(g?He(n,o,m):(it(n,o,m),Z("changed",m)))};var tt=this.setGradient=function(n){if(cur_properties[n+"_paint"]&&"solidColor"!=cur_properties[n+"_paint"].type){var o=v[n+"Grad"],g=Fe(o),m=svgedit.utilities.findDefs();g?o=g:(o=m.appendChild(S.importNode(o,!0))).id=Ae(),v.setColor(n,"url(#"+o.id+")")}},Fe=function(n){for(var o=svgedit.utilities.findDefs(),m=$(o).find("linearGradient, radialGradient"),c=m.length,v=["r","cx","cy","fx","fy"];c--;){var f=m[c];if("linearGradient"==n.tagName){if(n.getAttribute("x1")!=f.getAttribute("x1")||n.getAttribute("y1")!=f.getAttribute("y1")||n.getAttribute("x2")!=f.getAttribute("x2")||n.getAttribute("y2")!=f.getAttribute("y2"))continue}else{var p=$(n).attr(v),x=$(f).attr(v),b=!1;if($.each(v,(function(n,o){p[o]!=x[o]&&(b=!0)})),b)continue}var S=n.getElementsByTagNameNS(g.SVG,"stop"),C=f.getElementsByTagNameNS(g.SVG,"stop");if(S.length==C.length){for(var w=S.length;w--;){var _=S[w],N=C[w];if(_.getAttribute("offset")!=N.getAttribute("offset")||_.getAttribute("stop-opacity")!=N.getAttribute("stop-opacity")||_.getAttribute("stop-color")!=N.getAttribute("stop-color"))break}if(-1==w)return f}}return null};this.setPaint=function(n,o){var g=new $.jGraduate.Paint(o);switch(this.setPaintOpacity(n,g.alpha/100,!0),cur_properties[n+"_paint"]=g,g.type){case"solidColor":-1===g.solidColor.indexOf("rgb")?this.setColor(n,"none"!=g.solidColor?"#"+g.solidColor:"none"):this.setColor(n,g.solidColor);break;case"linearGradient":case"radialGradient":v[n+"Grad"]=g[g.type],tt(n)}},this.setStrokePaint=function(n){this.setPaint("stroke",n)},this.setFillPaint=function(n){this.setPaint("fill",n)},this.getStrokeWidth=function(){return cur_properties.stroke_width},this.setStrokeWidth=function(n){function t(n){"g"!=n.nodeName&&o.push(n)}if(0==n&&["line","path"].indexOf(current_mode)>=0)v.setStrokeWidth(1);else{cur_properties.stroke_width=n;for(var o=[],g=I.length;g--;){var m=I[g];m&&("g"==m.tagName?svgedit.utilities.walkTree(m,t):o.push(m))}o.length>0&&(it("stroke-width",n,o),Z("changed",I))}},this.setStrokeAttr=function(n,o){T[n.replace("-","_")]=o;for(var g=[],m=I.length;m--;){var c=I[m];c&&("g"==c.tagName?svgedit.utilities.walkTree(c,(function(n){"g"!=n.nodeName&&g.push(n)})):g.push(c))}g.length>0&&(it(n,o,g),Z("changed",I))},this.getStyle=function(){return T},this.getOpacity=function(){return T.opacity},this.setOpacity=function(n){T.opacity=n,it("opacity",n)},this.getFillOpacity=function(){return T.fill_opacity},this.getStrokeOpacity=function(){return T.stroke_opacity},this.setPaintOpacity=function(n,o,g){T[n+"_opacity"]=o,g?He(n+"-opacity",o):it(n+"-opacity",o)},this.getPaintOpacity=function(n){return"fill"===n?this.getFillOpacity():this.getStrokeOpacity()},this.getBlur=function(n){var o=0;if(n&&n.getAttribute("filter")){var g=svgedit.utilities.getElem(n.id+"_blur");g&&(o=g.firstChild.getAttribute("stdDeviation"))}return o},function(){function e(){var g=v.undoMgr.finishUndoableChange();n.addSubCommand(g),X(n),n=null,o=null}var n=null,o=null,g=!1;v.setBlurNoUndo=function(n){if(o)if(0===n)He("filter",""),g=!0;else{var m=I[0];g&&He("filter","url(#"+m.id+"_blur)"),svgedit.browser.isWebkit()&&(console.log("e",m),m.removeAttribute("filter"),m.setAttribute("filter","url(#"+m.id+"_blur)")),He("stdDeviation",n,[o.firstChild]),v.setBlurOffsets(o,n)}else v.setBlur(n)},v.setBlurOffsets=function(n,o){o>3?svgedit.utilities.assignAttributes(n,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100):svgedit.browser.isWebkit()||(n.removeAttribute("x"),n.removeAttribute("y"),n.removeAttribute("width"),n.removeAttribute("height"))},v.setBlur=function(g,m){if(n)e();else{var c=I[0],f=c.id;o=svgedit.utilities.getElem(f+"_blur"),g-=0;var p=new svgedit.history.BatchCommand;if(o)0===g&&(o=null);else{var x=M({element:"feGaussianBlur",attr:{in:"SourceGraphic",stdDeviation:g}});(o=M({element:"filter",attr:{id:f+"_blur"}})).appendChild(x),svgedit.utilities.findDefs().appendChild(o),p.addSubCommand(new svgedit.history.InsertElementCommand(o))}var b={filter:c.getAttribute("filter")};if(0===g)return c.removeAttribute("filter"),void p.addSubCommand(new svgedit.history.ChangeElementCommand(c,b));it("filter","url(#"+f+"_blur)"),p.addSubCommand(new svgedit.history.ChangeElementCommand(c,b)),v.setBlurOffsets(o,g),n=p,v.undoMgr.beginUndoableChange("stdDeviation",[o?o.firstChild:null]),m&&(v.setBlurNoUndo(g),e())}}}(),this.getBold=function(){var n=I[0];return null!=n&&"text"==n.tagName&&null==I[1]&&"bold"==n.getAttribute("font-weight")},this.setBold=function(n){var o=I[0];null!=o&&"text"==o.tagName&&null==I[1]&&it("font-weight",n?"bold":"normal"),I[0].textContent||ke.setCursor()},this.getItalic=function(){var n=I[0];return null!=n&&"text"==n.tagName&&null==I[1]&&"italic"==n.getAttribute("font-style")},this.setItalic=function(n){var o=I[0];null!=o&&"text"==o.tagName&&null==I[1]&&it("font-style",n?"italic":"normal"),I[0].textContent||ke.setCursor()},this.getFontFamily=function(){return cur_text.font_family},this.setFontFamily=function(n){cur_text.font_family=n,it("font-family",n),I[0]&&!I[0].textContent&&ke.setCursor(),ve("setFontAttribute",{elem:I[0],attr:"font-family",value:n})},this.setTextAlign=function(n){cur_text.text_anchor=n,it("text-anchor",n),I[0]&&!I[0].textContent&&ke.setCursor(),ve("setFontAttribute",{elem:I[0],attr:"text-anchor",value:n})},this.setFontColor=function(n){cur_text.fill=n,it("fill",n)},this.getFontColor=function(){return cur_text.fill},this.getFontSize=function(){return cur_text.font_size},this.setFontSize=function(n){I[0]&&(cur_text.font_size=n,it("font-size",n),I[0].textContent||ke.setCursor(),ve("setFontAttribute",{elem:I[0],attr:"font-size",value:n+"px"}))},this.getExtensionFont=function(n){return pe("getFontAttribute",{elem:n})},this.getText=function(){var n=I[0];return null==n?"":n.textContent},this.setTextContent=function(n){it("#text",n),ke.init(n),ke.setCursor()},this.setImageURL=function(n){var o=I[0];if(o){var g=$(o).attr(["width","height"]),m=!g.width||!g.height,c=F(o);if(c!==n)m=!0;else if(!m)return;var v=new svgedit.history.BatchCommand("Change Image URL");j(o,n),v.addSubCommand(new svgedit.history.ChangeElementCommand(o,{"#href":c})),m?$(new Image).load((function(){var n=$(o).attr(["width","height"]);$(o).attr({width:this.width,height:this.height}),oe.requestSelector(o).resize(),v.addSubCommand(new svgedit.history.ChangeElementCommand(o,n)),X(v),Z("changed",[o])})).attr("src",n):X(v)}},this.setLinkURL=function(n){var o=I[0];if(o){if("a"!==o.tagName){var g=$(o).parents("a");if(!g.length)return;o=g[0]}var m=F(o);if(m!==n){var c=new svgedit.history.BatchCommand("Change Link URL");j(o,n),c.addSubCommand(new svgedit.history.ChangeElementCommand(o,{"#href":m})),X(c)}}},this.setRectRadius=function(n){var o=I[0];if(null!=o&&"rect"==o.tagName){var g=o.getAttribute("rx");g!=n&&(o.setAttribute("rx",n),o.setAttribute("ry",n),X(new svgedit.history.ChangeElementCommand(o,{rx:g,ry:g},"Radius")),Z("changed",[o]))}},this.convertToPath=function(n,o){if(null!=n){if(!o)var g=new svgedit.history.BatchCommand("Convert element to Path");var m=o?{}:{fill:T.fill,"fill-opacity":T.fill_opacity,stroke:T.stroke,"stroke-width":T.stroke_width,"stroke-dasharray":T.stroke_dasharray,"stroke-linejoin":T.stroke_linejoin,"stroke-linecap":T.stroke_linecap,"stroke-opacity":T.stroke_opacity,opacity:T.opacity,visibility:"hidden"};$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],(function(){n.getAttribute(this)&&(m[this]=n.getAttribute(this))}));var c=M({element:"path",attr:m}),f=n.getAttribute("transform");f&&c.setAttribute("transform",f);var p=n.id,x=n.parentNode;n.nextSibling?x.insertBefore(c,n):x.appendChild(c);var b,S,C="",h=function(n){$.each(n,(function(n,o){var g,m=o[0],c=o[1];for(C+=m,g=0;g<c.length;g+=2)C+=c[g]+","+c[g+1]+" "}))},w=1.81;switch(n.tagName){case"ellipse":case"circle":var _=(b=$(n).attr(["rx","ry","cx","cy"])).cx,N=b.cy;S=b.rx,ry=b.ry,"circle"==n.tagName&&(S=ry=$(n).attr("r")),h([["M",[_-S,N]],["C",[_-S,N-ry/w,_-S/w,N-ry,_,N-ry]],["C",[_+S/w,N-ry,_+S,N-ry/w,_+S,N]],["C",[_+S,N+ry/w,_+S/w,N+ry,_,N+ry]],["C",[_-S/w,N+ry,_-S,N+ry/w,_-S,N]],["Z",[]]]);break;case"path":C=n.getAttribute("d");break;case"line":b=$(n).attr(["x1","y1","x2","y2"]),C="M"+b.x1+","+b.y1+"L"+b.x2+","+b.y2;break;case"polyline":case"polygon":C="M"+n.getAttribute("points");break;case"rect":var A=$(n).attr(["rx","ry"]);S=A.rx,ry=A.ry;var k=n.getBBox(),E=k.x,B=k.y,L=k.width,O=k.height;w=4-w,S||ry?h([["M",[E,B+ry]],["C",[E,B+ry/w,E+S/w,B,E+S,B]],["L",[E+L-S,B]],["C",[E+L-S/w,B,E+L,B+ry/w,E+L,B+ry]],["L",[E+L,B+O-ry]],["C",[E+L,B+O-ry/w,E+L-S/w,B+O,E+L-S,B+O]],["L",[E+S,B+O]],["C",[E+S/w,B+O,E,B+O-ry/w,E,B+O-ry]],["L",[E,B+ry]],["Z",[]]]):h([["M",[E,B]],["L",[E+L,B]],["L",[E+L,B+O]],["L",[E,B+O]],["L",[E,B]],["Z",[]]]);break;default:c.parentNode.removeChild(c)}if(C&&c.setAttribute("d",C),o){Ee.resetOrientation(c);var D=!1;try{D=c.getBBox()}catch(n){}return c.parentNode.removeChild(c),D}if(f){var V=svgedit.transformlist.getTransformList(c);svgedit.math.hasMatrixTransform(V)&&Ee.resetOrientation(c)}var R=n.nextSibling;g.addSubCommand(new svgedit.history.RemoveElementCommand(n,R,x)),g.addSubCommand(new svgedit.history.InsertElementCommand(c)),De(),n.parentNode.removeChild(n),c.setAttribute("id",p),c.removeAttribute("visibility"),Ve([c],!0),X(g)}else $.each(I,(function(n,o){o&&v.convertToPath(o)}))},this.makeHyperlink=function(n){v.groupSelectedElements("a",n)},this.removeHyperlink=function(){v.ungroupSelectedElement()},this.setSegType=function(n){Ee.setSegType(n)};var it=this.changeSelectedAttribute=function(n,o,g){1===(g=g||I).length&&f&&g[0]&&f.indexOf(g[0].id.substr(0,4))>=0&&(g=g[0].childNodes),v.undoMgr.beginUndoableChange(n,g),g.length,He(n,o,g);var m=v.undoMgr.finishUndoableChange();m.isEmpty()||X(m)},He=function(n,o,g){var m=C.suspendRedraw(1e3);"pathedit"==current_mode&&Ee.moveNode(n,o);for(var c=(g=g||I).length,f=["g","polyline","path"],p=["transform","opacity","filter"];c--;){var x=g[c];if(null!=x)if(("x"===n||"y"===n)&&f.indexOf(x.tagName)>=0){var b=getStrokedBBox([x]),S="x"===n?o-b.x:0,w="y"===n?o-b.y:0;v.moveSelectedElements(S*k,w*k,!0)}else{"g"===x.tagName&&p.indexOf(n);var _="#text"===n?x.textContent:x.getAttribute(n);if(null==_&&(_=""),_!==String(o)){"#text"==n?(svgedit.utilities.getBBox(x).width,x.textContent=o,/rotate/.test(x.getAttribute("transform"))&&(x=Se(x))):"#href"==n?j(x,o):(x.setAttribute(n,o),ve("setGaugeAttribute",{elem:x,attr:n,value:o})),"textedit"===current_mode&&"#text"!==n&&x.textContent.length&&ke.toSelectMode(x),svgedit.browser.isGecko()&&"text"===x.nodeName&&/rotate/.test(x.getAttribute("transform"))&&(0===String(o).indexOf("url")||["font-size","font-family","x","y"].indexOf(n)>=0&&x.textContent)&&(x=Se(x)),I.indexOf(x)>=0&&setTimeout((function(){x.parentNode&&oe.requestSelector(x).resize()}),0);var N=svgedit.utilities.getRotationAngle(x);if(0!=N&&"transform"!=n)for(var A=svgedit.transformlist.getTransformList(x),E=A.numberOfItems;E--;){if(4==A.getItem(E).type){A.removeItem(E);var B=svgedit.utilities.getBBox(x),T=svgedit.math.transformPoint(B.x+B.width/2,B.y+B.height/2,svgedit.math.transformListToTransform(A).matrix),M=T.x,L=T.y,$=C.createSVGTransform();$.setRotate(N,M,L),A.insertItemBefore($,E);break}}}}}C.unsuspendRedraw(m)};this.deleteSelectedElements=function(){var n,o=new svgedit.history.BatchCommand("Delete Elements"),g=I.length,m=[];for(n=0;n<g;++n){var c=I[n];if(null==c)break;var v=c.parentNode,f=c;oe.releaseSelector(f),svgedit.path.removePath_(f.id),"a"===v.tagName&&1===v.childNodes.length&&(f=v,v=v.parentNode);var p=f.nextSibling,x=v.removeChild(f);m.push(c),I[n]=null,o.addSubCommand(new ne(x,p,v))}return o.isEmpty()||X(o),Z("changed",m),De(),m},this.cutSelectedElements=function(){var n,o=new svgedit.history.BatchCommand("Cut Elements"),g=I.length,m=[];for(n=0;n<g;++n){var c=I[n];if(null==c)break;var f=c.parentNode,p=c;oe.releaseSelector(p),svgedit.path.removePath_(p.id);var x=p.nextSibling,b=f.removeChild(p);m.push(c),I[n]=null,o.addSubCommand(new ne(b,x,f))}o.isEmpty()||X(o),Z("changed",m),De(),v.clipBoard=m},this.pasteElements=function(n,o,g){var m=v.clipBoard,c=m.length;if(c){for(var f=[],p=new svgedit.history.BatchCommand("Paste elements");c--;){var x=m[c];if(x)if(x.symbols&&x.symbols.length){var b=svgedit.utilities.findDefs();x.symbols.forEach((n=>{svgedit.utilities.getElem(n.id)||b.appendChild(n)})),x.defs&&x.defs.appendTo(b)}else{var S=be(x);f.push(S),(E||A().getCurrentLayer()).appendChild(S),p.addSubCommand(new svgedit.history.InsertElementCommand(S))}}if(Re(f),"in_place"!==n){var C,w;n?"point"===n&&(C=o,w=g):(C=lastClickPoint.x,w=lastClickPoint.y);var _=getStrokedBBox(f),N=C-(_.x+_.width/2),k=w-(_.y+_.height/2),B=[],T=[];$.each(f,(function(n,o){B.push(N),T.push(k)}));var I=v.moveSelectedElements(B,T,!1);p.addSubCommand(I)}X(p),Z("onGaugeCopyPaste",{copy:m,past:f.reverse()}),Z("changed",f)}},this.copySelectedElements=function(){v.clipBoard=$.merge([],I),qe()};var qe=function(){for(var n={symbols:[],defs:null},o=0;o<v.clipBoard.length;o++){var g=v.clipBoard[o];if(g){var m=[];svgedit.utilities.walkTree(g,(function(n){"use"===n.tagName&&m.push(n)}))}m.forEach((o=>{var g=svgedit.utilities.getElem(F(o).substr(1)),m=g.getAttribute("type");!o.getAttribute("type")&&m&&o.setAttribute("type",m),n.symbols.find((n=>n.id===g.id))||n.symbols.push(g)}))}if(n.symbols.length){const o=svgedit.utilities.findDefs();n.defs=$(o).find("linearGradient, radialGradient, pattern"),v.clipBoard.push(n)}};this.groupSelectedElements=function(n,o){n||(n="g");var g="";if("a"===n){g="Make hyperlink";var m="";arguments.length>1&&(m=o)}else n="g",g="Group Elements";var c=new svgedit.history.BatchCommand(g),v=M({element:n,attr:{id:Ae(),target:"_blank",type:"svg-ext-shapes-group"}});"a"===n&&j(v,m),c.addSubCommand(new svgedit.history.InsertElementCommand(v));for(var f=I.length;f--;){var p=I[f];if(null!=p){"a"===p.parentNode.tagName&&1===p.parentNode.childNodes.length&&(p=p.parentNode);var x=p.nextSibling,b=p.parentNode;v.appendChild(p),c.addSubCommand(new svgedit.history.MoveElementCommand(p,x,b))}}c.isEmpty()||X(c),Re([v],!0)};var rt=this.pushGroupProperties=function(n,o){var g,m,c,f=n.childNodes,p=f.length,x=n.getAttribute("transform"),b=svgedit.transformlist.getTransformList(n),S=svgedit.math.transformListToTransform(b).matrix,w=new svgedit.history.BatchCommand("Push group properties"),_=0,N=svgedit.utilities.getRotationAngle(n),A=$(n).attr(["filter","opacity"]);for(_=0;_<p;_++){var k=f[_];if(1===k.nodeType){if(null!==A.opacity&&1!==A.opacity){k.getAttribute("opacity");var E=Math.round((k.getAttribute("opacity")||1)*A.opacity*100)/100;it("opacity",E,[k])}if(A.filter){var B=this.getBlur(k),T=B;m||(m=this.getBlur(n)),B?B=Number(m)+Number(B):0===B&&(B=m),T?g=svgedit.utilities.getRefElem(k.getAttribute("filter")):g?(g=be(g),svgedit.utilities.findDefs().appendChild(g)):g=svgedit.utilities.getRefElem(A.filter);var I="feGaussianBlur"===g.firstChild.tagName?"blur":"filter";g.id=k.id+"_"+I,it("filter","url(#"+g.id+")",[k]),B&&(it("stdDeviation",B,[g.firstChild]),v.setBlurOffsets(g,B))}var M=svgedit.transformlist.getTransformList(k);if(~k.tagName.indexOf("Gradient")&&(M=null),M&&"defs"!==k.tagName&&b.numberOfItems){if(N&&1==b.numberOfItems){var L=b.getItem(0).matrix,O=C.createSVGMatrix(),D=svgedit.utilities.getRotationAngle(k);D&&(O=M.getItem(0).matrix);var V=svgedit.utilities.getBBox(k),R=svgedit.math.transformListToTransform(M).matrix,U=svgedit.math.transformPoint(V.x+V.width/2,V.y+V.height/2,R),z=N+D,F=C.createSVGTransform();F.setRotate(z,U.x,U.y);var j=svgedit.math.matrixMultiply(L,O,F.matrix.inverse());if(D&&M.removeItem(0),z&&(M.numberOfItems?M.insertItemBefore(F,0):M.appendItem(F)),j.e||j.f){var H=C.createSVGTransform();H.setTranslate(j.e,j.f),M.numberOfItems?M.insertItemBefore(H,0):M.appendItem(H)}}else{var q=k.getAttribute("transform");(c={}).transform=q||"";var W=C.createSVGTransform(),K=svgedit.math.transformListToTransform(M).matrix,Y=K.inverse(),Z=svgedit.math.matrixMultiply(Y,S,K);W.setMatrix(Z),M.appendItem(W)}var J=svgedit.recalculate.recalculateDimensions(k);J&&w.addSubCommand(J)}}}if(x&&((c={}).transform=x,n.setAttribute("transform",""),n.removeAttribute("transform"),w.addSubCommand(new svgedit.history.ChangeElementCommand(n,c))),o&&!w.isEmpty())return w};this.ungroupSelectedElement=function(){var n=I[0];if(n)if($(n).data("gsvg")||$(n).data("symbol"))Xe(n);else{if("use"===n.tagName){var o=svgedit.utilities.getElem(F(n).substr(1));return $(n).data("symbol",o).data("ref",o),void Xe(n)}var g=$(n).parents("a");if(g.length&&(n=g[0]),"g"===n.tagName||"a"===n.tagName){var m=new svgedit.history.BatchCommand("Ungroup Elements"),c=rt(n,!0);c&&m.addSubCommand(c);for(var v=n.parentNode,f=n.nextSibling,p=new Array(n.childNodes.length),x=0;n.firstChild;){var b=n.firstChild,S=b.nextSibling,C=b.parentNode;if("title"!==b.tagName)p[x++]=b=v.insertBefore(b,f),m.addSubCommand(new svgedit.history.MoveElementCommand(b,S,C));else{var w=b.nextSibling;m.addSubCommand(new svgedit.history.RemoveElementCommand(b,w,C)),C.removeChild(b)}}De();var _=n.nextSibling;n=v.removeChild(n),m.addSubCommand(new svgedit.history.RemoveElementCommand(n,_,v)),m.isEmpty()||X(m),Ve(p)}}},this.moveToTopSelectedElement=function(){var n=I[0];if(null!=n){var o=n,g=o.parentNode,m=o.nextSibling;m!=(o=o.parentNode.appendChild(o)).nextSibling&&(X(new svgedit.history.MoveElementCommand(o,m,g,"top")),Z("changed",[o]))}},this.moveToBottomSelectedElement=function(){var n=I[0];if(null!=n){var o=n,g=o.parentNode,m=o.nextSibling,c=o.parentNode.firstChild;"title"==c.tagName&&(c=c.nextSibling),"defs"==c.tagName&&(c=c.nextSibling),m!=(o=o.parentNode.insertBefore(o,c)).nextSibling&&(X(new svgedit.history.MoveElementCommand(o,m,g,"bottom")),Z("changed",[o]))}},this.moveUpDownSelected=function(n){var o=I[0];if(o){var g,m;curBBoxes=[];var c=$(we(getStrokedBBox([o]))).toArray();if("Down"==n&&c.reverse(),$.each(c,(function(){if(m)return g=this,!1;this==o&&(m=!0)})),g){var v=o,f=v.parentNode,p=v.nextSibling;$(g)["Down"==n?"before":"after"](v),p!=v.nextSibling&&(X(new svgedit.history.MoveElementCommand(v,p,f,"Move "+n)),Z("changed",[v]))}}},this.moveSelectedElements=function(n,o,g){n.constructor!=Array&&(n/=k,o/=k),g=g||!0;for(var m=new svgedit.history.BatchCommand("position"),c=I.length;c--;){var v=I[c];if(null!=v){var f=C.createSVGTransform(),p=svgedit.transformlist.getTransformList(v);n.constructor==Array?f.setTranslate(n[c],o[c]):f.setTranslate(n,o),p.numberOfItems?p.insertItemBefore(f,0):p.appendItem(f);var x=svgedit.recalculate.recalculateDimensions(v);x&&m.addSubCommand(x),oe.requestSelector(v).resize()}}if(!m.isEmpty())return g&&X(m),Z("changed",I),m},this.setFilterShadow=function(n){if(!(I.length<=0)){var o=I[0];if(n){var m=svgedit.utilities.findDefs();if(m){var c=$(m).find("filter");c&&c.length||(c=S.createElementNS(g.SVG,"filter"),m.appendChild(c),c.setAttribute("id","shadow-box"));var v=$(c).find("feDropShadow");v&&v.length||((v=S.createElementNS(g.SVG,"feDropShadow")).setAttribute("dx","2"),v.setAttribute("dy","2"),v.setAttribute("stdDeviation","2"),c.appendChild(v)),o.setAttribute("filter","url(#shadow-box)")}}else o.removeAttribute("filter")}},this.cloneSelectedElements=function(n,o){var g,m,c=new svgedit.history.BatchCommand("Clone Elements"),v=I.length;for(I.sort((function i(n,o){return $(o).index()-$(n).index()})),g=0;g<v&&null!=(m=I[g]);++g);var f=I.slice(0,g);for(this.clearSelection(!0),g=f.length;g--;)m=f[g]=be(f[g]),(E||A().getCurrentLayer()).appendChild(m),c.addSubCommand(new svgedit.history.InsertElementCommand(m));c.isEmpty()||(Ve(f.reverse()),this.moveSelectedElements(n,o,!1),X(c)),Z("onGaugeCopyPaste",{copy:I,past:f})},this.alignSelectedElements=function(n,o){var g,m,c=[],f=Number.MAX_VALUE,p=Number.MIN_VALUE,x=Number.MAX_VALUE,b=Number.MIN_VALUE,S=Number.MIN_VALUE,C=Number.MIN_VALUE,w=I.length;if(w){for(g=0;g<w&&null!=I[g];++g)switch(m=I[g],c[g]=getStrokedBBox([m]),o){case"smallest":(("l"==n||"c"==n||"r"==n)&&(S==Number.MIN_VALUE||S>c[g].width)||("t"==n||"m"==n||"b"==n)&&(C==Number.MIN_VALUE||C>c[g].height))&&(f=c[g].x,x=c[g].y,p=c[g].x+c[g].width,b=c[g].y+c[g].height,S=c[g].width,C=c[g].height);break;case"largest":(("l"==n||"c"==n||"r"==n)&&(S==Number.MIN_VALUE||S<c[g].width)||("t"==n||"m"==n||"b"==n)&&(C==Number.MIN_VALUE||C<c[g].height))&&(f=c[g].x,x=c[g].y,p=c[g].x+c[g].width,b=c[g].y+c[g].height,S=c[g].width,C=c[g].height);break;default:c[g].x<f&&(f=c[g].x),c[g].y<x&&(x=c[g].y),c[g].x+c[g].width>p&&(p=c[g].x+c[g].width),c[g].y+c[g].height>b&&(b=c[g].y+c[g].height)}"page"==o&&(f=0,x=0,p=v.contentW,b=v.contentH);var _=new Array(w),N=new Array(w);for(g=0;g<w&&null!=I[g];++g){m=I[g];var A=c[g];switch(_[g]=0,N[g]=0,n){case"l":_[g]=f-A.x;break;case"c":_[g]=(f+p)/2-(A.x+A.width/2);break;case"r":_[g]=p-(A.x+A.width);break;case"t":N[g]=x-A.y;break;case"m":N[g]=(x+b)/2-(A.y+A.height/2);break;case"b":N[g]=b-(A.y+A.height)}}this.moveSelectedElements(_,N)}},this.divideSelectedElements=function(n){var o,g,m=[],c=Number.MAX_VALUE,v=Number.MIN_VALUE,f=Number.MAX_VALUE,p=Number.MIN_VALUE,x=0,b=0,S=0,C=I.length;if(C&&!(C<3)){for(o=0;o<C&&null!=I[o];++o)g=I[o],S++,m[o]=getStrokedBBox([g]),m[o].index=o,m[o].x<c&&(c=m[o].x),m[o].y<f&&(f=m[o].y),m[o].x+m[o].width>v&&(v=m[o].x+m[o].width),m[o].y+m[o].height>p&&(p=m[o].y+m[o].height),b+=m[o].height,x+=m[o].width;"h"===n?m.sort(((n,o)=>n.x>o.x?1:-1)):"v"===n&&m.sort(((n,o)=>n.y>o.y?1:-1)),S--;var w=new Array(m.length),_=new Array(m.length),N=(v-c-x)/S,A=(p-f-b)/S,k=c,E=f;for(o=0;o<m.length;++o){var B=m[o];switch(w[o]={x:B.x,i:B.index},_[o]={y:B.y,i:B.index},n){case"h":w[o].x=o>0?k>B.x?k-B.x:-(B.x-k):0,k+=B.width+N,_[o].y=0;break;case"v":_[o].y=o>0?E>B.y?E-B.y:-(B.y-E):0,E+=B.height+A,w[o].x=0}}w.sort(((n,o)=>n.i>o.i?1:-1)),_.sort(((n,o)=>n.i>o.i?1:-1)),w=w.map((n=>Math.round(100*n.x)/100)),_=_.map((n=>Math.round(100*n.y)/100)),this.moveSelectedElements(w,_)}},this.contentW=Qe().w,this.contentH=Qe().h,this.updateCanvas=function(n,o){C.setAttribute("width",n),C.setAttribute("height",o);var g=$("#canvasBackground")[0],m=w.getAttribute("x"),c=w.getAttribute("y"),v=n/2-this.contentW*k/2,f=o/2-this.contentH*k/2;svgedit.utilities.assignAttributes(w,{width:this.contentW*k,height:this.contentH*k,x:v,y:f,viewBox:"0 0 "+this.contentW+" "+this.contentH}),svgedit.utilities.assignAttributes(g,{width:w.getAttribute("width"),height:w.getAttribute("height"),x:v,y:f});var p=svgedit.utilities.getElem("background_image");return p&&svgedit.utilities.assignAttributes(p,{width:"100%",height:"100%"}),oe.selectorParentGroup.setAttribute("transform","translate("+v+","+f+")"),ve("canvasUpdated",{new_x:v,new_y:f,old_x:m,old_y:c,d_x:v-m,d_y:f-c}),{x:v,y:f,old_x:m,old_y:c,d_x:v-m,d_y:f-c}},this.setBackground=function(n,o){var m=svgedit.utilities.getElem("canvasBackground"),c=$(m).find("rect")[0],v=svgedit.utilities.getElem("background_image");c.setAttribute("fill",n),o?(v||(v=S.createElementNS(g.SVG,"image"),svgedit.utilities.assignAttributes(v,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})),j(v,o),m.appendChild(v)):v&&v.parentNode.removeChild(v)},this.cycleElement=function(n){var o,g=I[0],m=!1,c=Ie(E||A().getCurrentLayer());if(c.length){if(null==g)m=c[o=n?c.length-1:0];else for(var v=c.length;v--;)if(c[v]==g){(o=n?v-1:v+1)>=c.length?o=0:o<0&&(o=c.length-1),m=c[o];break}Re([m],!0),Z("selected",I)}},this.clear(),this.getExtensionMember=function(n,o){var g=[];return $.each(extensions,(function(m,c){c&&n in c&&g.push(c[n](o))})),g},this.getPrivateMethods=function(){return{addCommandToHistory:X,setGradient:tt,addSvgElementFromJson:M,addSvgGroupFromJson:L,assignAttributes:W,BatchCommand:se,call:Z,ChangeElementCommand:ae,copyElem:be,ffClone:Se,findDefs:U,findDuplicateGradient:Fe,getElem:q,getId:_e,getIntersectionList:we,getMouseTarget:Ue,getNextId:Ae,getPathBBox:H,getUrlFromAttr:z,hasMatrixTransform:V,identifyLayers:Ye,InsertElementCommand:re,isIdentity:svgedit.math.isIdentity,logMatrix:Ne,matrixMultiply:D,MoveElementCommand:te,preventClickDefault:Ge,recalculateAllSelectedDimensions:$e,recalculateDimensions:J,remapElement:Y,RemoveElementCommand:ne,removeUnusedDefElems:ze,round:xe,runExtensions:ve,setSpecialsIds:fe,runGetExtensions:pe,runExtension:ye,sanitizeSvg:ee,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:R,transformPoint:O,walkTree:svgedit.utilities.walkTree}}};
17
+ var mysvgeditor={initSvgEditor:function(e,u,d,f,p,g,v,h,m){window.svgEditor=function(e){function c(u,d){var f=!1!==P.setSvgString(u);d=d||e.noop,f?d(!0):e.alert(uiStrings.notification.errorLoadingSVG,(function(){d(!1)}))}var F={};console.log("editor v2.9.12-172"),e(document).unbind("keydown"),F.tool_scale=1,F.exportWindowCt=0,F.langChanged=!1,F.showSaveWarning=!1,F.storagePromptClosed=!1,F.extensionLoadedCallback=d,F.onSelectedElement=u,F.changeColor=f,F.onGaugeAdded=p,F.onGaugeResized=v,F.onGaugeRemoved=g,F.onGaugeCopyPaste=h,F.onGroupChanged=m,F.currentExtensionsInteractivityType=[],F.currentExtensionsPrefixIdType=[],F.shapesGrps={},F.shapesList=[],F.baseSvgTags=["path","line","rect","circle","ellipse","text","image"];var P,T,L=["VAL_","HXI_","HXB_","HXS_"],D=["HXI_","HXB_","HXS_","GXP_","HXC_","BAG_","SLI_","HXT_"],I=["SHE_"],N=svgedit.utilities,B=svgedit.shapes;return isReady=!1,customExportImage=!1,customExportPDF=!1,callbacks=[],defaultPrefs={lang:"",iconsize:"",bkgd_color:"#FFF",bkgd_url:"",img_save:"embed",save_notice_done:!1,export_notice_done:!1},curPrefs={},curConfig={extensions:[],allowedOrigins:[]},defaultExtensions=["ext-overview_window.js","ext-markers.js","ext-connector.js","ext-eyedropper.js","ext-imagelib.js","ext-grid.js","ext-polygon.js","ext-panning.js","ext-storage.js"],defaultConfig={canvasName:"default",canvas_expansion:3,initFill:{color:"FF0000",opacity:1},initStroke:{width:1,color:"000000",opacity:1},initOpacity:1,colorPickerCSS:null,initTool:"select",exportWindowType:"new",wireframe:!1,showlayers:!1,no_save_warning:!1,imgPath:"images/",langPath:"locale/",extPath:"extensions/",jGraduatePath:"jgraduate/images/",shapesPath:"assets/lib/svgeditor/shapes/",dimensions:[640,480],gridSnapping:!0,gridColor:"#000",baseUnit:"px",snappingStep:2,showRulers:!0,preventAllURLConfig:!1,preventURLContentLoading:!1,lockExtensions:!1,noDefaultExtensions:!1,showGrid:!1,noStorageOnLoad:!1,forceStorage:!1,emptyStorageOnDecline:!1},uiStrings=F.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.pref=function(e,u){return u?(curPrefs[e]=u,void(F.curPrefs=curPrefs)):e in curPrefs?curPrefs[e]:defaultPrefs[e]},F.loadContentAndPrefs=function(){if(curConfig.forceStorage||!curConfig.noStorageOnLoad&&document.cookie.match(/(?:^|;\s*)store=(?:prefsAndContent|prefsOnly)/)){if(F.storage&&(curConfig.forceStorage||!curConfig.noStorageOnLoad&&document.cookie.match(/(?:^|;\s*)store=prefsAndContent/))){var e="svgedit-"+curConfig.canvasName,u=F.storage.getItem(e);u&&F.loadFromString(u)}var d;for(d in defaultPrefs)if(defaultPrefs.hasOwnProperty(d)){var f="web-edit-"+d;if(F.storage){var p=F.storage.getItem(f);p&&(defaultPrefs[d]=String(p))}else if(window.widget)defaultPrefs[d]=widget.preferenceForKey(f);else{var g=document.cookie.match(new RegExp("(?:^|;\\s*)"+N.preg_quote(encodeURIComponent(f))+"=([^;]+)"));defaultPrefs[d]=g?decodeURIComponent(g[1]):""}}}},F.setConfig=function(u,d){function o(u,d,f){u[d]&&"object"==typeof u[d]?e.extend(!0,u[d],f):u[d]=f}d=d||{},e.each(u,(function(f,p){if(u.hasOwnProperty(f))if(defaultPrefs.hasOwnProperty(f)){if(!1===d.overwrite&&(curConfig.preventAllURLConfig||curPrefs.hasOwnProperty(f)))return;!0===d.allowInitialUserOverride?defaultPrefs[f]=p:e.pref(f,p)}else if(["extensions","allowedOrigins"].indexOf(f)>-1){if(!1===d.overwrite&&(curConfig.preventAllURLConfig||"allowedOrigins"===f||"extensions"===f&&curConfig.lockExtensions))return;curConfig[f]=curConfig[f].concat(p)}else if(defaultConfig.hasOwnProperty(f)){if(!1===d.overwrite&&(curConfig.preventAllURLConfig||curConfig.hasOwnProperty(f)))return;if(curConfig.hasOwnProperty(f)){if(!1===d.overwrite)return;o(curConfig,f,p)}else!0===d.allowInitialUserOverride?o(defaultConfig,f,p):defaultConfig[f]&&"object"==typeof defaultConfig[f]?(curConfig[f]={},e.extend(!0,curConfig[f],p)):curConfig[f]=p}})),F.curConfig=curConfig},F.setCustomHandlers=function(u){F.ready((function(){u.open&&(e('#tool_open > input[type="file"]').remove(),e("#tool_open").show(),P.open=u.open),u.save&&(F.showSaveWarning=!1,P.bind("saved",u.save)),u.exportImage&&(customExportImage=u.exportImage,P.bind("exported",customExportImage)),u.exportPDF&&(customExportPDF=u.exportPDF,P.bind("exportedPDF",customExportPDF))}))},F.randomizeIds=function(){P.randomizeIds(arguments)},F.init=function(u){function n(){curPrefs=e.extend(!0,{},defaultPrefs,curPrefs),F.curPrefs=curPrefs}function o(){curConfig=e.extend(!0,{},defaultConfig,curConfig),curConfig.noDefaultExtensions||(curConfig.extensions=curConfig.extensions.concat(defaultExtensions)),e.each(["extensions","allowedOrigins"],(function(u,d){curConfig[d]=e.grep(curConfig[d],(function(e,u){return u===curConfig[d].indexOf(e)}))})),F.curConfig=curConfig}function i(u,d){var p=u.id,g=p.split("_"),v=g[0],h=g[1];d&&P.setStrokeAttr("stroke-"+v,h),pe(),f("#cur_"+v,p,20),e(u).addClass("current").siblings().removeClass("current")}function r(u,d){e.pref("bkgd_color",u),e.pref("bkgd_url",d),P.setBackground(u,d)}function l(){var u=P.getHref(K);if(u=0===u.indexOf("data:")?"":u,F.promptImgURLcallback){var d=F.promptImgURLcallback;d&&fe(d)}else e.prompt(uiStrings.notification.enterNewImgURL,u,(function(e){e&&fe(e)}))}function s(u,d){var f,p;d||(d=P.getZoom()),u||(u=e("#svgcanvas"));var g=3e4,v=P.getContentElem(),h=svgedit.units.getTypeMap()[curConfig.baseUnit];for(f=0;f<2;f++){var m=0===f,F=m?"x":"y",T=m?"width":"height",L=Number(v.getAttribute(F)),D=e("#ruler_"+F+" canvas:first"),I=D.clone();D.replaceWith(I);var N=I[0],B=u[T](),O=B;N.parentNode.style[T]=O+"px";var U,R,M,G=0,z=N.getContext("2d");if(z.fillStyle="#666666",z.fillRect(0,0,N.width,N.height),I.siblings().remove(),B>=g){var j;for(M=parseInt(B/g,10)+1,(U=[])[0]=z,p=1;p<M;p++)N[T]=g,j=N.cloneNode(!0),N.parentNode.appendChild(j),U[p]=j.getContext("2d");j[T]=B%g,B=g}N[T]=B;var H=h*d,W=50/H,V=1;for(p=0;p<re.length&&(V=R=re[p],!(W<=R));p++);var X=V*H;z.font="8px sans-serif";for(var Z=L/H%V*H,q=Z-X;Z<O;){q+=X,z.fillStyle="#CACACA";var K,Y=Math.round(Z)+.5;if(m?(z.moveTo(Y,15),z.lineTo(Y,0)):(z.moveTo(15,Y),z.lineTo(0,Y)),R=(q-L)/H,V>=1)K=Math.round(R);else{var J=String(V).split(".")[1].length;K=R.toFixed(J)}if(0!==K&&1e3!==K&&K%1e3==0&&(K=K/1e3+"K"),m)z.fillText(K,Z+2,8);else{var $=String(K).split("");for(p=0;p<$.length;p++)z.fillText($[p],1,Z+9+9*p)}var ee=X/10;for(p=1;p<10;p++){var te=Math.round(Z+ee*p)+.5;if(U&&te>B){if(G++,z.stroke(),G>=M){p=10,Z=O;continue}z=U[G],Z-=g,te=Math.round(Z+ee*p)+.5}var ne=p%2?12:10;m?(z.moveTo(te,15),z.lineTo(te,ne)):(z.moveTo(15,te),z.lineTo(ne,te))}Z+=X}z.strokeStyle="#666666",z.stroke()}}function _(){P.deleteCurrentLayer()&&(ye(),se(),e("#layerlist tr.layer").removeClass("layersel"),e("#layerlist tr.layer:first").addClass("layersel"))}function w(){var u=P.getCurrentDrawing().getCurrentLayerName()+" copy";e.prompt(uiStrings.notification.enterUniqueLayerName,u,(function(u){u&&(P.getCurrentDrawing().hasLayer(u)?e.alert(uiStrings.notification.dupeLayerName):(P.cloneLayer(u),ye(),se()))}))}function y(){e("#layerlist tr.layersel").index()!=P.getCurrentDrawing().getNumLayers()-1&&(P.mergeLayer(),ye(),se())}function b(u){var d=e("#layerlist tr.layersel").index(),f=P.getCurrentDrawing().getNumLayers();(d>0||d<f-1)&&(d+=u,P.setCurrentLayerPosition(f-d-1),se())}try{"localStorage"in window&&(F.storage=localStorage)}catch(e){}var d=[];e("#lang_select option").each((function(){d.push(this.value)})),function(){var u,d;if(T=e.deparam.querystring(!0),e.isEmptyObject(T))o(),F.loadContentAndPrefs(),n();else{if(T.dimensions&&(T.dimensions=T.dimensions.split(",")),T.bkgd_color&&(T.bkgd_color="#"+T.bkgd_color),T.extensions&&(T.extensions=T.extensions.match(/[:\/\\]/)?"":T.extensions.split(",")),e.each(["extPath","imgPath","langPath","jGraduatePath"],(function(e){T[e]&&delete T[e]})),F.setConfig(T,{overwrite:!1}),o(),!curConfig.preventURLContentLoading){if(u=T.source,d=e.param.querystring(),u||d.indexOf("source=data:")>=0&&(u=d.match(/source=(data:[^&]*)/)[1]),u)return void(0===u.indexOf("data:")?F.loadFromDataURI(u):F.loadFromString(u));if(T.url)return void F.loadFromURL(T.url)}T.noStorageOnLoad&&!curConfig.forceStorage||F.loadContentAndPrefs(),n()}}(),function(){var e,d=window.opener;if(d)try{(e=d.document.createEvent("Event")).initEvent("svgEditorReady",!0,!0),d.document.documentElement.dispatchEvent(e)}catch(e){}u&&setTimeout(u,2e3)}();var f=F.setIcon=function(u,d,f){var p="string"==typeof d?e.getSvgIcon(d,!0):d.clone();p&&e(u).empty().append(p)},A=function(){window.extOverview&&window.extOverview(),window.extMarkers&&window.extMarkers(),window.extEyedropper&&window.extEyedropper(),window.extImagelib&&window.extImagelib(),window.extGrid&&window.extGrid(),window.extPanning&&window.extPanning(),window.extStorage&&window.extStorage(),window.extSwitch&&window.extSwitch(),window.extValue&&window.extValue(),window.extHtmlInput&&window.extHtmlInput(),window.extHtmlChart&&window.extHtmlChart(),window.extHtmlGraph&&window.extHtmlGraph(),window.extHtmlSelect&&window.extHtmlSelect(),window.extHtmlButton&&window.extHtmlButton(),window.extGaugeProgress&&window.extGaugeProgress(),window.extGaugeSemaphore&&window.extGaugeSemaphore(),window.extHtmlBag&&window.extHtmlBag(),window.extLinear&&window.extLinear(),window.extPipe&&window.extPipe(),window.extHtmlSlider&&window.extHtmlSlider(),window.extHtmlSwitch&&window.extHtmlSwitch(),window.extOwnCtrl&&window.extOwnCtrl(),F.putLocale&&F.putLocale(null,d)};"file:"===document.location.protocol&&setTimeout(A,100),F.canvas=P=new e.SvgCanvas(document.getElementById("svgcanvas"),curConfig);var p,v,h,m,O=svgedit.browser.isMac()?"meta+":"ctrl+",U=P.pathActions,R=P.undoMgr,M=curConfig.imgPath+"logo.png",G=e("#workarea"),z=e("#cmenu_canvas"),j=null,H="crosshair",W="crosshair",V="toolbars",X="",Z={fill:null,stroke:null};!function(){e("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var u=e("#dialog_box"),d=e("#dialog_buttons"),f=e("#dialog_content"),i=function(p,g,v,h,m,F,P){var T,L,D;if(f.html("<p>"+g.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt","prompt"==p),d.empty(),T=e('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(d),"alert"!==p&&e('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(d).click((function(){u.hide(),v&&v(!1)})),"prompt"===p)(L=e('<input type="text">').prependTo(d)).val(h||""),L.bind("keydown","return",(function(){T.click()}));else if("select"===p){var I=e('<div style="text-align:center;">');if(L=e("<select>").appendTo(I),P){var N=e("<label>").text(P.label);(D=e('<input type="checkbox">').appendTo(N)).val(P.value),P.tooltip&&N.attr("title",P.tooltip),D.prop("checked",!!P.checked),I.append(e("<div>").append(N))}e.each(m||[],(function(u,d){"object"==typeof d?L.append(e("<option>").val(d.value).html(d.text)):L.append(e("<option>").html(d))})),f.append(I),h&&L.val(h),F&&L.bind("change","return",F),L.bind("keydown","return",(function(){T.click()}))}else"process"===p&&T.hide();u.show(),T.click((function(){u.hide();var e="prompt"!==p&&"select"!==p||L.val();v&&(D?v(e,D.prop("checked")):v(e))})).focus(),"prompt"!==p&&"select"!==p||L.focus()};e.alert=function(e,u){i("alert",e,u)},e.confirm=function(e,u){i("confirm",e,u)},e.process_cancel=function(e,u){i("process",e,u)},e.prompt=function(e,u,d){i("prompt",e,d,u)},e.select=function(e,u,d,f,p,g){i("select",e,d,p,u,f,g)}}();var q,Q=function(){var u=e(".tool_button_current");u.length&&"tool_select"!==u[0].id&&(u.removeClass("tool_button_current").addClass("tool_button"),e("#tool_select").addClass("tool_button_current").removeClass("tool_button"),e("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all} #svgcanvas svg{cursor:default}")),P.setMode("select"),G.css("cursor","auto")},K=null,Y=!1,J=!1,$=!1,ee=!1,te=!1,ne=!1,oe=!1,ie="",ae=e("title:first").text(),re=[];for(q=.1;q<1e5;q*=10)re.push(q),re.push(2*q),re.push(5*q);var le=function(e){var u,d=[],f=P.getCurrentDrawing().getNumLayers();for(u=0;u<f;u++)d[u]=P.getCurrentDrawing().getLayerName(u);if(e)for(u=0;u<f;++u)d[u]!=e&&P.getCurrentDrawing().setLayerOpacity(d[u],.5);else for(u=0;u<f;++u)P.getCurrentDrawing().setLayerOpacity(d[u],1)},se=function(){P.clearSelection();for(var u=e("#layerlist tbody").empty(),d=e("#selLayerNames").empty(),f=P.getCurrentDrawing(),p=f.getCurrentLayerName(),g=P.getCurrentDrawing().getNumLayers(),v=e.getSvgIcon("eye");g--;){var h=f.getLayerName(g),m=e('<tr class="layer">').toggleClass("layersel",h===p),F=e('<td class="layervis">').toggleClass("layerinvis",!f.getLayerVisibility(h)),T=e('<td class="layername">'+h+"</td>");u.append(m.append(F,T)),d.append('<option value="'+h+'">'+h+"</option>")}if(void 0!==v){var L=v.clone();e("td.layervis",u).append(L),e.resizeSvgIcons({"td.layervis .svg_icon":14})}e("#layerlist td.layername").mouseup((function(u){e("#layerlist tr.layer").removeClass("layersel"),e(this.parentNode).addClass("layersel"),P.setCurrentLayer(this.textContent),u.preventDefault()})).mouseover((function(){le(this.textContent)})).mouseout((function(){le()})),e("#layerlist td.layervis").click((function(){var u=e(this.parentNode).prevAll().length,d=e("#layerlist tr.layer:eq("+u+") td.layername").text(),f=e(this).hasClass("layerinvis");P.setLayerVisibility(d,f),e(this).toggleClass("layerinvis")}));for(var D=5-e("#layerlist tr.layer").size();D-- >0;)u.append('<tr><td style="color:white">_</td><td/></tr>')},ce=function(u,d){te||(te=!0,X=P.getSvgString(),e("#save_output_btns").toggle(!!d),e("#tool_source_back").toggle(!d),e("#svg_source_textarea").val(X),e("#svg_source_editor").fadeIn(),e("#svg_source_textarea").focus())},pe=function(){window.opera&&e("<p/>").hide().appendTo("body").remove()},ue=F.toolButtonClick=function(u,d){if(e(u).hasClass("disabled"))return!1;if(e(u).parent().hasClass("tools_flyout"))return!0;return d||e(".tools_flyout").fadeOut("normal"),e("#styleoverrides").text(""),G.css("cursor","auto"),e(".tool_button_current").removeClass("tool_button_current").addClass("tool_button"),e(u).addClass("tool_button_current").removeClass("tool_button"),!0},de=F.clickSelect=function(){ue("#tool_select")&&(P.setMode("select"),e("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}"))},fe=F.setImageURL=function(u){u||(u=M),P.setImageURL(u),e("#image_url").val(u),0===u.indexOf("data:")?(e("#image_url").hide(),e("#change_image_url").hide()):(P.embedImage(u,(function(d){e("#url_notice").toggle(!d),M=u})),e("#image_url").hide(),e("#change_image_url").hide())};F.promptImgURLcallback=null;var ge=F.updateCanvas=function(u,d){var f=G.width(),p=G.height(),g=f,v=p,h=P.getZoom(),m=G,L=e("#svgcanvas"),D=m[0].scrollLeft+g/2,I=m[0].scrollTop+v/2,N=curConfig.canvas_expansion;f=Math.max(g,P.contentW*h*N),p=Math.max(v,P.contentH*h*N),f==g&&p==v?G.css("overflow","hidden"):G.css("overflow","scroll");var B=L.height()/2,O=L.width()/2;L.width(f).height(p);var U=p/2,R=f/2,M=P.updateCanvas(f,p),z=R/O,j=f/2-g/2,H=p/2-v/2;d?(d.x+=M.x,d.y+=M.y):d={x:R+(D-O)*z,y:U+(I-B)*z};u?P.contentW>m.width()?(G[0].scrollLeft=M.x-10,G[0].scrollTop=M.y-10):(m[0].scrollLeft=j,m[0].scrollTop=H):(m[0].scrollLeft=d.x-g/2,m[0].scrollTop=d.y-v/2),curConfig.showRulers&&(s(L,h),G.scroll()),!0===T.storagePrompt||F.storagePromptClosed||e("#dialog_box").hide()},_e=function(){var u,d,f="none"==P.getColor("fill"),p="none"==P.getColor("stroke"),g=["#tool_fhpath","#tool_line"],v=["#tools_rect .tool_button","#tools_ellipse .tool_button","#tool_text","#tool_path"];if(p)for(u in g)e(d=g[u]).hasClass("tool_button_current")&&de(),e(d).addClass("disabled");else for(u in g)e(d=g[u]).removeClass("disabled");if(p&&f)for(u in v)e(d=v[u]).hasClass("tool_button_current")&&de(),e(d).addClass("disabled");else for(u in v)e(d=v[u]).removeClass("disabled");P.runExtensions("toolButtonStateUpdate",{nofill:f,nostroke:p}),e(".tools_flyout").each((function(){var u=e("#"+this.id+"_show"),d=!1;e(this).children().each((function(){e(this).hasClass("disabled")||(d=!0)})),u.toggleClass("disabled",!d)})),pe()},we=function(){var u,d;if(null!=K)switch(K.tagName){case"use":case"image":case"foreignObject":break;case"g":case"a":var f=null,p=K.getElementsByTagName("*");for(u=0,d=p.length;u<d;u++){var g=p[u].getAttribute("stroke-width");0===u?f=g:f!==g&&(f=null)}e("#stroke_width").val(null===f?"1":f),Z.fill.update(!0);break;default:Z.fill.update(!0),Z.stroke.update(!0);var v=K.getAttribute("stroke-width");e("#stroke_width").val(null===v||"null"===v?"1":v),e("#stroke_style").val(K.getAttribute("stroke-dasharray")||"none");var h=K.getAttribute("stroke-linejoin")||"miter";0!=e("#linejoin_"+h).length&&i(e("#linejoin_"+h)[0]),h=K.getAttribute("stroke-linecap")||"butt",0!=e("#linecap_"+h).length&&i(e("#linecap_"+h)[0])}if(null!=K){var m=100*(K.getAttribute("opacity")||1);e("#group_opacity").val(m),e("#opac_slider").slider("option","value",m),e("#elem_id").val(K.id),e("#elem_class").val(K.getAttribute("class"))}_e()},ye=function(){var u=K;null==u||u.parentNode||(u=null);var d=P.getCurrentDrawing().getCurrentLayerName(),p=P.getMode(),g="px"!==curConfig.baseUnit?curConfig.baseUnit:null,v="pathedit"==p,h=e("#cmenu_canvas li");if(e("#selected_panel, #multiselected_panel, #threemoreselected_panel, #g_panel, #rect_panel, #circle_panel,#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel, #xy_panel, #marker_panel, #htmlctrl_panel, #tool_stroke, #tool_angle, #shape_panel").hide(),$||ee||v||e("#tool_stroke").show(),null!=u){var m=u.nodeName;e("#tool_angle").show();var T=P.getRotationAngle(u);e("#angle").val(T);var I=P.getBlur(u);if(e("#blur").val(I),e("#blur_slider").slider("option","value",I),P.addedNew&&"image"===m&&0!==P.getHref(u).indexOf("data:")&&l(),v||"pathedit"==p){var N=U.getNodePoint();if(e("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button"),e("#tool_node_delete").toggleClass("disabled",!U.canDeleteNodes),f("#tool_openclose_path",U.closed_subpath?"open_path":"close_path"),N){var B=e("#seg_type");g&&(N.x=svgedit.units.convertUnit(N.x),N.y=svgedit.units.convertUnit(N.y)),e("#path_node_x").val(N.x),e("#path_node_y").val(N.y),N.type?B.val(N.type).removeAttr("disabled"):B.val(4).attr("disabled","disabled")}return}if(e("#selected_panel").show(),["line","circle","ellipse"].indexOf(m)>=0)e("#xy_panel").hide();else{var O,M;if(["g","polyline","path"].indexOf(m)>=0){var G=P.getStrokedBBox([u]);G&&(O=G.x,M=G.y)}else O=u.getAttribute("x"),M=u.getAttribute("y");if(g&&(O=svgedit.units.convertUnit(O),M=svgedit.units.convertUnit(M)),u.getAttribute("width"),u.getAttribute("heght"),O=(O=Number.parseFloat(O)).toFixed(Number.isInteger(O)?0:2),M=(M=Number.parseFloat(M)).toFixed(Number.isInteger(M)?0:2),e("#selected_x").val(O||0),e("#selected_y").val(M||0),e("#xy_panel").show(),D.indexOf(u.id.substr(0,4))>=0){var j=svgedit.utilities.getBBox(u);e("#htmlctrl_panel").show(),e("#htmlctrl_width").val(j.width||0),e("#htmlctrl_height").val(j.height||0)}}var H=-1==["image","text","path","g","use"].indexOf(m);e("#tool_topath").toggle(H),e("#tool_reorient").toggle("path"===m),e("#tool_reorient").toggleClass("disabled",0===T);var W={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:[]},V=u.tagName,X=null;"a"===V&&(X=P.getHref(u),e("#g_panel").show()),"a"===u.parentNode.tagName&&(e(u).siblings().length||(e("#a_panel").show(),X=P.getHref(u.parentNode))),e("#tool_make_link, #tool_make_link").toggle(!X),X&&e("#link_url").val(X);var Z=!1;if(W[V]){var q=W[V],te=u.getAttribute("type");te&&0===te.indexOf("svg-ext")?"svg-ext-shapes-group"!==te&&(Z=!0):e("#"+V+"_panel").show(),e.each(q,(function(d,f){var p=u.getAttribute(f);if("px"!==curConfig.baseUnit&&u[f]){var g=u[f].baseVal.value;p=svgedit.units.convertUnit(g)}e("#"+V+"_"+f).val(p||0)}));var ne="g"===V&&L.indexOf(u.id.substr(0,4))>=0;if("text"==V||ne){if(e("#text_panel").css("display","inline"),P.getItalic()?e("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):e("#tool_italic").removeClass("push_button_pressed").addClass("tool_button"),P.getBold()?e("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):e("#tool_bold").removeClass("push_button_pressed").addClass("tool_button"),e("#font_family").val(u.getAttribute("font-family")),e("#font_size").val(u.getAttribute("font-size")),e("#text_anchor").val(u.getAttribute("text-anchor")),ne){var oe=P.getExtensionFont(u);oe&&(oe.fontFamily&&e("#font_family").val(oe.fontFamily),oe.fontSize&&e("#font_size").val(oe.fontSize.replace("px","")),oe.textAnchor&&e("#text_anchor").val(oe.textAnchor))}e("#text").val(u.textContent),P.addedNew&&!ne&&setTimeout((function(){e("#text").focus().select()}),100)}else"image"==V?fe(P.getHref(u)):"g"===V||"use"===V?(e("#container_panel").show(),P.getTitle()):"line"===V&&e("#marker_panel").show()}h[("g"===V?"en":"dis")+"ableContextMenuItems"]("#ungroup"),h[("g"!==V&&Y?"en":"dis")+"ableContextMenuItems"]("#group"),Z&&h.disableContextMenuItems("#ungroup"),"svg-ext-shapes-group"===u.getAttribute("type")&&e("#g_panel").show()}else Y?(e("#multiselected_panel").show(),h.enableContextMenuItems("#group").disableContextMenuItems("#ungroup"),J&&e("#threemoreselected_panel").show()):h.disableContextMenuItems("#interactivity,#editBindOfTags,#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");!$&&!ee||Y||(h.disableContextMenuItems("#ungroup"),e("#g_panel").hide()),e("#tool_undo").toggleClass("disabled",0===R.getUndoStackSize()),e("#tool_redo").toggleClass("disabled",0===R.getRedoStackSize()),P.addedNew=!1,u&&!v||Y?(e("#selLayerNames").removeAttr("disabled").val(d),z.enableContextMenuItems("#delete,#deselect,#cut,#copy,#move_front,#move_up,#move_down,#move_back")):e("#selLayerNames").attr("disabled","disabled"),h.disableContextMenuItems("#interactivity,#editBindOfTags"),u&&!Y&&(((te=u.getAttribute("type"))&&te.startsWith("svg-ext-")||F.baseSvgTags.indexOf(u.tagName)>-1)&&h.enableContextMenuItems("#interactivity,#editBindOfTags"))},be=function(){if(!p){var u="#workarea.wireframe #svgcontent * { stroke-width: "+1/P.getZoom()+"px; }";e("#wireframe_rules").text(G.hasClass("wireframe")?u:"")}},Ce=function(u){u=u||P.getDocumentTitle();var d=ae+(u?": "+u:"");e("title:first").text(d)},Ae=function(){be()},ve=P.zoomChanged=function(u,d,f){var p=G,g=P.setBBoxZoom(d,p.width()-0,p.height()-0);if(g){var h=g.zoom,m=g.bbox;h<.001?v({value:.1}):(e("#zoom").val((100*h).toFixed(1)),f?ge():ge(!1,{x:m.x*h+m.width*h/2,y:m.y*h+m.height*h/2}),"zoom"==P.getMode()&&m.width&&Q(),Ae())}},he=P.myZoomed=function(u,d){w_area=G;var f=P.setBBoxZoom(d.bbox,w_area.width()-0,w_area.height()-0);if(f){var p=f.zoom;p<.001?v({value:.1}):(e("#zoom").val((100*p).toFixed(1)),d.center?ge():ge(!1,d.bbox),Ae())}};v=function(e){var u=e.value/100;if(u<.001)e.value=.1;else{var d=P.getZoom(),f=G;ve(window,{width:0,height:0,x:(f[0].scrollLeft+f.width()/2)/d,y:(f[0].scrollTop+f.height()/2)/d,zoom:u},!0)}},e("#cur_context_panel").delegate("a","click",(function(){var u=e(this);return u.attr("data-root")?P.leaveContext():P.setContext(u.text()),P.clearSelection(),!1}));var Ie=function(){Z.fill.prep(),Z.stroke.prep()},me={},Be=function(){e(".tools_flyout").each((function(){var u=e("#"+this.id+"_show");if(!u.data("isLibrary")){var d=[];e(this).children().each((function(){d.push(this.title)})),u[0]&&(u[0].title=d.join(" / "))}}))},Oe=function(){e(".tools_flyout").each((function(){var u=e("#"+this.id+"_show"),d=u.offset(),f=u.outerWidth();d&&e(this).css({left:(d.left+f)*F.tool_scale,top:d.top})}))},xe=function(){var e,u=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,d=document.getElementsByTagName("script")[0];for(e in d.style)if(u.test(e))return e.match(u)[0];return"WebkitOpacity"in d.style?"Webkit":"KhtmlOpacity"in d.style?"Khtml":""}(),ke=F.setIconSize=function(u){var d="#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",f=e(d),p=1;if("number"==typeof u)p=u;else{p={s:.75,m:1,l:1.25,xl:1.5}[u]}F.tool_scale=p,Oe();var g=f.parents(":hidden");g.css("visibility","hidden").show(),function(u,d){var f=["top","left","bottom","right"];u.each((function(){var u,p=e(this),g=p.outerWidth()*(d-1),v=p.outerHeight()*(d-1);for(u=0;u<4;u++){var h=f[u],m=p.data("orig_margin-"+h);null==m&&(m=parseInt(p.css("margin-"+h),10),p.data("orig_margin-"+h,m));var F=m*d;"right"===h?F+=g:"bottom"===h&&(F+=v),p.css("margin-"+h,F)}}))}(f,p),g.css("visibility","visible").hide(),e.pref("iconsize",u),e("#iconsize").val(u);var v={"#tools_top":{left:50+e("#main_button").width(),height:72},"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}},h=e("#tool_size_rules");if(h.length?h.empty():h=e('<style id="tool_size_rules"></style>').appendTo("head"),"m"!==u){var m="";e.each(v,(function(d,f){d="#svg_editor "+d.replace(/,/g,", #svg_editor"),m+=d+"{",e.each(f,(function(e,d){var f;"number"==typeof d?f=d*p+"px":(d[u]||d.all)&&(f=d[u]||d.all),m+=e+":"+f+";"})),m+="}"}));var P="-"+xe.toLowerCase()+"-";m+=d+"{"+P+"transform: scale("+p+");} #svg_editor div.toolset .toolset {"+P+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+P+"transform: scale("+1/p+");}",h.text(m)}Oe()},je=function(u,d,p,g){var v=e(u);d=e(d);var h=!1,m=g.dropUp;m&&e(u).addClass("dropup"),d.find("li").bind("mouseup",(function(){g.seticon&&(f("#cur_"+v[0].id,e(this).children()),e(this).addClass("current").siblings().removeClass("current")),p.apply(this,arguments)})),e(window).mouseup((function(e){h||(v.removeClass("down"),d.hide(),d.css({top:0,left:0})),h=!1})),v.bind("mousedown",(function(){var e=v.offset();m?(e.top-=d.height(),e.left+=8):e.top+=v.height(),d.offset(e),v.hasClass("down")?(d.hide(),d.css({top:0,left:0})):(d.show(),h=!0),v.toggleClass("down")})).hover((function(){h=!0})).mouseout((function(){h=!1})),g.multiclick&&d.mousedown((function(){h=!0}))},Se=[],Ve=function(u,d,f){var p={alpha:d};if(0===u.indexOf("url(#")){var g=P.getRefElem(u);p[(g=g?g.cloneNode(!0):e("#"+f+"_color defs *")[0]).tagName]=g}else 0===u.indexOf("#")?p.solidColor=u.substr(1):p.solidColor="none";return new e.jGraduate.Paint(p)};e("#text").focus((function(){})),e("#text").blur((function(){})),P.bind("onGaugeAdded",(function(e,u){F.onGaugeAdded&&F.onGaugeAdded(u)})),P.bind("onGaugeResized",(function(e,u){F.onGaugeResized&&F.onGaugeResized(u)})),P.bind("onGaugeCopyPaste",(function(e,u){F.onGaugeCopyPaste&&F.onGaugeCopyPaste(u)})),P.bind("selected",(function(u,d){var p=P.getMode();"select"===p&&Q();var g="pathedit"==p;K=1===d.length||null==d[1]?d[0]:null,Y=d.length>=2&&null!=d[1],J=d.length>=3&&null!=d[2],$=!1,ee=!1;for(var v=0;v<d.length;v++)d[v]&&d[v].id&&(0===d[v].id.indexOf("HX")?$=!0:0===d[v].id.indexOf("PIE")&&(ee=!0));null!=K&&(g||ee||we()),function(u,d){e("#path_node_panel").toggle(u),e("#tools_bottom_2,#tools_bottom_3").toggle(!u),u?(e(".tool_button_current").removeClass("tool_button_current").addClass("tool_button"),e("#tool_select").addClass("tool_button_current").removeClass("tool_button"),f("#tool_select","select_node"),Y=!1,J=!1,d.length&&(K=d[0])):setTimeout((function(){f("#tool_select","select")}),1e3)}(g,d),ye(),P.runExtensions("selectedChanged",{elems:d,selectedElement:K,multiselected:Y}),ee&&e("#marker_panel").hide();var h=[];if(Y){for(v=0;v<d.length;v++)d[v]&&h.push({id:d[v].id,type:d[v].getAttribute("type")});F.onSelectedElement(h)}else K?(h.push({id:K.id,type:K.getAttribute("type")}),F.onSelectedElement(h)):F.onSelectedElement(null)})),P.bind("transition",(function(u,d){var f=P.getMode(),p=d[0];if(p){if(Y=d.length>=2&&null!=d[1],J=d.length>=3&&null!=d[2],!Y&&"rotate"===f){var g=P.getRotationAngle(p);e("#angle").val(g),e("#tool_reorient").toggleClass("disabled",0===g)}P.runExtensions("elementTransition",{elems:d})}})),P.bind("changed",(function(e,u){var d,f=P.getMode();for("select"===f&&Q(),d=0;d<u.length;++d){var p=u[d];p&&"svg"===p.tagName?(se(),ge()):p&&K&&null==K.parentNode&&(K=p)}F.showSaveWarning=!0,ye(),K&&"select"===f&&(Z.fill.update(),Z.stroke.update()),P.runExtensions("elementChanged",{elems:u})})),P.bind("saved",(function(u,d){if(F.showSaveWarning=!1,d='<?xml version="1.0"?>\n'+d,svgedit.browser.isIE())ce(0,!0);else{var f=u.open("data:image/svg+xml;base64,"+N.encode64(d)),p=e.pref("save_notice_done");if("all"!==p){var g=uiStrings.notification.saveFromBrowser.replace("%s","SVG");svgedit.browser.isGecko()?-1!==d.indexOf("<defs")?(g+="\n\n"+uiStrings.notification.defsFailOnSave,e.pref("save_notice_done","all"),p="all"):e.pref("save_notice_done","part"):e.pref("save_notice_done","all"),"part"!==p&&f.alert(g)}}})),P.bind("exported",(function(u,d){var f=d.issues,p=d.exportWindowName;if(p&&(j=window.open("",p)),j.location.href=d.datauri,"all"!==e.pref("export_notice_done")){var g=uiStrings.notification.saveFromBrowser.replace("%s",d.type);if(f.length){var v="\n • ";g+="\n\n"+uiStrings.notification.noteTheseIssues+v+f.join(v)}e.pref("export_notice_done","all"),j.alert(g)}})),P.bind("exportedPDF",(function(e,u){var d=u.exportWindowName;d&&(j=window.open("",d)),j.location.href=u.dataurlstring})),P.bind("zoomed",ve),P.bind("myZoomed",he),P.bind("contextset",(function(u,d){var f="";if(d){var p="";f='<a href="#" data-root="y">'+P.getCurrentDrawing().getCurrentLayerName()+"</a>",e(d).parentsUntil("#svgcontent > g").andSelf().each((function(){this.id&&(p+=" > "+this.id,f+=this!==d?' > <a href="#">'+this.id+"</a>":" > "+this.id)})),ie=p}else ie=null;e("#cur_context_panel").toggle(!!d).html(f),Ce()})),P.bind("extension_added",(function(u,d){if(d){var f=!1;if(d.langReady)if(F.langChanged){var p=e.pref("lang");d.langReady({lang:p,uiStrings:uiStrings})}else Se.push(d);var g=[];d.context_tools&&e.each(d.context_tools,(function(u,d){var f,p=d.container_id?' id="'+d.container_id+'"':"",v=e("#"+d.panel);switch(v.length||(v=e("<div>",{id:d.panel}).appendTo("#tools_top")),d.type){case"tool_button":f='<div class="tool_button">'+d.id+"</div>";var h=e(f).appendTo(v);d.events&&e.each(d.events,(function(u,d){e(h).bind(u,d)}));break;case"select":f="<label"+p+'><select id="'+d.id+'">',e.each(d.options,(function(e,u){var p=e==d.defval?" selected":"";f+='<option value="'+e+'"'+p+">"+u+"</option>"}));var m=e(f+="</select></label>").appendTo(v).find("select");e.each(d.events,(function(u,d){e(m).bind(u,d)}));break;case"button-select":f='<div id="'+d.id+'" class="dropdown toolset" title="'+d.title+'"><div id="cur_'+d.id+'" class="icon_label"></div><button></button></div>';var F=e('<ul id="'+d.id+'_opts"></ul>').appendTo("#option_lists");d.colnum&&F.addClass("optcols"+d.colnum),e(f).appendTo(v).children(),g.push({elem:"#"+d.id,list:"#"+d.id+"_opts",title:d.title,callback:d.events.change,cur:"#cur_"+d.id});break;case"input":f="<label"+p+'><span id="'+d.id+'_label">'+d.label+':</span><input id="'+d.id+'" title="'+d.title+'" size="'+(d.size||"4")+'" value="'+(d.defval||"")+'" type="text"/></label>';var P=e(f).appendTo(v).find("input");d.spindata&&P.SpinButton(d.spindata),d.events&&e.each(d.events,(function(e,u){P.bind(e,u)}))}})),d.mySetMarker&&(F.setMarker=d.mySetMarker),d.callback&&!f&&(f=!0,d.callback())}})),P.textActions.setInputElem(e("#text")[0]);var Ee='<div class="palette_item" style="background-color:#FFF;color:red;font-size:20px;line-height: 15px;text-align:center;" data-rgb="none">X</div>';e.each(["#FFFFFF","#000000","#333333","#4D4D4D","#666666","#808080","#999999","#B3B3B3","#CCCCCC","#E6E6E6","#ECECEC","#F9F9F9","#05285B","#073984","#094BAC","#0B5CD5","#0D6EFD","#3485FD","#5A9CFE","#81B4FE","#A8CBFE","#250657","#35087E","#450BA5","#560DCB","#6610F2","#7E36F4","#975CF6","#AF83F8","#C8A9FA","#281845","#3A2264","#4B2D83","#5D37A2","#6F42C1","#8660CB","#9D7ED5","#B49DDF","#CBBBE9","#4D1230","#6F1B45","#92235A","#B42B6F","#D63384","#DD5498","#E374AB","#EA95BF","#F0B6D3","#4F1319","#721C24","#96242F","#B92D3A","#DC3545","#E25563","#E77681","#ED969E","#F2B6BC","#5B2D07","#84420A","#AC560E","#D56A11","#FD7E14","#FD933A","#FEA75F","#FEBC85","#FED1AA","#5C4503","#856404","#AD8305","#D6A206","#FFC107","#FFCB2F","#FFD556","#FFDF7E","#FFE9A6","#0E3C19","#155724","#1B722F","#228C3A","#28A745","#4AB563","#6DC381","#8FD19E","#B2DFBC","#0C4836","#11694F","#168967","#1BA97F","#20C997","#44D2A8","#67DAB8","#8BE3C9","#AFECDA","#083A42","#0C5460","#106E7D","#13889B","#17A2B8","#3CB1C3","#61C0CF","#86CFDA","#ABDEE5"],(function(e,u){Ee+='<div class="palette_item" style="background-color: '+u+';" data-rgb="'+u+'"></div>'})),e("#palette").append(Ee);Ee="",e.each(["#FFF","#888","#000"],(function(){Ee+='<div class="color_block" style="background-color:'+this+';"></div>'})),e("#bg_blocks").append(Ee);var Fe=e("#bg_blocks div"),Pe="cur_background";Fe.each((function(){e(this).click((function(){Fe.removeClass(Pe),e(this).addClass(Pe)}))})),r(e.pref("bkgd_color"),e.pref("bkgd_url")),e("#image_save_opts input").val([e.pref("img_save")]);var et=function(u,d){null==d&&(d=u.value),e("#group_opacity").val(d),u&&u.handle||e("#opac_slider").slider("option","value",d),P.setOpacity(d/100)},tt=function(u,d,f){null==d&&(d=u.value),e("#blur").val(d);var p=!1;u&&u.handle||(e("#blur_slider").slider("option","value",d),p=!0),f?P.setBlurNoUndo(d):P.setBlur(d,p)};e("#stroke_style").change((function(){P.setStrokeAttr("stroke-dasharray",e(this).val()),pe()})),e("#stroke_linejoin").change((function(){P.setStrokeAttr("stroke-linejoin",e(this).val()),pe()})),e("select").change((function(){e(this).blur()}));var Te=!1;e("#selLayerNames").change((function(){var u=this.options[this.selectedIndex].value,d=uiStrings.notification.QmoveElemsToLayer.replace("%s",u),o=function(e){e&&(Te=!0,P.moveSelectedToLayer(u),P.clearSelection(),se())};u&&(Te?o(!0):e.confirm(d,o))})),e("#font_family").change((function(){P.setFontFamily(this.value)})),e("#seg_type").change((function(){P.setSegType(e(this).val())})),e("#text").keyup((function(){P.setTextContent(this.value)})),e("#image_url").change((function(){fe(this.value)})),e("#link_url").change((function(){this.value.length?P.setLinkURL(this.value):P.removeHyperlink()})),e("#g_title").change((function(){P.setGroupTitle(this.value)})),e(".attr_changer").change((function(){var u=this.getAttribute("data-attr"),d=this.value;if(!svgedit.units.isValidUnit(u,d,K))return e.alert(uiStrings.notification.invalidAttrValGiven),this.value=K.getAttribute(u),!1;if("id"!==u&&"class"!==u)if(isNaN(d))d=P.convertToNum(u,d);else if("px"!==curConfig.baseUnit){var f=svgedit.units.getTypeMap();(K[u]||"pathedit"===P.getMode()||"x"===u||"y"===u)&&(d*=f[curConfig.baseUnit])}if("id"===u){var p=K;P.clearSelection(),p.id=d,P.addToSelection([p],!0)}else P.changeSelectedAttribute(u,d),p=K,P.clearSelection(),P.addToSelection([p],!0);this.blur()})),e("#palette").mouseover((function(){var u=e('<input type="hidden">');e(this).append(u),u.focus().remove()})),e(".palette_item").mousedown((function(u){var d,f=u.shiftKey||2===u.button?"stroke":"fill",p=e(this).data("rgb");"none"===p||"transparent"===p||"initial"===p?(p="none",d=new e.jGraduate.Paint):d=new e.jGraduate.Paint({alpha:100,solidColor:p.substr(1)}),Z[f].setPaint(d),P.setColor(f,p),"none"!==p&&1!==P.getPaintOpacity(f)&&P.setPaintOpacity(f,1),F.changeColor&&F.changeColor(f,p),_e()})).bind("contextmenu",(function(e){e.preventDefault()})),e("#toggle_stroke_tools").on("click",(function(){e("#tools_bottom").toggleClass("expanded")})),function(){var u=null,d=null,f=G[0],p=!1,g=!1;e("#svgcanvas").bind("mousemove mouseup",(function(e){if(!1!==p)return f.scrollLeft-=e.clientX-u,f.scrollTop-=e.clientY-d,u=e.clientX,d=e.clientY,"mouseup"===e.type&&(p=!1),!1})).mousedown((function(e){if(1===e.button||!0===g)return p=!0,u=e.clientX,d=e.clientY,!1})),e(window).mouseup((function(){p=!1})),e(document).bind("keydown","space",(function(e){P.spaceKey=g=!0,e.preventDefault()})).bind("keyup","space",(function(e){e.preventDefault(),P.spaceKey=g=!1})).bind("keydown","shift",(function(e){"zoom"===P.getMode()&&G.css("cursor",W)})).bind("keyup","shift",(function(e){"zoom"===P.getMode()&&G.css("cursor",H)})),F.setPanning=function(e){P.spaceKey=g=e}}(),function(){var u=e("#main_icon"),d=e("#main_icon span"),f=e("#main_menu"),p=!1,g=0,v=!0,h=!1;e(window).mouseup((function(d){p||(u.removeClass("buttondown"),"INPUT"!=d.target.tagName?f.fadeOut(200):h||(h=!0,e(d.target).click((function(){f.css("margin-left","-9999px").show()})))),p=!1})).mousedown((function(u){e(u.target).closest("div.tools_flyout, .contextMenu").length||e(".tools_flyout:visible,.contextMenu").fadeOut(250)})),d.bind("mousedown",(function(){u.hasClass("buttondown")?f.fadeOut(200):(f.css("margin-left",0).show(),g||(g=f.height()),f.css("height",0).animate({height:g},200),p=!0),u.toggleClass("buttondown buttonup")})).hover((function(){p=!0})).mouseout((function(){p=!1}));var m=e("#main_menu li");m.mouseover((function(){v="rgba(0, 0, 0, 0)"==e(this).css("background-color"),m.unbind("mouseover"),v&&m.mouseover((function(){this.style.backgroundColor="#FFC"})).mouseout((function(){return this.style.backgroundColor="transparent",!0}))}))}(),F.addDropDown=function(u,d,f){if(0!=e(u).length){var p=e(u).find("button"),g=e(u).find("ul").attr("id",e(u)[0].id+"-list"),v=!1;f?e(u).addClass("dropup"):e("#option_lists").append(g),g.find("li").bind("mouseup",d),e(window).mouseup((function(e){v||(p.removeClass("down"),g.hide()),v=!1})),p.bind("mousedown",(function(){if(p.hasClass("down"))g.hide();else{if(!f){var d=e(u).position();g.css({top:d.top+24,left:d.left-10})}g.show(),v=!0}p.toggleClass("down")})).hover((function(){v=!0})).mouseout((function(){v=!1}))}},F.addDropDown("#font_family_dropdown",(function(){e("#font_family").val(e(this).text()).change()})),F.addDropDown("#opacity_dropdown",(function(){if(!e(this).find("div").length){var u=parseInt(e(this).text().split("%")[0],10);et(!1,u)}}),!0),e("#opac_slider").slider({start:function(){e("#opacity_dropdown li:not(.special)").hide()},stop:function(){e("#opacity_dropdown li").show(),e(window).mouseup()},slide:function(e,u){et(u)}}),F.addDropDown("#blur_dropdown",e.noop);var Le,De,Ne=!1;e("#blur_slider").slider({max:10,step:.1,stop:function(u,d){Ne=!1,tt(d),e("#blur_dropdown li").show(),e(window).mouseup()},start:function(){Ne=!0},slide:function(e,u){tt(u,null,Ne)}}),F.addDropDown("#zoom_dropdown",(function(){var u=e(this),d=u.data("val");d?ve(window,d):v({value:parseFloat(u.text())})}),!0),je("#stroke_linecap","#linecap_opts",(function(){i(this,!0)}),{dropUp:!0}),je("#stroke_linejoin","#linejoin_opts",(function(){i(this,!0)}),{dropUp:!0}),je("#tool_position","#position_opts",(function(){var e=this.id.replace("tool_pos","").charAt(0);P.alignSelectedElements(e,"page")}),{multiclick:!0}),De=function(){e(Le).blur()},e("#svg_editor").find("button, select, input:not(#text)").focus((function(){Le=this,V="toolbars",G.mousedown(De)})).blur((function(){V="canvas",G.unbind("mousedown",De),"textedit"==P.getMode()&&e("#text").focus()}));var ht=function(u){var d=P.getResolution();u=u?d.zoom*u:1,e("#zoom").val(100*u),P.setZoom(u),Ae(),ge(!0)},mt=function(){ue("#tool_zoom")&&(ht(),Q())};F.clickExtension=function(e){P.clickExtension(e)},F.clickZoom=function(){P.setMode("zoom"),G.css("cursor",H)},F.clickToSetMode=function(e){P.setMode(e)},F.getSvgString=function(){return F.showSaveWarning=!1,P.getSvgString()},F.getSelectedElements=function(){return P.getSelectedElems()},F.setSvgString=function(e){return P.setSvgString(e)},F.enableGridSnapping=function(e){curConfig.gridSnapping=e},F.setDocProperty=function(e,u,d,f){return!("fit"!=u&&!svgedit.units.isValidUnit("width",u))&&!("fit"!=d&&!svgedit.units.isValidUnit("height",d))&&!!P.setResolution(u,d)&&(f||(f="#ffffff"),!(f&&!P.setBackground(f))&&void ge())},F.alignSelectedElements=function(e){P.alignSelectedElements(e,"page")},F.setColor=function(e,u,d){var f={alpha:u,solidColor:e,type:"solidColor"};Z[d].setPaint(f),P.setPaint(d,f)},F.setStrokeOption=function(e){i(e,!0)},F.setFilterShadow=function(e){P.setFilterShadow(e)},F.setFontFamily=function(e){P.setFontFamily(e)},F.setTextAlign=function(e){P.setTextAlign(e)},F.clickClearAll=function(){var e=curConfig.dimensions;Q(),P.clear(),P.setResolution(e[0],e[1]),ge(!0),ht(),se(),ye(),Ie(),P.runExtensions("onNewDocument")},F.clearSelection=function(){P.clearSelection()},F.selectOnly=function(e,u){P.selectOnly(e,u)},F.setMarker=function(e,u){},F.setSvgImageToAdd=function(e){P.setGoodSvgImageContent(e)},F.setUrlImageToAdd=function(e){console.log("url",e),P.setGoodImage(e),F.promptImgURLcallback=e},F.getShapes=function(){return F.shapesGrps},F.runExtension=function(e,u,...d){return P.runExtension(e,u,d)},F.makeHyperlink=function(e){e&&P.makeHyperlink(e)},F.lockSelection=function(e){P.lockSelection(e)},F.renameSvgExtensionId=function(e){let u=e.id.substring(0,e.id.indexOf("_"));var d=P.getNextId().replace("svg_",u+"_");return e.content=e.content.split(e.id).join(d),d},F.renameAllSvgExtensionId=function(u,d){var f={content:u,id:""};return e.each(F.currentExtensionsPrefixIdType,(function(e,p){for(var g='id=\\"'+p,v=f.content.indexOf(g);v>0;){idend=f.content.indexOf('\\"',v+g.length),f.id=f.content.substring(v,idend);var h=f.id.replace('id=\\"',"");if(-1===d.indexOf(h)){var m=F.renameSvgExtensionId(f);d.push(m.replace('id=\\"',""))}v=u.indexOf(g,v+1)}})),u=f.content},F.resetZoom=function(){v({value:100})},F.refreshCanvas=function(){ge(!0)},F.resetUndoStack=function(){P.undoMgr.resetUndoStack()};var yt=function(){if(null!=K||Y){var e=P.deleteSelectedElements();null!=g&&g(e)}},bt=function(){(null!=K||Y)&&P.cutSelectedElements()},Ct=function(){(null!=K||Y)&&P.copySelectedElements()},kt=function(){null!=K&&P.moveToTopSelectedElement()},St=function(){null!=K&&P.moveToBottomSelectedElement()},Et=function(e){null!=K&&P.moveUpDownSelected(e)},At=function(e,u){if(null!=K||Y){if(curConfig.gridSnapping){var d=P.getZoom()*curConfig.snappingStep;e*=d,u*=d}P.moveSelectedElements(e,u)}},Bt=function(){P.cycleElement(1)},Ot=function(){P.cycleElement(0)},Ut=function(u,d){if(null!=K&&!Y){u||(d*=-1);var f=parseFloat(e("#angle").val())+d;P.setRotationAngle(f),ye()}};clickClear=function(){var u=curConfig.dimensions;e.confirm(uiStrings.notification.QwantToClear,(function(e){e&&(Q(),P.clear(),P.setResolution(u[0],u[1]),ge(!0),ht(),se(),ye(),Ie(),P.runExtensions("onNewDocument"))}))};var Wt=function(){R.getUndoStackSize()>0&&(R.undo(),se())},Vt=function(){R.getRedoStackSize()>0&&(R.redo(),se())},Xt=function(){Y?P.groupSelectedElements():K&&P.ungroupSelectedElement(),F.onGroupChanged&&F.onGroupChanged(K)};e("#svg_docprops_container, #svg_prefs_container").draggable({cancel:"button,fieldset",containment:"window"});var Ue,Re,Me,nn=function(){e("#svg_source_editor").hide(),te=!1,e("#svg_source_textarea").blur()},on=function(){if(te){var t=function(){P.clearSelection(),nn(),ht(),se(),Ce(),Ie()};P.setSvgString(e("#svg_source_textarea").val())?t():e.confirm(uiStrings.notification.QerrorsRevertToSource,(function(e){if(!e)return!1;t()})),Q()}},an=function(){e("#svg_docprops").hide(),e("#canvas_width,#canvas_height").removeAttr("disabled"),e("#resolution")[0].selectedIndex=0,e("#image_save_opts input").val([e.pref("img_save")]),ne=!1},rn=function(){e("#svg_prefs").hide(),oe=!1},Ge=F.savePreferences=function(){r(e("#bg_blocks div.cur_background").css("background-color")||"#FFF",e("#canvas_bg_url").val());var u=e("#lang_select").val();u!==e.pref("lang")&&F.putLocale(u,d),ke(e("#iconsize").val()),curConfig.gridSnapping=e("#grid_snapping_on")[0].checked,curConfig.snappingStep=e("#grid_snapping_step").val(),curConfig.gridColor=e("#grid_color").val(),curConfig.showRulers=e("#show_rulers")[0].checked,e("#rulers").toggle(curConfig.showRulers),curConfig.showRulers&&s(),curConfig.baseUnit=e("#base_unit").val(),P.setConfig(curConfig),ge(),rn()},ze=e.noop,He={width:e(window).width(),height:e(window).height()};if(svgedit.browser.isIE()&&(ze=function(){0===G[0].scrollLeft&&0===G[0].scrollTop&&(G[0].scrollLeft=m.left,G[0].scrollTop=m.top)},m={left:G[0].scrollLeft,top:G[0].scrollTop},e(window).resize(ze),F.ready((function(){setTimeout((function(){ze()}),500)})),G.scroll((function(){m={left:G[0].scrollLeft,top:G[0].scrollTop}}))),e(window).resize((function(u){e.each(He,(function(u,d){var f=e(window)[u]();G[0]["scroll"+("width"===u?"Left":"Top")]-=(f-d)/2,He[u]=f})),Oe()})),G.scroll((function(){0!=e("#ruler_x").length&&(e("#ruler_x")[0].scrollLeft=G[0].scrollLeft),0!=e("#ruler_y").length&&(e("#ruler_y")[0].scrollTop=G[0].scrollTop)})),e("#url_notice").click((function(){e.alert(this.title)})),e("#change_image_url").click(l),Ue=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],Re="",Me="tool_button_current",e.each(Ue,(function(e,u){Re+=(e?",":"")+"#tool_"+u})),e(Re).mousedown((function(){e(this).addClass(Me)})).bind("mousedown mouseout",(function(){e(this).removeClass(Me)})),e("#tool_undo, #tool_redo").mousedown((function(){e(this).hasClass("disabled")||e(this).addClass(Me)})).bind("mousedown mouseout",(function(){e(this).removeClass(Me)})),svgedit.browser.isMac()&&!window.opera){var We=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(q=We.length;q--;){var Xe=document.getElementById(We[q]);if(Xe){var Ze=Xe.title,qe=Ze.indexOf("Ctrl+");Xe.title=[Ze.substr(0,qe),"Cmd+",Ze.substr(qe+5)].join("")}}}var hn=function(u){var d="stroke_color"==u.attr("id")?"stroke":"fill",f=Z[d].paint,p="stroke"==d?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity",g=u.offset();e("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(curConfig.colorPickerCSS||{left:g.left-140,bottom:40}).jGraduate({paint:f,window:{pickerTitle:p},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},(function(u){f=new e.jGraduate.Paint(u),Z[d].setPaint(f),P.setPaint(d,f),e("#color_picker").hide()}),(function(){e("#color_picker").hide()}))},mn=function(u,d){var f,p,g=curConfig["fill"===d?"initFill":"initStroke"],v=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="16.5" height="16.5"\t\t\t\t\tfill="#'+g.color+'" opacity="'+g.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;(v=e(u)[0].appendChild(document.importNode(v,!0))).setAttribute("width",16.5),this.rect=v.firstChild,this.defs=v.getElementsByTagName("defs")[0],this.grad=this.defs.firstChild,this.paint=new e.jGraduate.Paint({solidColor:g.color}),this.type=d,this.setPaint=function(e,u){this.paint=e;var d="none",g=e.type,v=e.alpha/100;switch(g){case"solidColor":d="none"!=e[g]?"#"+e[g]:e[g];break;case"linearGradient":case"radialGradient":this.defs.removeChild(this.grad),this.grad=this.defs.appendChild(e[g]),d="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",d),this.rect.setAttribute("opacity",v),u&&(P.setColor(this.type,f,!0),P.setPaintOpacity(this.type,p,!0))},this.update=function(e){if(K){var u,d,g=this.type;switch(K.tagName){case"use":case"image":case"foreignObject":return;case"g":case"a":var v=null,h=K.getElementsByTagName("*");for(u=0,d=h.length;u<d;u++){var m=h[u].getAttribute(g);if(0===u)v=m;else if(v!==m){v=null;break}}if(null===v)return void(f=null);f=v,p=1;break;default:p=parseFloat(K.getAttribute(g+"-opacity")),isNaN(p)&&(p=1);var F="fill"===g?"black":"none";f=K.getAttribute(g)||F}e&&(P.setColor(g,f,!0),P.setPaintOpacity(g,p,!0));var T=Ve(f,p*=100,g);this.setPaint(T)}},this.prep=function(){switch(this.paint.type){case"linearGradient":case"radialGradient":var u=new e.jGraduate.Paint({copy:this.paint});P.setPaint(d,u)}}};Z.fill=new mn("#fill_color","fill"),Z.stroke=new mn("#stroke_color","stroke"),e("#stroke_width").val(curConfig.initStroke.width),e("#group_opacity").val(100*curConfig.initOpacity);var Qe=Z.fill.rect.cloneNode(!1);Qe.setAttribute("style","vector-effect:non-scaling-stroke"),p="non-scaling-stroke"===Qe.style.vectorEffect,Qe.removeAttribute("style");var Ke,Ye,Je=Z.fill.rect.ownerDocument.createElementNS(svgedit.NS.SVG,"feGaussianBlur");void 0===Je.stdDeviationX&&e("#tool_blur").hide(),e(Je).remove(),Ye=(Ke="-"+xe.toLowerCase()+"-zoom-")+"in",G.css("cursor",Ye),G.css("cursor")===Ye&&(H=Ye,W=Ke+"out"),G.css("cursor","auto"),e("#fill_color, #tool_fill .icon_label").click((function(){hn(e("#fill_color")),_e()})),e("#stroke_color, #tool_stroke .icon_label").click((function(){hn(e("#stroke_color")),_e()})),e("#group_opacityLabel").click((function(){e("#opacity_dropdown button").mousedown(),e(window).mouseup()})),e("#zoomLabel").click((function(){e("#zoom_dropdown button").mousedown(),e(window).mouseup()})),e("#tool_move_top").mousedown((function(u){e("#tools_stacking").show()})),e(".layer_button").mousedown((function(){e(this).addClass("layer_buttonpressed")})).mouseout((function(){e(this).removeClass("layer_buttonpressed")})).mouseup((function(){e(this).removeClass("layer_buttonpressed")})),e(".push_button").mousedown((function(){e(this).hasClass("disabled")||e(this).addClass("push_button_pressed").removeClass("push_button")})).mouseout((function(){e(this).removeClass("push_button_pressed").addClass("push_button")})).mouseup((function(){e(this).removeClass("push_button_pressed").addClass("push_button")})),e("#layer_new").click((function(){var u,d=P.getCurrentDrawing().getNumLayers();do{u=uiStrings.layers.layer+" "+ ++d}while(P.getCurrentDrawing().hasLayer(u));e.prompt(uiStrings.notification.enterUniqueLayerName,u,(function(u){u&&(P.getCurrentDrawing().hasLayer(u)?e.alert(uiStrings.notification.dupeLayerName):(P.createLayer(u),ye(),se()))}))})),e("#layer_delete").click(_),e("#layer_up").click((function(){b(-1)})),e("#layer_down").click((function(){b(1)})),e("#layer_rename").click((function(){var u=e("#layerlist tr.layersel td.layername").text();e.prompt(uiStrings.notification.enterNewLayerName,"",(function(d){d&&(u==d||P.getCurrentDrawing().hasLayer(d)?e.alert(uiStrings.notification.layerHasThatName):(P.renameCurrentLayer(d),se()))}))}));var $e=-1,nt=!1,ot=!1,Pn=function(u){var d=e("#ruler_x");e("#sidepanels").width("+="+u),e("#layerpanel").width("+="+u),d.css("right",parseInt(d.css("right"),10)+u),G.css("right",parseInt(G.css("right"),10)+u),P.runExtensions("workareaResized")},An=function(u){if(ot&&-1!=$e){nt=!0;var d=$e-u.pageX,f=e("#sidepanels").width();f+d>300?(d=300-f,f=300):f+d<2&&(d=2-f,f=2),0!=d&&($e-=d,Pn(d))}},Tn=function(u){var d=e("#sidepanels").width();Pn((d>2||u?2:150)-d)};e("#sidepanel_handle").mousedown((function(u){$e=u.pageX,e(window).mousemove(An),ot=!1,setTimeout((function(){ot=!0}),20)})).mouseup((function(e){nt||Tn(),$e=-1,nt=!1})),e(window).mouseup((function(){$e=-1,nt=!1,e("#svg_editor").unbind("mousemove",An)})),se();var it,at;e(window).bind("load resize",(function(){G.css("line-height",G.height()+"px")})),e("#resolution").change((function(){var u=e("#canvas_width,#canvas_height");if(this.selectedIndex)if("content"==this.value)u.val("fit").attr("disabled","disabled");else{var d=this.value.split("x");e("#canvas_width").val(d[0]),e("#canvas_height").val(d[1]),u.removeAttr("disabled")}else"fit"==e("#canvas_width").val()&&u.removeAttr("disabled").val(100)})),e("input,select").attr("autocomplete","off"),it=[{sel:"#tool_select",fn:de,evt:"click",key:["V",!0]},{sel:"#tool_fhpath",fn:function(){ue("#tool_fhpath")&&P.setMode("fhpath")},evt:"click",key:["Q",!0]},{sel:"#tool_line",fn:function(){ue("#tool_line")&&P.setMode("line")},evt:"click",key:["L",!0]},{sel:"#tool_rect",fn:function(){ue("#tool_rect")&&P.setMode("rect")},evt:"mouseup",key:["R",!0],parent:"#tools_rect",icon:"rect"},{sel:"#tool_square",fn:function(){ue("#tool_square")&&P.setMode("square")},evt:"mouseup",parent:"#tools_rect",icon:"square"},{sel:"#tool_fhrect",fn:function(){ue("#tool_fhrect")&&P.setMode("fhrect")},evt:"mouseup",parent:"#tools_rect",icon:"fh_rect"},{sel:"#tool_ellipse",fn:function(){ue("#tool_ellipse")&&P.setMode("ellipse")},evt:"mouseup",key:["E",!0],parent:"#tools_ellipse",icon:"ellipse"},{sel:"#tool_circle",fn:function(){ue("#tool_circle")&&P.setMode("circle")},evt:"mouseup",parent:"#tools_ellipse",icon:"circle"},{sel:"#tool_fhellipse",fn:function(){ue("#tool_fhellipse")&&P.setMode("fhellipse")},evt:"mouseup",parent:"#tools_ellipse",icon:"fh_ellipse"},{sel:"#tool_path",fn:function(){ue("#tool_path")&&P.setMode("path")},evt:"click",key:["P",!0]},{sel:"#tool_text",fn:function(){ue("#tool_text")&&P.setMode("text")},evt:"click",key:["T",!0]},{sel:"#tool_image",fn:function(){ue("#tool_image")&&P.setMode("image")},evt:"mouseup"},{sel:"#tool_zoom",fn:function(){ue("#tool_zoom")&&(P.setMode("zoom"),G.css("cursor",H))},evt:"mouseup",key:["Z",!0]},{sel:"#tool_clear",fn:clickClear,evt:"mouseup",key:["N",!0]},{sel:"#tool_save",fn:function(){te?on():function(){var u={images:e.pref("img_save"),round_digits:6};P.save(u)}()},evt:"mouseup",key:["S",!0]},{sel:"#tool_export",fn:function(){e.select("Select an image type for export: ",["PNG","JPEG","BMP","WEBP","PDF"],(function(u){function n(){var e=uiStrings.notification.loadingImage;"new"===curConfig.exportWindowType&&F.exportWindowCt++,d=curConfig.canvasName+F.exportWindowCt,j=window.open("data:text/html;charset=utf-8,"+encodeURIComponent("<title>"+e+"</title><h1>"+e+"</h1>"),d)}var d;if(u)if("PDF"===u)customExportPDF||n(),P.exportPDF(d);else{customExportImage||n();var f=parseInt(e("#image-slider").val(),10)/100;P.rasterExport(u,f,d)}}),(function(){var u=e(this);"JPEG"===u.val()||"WEBP"===u.val()?e("#image-slider").length||e('<div><label>Quality: <input id="image-slider" type="range" min="1" max="100" value="92" /></label></div>').appendTo(u.parent()):e("#image-slider").parent().remove()}))},evt:"mouseup"},{sel:"#tool_open",fn:function(){P.open()},evt:"mouseup",key:["O",!0]},{sel:"#tool_import",fn:function(){},evt:"mouseup"},{sel:"#tool_source",fn:ce,evt:"click",key:["U",!0]},{sel:"#tool_wireframe",fn:function(){if(e("#tool_wireframe").toggleClass("push_button_pressed tool_button"),G.toggleClass("wireframe"),!p){var u=e("#wireframe_rules");u.length?u.empty():u=e('<style id="wireframe_rules"></style>').appendTo("head"),be()}},evt:"click",key:["F",!0]},{sel:"#tool_source_save",fn:on,evt:"click"},{sel:"#tool_docprops_save",fn:function(){var u=e("#canvas_title").val();Ce(u),P.setDocumentTitle(u);var d=e("#canvas_width"),f=d.val(),p=e("#canvas_height"),g=p.val();return"fit"==f||svgedit.units.isValidUnit("width",f)?(d.parent().removeClass("error"),"fit"==g||svgedit.units.isValidUnit("height",g)?(p.parent().removeClass("error"),P.setResolution(f,g)?(e.pref("img_save",e("#image_save_opts :checked").val()),ge(),void an()):(e.alert(uiStrings.notification.noContentToFitTo),!1)):(e.alert(uiStrings.notification.invalidAttrValGiven),p.parent().addClass("error"),!1)):(e.alert(uiStrings.notification.invalidAttrValGiven),d.parent().addClass("error"),!1)},evt:"click"},{sel:"#tool_docprops",fn:function(){if(!ne){ne=!0,e("#image_save_opts input").val([e.pref("img_save")]);var u=P.getResolution();"px"!==curConfig.baseUnit&&(u.w=svgedit.units.convertUnit(u.w)+curConfig.baseUnit,u.h=svgedit.units.convertUnit(u.h)+curConfig.baseUnit),e("#canvas_width").val(u.w),e("#canvas_height").val(u.h),e("#canvas_title").val(P.getDocumentTitle()),e("#svg_docprops").show()}},evt:"mouseup"},{sel:"#tool_prefs_save",fn:Ge,evt:"click"},{sel:"#tool_prefs_option",fn:function(){return function(){if(!oe){oe=!0,e("#main_menu").hide();var u=e("#bg_blocks div"),d="cur_background",f=curPrefs.bkgd_color,p=e.pref("bkgd_url");u.each((function(){var u=e(this),p=u.css("background-color")==f;u.toggleClass(d,p),p&&e("#canvas_bg_url").removeClass(d)})),f||u.eq(0).addClass(d),p&&e("#canvas_bg_url").val(p),e("#grid_snapping_on").prop("checked",curConfig.gridSnapping),e("#grid_snapping_step").attr("value",curConfig.snappingStep),e("#grid_color").attr("value",curConfig.gridColor),e("#svg_prefs").show()}}(),!1},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:yt,evt:"click",key:["del/backspace",!0]},{sel:"#tool_reorient",fn:function(){null!=K&&U.reorient()},evt:"click"},{sel:"#tool_node_link",fn:function(){e("#tool_node_link").toggleClass("push_button_pressed tool_button");var u=e("#tool_node_link").hasClass("push_button_pressed");U.linkControlPoints(u)},evt:"click"},{sel:"#tool_node_clone",fn:function(){U.getNodePoint()&&U.clonePathNode()},evt:"click"},{sel:"#tool_node_delete",fn:function(){U.getNodePoint()&&U.deletePathNode()},evt:"click"},{sel:"#tool_openclose_path",fn:function(){U.opencloseSubPath()},evt:"click"},{sel:"#tool_add_subpath",fn:function(){var u=e("#tool_add_subpath"),d=!u.hasClass("push_button_pressed");u.toggleClass("push_button_pressed tool_button"),U.addSubPath(d)},evt:"click"},{sel:"#tool_move_top",fn:kt,evt:"click",key:O+"shift+]"},{sel:"#tool_move_bottom",fn:St,evt:"click",key:O+"shift+["},{sel:"#tool_topath",fn:function(){null!=K&&P.convertToPath()},evt:"click"},{sel:"#tool_undo",fn:Wt,evt:"click",key:[O+"Z",!0]},{sel:"#tool_redo",fn:Vt,evt:"click",key:[O+"Y",!0]},{sel:"#tool_clone,#tool_clone_multi",fn:function(){P.copySelectedElements(),P.pasteElements("point",20,20)},evt:"click",key:[O+"D",!0]},{sel:"#tool_group_elements",fn:Xt,evt:"click",key:[O+"G",!0]},{sel:"#tool_ungroup",fn:Xt,evt:"click"},{sel:"#tool_unlink_use",fn:Xt,evt:"click"},{sel:"[id^=tool_align]",fn:function(){var u=this.id.replace("tool_align","").charAt(0);P.alignSelectedElements(u,e("#align_relative_to").val())},evt:"click"},{sel:"[id^=tool_divide]",fn:function(){var e=this.id.replace("tool_divide","").charAt(0);P.divideSelectedElements(e)},evt:"click"},{sel:"#tool_bold",fn:function(){return P.setBold(!P.getBold()),ye(),!1},evt:"mousedown"},{sel:"#tool_italic",fn:function(){return P.setItalic(!P.getItalic()),ye(),!1},evt:"mousedown"},{sel:"#sidepanel_handle",fn:Tn,key:["X"]},{sel:"#copy_save_done",fn:function(){e("#dialog_box").hide(),te||ne||oe?(te?X!==e("#svg_source_textarea").val()?e.confirm(uiStrings.notification.QignoreSourceChanges,(function(e){e&&nn()})):nn():ne?an():oe&&rn(),ze()):ie&&P.leaveContext()},evt:"click"},{key:O+"left",fn:function(){Ut(0,1)}},{key:O+"right",fn:function(){Ut(1,1)}},{key:O+"shift+left",fn:function(){Ut(0,5)}},{key:O+"shift+right",fn:function(){Ut(1,5)}},{key:"shift+O",fn:Ot},{key:"shift+P",fn:Bt},{key:[O+"up",!0],fn:function(){ht(2)}},{key:[O+"down",!0],fn:function(){ht(.5)}},{key:[O+"]",!0],fn:function(){Et("Up")}},{key:[O+"[",!0],fn:function(){Et("Down")}},{key:["up",!0],fn:function(){At(0,-1)}},{key:["down",!0],fn:function(){At(0,1)}},{key:["left",!0],fn:function(){At(-1,0)}},{key:["right",!0],fn:function(){At(1,0)}},{key:"shift+up",fn:function(){At(0,-10)}},{key:"shift+down",fn:function(){At(0,10)}},{key:"shift+left",fn:function(){At(-10,0)}},{key:"shift+right",fn:function(){At(10,0)}},{key:O+"A",fn:function(){P.selectAllInCurrentLayer()}},{key:O+"z",fn:Wt},{key:O+"shift+z",fn:Vt},{key:O+"y",fn:Vt},{key:O+"x",fn:bt},{key:O+"c",fn:Ct},{key:O+"v",fn:function(){var e=P.getZoom(),u=(G[0].scrollLeft+G.width()/2)/e-P.contentW,d=(G[0].scrollTop+G.height()/2)/e-P.contentH;P.pasteElements("point",u,d)}}],at={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"},h={setAll:function(){var u={};e.each(it,(function(d,f){var p;if(f.sel){if(0==(p=e(f.sel)).length)return!0;if(f.evt&&(svgedit.browser.isTouch()&&"click"===f.evt&&(f.evt="mousedown"),p[f.evt](f.fn)),f.parent&&0!=e(f.parent+"_show").length){var g=e(f.parent);g.length||(g=function(u,d){return e("<div>",{class:"tools_flyout",id:u}).appendTo("#svg_editor").append(d)}(f.parent.substr(1))),g.append(p),e.isArray(u[f.parent])||(u[f.parent]=[]),u[f.parent].push(f)}}if(f.key){var v,h=f.fn,m=!1;if(e.isArray(f.key)?(v=f.key[0],f.key.length>1&&(m=f.key[1]),f.key.length>2&&f.key[2]):v=f.key,v+="",e.each(v.split("/"),(function(u,d){e(document).bind("keydown",d,(function(e){return h(),m&&e.preventDefault(),!1}))})),f.sel&&!f.hidekey&&p.attr("title")){var F=p.attr("title").split("[")[0]+" ("+v+")";at[v]=f.sel,p.parents("#main_menu").length||p.attr("title",F)}}})),function(u){e.each(u,(function(d,f){var p,g=e(d).children(),v=d+"_show",h=e(v),m=!1;g.addClass("tool_button").unbind("click mousedown mouseup").each((function(d){var p=f[d];me[p.sel]=p.fn,p.isDefault&&(m=d);var a=function(d){var f,g=p;if("keydown"===d.type){var m=e(g.parent+"_show").hasClass("tool_button_current"),F=e(g.parent+"_show").attr("data-curopt");e.each(u[p.parent],(function(e,f){f.sel==F&&(g=d.shiftKey&&m?u[p.parent][e+1]||u[p.parent][0]:f)}))}if(e(this).hasClass("disabled"))return!1;ue(v)&&g.fn(),(f=g.icon?e.getSvgIcon(g.icon,!0):e(g.sel).children().eq(0).clone())[0].setAttribute("width",h.width()),f[0].setAttribute("height",h.height()),h.children(":not(.flyout_arrow_horiz)").remove(),h.append(f).attr("data-curopt",g.sel)};e(this).mouseup(a),p.key&&e(document).bind("keydown",p.key[0]+" shift+"+p.key[0],a)})),m?h.attr("data-curopt",f[m].sel):h.attr("data-curopt")||h.attr("data-curopt",f[0].sel);var F=e(v).position();h.mousedown((function(u){if(h.hasClass("disabled"))return!1;var f=e(d),g=F.left+34,v=-1*f.width(),m=f.data("shown_popop")?200:0;p=setTimeout((function(){h.data("isLibrary")?f.css("left",g).show():f.css("left",v).show().animate({left:g},150),f.data("shown_popop",!0)}),m),u.preventDefault()})).mouseup((function(u){clearTimeout(p);var d=e(this).attr("data-curopt");h.data("isLibrary")&&e(v.replace("_show","")).is(":visible")?ue(v,!0):ue(v)&&me[d]&&me[d]()}))})),Be(),Oe()}(u),e(".attr_changer, #image_url").bind("keydown","return",(function(u){e(this).change(),u.preventDefault()})),e(window).bind("keydown","tab",(function(e){"canvas"===V&&(e.preventDefault(),Bt())})).bind("keydown","shift+tab",(function(e){"canvas"===V&&(e.preventDefault(),Ot())})),e("#tool_zoom").dblclick(mt)},setTitles:function(){e.each(at,(function(u,d){var f=e(d).parents("#main_menu").length;e(d).each((function(){var d;d=f?e(this).text().split(" [")[0]:this.title.split(" [")[0];var p="";e.each(u.split("/"),(function(e,u){var d=u.split("+"),f="";d.length>1&&(f=d[0]+"+",u=d[1]),p+=(e?"/":"")+f+(uiStrings["key_"+u]||u)})),f?this.lastChild.textContent=d+" ["+p+"]":this.title=d+" ["+p+"]"}))}))},getButtonData:function(u){var d;return e.each(it,(function(e,f){f.sel===u&&(d=f)})),d}},h.setAll(),F.ready((function(){var u=curConfig.initTool,d=e("#tools_left, #svg_editor .tools_flyout"),f=d.find("#tool_"+u),p=d.find("#"+u);(f.length?f:p.length?p:e("#tool_select")).click().mouseup(),curConfig.wireframe&&e("#tool_wireframe").click(),curConfig.showlayers&&Tn(),e("#rulers").toggle(!!curConfig.showRulers),curConfig.showRulers&&(e("#show_rulers")[0].checked=!0),curConfig.baseUnit&&e("#base_unit").val(curConfig.baseUnit),curConfig.gridSnapping&&(e("#grid_snapping_on")[0].checked=!0),curConfig.snappingStep&&e("#grid_snapping_step").val(curConfig.snappingStep),curConfig.gridColor&&e("#grid_color").val(curConfig.gridColor)})),e("#rect_rx").SpinButton({min:0,max:1e3,callback:function(e){P.setRectRadius(e.value)}}),e("#stroke_width").SpinButton({min:0,max:99,smallStep:.1,callback:function(e){var u=e.value;0==u&&K&&["line","polyline"].indexOf(K.nodeName)>=0&&(u=e.value=1),P.setStrokeWidth(u)}}),e("#angle").SpinButton({min:-180,max:180,step:5,callback:function(u){P.setRotationAngle(u.value),e("#tool_reorient").toggleClass("disabled",0===parseInt(u.value,10))}}),e("#font_size").SpinButton({min:.001,stepfunc:function C(e,u){var d=Number(e.value),f=d+u,p=f>=d;return 0===u?d:d>=24?p?Math.round(1.1*d):Math.round(d/1.1):d<=1?p?2*d:d/2:f},callback:function(e){P.setFontSize(e.value)}}),e("#group_opacity").SpinButton({min:0,max:100,step:5,callback:et}),e("#blur").SpinButton({min:0,max:10,step:.1,callback:tt}),e("#zoom").SpinButton({min:.001,max:1e4,step:50,stepfunc:function x(e,u){var d=Number(e.value);if(0===d)return 100;var f=d+u;return 0===u?d:d>=100?f:f>=d?2*d:d/2},callback:v}).val(100*P.getZoom()),e("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},(function(e,u,d){switch(e){case"interactivity":case"editBindOfTags":break;case"delete":yt();break;case"deselect":var f=P.getMode();P.clearSelection(),P.setMode(f);break;case"cut":bt();break;case"copy":Ct();break;case"paste":P.pasteElements();break;case"paste_in_place":P.pasteElements("in_place");break;case"group":case"group_elements":P.groupSelectedElements();break;case"ungroup":P.ungroupSelectedElement();break;case"move_front":kt();break;case"move_up":Et("Up");break;case"move_down":Et("Down");break;case"move_back":St();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(e)&&svgedit.contextmenu.getCustomHandler(e).call()}P.clipBoard.length&&z.enableContextMenuItems("#paste,#paste_in_place")}));var Nn=function(e,u,d){switch(e){case"dupe":w();break;case"delete":_();break;case"merge_down":y();break;case"merge_all":P.mergeAllLayers(),ye(),se()}};if(e("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},Nn),e("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:!0},Nn),e(".contextMenu li").mousedown((function(e){e.preventDefault()})),e("#cmenu_canvas li").disableContextMenu(),z.enableContextMenuItems("#delete,#deselect,#cut,#copy"),window.addEventListener("beforeunload",(function(e){if(0===R.getUndoStackSize()&&(F.showSaveWarning=!1),!curConfig.no_save_warning&&F.showSaveWarning)return e.returnValue=uiStrings.notification.unsavedChanges,uiStrings.notification.unsavedChanges}),!1),F.openPrep=function(u){e("#main_menu").hide(),0===R.getUndoStackSize()?u(!0):e.confirm(uiStrings.notification.QwantToOpen,u)},window.FileReader){var Bn=function(u){e.process_cancel(uiStrings.notification.loadingImage),u.stopPropagation(),u.preventDefault(),e("#workarea").removeAttr("style"),e("#main_menu").hide();var d,f="drop"==u.type?u.dataTransfer.files[0]:this.files[0];f?-1!=f.type.indexOf("image")&&(-1!=f.type.indexOf("svg")?((d=new FileReader).onloadend=function(u){P.importSvgString(u.target.result,!0),e("#dialog_box").hide()},d.readAsText(f)):((d=new FileReader).onloadend=function(u){var d=100,f=100,p=new Image;p.src=u.target.result,p.style.opacity=0,p.onload=function(){d=p.offsetWidth,f=p.offsetHeight,function(d,f){var p=P.addSvgElementFromJson({element:"image",attr:{x:0,y:0,width:d,height:f,id:P.getNextId(),style:"pointer-events:inherit"}});P.setHref(p,u.target.result),P.selectOnly([p]),P.alignSelectedElements("m","page"),P.alignSelectedElements("c","page"),ye(),e("#dialog_box").hide()}(d,f)}},d.readAsDataURL(f))):e("#dialog_box").hide()};G[0].addEventListener("dragenter",(function k(e){e.stopPropagation(),e.preventDefault()}),!1),G[0].addEventListener("dragover",(function S(e){e.stopPropagation(),e.preventDefault()}),!1),G[0].addEventListener("dragleave",(function E(e){e.stopPropagation(),e.preventDefault()}),!1),G[0].addEventListener("drop",Bn,!1);var rt=e('<input type="file">').change((function(){var u=this;F.openPrep((function(d){if(d&&(P.clear(),1===u.files.length)){e.process_cancel(uiStrings.notification.loadingImage);var f=new FileReader;f.onloadend=function(e){c(e.target.result),ge()},f.readAsText(u.files[0])}}))}));e("#tool_open").show().prepend(rt);var lt=e('<input type="file">').change(Bn);e("#tool_import").show().prepend(lt)}ge(!0),e((function(){window.svgCanvas=P,P.ready=F.ready,P.setSpecialsIds(D,I)})),F.setLang=function(u,d){if(F.langChanged=!0,e.pref("lang",u),e("#lang_select").val(u),d){var f=e("#layerlist tr.layersel td.layername").text()==uiStrings.common.layer+" 1";if(e.extend(uiStrings,d),P.setUiStrings(d),h.setTitles(),f&&(P.renameCurrentLayer(uiStrings.common.layer+" 1"),se()),Se.length)for(;Se.length;){Se.shift().langReady({lang:u,uiStrings:uiStrings})}else P.runExtensions("langReady",{lang:u,uiStrings:uiStrings});P.runExtensions("langChanged",u),Be();e.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(u,d){e(d).attr("title",e(u)[0].title)})),e("#multiselected_panel div[id^=tool_align]").each((function(){e("#tool_pos"+this.id.substr(10))[0].title=this.title}))}},P&&P.setColor("fill","#FFFFFF"),N.takePil()&&(A(),function(e){B.load(curConfig.shapesPath,(function(){Object.values(F.shapesGrps).forEach((e=>{for(var u=0;u<e.length;u++)F.shapesList.push(e[u])})),window.extShapes&&window.extShapes(),e&&e()}))}((function(){F.currentExtensionsInteractivityType=P.getExtensionMember("getClassId"),F.currentExtensionsPrefixIdType=P.getExtensionMember("getPrefixId")})))},F.ready=function(e){isReady?e():callbacks.push(e)},F.runCallbacks=function(){e.each(callbacks,(function(){this()})),isReady=!0},F.loadFromString=function(e){F.ready((function(){c(e)}))},F.disableUI=function(e){},F.loadFromURL=function(u,d){d||(d={});var f=d.cache,p=d.callback;F.ready((function(){e.ajax({url:u,dataType:"text",cache:!!f,beforeSend:function(){e.process_cancel(uiStrings.notification.loadingImage)},success:function(e){c(e,p)},error:function(u,d,f){404!=u.status&&u.responseText?c(u.responseText,p):e.alert(uiStrings.notification.URLloadFail+": \n"+f,p)},complete:function(){e("#dialog_box").hide()}})}))},F.loadFromDataURI=function(e){F.ready((function(){var u=!1,d=e.match(/^data:image\/svg\+xml;base64,/);d?u=!0:d=e.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/),d&&(d=d[0]);var f=e.slice(d.length);c(u?N.decode64(f):decodeURIComponent(f))}))},F.addExtension=function(){var e=arguments;P&&(P.addExtension.apply(this,e),F&&F.extensionLoadedCallback&&F.extensionLoadedCallback(e[0],e))},F}(jQuery)}};