svgedit/dist/svgcanvas-iife.min.js

20 lines
188 KiB
JavaScript

var SvgCanvas=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t,r,n,i,a,s){try{var o=e[a](s),u=o.value}catch(e){return void r(e)}o.done?t(u):Promise.resolve(u).then(n,i)}function r(e){return function(){var r=this,n=arguments;return new Promise((function(i,a){var s=e.apply(r,n);function o(e){t(s,i,a,o,u,"next",e)}function u(e){t(s,i,a,o,u,"throw",e)}o(void 0)}))}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),e}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=o(e);if(t){var i=o(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return l(this,r)}}function h(e,t,r){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,a=void 0;try{for(var s,o=e[Symbol.iterator]();!(n=(s=o.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==o.return||o.return()}finally{if(i)throw a}}return r}(e,t)||f(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||f(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=f(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}
/**
* A jQuery module to work with SVG attributes.
* @module jQueryAttr
* @license MIT
*/
function y(t){var r=t.fn.attr;return t.fn.attr=function(t,n){var i=this.length;if(!i)return r.call(this,t,n);for(var a=0;a<i;++a){var s=this[a];if("http://www.w3.org/2000/svg"!==s.namespaceURI)return r.call(this,t,n);if(void 0!==n)s.setAttribute(t,n);else if(Array.isArray(t)){for(var o={},u=t.length;u--;){var l=t[u],c=s.getAttribute(l);(c||"0"===c)&&(c=isNaN(c)?c:c-0),o[l]=c}return o}if("object"!==e(t)){var h=s.getAttribute(t);return(h||"0"===h)&&(h=isNaN(h)?h:h-0),h}for(var m=0,f=Object.entries(t);m<f.length;m++){var g=d(f[m],2),p=g[0],y=g[1];s.setAttribute(p,y)}}return this},t}!function(){if(!("SVGPathSeg"in window)){var e=function(){function e(t,r,i){n(this,e),this.pathSegType=t,this.pathSegTypeAsLetter=r,this._owningPathSegList=i}return a(e,[{key:"_segmentChanged",value:function(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)}}]),e}();e.prototype.classname="SVGPathSeg",e.PATHSEG_UNKNOWN=0,e.PATHSEG_CLOSEPATH=1,e.PATHSEG_MOVETO_ABS=2,e.PATHSEG_MOVETO_REL=3,e.PATHSEG_LINETO_ABS=4,e.PATHSEG_LINETO_REL=5,e.PATHSEG_CURVETO_CUBIC_ABS=6,e.PATHSEG_CURVETO_CUBIC_REL=7,e.PATHSEG_CURVETO_QUADRATIC_ABS=8,e.PATHSEG_CURVETO_QUADRATIC_REL=9,e.PATHSEG_ARC_ABS=10,e.PATHSEG_ARC_REL=11,e.PATHSEG_LINETO_HORIZONTAL_ABS=12,e.PATHSEG_LINETO_HORIZONTAL_REL=13,e.PATHSEG_LINETO_VERTICAL_ABS=14,e.PATHSEG_LINETO_VERTICAL_REL=15,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19;var t=function(t){s(i,t);var r=c(i);function i(t){return n(this,i),r.call(this,e.PATHSEG_CLOSEPATH,"z",t)}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegClosePath]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter}},{key:"clone",value:function(){return new i(void 0)}}]),i}(e),r=function(t){s(i,t);var r=c(i);function i(t,a,s){var o;return n(this,i),(o=r.call(this,e.PATHSEG_MOVETO_ABS,"M",t))._x=a,o._y=s,o}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegMovetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y)}}]),i}(e);Object.defineProperties(r.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var i=function(t){s(i,t);var r=c(i);function i(t,a,s){var o;return n(this,i),(o=r.call(this,e.PATHSEG_MOVETO_REL,"m",t))._x=a,o._y=s,o}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegMovetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y)}}]),i}(e);Object.defineProperties(i.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var o=function(t){s(i,t);var r=c(i);function i(t,a,s){var o;return n(this,i),(o=r.call(this,e.PATHSEG_LINETO_ABS,"L",t))._x=a,o._y=s,o}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegLinetoAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y)}}]),i}(e);Object.defineProperties(o.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var u=function(t){s(i,t);var r=c(i);function i(t,a,s){var o;return n(this,i),(o=r.call(this,e.PATHSEG_LINETO_REL,"l",t))._x=a,o._y=s,o}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegLinetoRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y)}}]),i}(e);Object.defineProperties(u.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var l=function(t){s(i,t);var r=c(i);function i(t,a,s,o,u,l,c){var h;return n(this,i),(h=r.call(this,e.PATHSEG_CURVETO_CUBIC_ABS,"C",t))._x=a,h._y=s,h._x1=o,h._y1=u,h._x2=l,h._y2=c,h}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),i}(e);Object.defineProperties(l.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var h=function(t){s(i,t);var r=c(i);function i(t,a,s,o,u,l,c){var h;return n(this,i),(h=r.call(this,e.PATHSEG_CURVETO_CUBIC_REL,"c",t))._x=a,h._y=s,h._x1=o,h._y1=u,h._x2=l,h._y2=c,h}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}]),i}(e);Object.defineProperties(h.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var d=function(t){s(i,t);var r=c(i);function i(t,a,s,o,u){var l;return n(this,i),(l=r.call(this,e.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",t))._x=a,l._y=s,l._x1=o,l._y1=u,l}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y,this._x1,this._y1)}}]),i}(e);Object.defineProperties(d.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}});var m=function(t){s(i,t);var r=c(i);function i(t,a,s,o,u){var l;return n(this,i),(l=r.call(this,e.PATHSEG_CURVETO_QUADRATIC_REL,"q",t))._x=a,l._y=s,l._x1=o,l._y1=u,l}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y,this._x1,this._y1)}}]),i}(e);Object.defineProperties(m.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get:function(){return this._x1},set:function(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get:function(){return this._y1},set:function(e){this._y1=e,this._segmentChanged()},enumerable:!0}});var f=function(t){s(i,t);var r=c(i);function i(t,a,s,o,u,l,c,h){var d;return n(this,i),(d=r.call(this,e.PATHSEG_ARC_ABS,"A",t))._x=a,d._y=s,d._r1=o,d._r2=u,d._angle=l,d._largeArcFlag=c,d._sweepFlag=h,d}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegArcAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),i}(e);Object.defineProperties(f.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});var g=function(t){s(i,t);var r=c(i);function i(t,a,s,o,u,l,c,h){var d;return n(this,i),(d=r.call(this,e.PATHSEG_ARC_REL,"a",t))._x=a,d._y=s,d._r1=o,d._r2=u,d._angle=l,d._largeArcFlag=c,d._sweepFlag=h,d}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegArcRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}]),i}(e);Object.defineProperties(g.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get:function(){return this._r1},set:function(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get:function(){return this._r2},set:function(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get:function(){return this._angle},set:function(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get:function(){return this._largeArcFlag},set:function(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get:function(){return this._sweepFlag},set:function(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});var p=function(t){s(i,t);var r=c(i);function i(t,a){var s;return n(this,i),(s=r.call(this,e.PATHSEG_LINETO_HORIZONTAL_ABS,"H",t))._x=a,s}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new i(void 0,this._x)}}]),i}(e);Object.defineProperty(p.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var y=function(t){s(i,t);var r=c(i);function i(t,a){var s;return n(this,i),(s=r.call(this,e.PATHSEG_LINETO_HORIZONTAL_REL,"h",t))._x=a,s}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegLinetoHorizontalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x}},{key:"clone",value:function(){return new i(void 0,this._x)}}]),i}(e);Object.defineProperty(y.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0});var v=function(t){s(i,t);var r=c(i);function i(t,a){var s;return n(this,i),(s=r.call(this,e.PATHSEG_LINETO_VERTICAL_ABS,"V",t))._y=a,s}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._y)}}]),i}(e);Object.defineProperty(v.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var x=function(t){s(i,t);var r=c(i);function i(t,a){var s;return n(this,i),(s=r.call(this,e.PATHSEG_LINETO_VERTICAL_REL,"v",t))._y=a,s}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegLinetoVerticalRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._y)}}]),i}(e);Object.defineProperty(x.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0});var S=function(t){s(i,t);var r=c(i);function i(t,a,s,o,u){var l;return n(this,i),(l=r.call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",t))._x=a,l._y=s,l._x2=o,l._y2=u,l}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y,this._x2,this._y2)}}]),i}(e);Object.defineProperties(S.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var _=function(t){s(i,t);var r=c(i);function i(t,a,s,o,u){var l;return n(this,i),(l=r.call(this,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",t))._x=a,l._y=s,l._x2=o,l._y2=u,l}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoCubicSmoothRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y,this._x2,this._y2)}}]),i}(e);Object.defineProperties(_.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get:function(){return this._x2},set:function(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get:function(){return this._y2},set:function(e){this._y2=e,this._segmentChanged()},enumerable:!0}});var b=function(t){s(i,t);var r=c(i);function i(t,a,s){var o;return n(this,i),(o=r.call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",t))._x=a,o._y=s,o}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y)}}]),i}(e);Object.defineProperties(b.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}});var w=function(t){s(i,t);var r=c(i);function i(t,a,s){var o;return n(this,i),(o=r.call(this,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",t))._x=a,o._y=s,o}return a(i,[{key:"toString",value:function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"}},{key:"_asPathString",value:function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}},{key:"clone",value:function(){return new i(void 0,this._x,this._y)}}]),i}(e);Object.defineProperties(w.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get:function(){return this._y},set:function(e){this._y=e,this._segmentChanged()},enumerable:!0}}),SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new t(void 0)},SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(e,t){return new r(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegMovetoRel=function(e,t){return new i(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(e,t){return new o(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoRel=function(e,t){return new u(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(e,t,r,n,i,a){return new l(void 0,e,t,r,n,i,a)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(e,t,r,n,i,a){return new h(void 0,e,t,r,n,i,a)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(e,t,r,n){return new d(void 0,e,t,r,n)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(e,t,r,n){return new m(void 0,e,t,r,n)},SVGPathElement.prototype.createSVGPathSegArcAbs=function(e,t,r,n,i,a,s){return new f(void 0,e,t,r,n,i,a,s)},SVGPathElement.prototype.createSVGPathSegArcRel=function(e,t,r,n,i,a,s){return new g(void 0,e,t,r,n,i,a,s)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(e){return new p(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(e){return new y(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(e){return new v(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(e){return new x(void 0,e)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(e,t,r,n){return new S(void 0,e,t,r,n)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(e,t,r,n){return new _(void 0,e,t,r,n)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(e,t){return new b(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(e,t){return new w(void 0,e,t)},"getPathSegAtLength"in SVGPathElement.prototype||(SVGPathElement.prototype.getPathSegAtLength=function(e){if(void 0===e||!isFinite(e))throw new Error("Invalid arguments.");var t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",this.getAttribute("d"));var r=t.pathSegList.numberOfItems-1;if(r<=0)return 0;do{if(t.pathSegList.removeItem(r),e>t.getTotalLength())break;r--}while(r>0);return r}),window.SVGPathSeg=e,window.SVGPathSegClosePath=t,window.SVGPathSegMovetoAbs=r,window.SVGPathSegMovetoRel=i,window.SVGPathSegLinetoAbs=o,window.SVGPathSegLinetoRel=u,window.SVGPathSegCurvetoCubicAbs=l,window.SVGPathSegCurvetoCubicRel=h,window.SVGPathSegCurvetoQuadraticAbs=d,window.SVGPathSegCurvetoQuadraticRel=m,window.SVGPathSegArcAbs=f,window.SVGPathSegArcRel=g,window.SVGPathSegLinetoHorizontalAbs=p,window.SVGPathSegLinetoHorizontalRel=y,window.SVGPathSegLinetoVerticalAbs=v,window.SVGPathSegLinetoVerticalRel=x,window.SVGPathSegCurvetoCubicSmoothAbs=S,window.SVGPathSegCurvetoCubicSmoothRel=_,window.SVGPathSegCurvetoQuadraticSmoothAbs=b,window.SVGPathSegCurvetoQuadraticSmoothRel=w}if(!("SVGPathSegList"in window)||!("appendItem"in window.SVGPathSegList.prototype)){var A=function(){function e(t){n(this,e),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)}return a(e,[{key:"_checkPathSynchronizedToList",value:function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())}},{key:"_updateListFromPathMutations",value:function(e){if(this._pathElement){var t=!1;e.forEach((function(e){"d"===e.attributeName&&(t=!0)})),t&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}}},{key:"_writeListToPath",value:function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",e._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}},{key:"segmentChanged",value:function(e){this._writeListToPath()}},{key:"clear",value:function(){this._checkPathSynchronizedToList(),this._list.forEach((function(e){e._owningPathSegList=null})),this._list=[],this._writeListToPath()}},{key:"initialize",value:function(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_checkValidIndex",value:function(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw new Error("INDEX_SIZE_ERR")}},{key:"getItem",value:function(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]}},{key:"insertItemBefore",value:function(e,t){return this._checkPathSynchronizedToList(),t>this.numberOfItems&&(t=this.numberOfItems),e._owningPathSegList&&(e=e.clone()),this._list.splice(t,0,e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"replaceItem",value:function(e,t){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._checkValidIndex(t),this._list[t]=e,e._owningPathSegList=this,this._writeListToPath(),e}},{key:"removeItem",value:function(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);var t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t}},{key:"appendItem",value:function(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_parsePath",value:function(e){if(!e||!e.length)return[];var t=this,r=function(){function e(){n(this,e),this.pathSegList=[]}return a(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),i=function(){function e(t){n(this,e),this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return a(e,[{key:"_isCurrentSpace",value:function(){var e=this._string[this._currentIndex];return e<=" "&&(" "===e||"\n"===e||"\t"===e||"\r"===e||"\f"===e)}},{key:"_skipOptionalSpaces",value:function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex}},{key:"_skipOptionalSpacesOrDelimiter",value: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)}},{key:"hasMoreData",value:function(){return this._currentIndex<this._endIndex}},{key:"peekSegmentType",value:function(){var e=this._string[this._currentIndex];return this._pathSegTypeFromChar(e)}},{key:"_pathSegTypeFromChar",value:function(e){switch(e){case"Z":case"z":return SVGPathSeg.PATHSEG_CLOSEPATH;case"M":return SVGPathSeg.PATHSEG_MOVETO_ABS;case"m":return SVGPathSeg.PATHSEG_MOVETO_REL;case"L":return SVGPathSeg.PATHSEG_LINETO_ABS;case"l":return SVGPathSeg.PATHSEG_LINETO_REL;case"C":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;case"c":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;case"Q":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return SVGPathSeg.PATHSEG_ARC_ABS;case"a":return SVGPathSeg.PATHSEG_ARC_REL;case"H":return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;case"v":return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;case"S":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return SVGPathSeg.PATHSEG_UNKNOWN}}},{key:"_nextCommandHelper",value:function(e,t){return("+"===e||"-"===e||"."===e||e>="0"&&e<="9")&&t!==SVGPathSeg.PATHSEG_CLOSEPATH?t===SVGPathSeg.PATHSEG_MOVETO_ABS?SVGPathSeg.PATHSEG_LINETO_ABS:t===SVGPathSeg.PATHSEG_MOVETO_REL?SVGPathSeg.PATHSEG_LINETO_REL:t:SVGPathSeg.PATHSEG_UNKNOWN}},{key:"initialCommandIsMoveTo",value:function(){if(!this.hasMoreData())return!0;var e=this.peekSegmentType();return e===SVGPathSeg.PATHSEG_MOVETO_ABS||e===SVGPathSeg.PATHSEG_MOVETO_REL}},{key:"_parseNumber",value:function(){var e=0,t=0,r=1,n=0,i=1,a=1,s=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++,i=-1),!(this._currentIndex===this._endIndex||(this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")&&"."!==this._string.charAt(this._currentIndex))){for(var o=this._currentIndex;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!==o)for(var u=this._currentIndex-1,l=1;u>=o;)t+=l*(this._string.charAt(u--)-"0"),l*=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";)r*=10,n+=(this._string.charAt(this._currentIndex)-"0")/r,this._currentIndex+=1}if(this._currentIndex!==s&&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++,a=-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";)e*=10,e+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var c=t+n;if(c*=i,e&&(c*=Math.pow(10,a*e)),s!==this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),c}}},{key:"_parseArcFlag",value:function(){if(!(this._currentIndex>=this._endIndex)){var e=!1,t=this._string.charAt(this._currentIndex++);if("0"===t)e=!1;else{if("1"!==t)return;e=!0}return this._skipOptionalSpacesOrDelimiter(),e}}},{key:"parseSegment",value:function(){var e=this._string[this._currentIndex],r=this._pathSegTypeFromChar(e);if(r===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if((r=this._nextCommandHelper(e,this._previousCommand))===SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=r,r){case SVGPathSeg.PATHSEG_MOVETO_REL:return new SVGPathSegMovetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_MOVETO_ABS:return new SVGPathSegMovetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_REL:return new SVGPathSegLinetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_ABS:return new SVGPathSegLinetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new SVGPathSegLinetoHorizontalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new SVGPathSegLinetoHorizontalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new SVGPathSegLinetoVerticalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new SVGPathSegLinetoVerticalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new SVGPathSegClosePath(t);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var n={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(t,n.x,n.y,n.x1,n.y1,n.x2,n.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(t,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:var a={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(t,a.x,a.y,a.x2,a.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:var s={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(t,s.x,s.y,s.x2,s.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var o={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(t,o.x,o.y,o.x1,o.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:var u={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(t,u.x,u.y,u.x1,u.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new SVGPathSegCurvetoQuadraticSmoothRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new SVGPathSegCurvetoQuadraticSmoothAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_ARC_REL:var l={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcRel(t,l.x,l.y,l.x1,l.y1,l.arcAngle,l.arcLarge,l.arcSweep);case SVGPathSeg.PATHSEG_ARC_ABS:var c={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcAbs(t,c.x,c.y,c.x1,c.y1,c.arcAngle,c.arcLarge,c.arcSweep);default:throw new Error("Unknown path seg type.")}}}]),e}(),s=new r,o=new i(e);if(!o.initialCommandIsMoveTo())return[];for(;o.hasMoreData();){var u=o.parseSegment();if(!u)return[];s.appendSegment(u)}return s.pathSegList}}],[{key:"_pathSegArrayAsString",value:function(e){var t="",r=!0;return e.forEach((function(e){r?(r=!1,t+=e._asPathString()):t+=" "+e._asPathString()})),t}}]),e}();A.prototype.classname="SVGPathSegList",Object.defineProperty(A.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get:function(){return this._pathSegList||(this._pathSegList=new A(this)),this._pathSegList},enumerable:!0},normalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedNormalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0}}),window.SVGPathSegList=A}}();
/**
* Namespaces or tools therefor.
* @module namespaces
* @license MIT
*/
var v,x={HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://svg-edit.googlecode.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"},S=function(){var e={};return Object.entries(x).forEach((function(t){var r=d(t,2),n=r[0],i=r[1];e[i]=n.toLowerCase()})),e},_=jQuery,b=(Boolean(document.createElementNS&&document.createElementNS(x.SVG,"svg").createSVGRect),navigator.userAgent),w=document.createElementNS(x.SVG,"svg"),A=Boolean(window.opera),k=b.includes("AppleWebKit"),C=b.includes("Gecko/"),E=b.includes("MSIE"),G=b.includes("Chrome/"),I=(b.includes("Windows"),b.includes("Macintosh"),"ontouchstart"in window),N=Boolean(w.querySelector),P=Boolean(document.evaluate),T=function(){var e=document.createElementNS(x.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,r=e.createSVGPathSegLinetoAbs(5,5);try{return t.replaceItem(r,1),!0}catch(e){}return!1}(),L=function(){var e=document.createElementNS(x.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,r=e.createSVGPathSegLinetoAbs(5,5);try{return t.insertItemBefore(r,1),!0}catch(e){}return!1}(),V=function(){var e=document.createElementNS(x.SVG,"svg"),t=document.createElementNS(x.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var r=document.createElementNS(x.SVG,"text");r.textContent="a",t.append(r);try{return 0===r.getStartPositionOfChar(0).x}catch(e){return!1}finally{e.remove()}}(),O=function(){var e=document.createElementNS(x.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(x.SVG,"path");t.setAttribute("d","M0,0 C0,0 10,10 10,0"),e.append(t);var r=t.getBBox();return e.remove(),r.height>4&&r.height<5}(),M=function(){var e=document.createElementNS(x.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(x.SVG,"path");t.setAttribute("d","M0,0 10,0");var r=document.createElementNS(x.SVG,"path");r.setAttribute("d","M5,0 15,0");var n=document.createElementNS(x.SVG,"g");n.append(t,r),e.append(n);var i=n.getBBox();return e.remove(),15===i.width}(),R=(function(){var e=document.createElementNS(x.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");t||_.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the <a href="http://opera.com">latest version</a> in which the problems have been fixed.')}(),(v=document.createElementNS(x.SVG,"rect")).setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===v.style.vectorEffect),B=function(){var t=document.createElementNS(x.SVG,"rect").transform.baseVal,r=w.createSVGTransform();t.appendItem(r);var n=t.getItem(0),i=function(t){return t&&"object"===e(t)&&"function"==typeof t.setMatrix&&"angle"in t};return i(n)&&i(r)&&n.type===r.type&&n.angle===r.angle&&n.matrix.a===r.matrix.a&&n.matrix.b===r.matrix.b&&n.matrix.c===r.matrix.c&&n.matrix.d===r.matrix.d&&n.matrix.e===r.matrix.e&&n.matrix.f===r.matrix.f}(),U=function(){return k},j=function(){return C},H=function(){return E},F=function(){return G},D=function(){return R},z=document.createElementNS(x.SVG,"svg");function q(e){var t=e.matrix,r="";switch(e.type){case 1:r="matrix("+[t.a,t.b,t.c,t.d,t.e,t.f].join(",")+")";break;case 2:r="translate("+t.e+","+t.f+")";break;case 3:r=t.a===t.d?"scale("+t.a+")":"scale("+t.a+","+t.d+")";break;case 4:var n=0,i=0;if(0!==e.angle){var a=1-t.a;i=(a*t.f+t.b*t.e)/(a*a+t.b*t.b),n=(t.e-t.b*i)/a}r="rotate("+e.angle+" "+n+","+i+")"}return r}var Q,W={},X=function(){function e(t){n(this,e),this._elem=t||null,this._xforms=[],this._update=function(){for(var e="",t=0;t<this.numberOfItems;++t){e+=q(this._list.getItem(t))+" "}this._elem.setAttribute("transform",e)},this._list=this,this._init=function(){var e=this,t=this._elem.getAttribute("transform");if(t)for(var r=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,n=!0;n;)n=t.match(r),t=t.replace(r,""),n&&n[1]&&function(){var t=n[1].split(/\s*\(/),r=t[0],i=t[1].match(/\s*(.*?)\s*\)/);i[1]=i[1].replace(/(\d)-/g,"$1 -");var a=i[1].split(/[, ]+/),s="abcdef".split(""),o=z.createSVGMatrix();Object.values(a).forEach((function(e,t){a[t]=Number.parseFloat(e),"matrix"===r&&(o[s[t]]=a[t])}));var u=z.createSVGTransform(),l="set"+r.charAt(0).toUpperCase()+r.slice(1),c="matrix"===r?[o]:a;"scale"===r&&1===c.length?c.push(c[0]):"translate"===r&&1===c.length?c.push(0):"rotate"===r&&1===c.length&&c.push(0,0),u[l].apply(u,m(c)),e._list.appendItem(u)}()},this._removeFromOtherLists=function(e){e&&Object.values(W).some((function(t){for(var r=0,n=t._xforms.length;r<n;++r)if(t._xforms[r]===e)return t.removeItem(r),!0;return!1}))},this.numberOfItems=0}return a(e,[{key:"clear",value:function(){this.numberOfItems=0,this._xforms=[]}},{key:"initialize",value:function(e){this.numberOfItems=1,this._removeFromOtherLists(e),this._xforms=[e]}},{key:"getItem",value:function(e){if(e<this.numberOfItems&&e>=0)return this._xforms[e];var t=new Error("DOMException with code=INDEX_SIZE_ERR");throw t.code=1,t}},{key:"insertItemBefore",value:function(e,t){var r=null;if(t>=0)if(t<this.numberOfItems){this._removeFromOtherLists(e);var n,i=new Array(this.numberOfItems+1);for(n=0;n<t;++n)i[n]=this._xforms[n];i[n]=e;for(var a=n+1;n<this.numberOfItems;++a,++n)i[a]=this._xforms[n];this.numberOfItems++,this._xforms=i,r=e,this._list._update()}else r=this._list.appendItem(e);return r}},{key:"replaceItem",value:function(e,t){var r=null;return t<this.numberOfItems&&t>=0&&(this._removeFromOtherLists(e),this._xforms[t]=e,r=e,this._list._update()),r}},{key:"removeItem",value:function(e){if(e<this.numberOfItems&&e>=0){var t,r=this._xforms[e],n=new Array(this.numberOfItems-1);for(t=0;t<e;++t)n[t]=this._xforms[t];for(var i=t;i<this.numberOfItems-1;++i,++t)n[i]=this._xforms[t+1];return this.numberOfItems--,this._xforms=n,this._list._update(),r}var a=new Error("DOMException with code=INDEX_SIZE_ERR");throw a.code=1,a}},{key:"appendItem",value:function(e){return this._removeFromOtherLists(e),this._xforms.push(e),this.numberOfItems++,this._list._update(),e}}]),e}(),K=function(e){e.id&&W[e.id]&&delete W[e.id]},Z=function(e){if(!B){var t=e.id||"temp",r=W[t];return r&&"temp"!==t||(W[t]=new X(e),W[t]._init(),r=W[t]),r}return e.transform?e.transform.baseVal:e.gradientTransform?e.gradientTransform.baseVal:e.patternTransform?e.patternTransform.baseVal:null},Y=["x","x1","cx","rx","width"],$=["y","y1","cy","ry","height"],J={},ee=function(){return J},te=function e(t){var r=Q.getRoundDigits();return isNaN(t)?Array.isArray(t)?e(t[0])+","+e(t[1]):Number.parseFloat(t).toFixed(r)-0:Number(Number(t).toFixed(r))},re=function(e,t){return t=t||Q.getBaseUnit(),te(e/J[t])},ne=function(e,t,r){e.setAttribute(t,r)},ie=function(e,t){if(!isNaN(t))return t-0;if("%"===t.substr(-1)){var r=t.substr(0,t.length-1)/100,n=Q.getWidth(),i=Q.getHeight();return Y.includes(e)?r*n:$.includes(e)?r*i:r*Math.sqrt(n*n+i*i)/Math.sqrt(2)}var a=t.substr(-2);return t.substr(0,t.length-2)*J[a]},ae=document.createElementNS(x.SVG,"svg"),se=function(e,t,r){return{x:r.a*e+r.c*t+r.e,y:r.b*e+r.d*t+r.f}},oe=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},ue=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=t.reduceRight((function(e,t){return t.multiply(e)}));return Math.abs(n.a)<1e-14&&(n.a=0),Math.abs(n.b)<1e-14&&(n.b=0),Math.abs(n.c)<1e-14&&(n.c=0),Math.abs(n.d)<1e-14&&(n.d=0),Math.abs(n.e)<1e-14&&(n.e=0),Math.abs(n.f)<1e-14&&(n.f=0),n},le=function(e){if(!e)return!1;for(var t=e.numberOfItems;t--;){var r=e.getItem(t);if(1===r.type&&!oe(r.matrix))return!0}return!1},ce=function(e,t,r,n,i){var a=se(e,t,i),s=se(e+r,t,i),o=se(e,t+n,i),u=se(e+r,t+n,i),l=Math.min(a.x,s.x,o.x,u.x),c=Math.max(a.x,s.x,o.x,u.x),h=Math.min(a.y,s.y,o.y,u.y);return{tl:a,tr:s,bl:o,br:u,aabox:{x:l,y:h,width:c-l,height:Math.max(a.y,s.y,o.y,u.y)-h}}},he=function(e,t,r){if(!e)return ae.createSVGTransformFromMatrix(ae.createSVGMatrix());if(t=t||0,r=r||e.numberOfItems-1,(t=Number.parseInt(t))>(r=Number.parseInt(r))){var n=r;r=t,t=n}for(var i=ae.createSVGMatrix(),a=t;a<=r;++a){var s=a>=0&&a<e.numberOfItems?e.getItem(a).matrix:ae.createSVGMatrix();i=ue(i,s)}return ae.createSVGTransformFromMatrix(i)},de=function(e){var t=Z(e);return he(t).matrix},me=function(e,t,r,n){var i=Math.PI/4,a=r-e,s=n-t,o=Math.atan2(s,a),u=Math.sqrt(a*a+s*s),l=Math.round(o/i)*i;return{x:e+u*Math.cos(l),y:t+u*Math.sin(l),a:l}},fe=function(e,t){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y},ge=y(jQuery),pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ye="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath".split(","),ve=null,xe=null,Se=null,_e=null,be=function(e){return e.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/,"$1$2")},we=function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")};function Ae(e){if(e=Ee(e),window.btoa)return window.btoa(e);var t=new Array(4*Math.floor((e.length+2)/3)),r=0,n=0;do{var i=e.charCodeAt(r++),a=e.charCodeAt(r++),s=e.charCodeAt(r++),o=i>>2,u=(3&i)<<4|a>>4,l=(15&a)<<2|s>>6,c=63&s;Number.isNaN(a)?(l=64,c=64):Number.isNaN(s)&&(c=64),t[n++]=pe.charAt(o),t[n++]=pe.charAt(u),t[n++]=pe.charAt(l),t[n++]=pe.charAt(c)}while(r<e.length);return t.join("")}function ke(e){if(window.atob)return Ce(window.atob(e));e=e.replace(/[^A-Za-z\d+/=]/g,"");var t="",r=0;do{var n=pe.indexOf(e.charAt(r++)),i=pe.indexOf(e.charAt(r++)),a=pe.indexOf(e.charAt(r++)),s=pe.indexOf(e.charAt(r++)),o=n<<2|i>>4,u=(15&i)<<4|a>>2,l=(3&a)<<6|s;t+=String.fromCharCode(o),64!==a&&(t+=String.fromCharCode(u)),64!==s&&(t+=String.fromCharCode(l))}while(r<e.length);return Ce(t)}function Ce(e){return decodeURIComponent(escape(e))}var Ee=function(e){return unescape(encodeURIComponent(e))},Ge=function(e){if("undefined"==typeof Uint8Array||"undefined"==typeof Blob||"undefined"==typeof URL||!URL.createObjectURL)return"";for(var t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=atob(t[1]),i=n.length,a=new Uint8Array(i);i--;)a[i]=n.charCodeAt(i);var s=new Blob([a],{type:r});return URL.createObjectURL(s)},Ie=function(e){return e&&"undefined"!=typeof URL&&URL.createObjectURL?URL.createObjectURL(e):""},Ne=(function(){if("undefined"==typeof Blob)return"";var e=new Blob(["<html><head><title>SVG-edit</title></head><body>&nbsp;</body></html>"],{type:"text/html"});Ie(e)}(),function(e){var t,r;e.includes("<svg:svg")&&(e=e.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns"));try{(r=window.DOMParser?new DOMParser:new window.ActiveXObject("Microsoft.XMLDOM")).async=!1}catch(e){throw new Error("XML Parser could not be instantiated")}try{t=r.loadXML?!!r.loadXML(e)&&r:r.parseFromString(e,"text/xml")}catch(e){throw new Error("Error parsing XML string")}return t}),Pe=function e(t,r){if(t&&1===t.nodeType){r(t);for(var n=t.childNodes.length;n--;)e(t.childNodes.item(n),r)}},Te=function(e){if(e){if(e.startsWith('url("'))return e.substring(5,e.indexOf('"',6));if(e.startsWith("url('"))return e.substring(5,e.indexOf("'",6));if(e.startsWith("url("))return e.substring(4,e.indexOf(")"))}return null},Le=function(e){return e.getAttributeNS(x.XLINK,"href")},Ve=function(e,t){e.setAttributeNS(x.XLINK,"xlink:href",t)},Oe=function(){var e=ve.getSVGContent(),t=e.getElementsByTagNameNS(x.SVG,"defs");return t.length>0?t=t[0]:(t=e.ownerDocument.createElementNS(x.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},Me=function(e){for(var t=e.pathSegList,r=t.numberOfItems,n=[[],[]],i=t.getItem(0),a=[i.x,i.y],s=function(e,t,r,n){return function(i){return 1-Math.pow(i,3)*a[e]+3-Math.pow(i,2)*i*t[e]+3*(1-i)*Math.pow(i,2)*r[e]+Math.pow(i,3)*n[e]}},o=0;o<r;o++){var u=t.getItem(o);if(void 0!==u.x)if(n[0].push(a[0]),n[1].push(a[1]),u.x1){for(var l=[u.x1,u.y1],c=[u.x2,u.y2],h=[u.x,u.y],d=0;d<2;d++){var m=s(d,l,c,h),f=6*a[d]-12*l[d]+6*c[d],g=-3*a[d]+9*l[d]-9*c[d]+3*h[d],p=3*l[d]-3*a[d];if(0!==g){var y=Math.pow(f,2)-4*p*g;if(!(y<0)){var v=(-f+Math.sqrt(y))/(2*g);v>0&&v<1&&n[d].push(m(v));var x=(-f-Math.sqrt(y))/(2*g);x>0&&x<1&&n[d].push(m(x))}}else{if(0===f)continue;var S=-p/f;S>0&&S<1&&n[d].push(m(S))}}a=h}else n[0].push(u.x),n[1].push(u.y)}var _=Math.min.apply(null,n[0]),b=Math.max.apply(null,n[0])-_,w=Math.min.apply(null,n[1]);return{x:_,y:w,width:b,height:Math.max.apply(null,n[1])-w}};function Re(e){if(M)try{return e.getBBox()}catch(e){}var t,r,n=ge.data(e,"ref"),i=null;n?(r=ge(n).children().clone().attr("visibility","hidden"),ge(_e).append(r),i=r.filter("line, path")):i=ge(e).find("line, path");var a=!1;if(i.length)if(i.each((function(){var e=this.getBBox();e.width&&e.height||(a=!0)})),a){var s=n?r:ge(e).children();t=Ze(s)}else t=e.getBBox();else t=e.getBBox();return n&&r.remove(),t}var Be=function(e){var t=e||ve.geSelectedElements()[0];if(1!==e.nodeType)return null;var r,n=t.nodeName,i=null;switch(n){case"text":""===t.textContent?(t.textContent="a",i=t.getBBox(),t.textContent=""):t.getBBox&&(i=t.getBBox());break;case"path":O?t.getBBox&&(i=t.getBBox()):i=Me(t);break;case"g":case"a":i=Re(t);break;default:if("use"===n&&(i=Re(t)),"use"===n||"foreignObject"===n&&U()){if(i||(i=t.getBBox()),!U()){var a=i,s=a.x,o=a.y;i={width:a.width,height:a.height,x:s+Number.parseFloat(t.getAttribute("x")||0),y:o+Number.parseFloat(t.getAttribute("y")||0)}}}else if(ye.includes(n))if(t)try{i=t.getBBox()}catch(e){var u=t.getExtentOfChar(0),l=t.getComputedTextLength();i={x:u.x,y:u.y,width:l,height:u.height}}else{var c=ge(t).closest("foreignObject");c.length&&c[0].getBBox&&(i=c[0].getBBox())}}return i&&(i={x:(r=i).x,y:r.y,width:r.width,height:r.height}),i},Ue=function(e){var t="";return ge.each(e,(function(e,r){var n=d(r,2),i=n[0],a=n[1];t+=i;for(var s=0;s<a.length;s+=2)t+=a[s]+","+a[s+1]+" "})),t},je=function(e){var t,r,n,i,a=1.81;switch(e.tagName){case"ellipse":case"circle":var s=r=ge(e).attr(["rx","ry","cx","cy"]),o=s.cx,u=s.cy,l=r;n=l.rx,i=l.ry,"circle"===e.tagName&&(n=i=ge(e).attr("r")),t=Ue([["M",[o-n,u]],["C",[o-n,u-i/a,o-n/a,u-i,o,u-i]],["C",[o+n/a,u-i,o+n,u-i/a,o+n,u]],["C",[o+n,u+i/a,o+n/a,u+i,o,u+i]],["C",[o-n/a,u+i,o-n,u+i/a,o-n,u]],["Z",[]]]);break;case"path":t=e.getAttribute("d");break;case"line":t="M"+(r=ge(e).attr(["x1","y1","x2","y2"])).x1+","+r.y1+"L"+r.x2+","+r.y2;break;case"polyline":t="M"+e.getAttribute("points");break;case"polygon":t="M"+e.getAttribute("points")+" Z";break;case"rect":var c=ge(e).attr(["rx","ry"]);n=c.rx,i=c.ry;var h=e.getBBox(),d=h.x,m=h.y,f=h.width,g=h.height;a=4-a,t=Ue(n||i?[["M",[d,m+i]],["C",[d,m+i/a,d+n/a,m,d+n,m]],["L",[d+f-n,m]],["C",[d+f-n/a,m,d+f,m+i/a,d+f,m+i]],["L",[d+f,m+g-i]],["C",[d+f,m+g-i/a,d+f-n/a,m+g,d+f-n,m+g]],["L",[d+n,m+g]],["C",[d+n/a,m+g,d,m+g-i/a,d,m+g-i]],["L",[d,m+i]],["Z",[]]]:[["M",[d,m]],["L",[d+f,m]],["L",[d+f,m+g]],["L",[d,m+g]],["L",[d,m]],["Z",[]]])}return t},He=function(e){var t={};return ge.each(["marker-start","marker-end","marker-mid","filter","clip-path"],(function(){var r=e.getAttribute(this);r&&(t[this]=r)})),t},Fe=function(e,t,r){var n=t({element:"path",attr:He(e)}),i=e.getAttribute("transform");i&&n.setAttribute("transform",i);var a=e.parentNode;e.nextSibling?e.before(n):a.append(n);var s=je(e);s?n.setAttribute("d",s):n.remove(),r.resetOrientation(n);var o=!1;try{o=n.getBBox()}catch(e){}return n.remove(),o};var De=function(e,t,r){var n=Be(e);if(!n)return null;var i=Z(e),a=Je(i),s=le(i);if(a||s){var o=!1;if(function(e,t){var r=e%90;return t||!(r>-.001&&r<.001||(r<-89.99||r>89.99))}(a,s)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))n=o=Fe(e,t,r);else if("rect"===e.tagName){var u=e.getAttribute("rx"),l=e.getAttribute("ry");(u||l)&&(n=o=Fe(e,t,r))}}if(!o){var c=he(i).matrix;n=ce(n.x,n.y,n.width,n.height,c).aabox}}return n};function ze(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var qe,Qe,We,Xe,Ke,Ze=function(e,t,r){if(!e||!e.length)return!1;var n;if(ge.each(e,(function(){n||this.parentNode&&(n=De(this,t,r))})),void 0===n)return null;var i=n.x+n.width,a=n.y+n.height,s=n.x,o=n.y;if(1===e.length){var u=ze(e[0]);s-=u,o-=u,i+=u,a+=u}else ge.each(e,(function(e,n){var u=De(n,t,r);if(u){var l=ze(n);s=Math.min(s,u.x-l),o=Math.min(o,u.y-l),1===n.nodeType&&(i=Math.max(i,u.x+u.width+l),a=Math.max(a,u.y+u.height+l))}}));return n.x=s,n.y=o,n.width=i-s,n.height=a-o,n},Ye=function(e){e||(e=ge(ve.getSVGContent()).children());var t=[];return ge(e).children().each((function(e,r){r.getBBox&&t.push(r)})),t.reverse()},$e=function(e){return e||(e=Ye()),Ze(e,ve.addSVGElementFromJson,ve.pathActions)},Je=function(e,t){if(!e)return 0;for(var r=e.numberOfItems,n=0;n<r;++n){var i=e.getItem(n);if(4===i.type)return t?i.angle*Math.PI/180:i.angle}return 0},et=function(e,t){var r=e||ve.getSelectedElements()[0],n=Z(r);return Je(n,t)},tt=function(e){return rt(Te(e).substr(1))},rt=N?function(e){return _e.querySelector("#"+e)}:P?function(e){return xe.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+e+'"]',Se,(function(){return x.SVG}),9,null).singleNodeValue}:function(e){return ge(_e).find("[id=".concat(e,"]"))[0]},nt=function(e,t,r,n){for(var i=0,a=Object.entries(t);i<a.length;i++){var s=d(a[i],2),o=s[0],u=s[1],l="xml:"===o.substr(0,4)?x.XML:"xlink:"===o.substr(0,6)?x.XLINK:null;ot(u)?l?e.removeAttributeNS(l,o):e.removeAttribute(o):l?e.setAttributeNS(l,o,u):n?ne(e,o,u):e.setAttribute(o,u)}},it=function(e){var t={"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};"ellipse"===e.nodeName&&(delete t.rx,delete t.ry),Object.entries(t).forEach((function(t){var r=d(t,2),n=r[0],i=r[1];e.getAttribute(n)===String(i)&&e.removeAttribute(n)}))},at=function(e){var t=ve.getBaseUnit(),r=ve.getSnappingStep();return"px"!==t&&(r*=ee()[t]),e=Math.round(e/r)*r},st=function(e){ge(e).click((function(e){e.preventDefault()}))},ot=function(e){return null==e},ut={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"},lt=function(){function e(){n(this,e)}return a(e,[{key:"getText",value:function(){return this.text}},{key:"apply",value:function(e,t){e&&e.handleHistoryEvent(ut.BEFORE_APPLY,this),t(e),e&&e.handleHistoryEvent(ut.AFTER_APPLY,this)}},{key:"unapply",value:function(e,t){e&&e.handleHistoryEvent(ut.BEFORE_UNAPPLY,this),t(),e&&e.handleHistoryEvent(ut.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){return[this.elem]}},{key:"type",value:function(){return this.constructor.name}}]),e}(),ct=function(e){s(r,e);var t=c(r);function r(e,i,a,s){var o;return n(this,r),(o=t.call(this)).elem=e,o.text=s?"Move "+e.tagName+" to "+s:"Move "+e.tagName,o.oldNextSibling=i,o.oldParent=a,o.newNextSibling=e.nextSibling,o.newParent=e.parentNode,o}return a(r,[{key:"apply",value:function(e){var t=this;h(o(r.prototype),"apply",this).call(this,e,(function(){t.elem=t.newParent.insertBefore(t.elem,t.newNextSibling)}))}},{key:"unapply",value:function(e){var t=this;h(o(r.prototype),"unapply",this).call(this,e,(function(){t.elem=t.oldParent.insertBefore(t.elem,t.oldNextSibling)}))}}]),r}(lt),ht=function(e){s(r,e);var t=c(r);function r(e,i){var a;return n(this,r),(a=t.call(this)).elem=e,a.text=i||"Create "+e.tagName,a.parent=e.parentNode,a.nextSibling=a.elem.nextSibling,a}return a(r,[{key:"apply",value:function(e){var t=this;h(o(r.prototype),"apply",this).call(this,e,(function(){t.elem=t.parent.insertBefore(t.elem,t.nextSibling)}))}},{key:"unapply",value:function(e){var t=this;h(o(r.prototype),"unapply",this).call(this,e,(function(){t.parent=t.elem.parentNode,t.elem.remove()}))}}]),r}(lt),dt=function(e){s(r,e);var t=c(r);function r(e,i,a,s){var o;return n(this,r),(o=t.call(this)).elem=e,o.text=s||"Delete "+e.tagName,o.nextSibling=i,o.parent=a,K(e),o}return a(r,[{key:"apply",value:function(e){var t=this;h(o(r.prototype),"apply",this).call(this,e,(function(){K(t.elem),t.parent=t.elem.parentNode,t.elem.remove()}))}},{key:"unapply",value:function(e){var t=this;h(o(r.prototype),"unapply",this).call(this,e,(function(){K(t.elem),ot(t.nextSibling)&&window.console&&console.error("Reference element was lost"),t.parent.insertBefore(t.elem,t.nextSibling)}))}}]),r}(lt),mt=function(e){s(r,e);var t=c(r);function r(e,i,a){var s;for(var o in n(this,r),(s=t.call(this)).elem=e,s.text=a?"Change "+e.tagName+" "+a:"Change "+e.tagName,s.newValues={},s.oldValues=i,i)s.newValues[o]="#text"===o?e.textContent:"#href"===o?Le(e):e.getAttribute(o);return s}return a(r,[{key:"apply",value:function(e){var t=this;h(o(r.prototype),"apply",this).call(this,e,(function(){var e=!1;if(Object.entries(t.newValues).forEach((function(r){var n=d(r,2),i=n[0],a=n[1];a?"#text"===i?t.elem.textContent=a:"#href"===i?Ve(t.elem,a):t.elem.setAttribute(i,a):"#text"===i?t.elem.textContent="":(t.elem.setAttribute(i,""),t.elem.removeAttribute(i)),"transform"===i&&(e=!0)})),!e){var r=et(t.elem);if(r){var n=t.elem.getBBox(),i=["rotate(",r," ",n.x+n.width/2,",",n.y+n.height/2,")"].join("");i!==t.elem.getAttribute("transform")&&t.elem.setAttribute("transform",i)}}}))}},{key:"unapply",value:function(e){var t=this;h(o(r.prototype),"unapply",this).call(this,e,(function(){var e=!1;if(Object.entries(t.oldValues).forEach((function(r){var n=d(r,2),i=n[0],a=n[1];a?"#text"===i?t.elem.textContent=a:"#href"===i?Ve(t.elem,a):t.elem.setAttribute(i,a):"#text"===i?t.elem.textContent="":t.elem.removeAttribute(i),"transform"===i&&(e=!0)})),!e){var r=et(t.elem);if(r){var n=t.elem.getBBox(),i=["rotate(",r," ",n.x+n.width/2,",",n.y+n.height/2,")"].join("");i!==t.elem.getAttribute("transform")&&t.elem.setAttribute("transform",i)}}K(t.elem)}))}}]),r}(lt),ft=function(e){s(r,e);var t=c(r);function r(e){var i;return n(this,r),(i=t.call(this)).text=e||"Batch Command",i.stack=[],i}return a(r,[{key:"apply",value:function(e){var t=this;h(o(r.prototype),"apply",this).call(this,e,(function(){t.stack.forEach((function(t){console.assert(t,"stack item should not be null"),t&&t.apply(e)}))}))}},{key:"unapply",value:function(e){var t=this;h(o(r.prototype),"unapply",this).call(this,e,(function(){t.stack.reverse().forEach((function(t){console.assert(t,"stack item should not be null"),t&&t.unapply(e)}))}))}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)if(this.stack[t])for(var r=this.stack[t].elements(),n=r.length;n--;)e.includes(r[n])||e.push(r[n]);return e}},{key:"addSubCommand",value:function(e){console.assert(null!==e,"cmd should not be null"),this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),r}(lt),gt=function(){function e(t){n(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return a(e,[{key:"resetUndoStack",value:function(){this.undoStack=[],this.undoStackPointer=0}},{key:"getUndoStackSize",value:function(){return this.undoStackPointer}},{key:"getRedoStackSize",value:function(){return this.undoStack.length-this.undoStackPointer}},{key:"getNextUndoCommandText",value:function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""}},{key:"getNextRedoCommandText",value:function(){return this.undoStackPointer<this.undoStack.length?this.undoStack[this.undoStackPointer].getText():""}},{key:"undo",value:function(){this.undoStackPointer>0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}},{key:"redo",value:function(){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}},{key:"addCommandToHistory",value:function(e){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(e),this.undoStackPointer=this.undoStack.length}},{key:"beginUndoableChange",value:function(e,t){for(var r=++this.undoChangeStackPointer,n=t.length,i=new Array(n),a=new Array(n);n--;){var s=t[n];ot(s)||(a[n]=s,i[n]=s.getAttribute(e))}this.undoableChangeStack[r]={attrName:e,oldValues:i,elements:a}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],r=t.attrName,n=new ft("Change "+r),i=t.elements.length;i--;){var a=t.elements[i];if(!ot(a)){var s={};s[r]=t.oldValues[i],s[r]!==a.getAttribute(r)&&n.addSubCommand(new mt(a,s,r))}}return this.undoableChangeStack[e]=null,n}}]),e}(),pt=Object.freeze({__proto__:null,HistoryEventTypes:ut,Command:lt,MoveElementCommand:ct,InsertElementCommand:ht,RemoveElementCommand:dt,ChangeElementCommand:mt,BatchCommand:ft,UndoManager:gt}),yt=jQuery,vt={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"]},xt={},St=function(e){Object.assign(xt,e.ui)},_t=[],bt=!0,wt={},At=null,kt=null,Ct=function(e){kt=e,_t=[0,"ClosePath"];yt.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){_t.push(t+"Abs"),_t.push(t+"Rel")}))},Et=function(e,t,r){var n=e.pathSegList;if(L)n.insertItemBefore(t,r);else{for(var i=n.numberOfItems,a=[],s=0;s<i;s++){var o=n.getItem(s);a.push(o)}n.clear();for(var u=0;u<i;u++)u===r&&n.appendItem(t),n.appendItem(a[u])}},Gt=function(e,t){return vt[e].map((function(e){return t[e]}))},It=function(e,t){var r=e.path,n={x:t?t.x:e.item.x,y:t?t.y:e.item.y};r.matrix&&(n=se(n.x,n.y,r.matrix));var i=kt.getCurrentZoom();return n.x*=i,n.y*=i,n},Nt=function(e,t){var r={x:e.x,y:e.y};t.matrix&&(e=se(r.x,r.y,t.imatrix),r.x=e.x,r.y=e.y);var n=kt.getCurrentZoom();return r.x/=n,r.y/=n,r},Pt=function(e,t,r){var n=Tt(),i=rt("pathpointgrip_"+e);if(!i){i=document.createElementNS(x.SVG,"circle");var a={id:"pathpointgrip_"+e,display:"none",r:4,fill:"#0FF",stroke:"#00F","stroke-width":2,cursor:"move",style:"pointer-events:all"};"pathNodeTooltip"in xt&&(a["xlink:title"]=xt.pathNodeTooltip),nt(i,a),i=n.appendChild(i),yt("#pathpointgrip_"+e).dblclick((function(){At&&At.setSegType()}))}return t&&r&&nt(i,{cx:t,cy:r,display:"inline"}),i},Tt=function(){var e=rt("pathpointgrip_container");e||((e=rt("selectorParentGroup").appendChild(document.createElementNS(x.SVG,"g"))).id="pathpointgrip_container");return e},Lt=function(e){var t=rt("ctrlpointgrip_"+e);if(t)return t;t=document.createElementNS(x.SVG,"circle");var r={id:"ctrlpointgrip_"+e,display:"none",r:4,fill:"#0FF",stroke:"#55F","stroke-width":1,cursor:"move",style:"pointer-events:all"};return"pathCtrlPtTooltip"in xt&&(r["xlink:title"]=xt.pathCtrlPtTooltip),nt(t,r),Tt().append(t),t},Vt=function(e){var t=rt("ctrlLine_"+e);return t||(t=document.createElementNS(x.SVG,"line"),nt(t,{id:"ctrlLine_"+e,stroke:"#555","stroke-width":1,style:"pointer-events:none"}),Tt().append(t),t)},Ot=function(e){var t=e.item,r=e.index;if(!("x1"in t)||!("x2"in t))return null;var n={};Tt();for(var i=[At.segs[r-1].item,t],a=1;a<3;a++){var s=r+"c"+a,o=n["c"+a+"_line"]=Vt(s),u=It(e,{x:t["x"+a],y:t["y"+a]}),l=It(e,{x:i[a-1].x,y:i[a-1].y});nt(o,{x1:u.x,y1:u.y,x2:l.x,y2:l.y,display:"inline"}),n["c"+a+"_line"]=o;var c=n["c"+a]=Lt(s);nt(c,{cx:u.x,cy:u.y,display:"inline"}),n["c"+a]=c}return n},Mt=function(e,t,r,n){var i=n||At.elem,a=i["createSVGPathSeg"+_t[e]].apply(i,m(r));if(T)i.pathSegList.replaceItem(a,t);else{for(var s=i.pathSegList,o=s.numberOfItems,u=[],l=0;l<o;l++){var c=s.getItem(l);u.push(c)}s.clear();for(var h=0;h<o;h++)h===t?s.appendItem(a):s.appendItem(u[h])}},Rt=function(e,t){var r=e.index,n=rt("segline_"+r);if(!n){var i=Tt();n=document.createElementNS(x.SVG,"path"),nt(n,{id:"segline_"+r,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"}),i.append(n)}if(t){var a=e.prev;if(!a)return n.setAttribute("display","none"),n;var s=It(a);Mt(2,0,[s.x,s.y],n);for(var o=Gt(e.type,e.item),u=0;u<o.length;u+=2){var l=It(e,{x:o[u],y:o[u+1]});o[u]=l.x,o[u+1]=l.y}Mt(e.type,1,o,n)}return n},Bt=function(e,t,r){var n=e.x-r.x,i=e.y-r.y,a=t.x-r.x,s=t.y-r.y;if(!(0===n&&0===i||0===a&&0===s)){var o=Math.sqrt(n*n+i*i),u=Math.sqrt(a*a+s*s),l=kt.getSVGRoot().createSVGPoint(),c=kt.getSVGRoot().createSVGPoint(),h=Math.atan2(i,n),d=Math.atan2(s,a);h<0&&(h+=2*Math.PI),d<0&&(d+=2*Math.PI);var m,f,g=Math.abs(h-d),p=Math.abs(Math.PI-g)/2;return h-d>0?(m=g<Math.PI?h+p:h-p,f=g<Math.PI?d-p:d+p):(m=g<Math.PI?h-p:h+p,f=g<Math.PI?d+p:d-p),l.x=o*Math.cos(m)+r.x,l.y=o*Math.sin(m)+r.y,c.x=u*Math.cos(f)+r.x,c.y=u*Math.sin(f)+r.y,[l,c]}},Ut=function(){function e(t,r){n(this,e),this.selected=!1,this.index=t,this.item=r,this.type=r.pathSegType,this.ctrlpts=[],this.ptgrip=null,this.segsel=null}return a(e,[{key:"showCtrlPts",value:function(e){for(var t in this.ctrlpts)({}).hasOwnProperty.call(this.ctrlpts,t)&&this.ctrlpts[t].setAttribute("display",e?"inline":"none")}},{key:"selectCtrls",value:function(e){yt("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill",e?"#0FF":"#EEE")}},{key:"show",value:function(e){this.ptgrip&&(this.ptgrip.setAttribute("display",e?"inline":"none"),this.segsel.setAttribute("display",e?"inline":"none"),this.showCtrlPts(e))}},{key:"select",value:function(e){this.ptgrip&&(this.ptgrip.setAttribute("stroke",e?"#0FF":"#00F"),this.segsel.setAttribute("display",e?"inline":"none"),this.ctrlpts&&this.selectCtrls(e),this.selected=e)}},{key:"addGrip",value:function(){this.ptgrip=function(e,t){var r=e.index,n=Pt(r);if(t){var i=It(e);nt(n,{cx:i.x,cy:i.y,display:"inline"})}return n}(this,!0),this.ctrlpts=Ot(this),this.segsel=Rt(this,!0)}},{key:"update",value:function(e){if(this.ptgrip){var t=It(this);nt(this.ptgrip,{cx:t.x,cy:t.y}),Rt(this,!0),this.ctrlpts&&(e&&(this.item=At.elem.pathSegList.getItem(this.index),this.type=this.item.pathSegType),Ot(this))}}},{key:"move",value:function(e,t){var r=this.item,n=this.ctrlpts?[r.x+=e,r.y+=t,r.x1,r.y1,r.x2+=e,r.y2+=t]:[r.x+=e,r.y+=t];if(Mt(this.type,this.index,10===this.type?Gt(this.type,r):n),this.next&&this.next.ctrlpts){var i=this.next.item,a=[i.x,i.y,i.x1+=e,i.y1+=t,i.x2,i.y2];Mt(this.next.type,this.next.index,a)}if(this.mate){var s=this.mate.item,o=[s.x+=e,s.y+=t];Mt(this.mate.type,this.mate.index,o)}this.update(!0),this.next&&this.next.update(!0)}},{key:"setLinked",value:function(e){var t,r,n;if(2===e){if(r=1,!(t=this.next))return;n=this.item}else{if(r=2,!(t=this.prev))return;n=t.item}var i=t.item;i["x"+r]=n.x+(n.x-this.item["x"+e]),i["y"+r]=n.y+(n.y-this.item["y"+e]);var a=[i.x,i.y,i.x1,i.y1,i.x2,i.y2];Mt(t.type,t.index,a),t.update(!0)}},{key:"moveCtrl",value:function(e,t,r){var n=this.item;n["x"+e]+=t,n["y"+e]+=r;var i=[n.x,n.y,n.x1,n.y1,n.x2,n.y2];Mt(this.type,this.index,i),this.update(!0)}},{key:"setType",value:function(e,t){Mt(e,this.index,t),this.type=e,this.item=At.elem.pathSegList.getItem(this.index),this.showCtrlPts(6===e),this.ctrlpts=Ot(this),this.update(!0)}}]),e}(),jt=function(){function e(t){if(n(this,e),!t||"path"!==t.tagName)throw new Error("svgedit.path.Path constructed without a <path> element");this.elem=t,this.segs=[],this.selected_pts=[],At=this,this.init()}return a(e,[{key:"init",value:function(){yt(Tt()).find("*").each((function(){yt(this).attr("display","none")}));var e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(var r=0;r<t;r++){var n=e.getItem(r),i=new Ut(r,n);i.path=this,this.segs.push(i)}for(var a=this.segs,s=null,o=0;o<t;o++){var u=a[o],l=o+1>=t?null:a[o+1],c=o-1<0?null:a[o-1];if(2===u.type){if(c&&1!==c.type){var h=a[s];h.next=a[s+1],h.next.prev=h,h.addGrip()}s=o}else if(l&&1===l.type)u.next=a[s+1],u.next.prev=u,u.mate=a[s],u.addGrip(),ot(this.first_seg)&&(this.first_seg=u);else if(l)1!==u.type&&(u.addGrip(),l&&2!==l.type&&(u.next=l,u.next.prev=u));else if(1!==u.type){var d=a[s];d.next=a[s+1],d.next.prev=d,d.addGrip(),u.addGrip(),this.first_seg||(this.first_seg=a[s])}}return this}},{key:"eachSeg",value:function(e){for(var t=this.segs.length,r=0;r<t;r++){if(!1===e.call(this.segs[r],r))break}}},{key:"addSeg",value:function(e){var t=this.segs[e];if(t.prev){var r,n,i,a=t.prev;switch(t.item.pathSegType){case 4:n=(t.item.x+a.item.x)/2,i=(t.item.y+a.item.y)/2,r=this.elem.createSVGPathSegLinetoAbs(n,i);break;case 6:var s=(a.item.x+t.item.x1)/2,o=(t.item.x1+t.item.x2)/2,u=(t.item.x2+t.item.x)/2,l=(s+o)/2,c=(o+u)/2;n=(l+c)/2;var h=(a.item.y+t.item.y1)/2,d=(t.item.y1+t.item.y2)/2,m=(t.item.y2+t.item.y)/2,f=(h+d)/2,g=(d+m)/2;i=(f+g)/2,r=this.elem.createSVGPathSegCurvetoCubicAbs(n,i,s,h,l,f);var p=[t.item.x,t.item.y,c,g,u,m];Mt(t.type,e,p)}Et(this.elem,r,e)}}},{key:"deleteSeg",value:function(e){var t=this.segs[e],r=this.elem.pathSegList;t.show(!1);var n=t.next;if(t.mate){var i=[n.item.x,n.item.y];Mt(2,n.index,i),Mt(4,t.index,i),r.removeItem(t.mate.index)}else if(t.prev)r.removeItem(e);else{var a=[n.item.x,n.item.y];Mt(2,t.next.index,a),r.removeItem(e)}}},{key:"removePtFromSelection",value:function(e){var t=this.selected_pts.indexOf(e);-1!==t&&(this.segs[e].select(!1),this.selected_pts.splice(t,1))}},{key:"clearSelection",value:function(){this.eachSeg((function(){this.select(!1)})),this.selected_pts=[]}},{key:"storeD",value:function(){this.last_d=this.elem.getAttribute("d")}},{key:"show",value:function(e){return this.eachSeg((function(){this.show(e)})),e&&this.selectPt(this.first_seg.index),this}},{key:"movePts",value:function(e,t){for(var r=this.selected_pts.length;r--;){this.segs[this.selected_pts[r]].move(e,t)}}},{key:"moveCtrl",value:function(e,t){var r=this.segs[this.selected_pts[0]];r.moveCtrl(this.dragctrl,e,t),bt&&r.setLinked(this.dragctrl)}},{key:"setSegType",value:function(e){this.storeD();for(var t,r=this.selected_pts.length;r--;){var n=this.selected_pts[r],i=this.segs[n],a=i.prev;if(a){if(!e)t="Toggle Path Segment Type",e=6===i.type?4:6;e=Number(e);var s=i.item.x,o=i.item.y,u=a.item.x,l=a.item.y,c=void 0;switch(e){case 6:if(i.olditem){var h=i.olditem;c=[s,o,h.x1,h.y1,h.x2,h.y2]}else{var d=s-u,m=o-l;c=[s,o,u+d/3,l+m/3,s-d/3,o-m/3]}break;case 4:c=[s,o],i.olditem=i.item}i.setType(e,c)}}At.endChanges(t)}},{key:"selectPt",value:function(e,t){this.clearSelection(),ot(e)&&this.eachSeg((function(t){this.prev&&(e=t)})),this.addPtsToSelection(e),t&&(this.dragctrl=t,bt&&this.segs[e].setLinked(t))}},{key:"update",value:function(){var e=this.elem;return et(e)?(this.matrix=de(e),this.imatrix=this.matrix.inverse()):(this.matrix=null,this.imatrix=null),this.eachSeg((function(t){this.item=e.pathSegList.getItem(t),this.update()})),this}},{key:"endChanges",value:function(e){U()&&kt.resetD(this.elem);var t=new mt(this.elem,{d:this.last_d},e);kt.endChanges({cmd:t,elem:this.elem})}},{key:"addPtsToSelection",value:function(t){var r=this;Array.isArray(t)||(t=[t]),t.forEach((function(e){r.segs[e].ptgrip&&!r.selected_pts.includes(e)&&e>=0&&r.selected_pts.push(e)})),this.selected_pts.sort();var n=this.selected_pts.length,i=[];for(i.length=n;n--;){var a=this.selected_pts[n],s=this.segs[a];s.select(!0),i[n]=s.ptgrip}var o=e.subpathIsClosed(this.selected_pts[0]);kt.addPtsToSelection({grips:i,closedSubpath:o})}}],[{key:"subpathIsClosed",value:function(e){var t=!1;return At.eachSeg((function(r){return r<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}]),e}(),Ht=function(e){var t=wt[e.id];return t||(t=wt[e.id]=new jt(e)),t},Ft=function(e){e in wt&&delete wt[e]},Dt=function(e,t){var r=e-We,n=t-Xe,i=Math.sqrt(r*r+n*n),a=Math.atan2(n,r)+Ke;return r=i*Math.cos(a)+We,n=i*Math.sin(a)+Xe,r-=qe,n-=Qe,i=Math.sqrt(r*r+n*n),a=Math.atan2(n,r)-Ke,{x:i*Math.cos(a)+qe,y:i*Math.sin(a)+Qe}},zt=function(){var e=At.elem;if(Ke=et(e,!0)){var t=At.oldbbox;We=t.x+t.width/2,Xe=t.y+t.height/2;var r=Be(e);qe=r.x+r.width/2,Qe=r.y+r.height/2;var n=qe-We,i=Qe-Xe,a=Math.sqrt(n*n+i*i),s=Math.atan2(i,n)+Ke;qe=a*Math.cos(s)+We,Qe=a*Math.sin(s)+Xe;for(var o=e.pathSegList,u=o.numberOfItems;u;){u-=1;var l=o.getItem(u),c=l.pathSegType;if(1!==c){var h=Dt(l.x,l.y),d=[h.x,h.y];if(!ot(l.x1)&&!ot(l.x2)){var m=Dt(l.x1,l.y1),f=Dt(l.x2,l.y2);d.splice(d.length,0,m.x,m.y,f.x,f.y)}Mt(c,u,d)}}Be(e);var g=kt.getSVGRoot().createSVGTransform(),p=Z(e);g.setRotate(180*Ke/Math.PI,qe,Qe),p.replaceItem(g,0)}},qt=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Qt=function(e,t){for(var r=e.pathSegList,n=r.numberOfItems,i=0,a=0,s="",o=null,u=0;u<n;++u){var l=r.getItem(u),c=l.x||0,h=l.y||0,d=l.x1||0,m=l.y1||0,f=l.x2||0,g=l.y2||0,p=l.pathSegType,y=qt[p][t?"toLowerCase":"toUpperCase"]();switch(p){case 1:s+="z",o&&!t&&(i=o[0],a=o[1]);break;case 12:c-=i;case 13:t?(h=0,i+=c,y="l"):(h=a,i=c+=i,y="L"),s+=Wt(y,[[c,h]]);break;case 14:h-=a;case 15:t?(c=0,a+=h,y="l"):(c=i,a=h+=a,y="L"),s+=Wt(y,[[c,h]]);break;case 2:case 4:case 18:c-=i,h-=a;case 5:case 3:case 19:t?(i+=c,a+=h):(i=c+=i,a=h+=a),2!==p&&3!==p||(o=[i,a]),s+=Wt(y,[[c,h]]);break;case 6:c-=i,d-=i,f-=i,h-=a,m-=a,g-=a;case 7:t?(i+=c,a+=h):(d+=i,f+=i,m+=a,g+=a,i=c+=i,a=h+=a),s+=Wt(y,[[d,m],[f,g],[c,h]]);break;case 8:c-=i,d-=i,h-=a,m-=a;case 9:t?(i+=c,a+=h):(d+=i,m+=a,i=c+=i,a=h+=a),s+=Wt(y,[[d,m],[c,h]]);break;case 10:c-=i,h-=a;case 11:t?(i+=c,a+=h):(i=c+=i,a=h+=a),s+=Wt(y,[[l.r1,l.r2]],[l.angle,l.largeArcFlag?1:0,l.sweepFlag?1:0],[c,h]);break;case 16:c-=i,f-=i,h-=a,g-=a;case 17:t?(i+=c,a+=h):(f+=i,g+=a,i=c+=i,a=h+=a),s+=Wt(y,[[f,g],[c,h]])}}return s};function Wt(e,t,r,n){yt.each(t,(function(e,r){t[e]=te(r)}));var i=e+t.join(" ");return r&&(i+=" "+r.join(" ")),n&&(i+=" "+te(n)),i}var Xt,Kt,Zt,Yt,$t,Jt=(Zt=!1,Yt=null,$t=!1,{mouseDown:function(e,t,r,n){var i;if("path"!==kt.getCurrentMode()){if(At){var a;if(At.storeD(),"pathpointgrip_"===(i=e.target.id).substr(0,14)){a=At.cur_pt=Number.parseInt(i.substr(14)),At.dragging=[r,n];var s=At.segs[a];e.shiftKey?s.selected?At.removePtFromSelection(a):At.addPtsToSelection(a):((At.selected_pts.length<=1||!s.selected)&&At.clearSelection(),At.addPtsToSelection(a))}else if(i.startsWith("ctrlpointgrip_")){At.dragging=[r,n];var o=i.split("_")[1].split("c");a=Number(o[0]);var u=Number(o[1]);At.selectPt(a,u)}if(!At.dragging){var l=kt.getRubberBox();ot(l)&&(l=kt.setRubberBox(kt.selectorManager.getRubberBandBox())),c=kt.getCurrentZoom(),nt(l,{x:r*c,y:n*c,width:0,height:0,display:"inline"})}}}else{var c,h=r,d=n,m=h/(c=kt.getCurrentZoom()),f=d/c,g=rt("path_stretch_line");Xt=[m,f],kt.getGridSnapping()&&(m=at(m),f=at(f),h=at(h),d=at(d)),g||(g=document.createElementNS(x.SVG,"path"),nt(g,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"}),g=rt("selectorParentGroup").appendChild(g)),g.setAttribute("display","inline");var p,y=kt.getDrawnPath();if(y){for(var v=y.pathSegList,S=v.numberOfItems,_=6/c,b=!1;S;){S--;var w=v.getItem(S),A=w.x,k=w.y;if(m>=A-_&&m<=A+_&&f>=k-_&&f<=k+_){b=!0;break}}i=kt.getId(),Ft(i);var C,E,G=rt(i),I=v.numberOfItems;if(b){if(S<=1&&I>=2){var N=v.getItem(0).x,P=v.getItem(0).y;C=4===(E=g.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(N,P):y.createSVGPathSegCurvetoCubicAbs(N,P,E.x1/c,E.y1/c,N,P);var T=y.createSVGPathSegClosePath();v.appendItem(C),v.appendItem(T)}else if(I<3)return!1;if(yt(g).remove(),kt.setDrawnPath(null),kt.setStarted(!1),Zt){At.matrix&&kt.remapElement(G,{},At.matrix.inverse());var L=G.getAttribute("d"),V=yt(At.elem).attr("d");return yt(At.elem).attr("d",V+L),yt(G).remove(),At.matrix&&zt(),Ct(),Jt.toEditMode(At.elem),At.selectPt(),!1}}else{if(!yt.contains(kt.getContainer(),kt.getMouseTarget(e)))return!1;var O=y.pathSegList.numberOfItems,M=y.pathSegList.getItem(O-1),R=M.x,B=M.y;if(e.shiftKey){var U=me(R,B,m,f);m=U.x,f=U.y}C=4===(E=g.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(kt.round(m),kt.round(f)):y.createSVGPathSegCurvetoCubicAbs(kt.round(m),kt.round(f),E.x1/c,E.y1/c,E.x2/c,E.y2/c),y.pathSegList.appendItem(C),m*=c,f*=c,g.setAttribute("d",["M",m,f,m,f].join(" ")),p=O,Zt&&(p+=At.segs.length),Pt(p,m,f)}}else{var j="M"+m+","+f+" ";kt.setDrawnPath(kt.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:j,id:kt.getNextId(),opacity:kt.getOpacity()/2}})),g.setAttribute("d",["M",h,d,h,d].join(" ")),p=Zt?At.segs.length:0,Pt(p,h,d)}}},mouseMove:function(e,t){var r=kt.getCurrentZoom();$t=!0;var n=kt.getDrawnPath();if("path"!==kt.getCurrentMode())if(At.dragging){var i=Nt({x:At.dragging[0],y:At.dragging[1]},At),a=Nt({x:e,y:t},At),s=a.x-i.x,o=a.y-i.y;At.dragging=[e,t],At.dragctrl?At.moveCtrl(s,o):At.movePts(s,o)}else At.selected_pts=[],At.eachSeg((function(e){if(this.next||this.prev){var t=kt.getRubberBox().getBBox(),r=It(this),n={x:r.x,y:r.y,width:0,height:0},i=fe(t,n);this.select(i),i&&At.selected_pts.push(this.index)}}));else{if(!n)return;var u=n.pathSegList,l=u.numberOfItems-1;if(Xt){var c=Lt("1c1"),h=Lt("0c2");c.setAttribute("cx",e),c.setAttribute("cy",t),c.setAttribute("display","inline");var d=Xt[0],m=Xt[1],f=d+(d-e/r),g=m+(m-t/r);h.setAttribute("cx",f*r),h.setAttribute("cy",g*r),h.setAttribute("display","inline");var p=Vt(1);if(nt(p,{x1:e,y1:t,x2:f*r,y2:g*r,display:"inline"}),0===l)Kt=[e,t];else{var y=u.getItem(l-1),v=y.x,x=y.y;6===y.pathSegType?(v+=v-y.x2,x+=x-y.y2):Kt&&(v=Kt[0]/r,x=Kt[1]/r),Mt(6,l,[d,m,v,x,f,g],n)}}else{var S=rt("path_stretch_line");if(S){var _=u.getItem(l);if(6===_.pathSegType){var b=_.x+(_.x-_.x2),w=_.y+(_.y-_.y2);Mt(6,1,[e,t,b*r,w*r,e,t],S)}else Kt?Mt(6,1,[e,t,Kt[0],Kt[1],e,t],S):Mt(4,1,[e,t],S)}}}},mouseUp:function(e,t,r,n){var i=kt.getDrawnPath();if("path"===kt.getCurrentMode())return Xt=null,i||(t=rt(kt.getId()),kt.setStarted(!1),Kt=null),{keep:!0,element:t};var a=kt.getRubberBox();if(At.dragging){var s=At.cur_pt;At.dragging=!1,At.dragctrl=!1,At.update(),$t&&At.endChanges("Move path point(s)"),e.shiftKey||$t||At.selectPt(s)}else a&&"none"!==a.getAttribute("display")?(a.setAttribute("display","none"),a.getAttribute("width")<=2&&a.getAttribute("height")<=2&&Jt.toSelectMode(e.target)):Jt.toSelectMode(e.target);$t=!1},toEditMode:function(e){At=Ht(e),kt.setCurrentMode("pathedit"),kt.clearSelection(),At.show(!0).update(),At.oldbbox=Be(At.elem),Zt=!1},toSelectMode:function(e){var t=e===At.elem;kt.setCurrentMode("select"),At.show(!1),Yt=!1,kt.clearSelection(),At.matrix&&zt(),t&&(kt.call("selected",[e]),kt.addToSelection([e],!0))},addSubPath:function(e){e?(kt.setCurrentMode("path"),Zt=!0):(Jt.clear(!0),Jt.toEditMode(At.elem))},select:function(e){Yt===e?(Jt.toEditMode(e),kt.setCurrentMode("pathedit")):Yt=e},reorient:function(){var e=kt.getSelectedElements()[0];if(e&&0!==et(e)){var t=new ft("Reorient path"),r={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new mt(e,r)),kt.clearSelection(),this.resetOrientation(e),kt.addCommandToHistory(t),Ht(e).show(!1).matrix=null,this.clear(),kt.addToSelection([e],!0),kt.call("changed",kt.getSelectedElements())}},clear:function(e){var t=kt.getDrawnPath();if(Yt=null,t){var r=rt(kt.getId());yt(rt("path_stretch_line")).remove(),yt(r).remove(),yt(rt("pathpointgrip_container")).find("*").attr("display","none"),Kt=null,kt.setDrawnPath(null),kt.setStarted(!1)}else"pathedit"===kt.getCurrentMode()&&this.toSelectMode();At&&At.init().show(!1)},resetOrientation:function(e){if(ot(e)||"path"!==e.nodeName)return!1;var t=Z(e),r=he(t).matrix;t.clear(),e.removeAttribute("transform");for(var n=e.pathSegList,i=n.numberOfItems,a=function(t){var i=n.getItem(t),a=i.pathSegType;if(1===a)return"continue";var s=[];yt.each(["",1,2],(function(e,t){var n=i["x"+t],a=i["y"+t];if(void 0!==n&&void 0!==a){var o=se(n,a,r);s.splice(s.length,0,o.x,o.y)}})),Mt(a,t,s,e)},s=0;s<i;++s)a(s);!function(e,t){for(var r=Be(e),n=0;n<2;n++){var i=0===n?"fill":"stroke",a=e.getAttribute(i);if(a&&a.startsWith("url(")){var s=tt(a);if("linearGradient"===s.tagName){var o=s.getAttribute("x1")||0,u=s.getAttribute("y1")||0,l=s.getAttribute("x2")||1,c=s.getAttribute("y2")||0;o=r.width*o+r.x,u=r.height*u+r.y,l=r.width*l+r.x,c=r.height*c+r.y;var h=se(o,u,t),d=se(l,c,t),m={x1:(h.x-r.x)/r.width,y1:(h.y-r.y)/r.height,x2:(d.x-r.x)/r.width,y2:(d.y-r.y)/r.height},f=s.cloneNode(!0);yt(f).attr(m),f.id=kt.getNextId(),Oe().append(f),e.setAttribute(i,"url(#"+f.id+")")}}}}(e,r)},zoomChange:function(){"pathedit"===kt.getCurrentMode()&&At.update()},getNodePoint:function(){var e=At.selected_pts.length?At.selected_pts[0]:1,t=At.segs[e];return{x:t.item.x,y:t.item.y,type:t.type}},linkControlPoints:function(e){bt=e},clonePathNode:function(){At.storeD();for(var e=At.selected_pts,t=e.length,r=[];t--;){var n=e[t];At.addSeg(n),r.push(n+t),r.push(n+t+1)}At.init().addPtsToSelection(r),At.endChanges("Clone path node(s)")},opencloseSubPath:function(){var e=At.selected_pts;if(1===e.length){var t,r,n=At.elem,i=n.pathSegList,a=e[0],s=null,o=null;if(At.eachSeg((function(e){return 2===this.type&&e<=a&&(o=this.item),e<=a||(2===this.type?(s=e,!1):1!==this.type||(s=!1,!1))})),ot(s)&&(s=At.segs.length-1),!1!==s){var u=n.createSVGPathSegLinetoAbs(o.x,o.y),l=n.createSVGPathSegClosePath();return s===At.segs.length-1?(i.appendItem(u),i.appendItem(l)):(Et(n,l,s),Et(n,u,s)),void At.init().selectPt(s+1)}if(At.segs[a].mate)return i.removeItem(a),i.removeItem(a),void At.init().selectPt(a-1);for(var c=0;c<i.numberOfItems;c++){var h=i.getItem(c);if(2===h.pathSegType)t=c;else if(c===a)i.removeItem(t);else if(1===h.pathSegType&&a<c){r=c-1,i.removeItem(c);break}}for(var d=a-t-1;d--;)Et(n,i.getItem(t),r);var m=i.getItem(t);Mt(2,t,[m.x,m.y]),At.init().selectPt(0)}},deletePathNode:function(){if(Jt.canDeleteNodes){At.storeD();for(var e=At.selected_pts,t=e.length;t--;){var r=e[t];At.deleteSeg(r)}if(function e(){var t=At.elem.pathSegList,r=t.numberOfItems,n=function(e,r){for(;r--;)t.removeItem(e)};if(r<=1)return!0;for(;r--;){var i=t.getItem(r);if(1===i.pathSegType){var a=t.getItem(r-1),s=t.getItem(r-2);if(2===a.pathSegType){n(r-1,2),e();break}if(2===s.pathSegType){n(r-2,3),e();break}}else if(2===i.pathSegType&&r>0){var o=t.getItem(r-1).pathSegType;if(2===o){n(r-1,1),e();break}if(1===o&&t.numberOfItems-1===r){n(r,1),e();break}}}return!1}(),At.elem.pathSegList.numberOfItems<=1)return Jt.toSelectMode(At.elem),void kt.canvas.deleteSelectedElements();if(At.init(),At.clearSelection(),window.opera){var n=yt(At.elem);n.attr("d",n.attr("d"))}At.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t,r=e.points,n=r.numberOfItems;if(n>=4){var i=r.getItem(0),a=null,s=[];for(s.push(["M",i.x,",",i.y," C"].join("")),t=1;t<=n-4;t+=3){var o=r.getItem(t),u=r.getItem(t+1),l=r.getItem(t+2);if(a){var c=Bt(a,o,i);if(c&&2===c.length){var h=s[s.length-1].split(",");h[2]=c[0].x,h[3]=c[0].y,s[s.length-1]=h.join(","),o=c[1]}}s.push([o.x,o.y,u.x,u.y,l.x,l.y].join(",")),i=l,a=u}for(s.push("L");t<n;){var d=r.getItem(t);s.push([d.x,d.y].join(",")),t++}s=s.join(" "),e=kt.addSVGElementFromJson({element:"path",curStyles:!0,attr:{id:kt.getId(),d:s,fill:"none"}})}return e},setSegType:function(e){At.setSegType(e)},moveNode:function(e,t){var r=At.selected_pts;if(r.length){At.storeD();var n=At.segs[r[0]],i={x:0,y:0};i[e]=t-n.item[e],n.move(i.x,i.y),At.endChanges("Move path point")}},fixEnd:function(e){for(var t,r=e.pathSegList,n=r.numberOfItems,i=0;i<n;++i){var a=r.getItem(i);if(2===a.pathSegType&&(t=a),1===a.pathSegType){var s=r.getItem(i-1);if(s.x!==t.x||s.y!==t.y){var o=e.createSVGPathSegLinetoAbs(t.x,t.y);Et(e,o,i),Jt.fixEnd(e);break}}}U()&&kt.resetD(e)},convertPath:Qt}),er=jQuery,tr=function(){function e(t,r,i){if(n(this,e),this.name_=t,this.group_=i?null:r,i){var a=i.ownerDocument;this.group_=a.createElementNS(x.SVG,"g");var s=a.createElementNS(x.SVG,"title");s.textContent=t,this.group_.append(s),r?er(r).after(this.group_):i.append(this.group_)}rr(this.group_),Pe(this.group_,(function(e){e.setAttribute("style","pointer-events:inherit")})),this.group_.setAttribute("style",i?"pointer-events:all":"pointer-events:none")}return a(e,[{key:"getName",value:function(){return this.name_}},{key:"getGroup",value:function(){return this.group_}},{key:"activate",value:function(){this.group_.setAttribute("style","pointer-events:all")}},{key:"deactivate",value:function(){this.group_.setAttribute("style","pointer-events:none")}},{key:"setVisible",value:function(e){var t=void 0===e||e?"inline":"none";this.group_.getAttribute("display")!==t&&this.group_.setAttribute("display",t)}},{key:"isVisible",value:function(){return"none"!==this.group_.getAttribute("display")}},{key:"getOpacity",value:function(){var e=this.group_.getAttribute("opacity");return ot(e)?1:Number.parseFloat(e)}},{key:"setOpacity",value:function(e){"number"==typeof e&&e>=0&&e<=1&&this.group_.setAttribute("opacity",e)}},{key:"appendChildren",value:function(e){var t,r=p(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;this.group_.append(n)}}catch(e){r.e(e)}finally{r.f()}}},{key:"getTitleElement",value:function(){for(var e=this.group_.childNodes.length,t=0;t<e;++t){var r=this.group_.childNodes.item(t);if(r&&"title"===r.tagName)return r}return null}},{key:"setName",value:function(e,t){var r=this.name_;e=we(e);var n=this.getTitleElement();return n?(er(n).empty(),n.textContent=e,this.name_=e,t&&t.changeElement(n,{"#text":r}),this.name_):null}},{key:"removeGroup",value:function(){var e=this.group_;return this.group_.remove(),this.group_=void 0,e}}]),e}();function rr(e){var t=e.getAttribute("class");ot(t)||!t.length?e.setAttribute("class",tr.CLASS_NAME):tr.CLASS_REGEX.test(t)||e.setAttribute("class",t+" "+tr.CLASS_NAME)}tr.CLASS_NAME="layer",tr.CLASS_REGEX=new RegExp("(\\s|^)"+tr.CLASS_NAME+"(\\s|$)");var nr=function(){function e(t){n(this,e),this.undoManager_=t,this.currentBatchCommand_=null,this.batchCommandStack_=[]}return a(e,[{key:"startBatchCommand",value:function(e){return this.undoManager_?(this.currentBatchCommand_=new ft(e),this.batchCommandStack_.push(this.currentBatchCommand_),this):this}},{key:"endBatchCommand",value:function(){if(!this.undoManager_)return this;if(this.currentBatchCommand_){var e=this.currentBatchCommand_;this.batchCommandStack_.pop();var t=this.batchCommandStack_.length;this.currentBatchCommand_=t?this.batchCommandStack_[t-1]:null,this.addCommand_(e)}return this}},{key:"moveElement",value:function(e,t,r,n){return this.undoManager_?(this.addCommand_(new ct(e,t,r,n)),this):this}},{key:"insertElement",value:function(e,t){return this.undoManager_?(this.addCommand_(new ht(e,t)),this):this}},{key:"removeElement",value:function(e,t,r,n){return this.undoManager_?(this.addCommand_(new dt(e,t,r,n)),this):this}},{key:"changeElement",value:function(e,t,r){return this.undoManager_?(this.addCommand_(new mt(e,t,r)),this):this}},{key:"addCommand_",value:function(e){if(!this.undoManager_)return this;this.currentBatchCommand_?this.currentBatchCommand_.addSubCommand(e):this.undoManager_.addCommandToHistory(e)}}]),e}();nr.NO_HISTORY=new nr;var ir=y(jQuery),ar=jQuery,sr="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),or=1,ur=2,lr=0,cr=[];function hr(e){return e||new nr(fr.undoMgr)}function dr(e){return ar("title",e).text()||(A&&e.querySelectorAll?ar(e.querySelectorAll("title")).text():"")}function mr(e){for(var t=1;e.includes("Layer "+t);)t++;return"Layer "+t}var fr,gr=function(){function e(t,r){if(n(this,e),!t||!t.tagName||!t.namespaceURI||"svg"!==t.tagName||t.namespaceURI!==x.SVG)throw new Error("Error: svgedit.draw.Drawing instance initialized without a <svg> element");this.svgElem_=t,this.obj_num=0,this.idPrefix=r||"svg_",this.releasedNums=[],this.all_layers=[],this.layer_map={},this.current_layer=null,this.nonce_="";var i=this.svgElem_.getAttributeNS(x.SE,"nonce");i&&lr!==ur?this.nonce_=i:lr===or&&this.setNonce(Math.floor(100001*Math.random()))}return a(e,[{key:"getElem_",value:function(e){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+e):ar(this.svgElem_).find("[id="+e+"]")[0]}},{key:"getSvgElem",value:function(){return this.svgElem_}},{key:"getNonce",value:function(){return this.nonce_}},{key:"setNonce",value:function(e){this.svgElem_.setAttributeNS(x.XMLNS,"xmlns:se",x.SE),this.svgElem_.setAttributeNS(x.SE,"se:nonce",e),this.nonce_=e}},{key:"clearNonce",value:function(){this.nonce_=""}},{key:"getId",value:function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num}},{key:"getNextId",value:function(){var e=this.obj_num,t=!1;this.releasedNums.length>0?(this.obj_num=this.releasedNums.pop(),t=!0):this.obj_num++;for(var r=this.getId();this.getElem_(r);)t&&(this.obj_num=e,t=!1),this.obj_num++,r=this.getId();return t&&(this.obj_num=e),r}},{key:"releaseId",value:function(e){var t=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if("string"!=typeof e||!e.startsWith(t))return!1;var r=Number.parseInt(e.substr(t.length));return!("number"!=typeof r||r<=0||this.releasedNums.includes(r))&&(this.releasedNums.push(r),!0)}},{key:"getNumLayers",value:function(){return this.all_layers.length}},{key:"hasLayer",value:function(e){return void 0!==this.layer_map[e]}},{key:"getLayerName",value:function(e){return e>=0&&e<this.getNumLayers()?this.all_layers[e].getName():""}},{key:"getCurrentLayer",value:function(){return this.current_layer?this.current_layer.getGroup():null}},{key:"getLayerByName",value:function(e){var t=this.layer_map[e];return t?t.getGroup():null}},{key:"getCurrentLayerName",value:function(){return this.current_layer?this.current_layer.getName():""}},{key:"setCurrentLayerName",value:function(e,t){var r=null;if(this.current_layer){var n=this.current_layer.getName();(r=this.current_layer.setName(e,t))&&(delete this.layer_map[n],this.layer_map[r]=this.current_layer)}return r}},{key:"setCurrentLayerPosition",value:function(e){var t,r=this.getNumLayers();if(!this.current_layer||e<0||e>=r)return null;for(t=0;t<r&&this.all_layers[t]!==this.current_layer;++t);if(t===r)return null;if(t!==e){var n=this.current_layer.getGroup(),i=n.nextSibling,a=null;return e>t?e<r-1&&(a=this.all_layers[e+1].getGroup()):a=this.all_layers[e].getGroup(),this.svgElem_.insertBefore(n,a),this.identifyLayers(),this.setCurrentLayer(this.getLayerName(e)),{currentGroup:n,oldNextSibling:i}}return null}},{key:"mergeLayer",value:function(e){var t=this.current_layer.getGroup(),r=ar(t).prev()[0];if(r){e.startBatchCommand("Merge Layer");var n=t.nextSibling;for(e.removeElement(t,n,this.svgElem_);t.firstChild;){var i=t.firstChild;if("title"!==i.localName){var a=i.nextSibling;r.append(i),e.moveElement(i,a,t)}else e.removeElement(i,i.nextSibling,t),i.remove()}this.current_layer.removeGroup();var s=this.all_layers.indexOf(this.current_layer);if(s>0){var o=this.current_layer.getName();this.current_layer=this.all_layers[s-1],this.all_layers.splice(s,1),delete this.layer_map[o]}e.endBatchCommand()}}},{key:"mergeAllLayers",value:function(e){for(this.current_layer=this.all_layers[this.all_layers.length-1],e.startBatchCommand("Merge all Layers");this.all_layers.length>1;)this.mergeLayer(e);e.endBatchCommand()}},{key:"setCurrentLayer",value:function(e){var t=this.layer_map[e];return!!t&&(this.current_layer&&this.current_layer.deactivate(),this.current_layer=t,this.current_layer.activate(),!0)}},{key:"deleteCurrentLayer",value:function(){if(this.current_layer&&this.getNumLayers()>1){var e=this.current_layer.removeGroup();return this.identifyLayers(),e}return null}},{key:"identifyLayers",value:function(){this.all_layers=[],this.layer_map={};for(var e=this.svgElem_.childNodes.length,t=[],r=[],n=null,i=!1,a=0;a<e;++a){var s=this.svgElem_.childNodes.item(a);if(s&&1===s.nodeType)if("g"===s.tagName){i=!0;var o=dr(s);o?(r.push(o),n=new tr(o,s),this.all_layers.push(n),this.layer_map[o]=n):t.push(s)}else sr.includes(s.nodeName)&&t.push(s)}t.length>0||!i?((n=new tr(mr(r),null,this.svgElem_)).appendChildren(t),this.all_layers.push(n),this.layer_map[name]=n):n.activate(),this.current_layer=n}},{key:"createLayer",value:function(e,t){this.current_layer&&this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=mr(Object.keys(this.layer_map)));var r=new tr(e,null,this.svgElem_);return t&&(t.startBatchCommand("Create Layer"),t.insertElement(r.getGroup()),t.endBatchCommand()),this.all_layers.push(r),this.layer_map[e]=r,this.current_layer=r,r.getGroup()}},{key:"cloneLayer",value:function(e,t){var r=this;if(!this.current_layer)return null;this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=mr(Object.keys(this.layer_map)));var n=this.current_layer.getGroup(),i=new tr(e,n,this.svgElem_),a=i.getGroup();m(n.childNodes).forEach((function(e){"title"!==e.localName&&a.append(r.copyElem(e))})),t&&(t.startBatchCommand("Duplicate Layer"),t.insertElement(a),t.endBatchCommand());var s=this.all_layers.indexOf(this.current_layer);return s>=0?this.all_layers.splice(s+1,0,i):this.all_layers.push(i),this.layer_map[e]=i,this.current_layer=i,a}},{key:"getLayerVisibility",value:function(e){var t=this.layer_map[e];return!!t&&t.isVisible()}},{key:"setLayerVisibility",value:function(e,t){if("boolean"!=typeof t)return null;var r=this.layer_map[e];return r?(r.setVisible(t),r.getGroup()):null}},{key:"getLayerOpacity",value:function(e){var t=this.layer_map[e];return t?t.getOpacity():null}},{key:"setLayerOpacity",value:function(e,t){if(!("number"!=typeof t||t<0||t>1)){var r=this.layer_map[e];r&&r.setOpacity(t)}}},{key:"copyElem",value:function(e){var t=this;return function e(t,r){var n=document.createElementNS(t.namespaceURI,t.nodeName);if(ir.each(t.attributes,(function(e,t){"-moz-math-font-style"!==t.localName&&n.setAttributeNS(t.namespaceURI,t.nodeName,t.value)})),n.removeAttribute("id"),n.id=r(),U()&&"path"===t.nodeName){var i=Qt(t);n.setAttribute("d",i)}if(ir.each(t.childNodes,(function(t,i){switch(i.nodeType){case 1:n.append(e(i,r));break;case 3:n.textContent=i.nodeValue}})),ir(t).data("gsvg"))ir(n).data("gsvg",n.firstChild);else if(ir(t).data("symbol")){var a=ir(t).data("symbol");ir(n).data("ref",a).data("symbol",a)}else"image"===n.tagName&&st(n);return n}(e,(function(){return t.getNextId()}))}}]),e}(),pr=function(e,t){(lr=!1===e?ur:or)!==or||t.getNonce()?lr===ur&&t.getNonce()&&t.clearNonce():t.setNonce(Math.floor(100001*Math.random()))},yr=function(){Gr(),fr.getCurrentDrawing().identifyLayers()},vr=function(e,t){var r=fr.getCurrentDrawing().createLayer(e,hr(t));fr.clearSelection(),fr.call("changed",[r])},xr=function(e,t){var r=fr.getCurrentDrawing().cloneLayer(e,hr(t));fr.clearSelection(),Gr(),fr.call("changed",[r])},Sr=function(){var e=fr.getCurrentDrawing().getCurrentLayer(),t=e.nextSibling,r=e.parentNode;if(e=fr.getCurrentDrawing().deleteCurrentLayer()){var n=new ft("Delete Layer");return n.addSubCommand(new dt(e,t,r)),fr.addCommandToHistory(n),fr.clearSelection(),fr.call("changed",[r]),!0}return!1},_r=function(e){var t=fr.getCurrentDrawing().setCurrentLayer(we(e));return t&&fr.clearSelection(),t},br=function(e){var t=fr.getCurrentDrawing(),r=t.getCurrentLayer();if(r&&t.setCurrentLayerName(e,hr()))return fr.call("changed",[r]),!0;return!1},wr=function(e){var t=fr.getCurrentDrawing().setCurrentLayerPosition(e);return!!t&&(fr.addCommandToHistory(new ct(t.currentGroup,t.oldNextSibling,fr.getSVGContent())),!0)},Ar=function(e,t){var r=fr.getCurrentDrawing(),n=r.getLayerVisibility(e),i=r.setLayerVisibility(e,t);if(!i)return!1;var a=n?"inline":"none";return fr.addCommandToHistory(new mt(i,{display:a},"Layer Visibility")),i===r.getCurrentLayer()&&(fr.clearSelection(),fr.pathActions.clear()),!0},kr=function(e){var t=fr.getCurrentDrawing().getLayerByName(e);if(!t)return!1;for(var r=new ft("Move Elements to Layer"),n=fr.getSelectedElements(),i=n.length;i--;){var a=n[i];if(a){var s=a.nextSibling,o=a.parentNode;t.append(a),r.addSubCommand(new ct(a,s,o))}}return fr.addCommandToHistory(r),!0},Cr=function(e){fr.getCurrentDrawing().mergeLayer(hr(e)),fr.clearSelection(),Gr(),fr.changeSVGContent()},Er=function(e){fr.getCurrentDrawing().mergeAllLayers(hr(e)),fr.clearSelection(),Gr(),fr.changeSVGContent()},Gr=function(){var e=cr.length;if(e){for(var t=0;t<e;t++){var r=cr[t],n=fr.elData(r,"orig_opac");1!==n?r.setAttribute("opacity",n):r.removeAttribute("opacity"),r.setAttribute("style","pointer-events: inherit")}cr=[],fr.clearSelection(!0),fr.call("contextset",null)}fr.setCurrentGroup(null)},Ir=function(e){Gr(),"string"==typeof e&&(e=rt(e)),fr.setCurrentGroup(e),ar(e).parentsUntil("#svgcontent").andSelf().siblings().each((function(){var e=this.getAttribute("opacity")||1;fr.elData(this,"orig_opac",e),this.setAttribute("opacity",.33*e),this.setAttribute("style","pointer-events: none"),cr.push(this)})),fr.clearSelection(),fr.call("contextset",fr.getCurrentGroup())},Nr=S(),Pr={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"],feMorphology:["class","in","operator","radius"],filter:["class","color-interpolation-filters","filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display","fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id","class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class","clip-path","clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id","r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class","clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],switch:["class","id","requiredFeatures","systemLanguage"],symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures","spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[],mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth","height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},Tr={};Object.entries(Pr).forEach((function(e){var t=d(e,2),r=t[0],n=t[1],i={};Object.entries(n).forEach((function(e){var t=d(e,2),r=(t[0],t[1]);if(r.includes(":")){var n=r.split(":");i[n[1]]=x[n[0].toUpperCase()]}else i[r]="xmlns"===r?x.XMLNS:null})),Tr[r]=i}));var Lr=function e(t){if(3===t.nodeType&&(t.nodeValue=t.nodeValue.replace(/^\s+|\s+$/g,""),t.nodeValue.length||t.remove()),1===t.nodeType){var r=t.ownerDocument,n=t.parentNode;if(r&&n){var i=Pr[t.nodeName],a=Tr[t.nodeName];if(void 0!==i){for(var s=[],o=t.attributes.length;o--;){var u=t.attributes.item(o),l=u.nodeName,c=u.localName,h=u.namespaceURI;if({}.hasOwnProperty.call(a,c)&&h===a[c]&&h!==x.XMLNS||h===x.XMLNS&&Nr[u.value]||((l.startsWith("se:")||l.startsWith("data-"))&&s.push([l,u.value]),t.removeAttributeNS(h,c)),j())switch(l){case"transform":case"gradientTransform":case"patternTransform":var m=u.value.replace(/(\d)-/g,"$1 -");t.setAttribute(l,m)}if("style"===l){for(var f=u.value.split(";"),g=f.length;g--;){var p=d(f[g].split(":"),2),y=p[0],v=p[1],S=(y||"").trim(),_=(v||"").trim();i.includes(S)&&t.setAttribute(S,_)}t.removeAttribute("style")}}Object.values(s).forEach((function(e){var r=d(e,2),n=r[0],i=r[1];t.setAttributeNS(x.SE,n,i)}));var b=Le(t);if(b&&["filter","linearGradient","pattern","radialGradient","textPath","use"].includes(t.nodeName)&&"#"!==b[0]&&(Ve(t,""),t.removeAttributeNS(x.XLINK,"href")),"use"===t.nodeName&&!Le(t))return void t.remove();for(Object.values(["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],(function(e){var r=t.getAttribute(e);r&&(r=Te(r))&&"#"!==r[0]&&(t.setAttribute(e,""),t.removeAttribute(e))})),o=t.childNodes.length;o--;)e(t.childNodes.item(o))}else{for(var w=[];t.hasChildNodes();)w.push(n.insertBefore(t.firstChild,t));t.remove();for(var A=w.length;A--;)e(w[A])}}}};
/**
* Adapted from {@link https://github.com/uupaa/dynamic-import-polyfill/blob/master/importModule.js}.
* @module importModule
* @license MIT
*/function Vr(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}function Or(e,t){["id","class","type"].forEach((function(r){r in t&&(e[r]=t[r])}))}function Mr(e,t){return Rr.apply(this,arguments)}function Rr(){return(Rr=r(regeneratorRuntime.mark((function e(t,r){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.global,i=r.returnDefault,!(!("svgEditor"in window)||!window.svgEditor||!1!==window.svgEditor.modules)){e.next=4;break}return e.abrupt("return",Ur(t,void 0,{returnDefault:i}));case 4:return e.next=6,Br(t);case 6:return e.abrupt("return",window[n]);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Br(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map((function(e){return Br(e,t)}))):new Promise((function(r,n){var i=document.createElement("script");function a(){n(new Error("Failed to import: ".concat(e))),o()}function s(){r(),o()}var o=function(){i.removeEventListener("error",a),i.removeEventListener("load",s),i.remove(),i.src=""};i.defer="defer",Or(i,t),i.addEventListener("error",a),i.addEventListener("load",s),i.src=e,document.head.append(i)}))}function Ur(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.returnDefault,i=void 0!==n&&n;return Array.isArray(e)?Promise.all(e.map((function(e){return Ur(e,t)}))):new Promise((function(r,n){var a="$importModule$"+Math.random().toString(32).slice(2),s=document.createElement("script");function o(){n(new Error("Failed to import: ".concat(e))),l()}function u(){r(window[a]),l()}var l=function(){delete window[a],s.removeEventListener("error",o),s.removeEventListener("load",u),s.remove(),URL.revokeObjectURL(s.src),s.src=""};Or(s,t),s.defer="defer",s.type="module",s.addEventListener("error",o),s.addEventListener("load",u);var c=Vr(e),h="import * as m from '".concat(c.replace(/'/g,"\\'"),"'; window.").concat(a," = ").concat(i?"m.default || ":"","m;"),d=new Blob([h],{type:"text/javascript"});s.src=URL.createObjectURL(d),document.head.append(s)}))}var jr,Hr,Fr,Dr,zr=jQuery,qr=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Qr=null,Wr=function(e,t,r){for(var n=function(e,t){return se(e,t,r)},i=function(e){return r.a*e},a=function(e){return r.d*e},s=Qr.getGridSnapping()&&"svg"===e.parentNode.parentNode.localName,o=function(){s&&Object.entries(t).forEach((function(e){var r=d(e,2),n=r[0],i=r[1];t[n]=at(i)})),nt(e,t,0,!0)},u=Be(e),l=0;l<2;l++){var c=0===l?"fill":"stroke",h=e.getAttribute(c);if(h&&h.startsWith("url(")&&(r.a<0||r.d<0)){var m=tt(h).cloneNode(!0);if(r.a<0){var f=m.getAttribute("x1"),g=m.getAttribute("x2");m.setAttribute("x1",-(f-1)),m.setAttribute("x2",-(g-1))}if(r.d<0){var p=m.getAttribute("y1"),y=m.getAttribute("y2");m.setAttribute("y1",-(p-1)),m.setAttribute("y2",-(y-1))}m.id=Qr.getDrawing().getNextId(),Oe().append(m),e.setAttribute(c,"url(#"+m.id+")")}}var v=e.tagName;if("g"===v||"text"===v||"tspan"===v||"use"===v)if(1!==r.a||0!==r.b||0!==r.c||1!==r.d||0===r.e&&0===r.f){var x=Z(e),S=Qr.getSVGRoot().createSVGTransform();S.setMatrix(ue(he(x).matrix,r)),x.clear(),x.appendItem(S)}else{var _=he(e).matrix,b=ue(_.inverse(),r,_);t.x=Number.parseFloat(t.x)+b.e,t.y=Number.parseFloat(t.y)+b.f}switch(v){case"foreignObject":case"rect":case"image":if("image"===v&&(r.a<0||r.d<0)){var w=Z(e),A=Qr.getSVGRoot().createSVGTransform();A.setMatrix(ue(he(w).matrix,r)),w.clear(),w.appendItem(A)}else{var k=n(t.x,t.y);t.width=i(t.width),t.height=a(t.height),t.x=k.x+Math.min(0,t.width),t.y=k.y+Math.min(0,t.height),t.width=Math.abs(t.width),t.height=Math.abs(t.height)}o();break;case"ellipse":var C=n(t.cx,t.cy);t.cx=C.x,t.cy=C.y,t.rx=i(t.rx),t.ry=a(t.ry),t.rx=Math.abs(t.rx),t.ry=Math.abs(t.ry),o();break;case"circle":var E=n(t.cx,t.cy);t.cx=E.x,t.cy=E.y;var G=ce(u.x,u.y,u.width,u.height,r),I=G.tr.x-G.tl.x,N=G.bl.y-G.tl.y;t.r=Math.min(I/2,N/2),t.r&&(t.r=Math.abs(t.r)),o();break;case"line":var P=n(t.x1,t.y1),T=n(t.x2,t.y2);t.x1=P.x,t.y1=P.y,t.x2=T.x,t.y2=T.y;case"text":case"tspan":case"use":o();break;case"g":var L=zr(e).data("gsvg");L&&nt(L,t,0,!0);break;case"polyline":case"polygon":for(var V=t.points.length,O=0;O<V;++O){var M=t.points[O],R=n(M.x,M.y),B=R.x,U=R.y;t.points[O].x=B,t.points[O].y=U}for(var j="",H=0;H<V;++H){var F=t.points[H];j+=F.x+","+F.y+" "}e.setAttribute("points",j);break;case"path":var D=e.pathSegList,z=D.numberOfItems;t.d=[];for(var q=0;q<z;++q){var Q=D.getItem(q);t.d[q]={type:Q.pathSegType,x:Q.x,y:Q.y,x1:Q.x1,y1:Q.y1,x2:Q.x2,y2:Q.y2,r1:Q.r1,r2:Q.r2,angle:Q.angle,largeArcFlag:Q.largeArcFlag,sweepFlag:Q.sweepFlag}}z=t.d.length;var W=t.d[0],X=n(W.x,W.y);t.d[0].x=X.x,t.d[0].y=X.y;for(var K=1;K<z;++K){var Y=t.d[K];if(Y.type%2==0){var $=n(void 0!==Y.x?Y.x:X.x,void 0!==Y.y?Y.y:X.y),J=n(Y.x1,Y.y1),ee=n(Y.x2,Y.y2);Y.x=$.x,Y.y=$.y,Y.x1=J.x,Y.y1=J.y,Y.x2=ee.x,Y.y2=ee.y,Y.r1=i(Y.r1),Y.r2=a(Y.r2)}else Y.x=i(Y.x),Y.y=a(Y.y),Y.x1=i(Y.x1),Y.y1=a(Y.y1),Y.x2=i(Y.x2),Y.y2=a(Y.y2),Y.r1=i(Y.r1),Y.r2=a(Y.r2)}var te="";z=t.d.length;for(var re=0;re<z;++re){var ne=t.d[re],ie=ne.type;switch(te+=qr[ie],ie){case 13:case 12:te+=ne.x+" ";break;case 15:case 14:te+=ne.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:te+=ne.x+","+ne.y+" ";break;case 7:case 6:te+=ne.x1+","+ne.y1+" "+ne.x2+","+ne.y2+" "+ne.x+","+ne.y+" ";break;case 9:case 8:te+=ne.x1+","+ne.y1+" "+ne.x+","+ne.y+" ";break;case 11:case 10:te+=ne.r1+","+ne.r2+" "+ne.angle+" "+Number(ne.largeArcFlag)+" "+Number(ne.sweepFlag)+" "+ne.x+","+ne.y+" ";break;case 17:case 16:te+=ne.x2+","+ne.y2+" "+ne.x+","+ne.y+" "}}e.setAttribute("d",te)}},Xr=y(jQuery),Kr=function(e,t,r){var n=tt(e).firstChild,i=Z(n),a=jr.getSVGRoot().createSVGTransform();a.setTranslate(t,r),i.appendItem(a),Zr(n)},Zr=function e(t){if(ot(t))return null;if("svg"===t.nodeName&&navigator.userAgent.includes("Firefox/20"))return null;var r=jr.getSVGRoot(),n=Z(t);if(n&&n.numberOfItems>0){for(var i=n.numberOfItems,a=i;i--;){var s=n.getItem(i);if(0===s.type)n.removeItem(i);else if(1===s.type){if(oe(s.matrix)){if(1===a)return t.removeAttribute("transform"),null;n.removeItem(i)}}else 4===s.type&&0===s.angle&&n.removeItem(i)}if(1===n.numberOfItems&&et(t))return null}if(!n||0===n.numberOfItems)return t.setAttribute("transform",""),t.removeAttribute("transform"),null;if(n){for(var o=[],u=n.numberOfItems;u--;){var l=n.getItem(u);1===l.type?o.push([l.matrix,u]):o.length&&(o=[])}if(2===o.length){var c=r.createSVGTransformFromMatrix(ue(o[1][0],o[0][0]));n.removeItem(o[0][1]),n.removeItem(o[1][1]),n.insertItemBefore(c,o[1][1])}if((u=n.numberOfItems)>=2&&1===n.getItem(u-2).type&&2===n.getItem(u-1).type){var h=r.createSVGTransform(),d=ue(n.getItem(u-2).matrix,n.getItem(u-1).matrix);h.setMatrix(d),n.removeItem(u-2),n.removeItem(u-2),n.appendItem(h)}}switch(t.tagName){case"line":case"polyline":case"polygon":case"path":break;default:if(1===n.numberOfItems&&1===n.getItem(0).type||2===n.numberOfItems&&1===n.getItem(0).type&&4===n.getItem(0).type)return null}var m,f,g=Xr(t).data("gsvg"),p=new ft("Transform"),y={},v=null,S=[];switch(t.tagName){case"line":S=["x1","y1","x2","y2"];break;case"circle":S=["cx","cy","r"];break;case"ellipse":S=["cx","cy","rx","ry"];break;case"foreignObject":case"rect":case"image":S=["width","height","x","y"];break;case"use":case"text":case"tspan":S=["x","y"];break;case"polygon":case"polyline":(v={}).points=t.getAttribute("points");var _=t.points,b=_.numberOfItems;y.points=new Array(b);for(var w=0;w<b;++w){var A=_.getItem(w);y.points[w]={x:A.x,y:A.y}}break;case"path":(v={}).d=t.getAttribute("d"),y.d=t.getAttribute("d")}if(S.length?(y=Xr(t).attr(S),Xr.each(y,(function(e,t){y[e]=ie(e,t)}))):g&&(y={x:Xr(g).attr("x")||0,y:Xr(g).attr("y")||0}),ot(v)&&(v=Xr.extend(!0,{},y),Xr.each(v,(function(e,t){v[e]=ie(e,t)}))),v.transform=jr.getStartTransform()||"","g"===t.tagName&&!g||"a"===t.tagName){var k=Be(t);m={x:k.x+k.width/2,y:k.y+k.height/2},f=se(k.x+k.width/2,k.y+k.height/2,he(n).matrix);var C=et(t);if(C){var E,G=C*Math.PI/180;E=Math.abs(G)>1e-10?Math.sin(G)/(1-Math.cos(G)):2/G;for(var I=0;I<n.numberOfItems;++I){var N=n.getItem(I);if(4===N.type){var P=N.matrix;m.y=(E*P.e+P.f)/2,m.x=(P.e-E*P.f)/2,n.removeItem(I);break}}}var T,L,V=n.numberOfItems,O=0,M=0,R=0;if(V&&(T=n.getItem(0).matrix),V>=3&&3===n.getItem(V-2).type&&2===n.getItem(V-3).type&&2===n.getItem(V-1).type){R=3;for(var B=n.getItem(V-3).matrix,j=n.getItem(V-2).matrix,H=n.getItem(V-1).matrix,F=t.childNodes,D=F.length;D--;){var z=F.item(D);if(O=0,M=0,1===z.nodeType){var q=Z(z);if(!q)continue;var Q=he(q).matrix,W=et(z);if(L=jr.getStartTransform(),jr.setStartTransform(z.getAttribute("transform")),W||le(q)){var X=r.createSVGTransform();X.setMatrix(ue(B,j,H,Q)),q.clear(),q.appendItem(X)}else{var K=ue(Q.inverse(),H,Q),Y=r.createSVGMatrix();Y.e=-K.e,Y.f=-K.f;var $=ue(Y.inverse(),Q.inverse(),B,j,H,Q,K.inverse()),J=r.createSVGTransform(),ee=r.createSVGTransform(),te=r.createSVGTransform();J.setTranslate(K.e,K.f),ee.setScale($.a,$.d),te.setTranslate(Y.e,Y.f),q.appendItem(te),q.appendItem(ee),q.appendItem(J)}p.addSubCommand(e(z)),jr.setStartTransform(L)}}n.removeItem(V-1),n.removeItem(V-2),n.removeItem(V-3)}else if(V>=3&&1===n.getItem(V-1).type){R=3;var re=he(n).matrix,ne=r.createSVGTransform();ne.setMatrix(re),n.clear(),n.appendItem(ne)}else if((1===V||V>1&&3!==n.getItem(1).type)&&2===n.getItem(0).type){R=2;var ae=he(n).matrix;n.removeItem(0);var ce=he(n).matrix.inverse(),de=ue(ce,ae);if(O=de.e,M=de.f,0!==O||0!==M){for(var me=t.childNodes,fe=me.length,ge=[];fe--;){var pe=me.item(fe);if(1===pe.nodeType){if(pe.getAttribute("clip-path")){var ye=pe.getAttribute("clip-path");ge.includes(ye)||(Kr(ye,O,M),ge.push(ye))}L=jr.getStartTransform(),jr.setStartTransform(pe.getAttribute("transform"));var ve=Z(pe);if(ve){var xe=r.createSVGTransform();xe.setTranslate(O,M),ve.numberOfItems?ve.insertItemBefore(xe,0):ve.appendItem(xe),p.addSubCommand(e(pe));for(var Se=t.getElementsByTagNameNS(x.SVG,"use"),_e="#"+pe.id,be=Se.length;be--;){var we=Se.item(be);if(_e===Le(we)){var Ae=r.createSVGTransform();Ae.setTranslate(-O,-M),Z(we).insertItemBefore(Ae,0),p.addSubCommand(e(we))}}jr.setStartTransform(L)}}}jr.setStartTransform(L)}}else{if(1!==V||1!==n.getItem(0).type||C){if(C){var ke=r.createSVGTransform();ke.setRotate(C,f.x,f.y),n.numberOfItems?n.insertItemBefore(ke,0):n.appendItem(ke)}return 0===n.numberOfItems&&t.removeAttribute("transform"),null}R=1;for(var Ce=n.getItem(0).matrix,Ee=t.childNodes,Ge=Ee.length;Ge--;){var Ie=Ee.item(Ge);if(1===Ie.nodeType){L=jr.getStartTransform(),jr.setStartTransform(Ie.getAttribute("transform"));var Ne=Z(Ie);if(!Ne)continue;var Pe=ue(Ce,he(Ne).matrix),Te=r.createSVGTransform();Te.setMatrix(Pe),Ne.clear(),Ne.appendItem(Te,0),p.addSubCommand(e(Ie)),jr.setStartTransform(L);var Ve=Ie.getAttribute("stroke-width");if("none"!==Ie.getAttribute("stroke")&&!isNaN(Ve)){var Oe=(Math.abs(Pe.a)+Math.abs(Pe.d))/2;Ie.setAttribute("stroke-width",Ve*Oe)}}}n.clear()}if(2===R){if(C){f={x:m.x+T.e,y:m.y+T.f};var Me=r.createSVGTransform();Me.setRotate(C,f.x,f.y),n.numberOfItems?n.insertItemBefore(Me,0):n.appendItem(Me)}}else if(3===R){var Re=he(n).matrix,Ue=r.createSVGTransform();Ue.setRotate(C,m.x,m.y);var je=Ue.matrix,He=r.createSVGTransform();He.setRotate(C,f.x,f.y);var Fe=He.matrix.inverse(),De=Re.inverse(),ze=ue(De,Fe,je,Re);if(O=ze.e,M=ze.f,0!==O||0!==M)for(var qe=t.childNodes,Qe=qe.length;Qe--;){var We=qe.item(Qe);if(1===We.nodeType){L=jr.getStartTransform(),jr.setStartTransform(We.getAttribute("transform"));var Xe=Z(We),Ke=r.createSVGTransform();Ke.setTranslate(O,M),Xe.numberOfItems?Xe.insertItemBefore(Ke,0):Xe.appendItem(Ke),p.addSubCommand(e(We)),jr.setStartTransform(L)}}C&&(n.numberOfItems?n.insertItemBefore(He,0):n.appendItem(He))}}else{var Ze,Ye=Be(t);if(!Ye&&"path"!==t.tagName)return null;var $e=et(t);if($e){m={x:Ye.x+Ye.width/2,y:Ye.y+Ye.height/2},f=se(Ye.x+Ye.width/2,Ye.y+Ye.height/2,he(n).matrix);for(var Je=$e*Math.PI/180,rt=Math.abs(Je)>1e-10?Math.sin(Je)/(1-Math.cos(Je)):2/Je,nt=0;nt<n.numberOfItems;++nt){var it=n.getItem(nt);if(4===it.type){var at=it.matrix;m.y=(rt*at.e+at.f)/2,m.x=(at.e-rt*at.f)/2,n.removeItem(nt);break}}}var st=0,ut=n.numberOfItems;if(!U()){var lt=t.getAttribute("fill");if(lt&&lt.startsWith("url(")){var ct=tt(lt),ht="pattern";if(ct.tagName!==ht&&(ht="gradient"),"userSpaceOnUse"===ct.getAttribute(ht+"Units")){Ze=he(n).matrix;var dt=Z(ct),gt=he(dt).matrix,pt="matrix("+[(Ze=ue(Ze,gt)).a,Ze.b,Ze.c,Ze.d,Ze.e,Ze.f].join(",")+")";ct.setAttribute(ht+"Transform",pt)}}}if(ut>=3&&3===n.getItem(ut-2).type&&2===n.getItem(ut-3).type&&2===n.getItem(ut-1).type)st=3,Ze=he(n,ut-3,ut-1).matrix,n.removeItem(ut-1),n.removeItem(ut-2),n.removeItem(ut-3);else if(4===ut&&1===n.getItem(ut-1).type){st=3,Ze=he(n).matrix;var yt=r.createSVGTransform();yt.setMatrix(Ze),n.clear(),n.appendItem(yt),Ze=r.createSVGMatrix()}else if((1===ut||ut>1&&3!==n.getItem(1).type)&&2===n.getItem(0).type){st=2;var vt=n.getItem(0).matrix,xt=he(n,1).matrix,St=xt.inverse();Ze=ue(St,vt,xt),n.removeItem(0)}else{if(1!==ut||1!==n.getItem(0).type||$e){if($e){var _t=r.createSVGTransform();_t.setRotate($e,f.x,f.y),n.numberOfItems?n.insertItemBefore(_t,0):n.appendItem(_t)}return 0===n.numberOfItems&&t.removeAttribute("transform"),null}switch(Ze=he(n).matrix,t.tagName){case"line":y=Xr(t).attr(["x1","y1","x2","y2"]);case"polyline":case"polygon":if(y.points=t.getAttribute("points"),y.points){var bt=t.points,wt=bt.numberOfItems;y.points=new Array(wt);for(var At=0;At<wt;++At){var kt=bt.getItem(At);y.points[At]={x:kt.x,y:kt.y}}}case"path":y.d=t.getAttribute("d"),st=1,n.clear()}}if(1!==st&&2!==st&&3!==st||Wr(t,y,Ze),2===st){if($e){le(n)||(f={x:m.x+Ze.e,y:m.y+Ze.f});var Ct=r.createSVGTransform();Ct.setRotate($e,f.x,f.y),n.numberOfItems?n.insertItemBefore(Ct,0):n.appendItem(Ct)}if("text"===t.tagName)for(var Et=t.childNodes,Gt=Et.length;Gt--;){var It=Et.item(Gt);if("tspan"===It.tagName){var Nt={x:Xr(It).attr("x")||0,y:Xr(It).attr("y")||0};Wr(It,Nt,Ze)}}}else if(3===st&&$e){var Pt=he(n).matrix,Tt=r.createSVGTransform();Tt.setRotate($e,m.x,m.y);var Lt=Tt.matrix,Vt=r.createSVGTransform();Vt.setRotate($e,f.x,f.y);var Ot=Vt.matrix.inverse(),Mt=Pt.inverse(),Rt=ue(Mt,Ot,Lt,Pt);Wr(t,y,Rt),$e&&(n.numberOfItems?n.insertItemBefore(Vt,0):n.appendItem(Vt))}}return 0===n.numberOfItems&&t.removeAttribute("transform"),p.addSubCommand(new mt(t,v)),p},Yr=jQuery,$r=I?10:4,Jr=function(){function e(t,r,i){n(this,e),this.id=t,this.selectedElement=r,this.locked=!0,this.selectorGroup=Hr.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}}),this.selectorRect=this.selectorGroup.appendChild(Hr.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#22C","stroke-width":"1","stroke-dasharray":"5,5",style:"pointer-events:none"}})),this.gripCoords={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null},this.reset(this.selectedElement,i)}return a(e,[{key:"reset",value:function(e,t){this.locked=!0,this.selectedElement=e,this.resize(t),this.selectorGroup.setAttribute("display","inline")}},{key:"showGrips",value:function(t){var r=t?"inline":"none";Dr.selectorGripsGroup.setAttribute("display",r);var n=this.selectedElement;this.hasGrips=t,n&&t&&(this.selectorGroup.append(Dr.selectorGripsGroup),e.updateGripCursors(et(n)))}},{key:"resize",value:function(e){var t=this.selectorRect,r=Dr,n=r.selectorGrips,i=this.selectedElement,a=i.getAttribute("stroke-width"),s=Hr.getCurrentZoom(),o=1/s;"none"===i.getAttribute("stroke")||isNaN(a)||(o+=a/2);var u=i.tagName;"text"===u&&(o+=2/s);var l=Z(i),c=he(l).matrix;if(c.e*=s,c.f*=s,e||(e=Be(i)),"g"===u&&!Yr.data(i,"gsvg")){var h=Ze([i.childNodes]);h&&(e=h)}var m=e.x,f=e.y,g=e.width,p=e.height;o*=s;var y=ce(m*s,f*s,g*s,p*s,c),v=y.aabox,x=v.x-o,S=v.y-o,_=v.width+2*o,b=v.height+2*o,w=x+_/2,A=S+b/2,k=et(i);if(k){var C=Hr.svgRoot().createSVGTransform();C.setRotate(-k,w,A);var E=C.matrix;y.tl=se(y.tl.x,y.tl.y,E),y.tr=se(y.tr.x,y.tr.y,E),y.bl=se(y.bl.x,y.bl.y,E),y.br=se(y.br.x,y.br.y,E);var G=y.tl,I=G.x,N=G.y,P=G.x,T=G.y,L=Math.min,V=Math.max;x=I=L(I,L(y.tr.x,L(y.bl.x,y.br.x)))-o,S=N=L(N,L(y.tr.y,L(y.bl.y,y.br.y)))-o,_=(P=V(P,V(y.tr.x,V(y.bl.x,y.br.x)))+o)-I,b=(T=V(T,V(y.tr.y,V(y.bl.y,y.br.y)))+o)-N}var O="M"+x+","+S+" L"+(x+_)+","+S+" "+(x+_)+","+(S+b)+" "+x+","+(S+b)+"z";t.setAttribute("d",O);var M=k?"rotate("+[k,w,A].join(",")+")":"";this.selectorGroup.setAttribute("transform",M),this.gripCoords={nw:[x,S],ne:[x+_,S],sw:[x,S+b],se:[x+_,S+b],n:[x+_/2,S],w:[x,S+b/2],e:[x+_,S+b/2],s:[x+_/2,S+b]},Object.entries(this.gripCoords).forEach((function(e){var t=d(e,2),r=t[0],i=t[1];n[r].setAttribute("cx",i[0]),n[r].setAttribute("cy",i[1])})),r.rotateGripConnector.setAttribute("x1",x+_/2),r.rotateGripConnector.setAttribute("y1",S),r.rotateGripConnector.setAttribute("x2",x+_/2),r.rotateGripConnector.setAttribute("y2",S-5*$r),r.rotateGrip.setAttribute("cx",x+_/2),r.rotateGrip.setAttribute("cy",S-5*$r)}}],[{key:"updateGripCursors",value:function(e){var t=Object.keys(Dr.selectorGrips),r=Math.round(e/45);for(r<0&&(r+=8);r>0;)t.push(t.shift()),r--;Object.values(Dr.selectorGrips).forEach((function(e,r){e.setAttribute("style","cursor:"+t[r]+"-resize")}))}}]),e}(),en=function(){function t(){n(this,t),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()}return a(t,[{key:"initGroup",value:function(){var e=this;if(this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.remove(),this.selectorParentGroup=Hr.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}}),this.selectorGripsGroup=Hr.createSVGElement({element:"g",attr:{display:"none"}}),this.selectorParentGroup.append(this.selectorGripsGroup),Hr.svgRoot().append(this.selectorParentGroup),this.selectorMap={},this.selectors=[],this.rubberBandBox=null,Object.keys(this.selectorGrips).forEach((function(t){var r=Hr.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+t,fill:"#22C",r:$r,style:"cursor:"+t+"-resize","stroke-width":2,"pointer-events":"all"}});Yr.data(r,"dir",t),Yr.data(r,"type","resize"),e.selectorGrips[t]=e.selectorGripsGroup.appendChild(r)})),this.rotateGripConnector=this.selectorGripsGroup.appendChild(Hr.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}})),this.rotateGrip=this.selectorGripsGroup.appendChild(Hr.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:$r,stroke:"#22C","stroke-width":2,style:"cursor:url("+Fr.imgPath+"rotate.png) 12 12, auto;"}})),Yr.data(this.rotateGrip,"type","rotate"),!Yr("#canvasBackground").length){var t=d(Fr.dimensions,2),r=t[0],n=t[1],i=Hr.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:r,height:n,x:0,y:0,overflow:U()?"none":"visible",style:"pointer-events:none"}}),a=Hr.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});i.append(a),Hr.svgRoot().insertBefore(i,Hr.svgContent())}}},{key:"requestSelector",value:function(t,r){if(ot(t))return null;var n=this.selectors.length;if("object"===e(this.selectorMap[t.id]))return this.selectorMap[t.id].locked=!0,this.selectorMap[t.id];for(var i=0;i<n;++i)if(this.selectors[i]&&!this.selectors[i].locked)return this.selectors[i].locked=!0,this.selectors[i].reset(t,r),this.selectorMap[t.id]=this.selectors[i],this.selectors[i];return this.selectors[n]=new Jr(n,t,r),this.selectorParentGroup.append(this.selectors[n].selectorGroup),this.selectorMap[t.id]=this.selectors[n],this.selectors[n]}},{key:"releaseSelector",value:function(e){if(!ot(e)){var t=this.selectors.length,r=this.selectorMap[e.id];r.locked||console.log("WARNING! selector was released but was already unlocked");for(var n=0;n<t;++n)if(this.selectors[n]&&this.selectors[n]===r){delete this.selectorMap[e.id],r.locked=!1,r.selectedElement=null,r.showGrips(!1);try{r.selectorGroup.setAttribute("display","none")}catch(e){}break}}}},{key:"getRubberBandBox",value:function(){return this.rubberBandBox||(this.rubberBandBox=this.selectorParentGroup.appendChild(Hr.createSVGElement({element:"rect",attr:{id:"selectorRubberBand",fill:"#22C","fill-opacity":.15,stroke:"#22C","stroke-width":.5,display:"none",style:"pointer-events:none"}}))),this.rubberBandBox}}]),t}(),tn=y(jQuery),rn=ct,nn=ht,an=dt,sn=mt,on=ft,un=gt,ln=ut;window.console||(window.console={},window.console.log=function(e){},window.console.dir=function(e){}),window.opera&&(window.console.log=function(e){window.opera.postError(e)},window.console.dir=function(e){});return function t(i,a){n(this,t);var s={show_outside_canvas:!0,selectNew:!0,dimensions:[640,480]};a&&tn.extend(s,a);var o=s.dimensions,u=this,l=i.ownerDocument,c=l.importNode(Ne('<svg id="svgroot" xmlns="'+x.SVG+'" xlinkns="'+x.XLINK+'" width="'+o[0]+'" height="'+o[1]+'" x="'+o[0]+'" y="'+o[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);i.append(c);var h=l.createElementNS(x.SVG,"svg");(u.clearSvgContentElement=function(){tn(h).empty(),tn(h).attr({id:"svgcontent",width:o[0],height:o[1],x:o[0],y:o[1],overflow:s.show_outside_canvas?"visible":"hidden",xmlns:x.SVG,"xmlns:se":x.SE,"xmlns:xlink":x.XLINK}).appendTo(c);var e=l.createComment(" Created with SVG-edit - https://github.com/SVG-Edit/svgedit");h.append(e)})();var f="svg_";u.setIdPrefix=function(e){f=e},u.current_drawing_=new gr(h,f);var g=u.getCurrentDrawing=function(){return u.current_drawing_},y=1,v=null,_={shape:{fill:("none"===s.initFill.color?"":"#")+s.initFill.color,fill_paint:null,fill_opacity:s.initFill.opacity,stroke:"#"+s.initStroke.color,stroke_paint:null,stroke_opacity:s.initStroke.opacity,stroke_width:s.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:s.initOpacity}};_.text=tn.extend(!0,{},_.shape),tn.extend(_.text,{fill:"#000000",stroke_width:s.text&&s.text.stroke_width,font_size:s.text&&s.text.font_size,font_family:s.text&&s.text.font_family});var b=_.shape,w=[],A=this.getJsonFromSvgElement=function(e){if(3===e.nodeType)return e.nodeValue;for(var t,r={element:e.tagName,attr:{},children:[]},n=0;t=e.attributes[n];n++)r.attr[t.name]=t.value;for(var i,a=0;i=e.childNodes[a];a++)r.children[a]=A(i);return r},k=this.addSVGElementFromJson=function(e){if("string"==typeof e)return l.createTextNode(e);var t=rt(e.attr.id),r=g().getCurrentLayer();if(t&&e.element!==t.tagName&&(t.remove(),t=null),!t){var n=e.namespace||x.SVG;t=l.createElementNS(n,e.element),r&&(v||r).append(t)}return e.curStyles&&nt(t,{fill:b.fill,stroke:b.stroke,"stroke-width":b.stroke_width,"stroke-dasharray":b.stroke_dasharray,"stroke-linejoin":b.stroke_linejoin,"stroke-linecap":b.stroke_linecap,"stroke-opacity":b.stroke_opacity,"fill-opacity":b.fill_opacity,opacity:b.opacity/2,style:"pointer-events:inherit"}),nt(t,e.attr),it(t),e.children&&e.children.forEach((function(e){t.append(k(e))})),t};u.getTransformList=Z,u.matrixMultiply=ue,u.hasMatrixTransform=le,u.transformListToTransform=he;var C=function(){return s.baseUnit};!function(e){Q=e;var t=document.createElementNS(x.SVG,"svg");document.body.append(t);var r=document.createElementNS(x.SVG,"rect");r.setAttribute("width","1em"),r.setAttribute("height","1ex"),r.setAttribute("x","1in"),t.append(r);var n=r.getBBox();t.remove();var i=n.x;J={em:n.width,ex:n.height,in:i,cm:i/2.54,mm:i/25.4,pt:i/72,pc:i/6,px:1,"%":0}}({getBaseUnit:C,getElement:rt,getHeight:function(){return h.getAttribute("height")/y},getWidth:function(){return h.getAttribute("width")/y},getRoundDigits:function(){return qe.round_digits}}),u.convertToNum=ie;var E,G=function(){return h},I=this.getSelectedElems=function(){return w},N=Jt,P=function(){return c};ve=E={pathActions:N,getSVGContent:G,addSVGElementFromJson:k,getSelectedElements:I,getDOMDocument:function(){return l},getDOMContainer:function(){return i},getSVGRoot:P,getBaseUnit:C,getSnappingStep:function(){return s.snappingStep}},xe=E.getDOMDocument(),Se=E.getDOMContainer(),_e=E.getSVGRoot(),u.findDefs=Oe,u.getUrlFromAttr=Te,u.getHref=Le,u.setHref=Ve,u.getBBox=Be,u.getRotationAngle=et,u.getElem=rt,u.getRefElem=tt,u.assignAttributes=nt,this.cleanupElement=it;var T=function(){return s.gridSnapping};!function(e){Qr=e}({getDrawing:function(){return g()},getSVGRoot:P,getGridSnapping:T}),this.remapElement=Wr,function(e){jr=e}({getSVGRoot:P,getStartTransform:function(){return ut},setStartTransform:function(e){ut=e}}),this.recalculateDimensions=Zr;var L=S();u.sanitizeSvg=Lr;var O=u.undoMgr=new un({handleHistoryEvent:function(e,t){var r=ln;if(e===r.BEFORE_UNAPPLY||e===r.BEFORE_APPLY)u.clearSelection();else if(e===r.AFTER_APPLY||e===r.AFTER_UNAPPLY){var n=t.elements();u.pathActions.clear(),Y("changed",n);var i=t.type(),a=e===r.AFTER_APPLY;if("MoveElementCommand"===i)(a?t.newParent:t.oldParent)===h&&yr();else if("InsertElementCommand"===i||"RemoveElementCommand"===i)t.parent===h&&yr(),"InsertElementCommand"===i?a&&De(t.elem):a||De(t.elem),t.elem&&"use"===t.elem.tagName&&er(t.elem);else if("ChangeElementCommand"===i){"title"===t.elem.tagName&&t.elem.parentNode.parentNode===h&&yr();var s=a?t.newValues:t.oldValues;s.stdDeviation&&u.setBlurOffsets(t.elem.parentNode,s.stdDeviation)}}}}),M=function(e){u.undoMgr.addCommandToHistory(e)},R=this.getZoom=function(){return y},B=this.round=function(e){return Number.parseInt(e*y)/y};!function(e,t){Fr=e,Hr=t,Dr=new en}(s,{createSVGElement:function(e){return u.addSVGElementFromJson(e)},svgRoot:function(){return c},svgContent:function(){return h},getCurrentZoom:R});var z=this.selectorManager=Dr,q=u.getNextId=function(){return g().getNextId()},K=u.getId=function(){return g().getId()},Y=function(e,t){if(bt[e])return bt[e](window,t)},$=this.clearSelection=function(e){w.forEach((function(e){ot(e)||z.releaseSelector(e)})),w=[],e||Y("selected",w)},ne=this.addToSelection=function(e,t){if(e.length){for(var r=0;r<w.length&&!ot(w[r]);)++r;for(var n=e.length;n--;){var i=e[n];if(i){var a=Be(i);if(a&&("a"===i.tagName&&1===i.childNodes.length&&(i=i.firstChild),!w.includes(i))){w[r]=i,r++;var s=z.requestSelector(i,a);w.length>1&&s.showGrips(!1)}}}if(w.length)for(Y("selected",w),1===w.length&&z.requestSelector(w[0]).showGrips(t),w.sort((function(e,t){return e&&t&&e.compareDocumentPosition?3-(6&t.compareDocumentPosition(e)):ot(e)?1:0}));ot(w[0]);)w.shift(0)}},ae=function(){return b.opacity},pe=this.getMouseTarget=function(e){if(ot(e))return null;var t=e.target;if(t.correspondingUseElement&&(t=t.correspondingUseElement),[x.MATH,x.HTML].includes(t.namespaceURI)&&"svgcanvas"!==t.id)for(;"foreignObject"!==t.nodeName;)if(!(t=t.parentNode))return c;var r=g().getCurrentLayer();if([c,i,h,r].includes(t))return c;if(tn(t).closest("#selectorParentGroup").length)return z.selectorParentGroup;for(;t.parentNode!==(v||r);)t=t.parentNode;return t};u.pathActions=N,Ct({selectorManager:z,canvas:u,call:Y,resetD:function(e){e.setAttribute("d",N.convertPath(e))},round:B,clearSelection:$,addToSelection:ne,addCommandToHistory:M,remapElement:Wr,addSVGElementFromJson:k,getGridSnapping:T,getOpacity:ae,getSelectedElements:I,getContainer:function(){return i},setStarted:function(e){Je=e},getRubberBox:function(){return mt},setRubberBox:function(e){return mt=e},addPtsToSelection:function(e){var t=e.closedSubpath,r=e.grips;N.canDeleteNodes=!0,N.closed_subpath=t,Y("pointsAdded",{closedSubpath:t,grips:r}),Y("selected",r)},endChanges:function(e){var t=e.cmd,r=e.elem;M(t),Y("changed",[r])},getCurrentZoom:R,getId:K,getNextId:q,getMouseTarget:pe,getCurrentMode:function(){return lt},setCurrentMode:function(e){return lt=e},getDrawnPath:function(){return Wt},setDrawnPath:function(e){return Wt=e},getSVGRoot:P});var ye={},Ce="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use",Ee=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],Re=tn.data,Ue=document.createElementNS(x.SVG,"animate");tn(Ue).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(c);var De=function e(t){var r=tn(t).attr(Ee);Object.values(r).forEach((function(e){if(e&&e.startsWith("url(")){var t=Te(e).substr(1);rt(t)||(Oe().append(Ke[t]),delete Ke[t])}}));var n=t.getElementsByTagName("*");if(n.length)for(var i=0,a=n.length;i<a;i++)e(n[i])},ze={},qe={round_digits:5},Qe={},We=_.text,Xe={},Ke={},Ze=s.imgPath+"logo.png",Je=!1,ut=null,lt="select",ct="none",ht=b,dt=null,mt=null,ft=[],gt=null;this.runExtension=function(e,t,r){return this.runExtensions(t,r,!1,(function(t){return t===e}))};var yt=this.runExtensions=function(e,t,r,n){var i=!!r&&[];return tn.each(Xe,(function(a,s){n&&!n(a)||s&&e in s&&("function"==typeof t&&(t=t(a)),r?i.push(s[e](t)):i=s[e](t))})),i};this.addExtension=function(){var e=r(regeneratorRuntime.mark((function e(t,r,n){var i,a,s,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.$,a=n.importLocale,"function"==typeof r){e.next=3;break}throw new TypeError("Function argument expected for `svgcanvas.addExtension`");case 3:if(!(t in Xe)){e.next=5;break}throw new Error('Cannot add extension "'+t+'", an extension by that name already exists.');case 5:return s=tn.extend(u.getPrivateMethods(),{$:i,importLocale:a,svgroot:c,svgcontent:h,nonce:g().getNonce(),selectorManager:z}),e.next=8,r(s);case 8:return(o=e.sent)&&(o.name=t),Xe[t]=o,e.abrupt("return",Y("extension_added",o));case 12:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();var vt=this.getIntersectionList=function(e){if(ot(mt))return null;var t,r=v||g().getCurrentLayer();if(e)(t=h.createSVGRect()).x=e.x,t.y=e.y,t.width=e.width,t.height=e.height;else{t=mt.getBBox();var n=h.createSVGRect();["x","y","width","height","top","right","bottom","left"].forEach((function(e){n[e]=t[e]/y})),t=n}var i=null;if(H()||"function"==typeof c.getIntersectionList&&(t.x+=Number.parseInt(h.getAttribute("x")),t.y+=Number.parseInt(h.getAttribute("y")),i=c.getIntersectionList(t,r)),ot(i)||"function"!=typeof i.item){i=[],ft.length||(ft=xt(r));for(var a=ft.length;a--;)t.width&&fe(t,ft[a].bbox)&&i.push(ft[a].elem)}return i};this.getStrokedBBox=$e,this.getVisibleElements=Ye;var xt=this.getVisibleElementsAndBBoxes=function(e){e||(e=tn(h).children());var t=[];return tn(e).children().each((function(e,r){r.getBBox&&t.push({elem:r,bbox:$e([r])})})),t.reverse()},_t=this.groupSvgElem=function(e){var t=document.createElementNS(x.SVG,"g");e.replaceWith(t),tn(t).append(e).data("gsvg",e)[0].id=q()},bt={};u.call=Y,u.bind=function(e,t){var r=bt[e];return bt[e]=t,r},this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement),m(e.getElementsByTagNameNS(x.SVG,"path")).forEach((function(e){e.setAttribute("d",N.convertPath(e)),N.fixEnd(e)}))};var kt=function(e){if(!j())return e;var t=e.cloneNode(!0);return e.before(t),e.remove(),z.releaseSelector(e),w[0]=t,z.requestSelector(t).showGrips(!0),t};this.setRotationAngle=function(e,t){e=Number.parseFloat(e);var r=w[0],n=r.getAttribute("transform"),i=Be(r),a=i.x+i.width/2,s=i.y+i.height/2,o=Z(r);o.numberOfItems>0&&(4===o.getItem(0).type&&o.removeItem(0));if(0!==e){var u=se(a,s,he(o).matrix),l=c.createSVGTransform();l.setRotate(e,u.x,u.y),o.numberOfItems?o.insertItemBefore(l,0):o.appendItem(l)}else 0===o.numberOfItems&&r.removeAttribute("transform");if(!t){var h=r.getAttribute("transform");r.setAttribute("transform",n),lr("transform",h,w),Y("changed",w)}z.requestSelector(w[0]).resize(),Jr.updateGripCursors(e)};var Et=this.recalculateAllSelectedDimensions=function(){for(var e=new on("none"===ct?"position":"size"),t=w.length;t--;){var r=w[t],n=Zr(r);n&&e.addSubCommand(n)}e.isEmpty()||(M(e),Y("changed",w))},Gt=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},It=null,Nt=this.selectOnly=function(e,t){$(!0),ne(e,t)};this.removeFromSelection=function(e){if(!ot(w[0])&&e.length){for(var t=[],r=w.length,n=0;n<r;++n){var i=w[n];i&&(e.includes(i)?z.releaseSelector(i):t.push(i))}w=t}},this.selectAllInCurrentLayer=function(){var e=g().getCurrentLayer();e&&(lt="select",Nt(tn(v||e).children()))};var Pt,Tt,Lt,Vt,Ot,Mt,Rt,Bt,Ut,jt,Ht,Dt,zt,qt,Qt,Wt=null;Tt={minx:null,miny:null,maxx:null,maxy:null},Lt=null,Vt=null,Ot=null,Mt=null,Rt={},Bt=0,Ut={x:0,y:0},jt={x:0,y:0},Ht={x:0,y:0},Dt={x:0,y:0},zt={x:0,y:0},qt={x:0,y:0},Qt=function(e){var t={x:0,y:0},r=Ut,n=jt,i=Ht,a=Dt,s=e*e,o=s*e,u=[[-1,3,-3,1],[3,-6,3,0],[-3,0,3,0],[1,4,1,0]];return t.x=1/6*((r.x*u[0][0]+n.x*u[0][1]+i.x*u[0][2]+a.x*u[0][3])*o+(r.x*u[1][0]+n.x*u[1][1]+i.x*u[1][2]+a.x*u[1][3])*s+(r.x*u[2][0]+n.x*u[2][1]+i.x*u[2][2]+a.x*u[2][3])*e+(r.x*u[3][0]+n.x*u[3][1]+i.x*u[3][2]+a.x*u[3][3])),t.y=1/6*((r.y*u[0][0]+n.y*u[0][1]+i.y*u[0][2]+a.y*u[0][3])*o+(r.y*u[1][0]+n.y*u[1][1]+i.y*u[1][2]+a.y*u[1][3])*s+(r.y*u[2][0]+n.y*u[2][1]+i.y*u[2][2]+a.y*u[2][3])*e+(r.y*u[3][0]+n.y*u[3][1]+i.y*u[3][2]+a.y*u[3][3])),{x:t.x,y:t.y}},tn(i).mousedown((function(e){if(!u.spaceKey&&1!==e.button){var t=2===e.button;e.altKey&&u.cloneSelectedElements(0,0),It=tn("#svgcontent g")[0].getScreenCTM().inverse();var r=se(e.pageX,e.pageY,It),n=r.x*y,i=r.y*y;e.preventDefault(),t&&(lt="select",gt=r);var a=n/y,o=i/y,l=pe(e);"a"===l.tagName&&1===l.childNodes.length&&(l=l.firstChild);var h=a;Ot=Lt=a;var d=o;if(Mt=Vt=o,s.gridSnapping&&(a=at(a),o=at(o),Lt=at(Lt),Vt=at(Vt)),l===z.selectorParentGroup&&!ot(w[0])){var m=e.target,f=Re(m,"type");"rotate"===f?lt="rotate":"resize"===f&&(lt="resize",ct=Re(m,"dir")),l=w[0]}ut=l.getAttribute("transform");var g=Z(l);switch(lt){case"select":if(Je=!0,ct="none",t&&(Je=!1),l!==c){if(w.includes(l)||(e.shiftKey||$(!0),ne([l]),dt=l,N.clear()),!t){var v,x=p(w);try{for(x.s();!(v=x.n()).done;){var S=v.value;if(!ot(S)){var _=Z(S);_.numberOfItems?_.insertItemBefore(c.createSVGTransform(),0):_.appendItem(c.createSVGTransform())}}}catch(e){x.e(e)}finally{x.f()}}}else t||($(),lt="multiselect",ot(mt)&&(mt=z.getRubberBandBox()),nt(mt,{x:Ot*=y,y:Mt*=y,width:0,height:0,display:"inline"}));break;case"zoom":Je=!0,ot(mt)&&(mt=z.getRubberBandBox()),nt(mt,{x:h*y,y:h*y,width:0,height:0,display:"inline"});break;case"resize":Je=!0,Lt=a,Vt=o,Rt=Be(tn("#selectedBox0")[0]);var A={};tn.each(Rt,(function(e,t){A[e]=t/y})),Rt=A;var C=et(l)?1:0;if(le(g))g.insertItemBefore(c.createSVGTransform(),C),g.insertItemBefore(c.createSVGTransform(),C),g.insertItemBefore(c.createSVGTransform(),C);else if(g.appendItem(c.createSVGTransform()),g.appendItem(c.createSVGTransform()),g.appendItem(c.createSVGTransform()),D()){var E,G=U();G&&(E=function(e){var t=e.getAttribute("stroke");e.removeAttribute("stroke"),null!==t&&setTimeout((function(){e.setAttribute("stroke",t)}),0)}),l.style.vectorEffect="non-scaling-stroke",G&&E(l);for(var I=l.getElementsByTagName("*"),P=I.length,T=0;T<P;T++)I[T].style&&(I[T].style.vectorEffect="non-scaling-stroke",G&&E(I[T]))}break;case"fhellipse":case"fhrect":case"fhpath":Ht.x=h,Ht.y=d,jt={x:0,y:0},Ut={x:0,y:0},Je=!0,k({element:"polyline",curStyles:!0,attr:{points:h+","+d+" ",id:q(),fill:"none",opacity:b.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}}),Tt.minx=h,Tt.maxx=h,Tt.miny=d,Tt.maxy=d;break;case"image":Je=!0;var L=k({element:"image",attr:{x:a,y:o,width:0,height:0,id:q(),opacity:b.opacity/2,style:"pointer-events:inherit"}});Ve(L,Ze),st(L);break;case"square":case"rect":Je=!0,Lt=a,Vt=o,k({element:"rect",curStyles:!0,attr:{x:a,y:o,width:0,height:0,id:q(),opacity:b.opacity/2}});break;case"line":Je=!0;var V=0===Number(b.stroke_width)?1:b.stroke_width;k({element:"line",curStyles:!0,attr:{x1:a,y1:o,x2:a,y2:o,id:q(),stroke:b.stroke,"stroke-width":V,"stroke-dasharray":b.stroke_dasharray,"stroke-linejoin":b.stroke_linejoin,"stroke-linecap":b.stroke_linecap,"stroke-opacity":b.stroke_opacity,fill:"none",opacity:b.opacity/2,style:"pointer-events:none"}});break;case"circle":Je=!0,k({element:"circle",curStyles:!0,attr:{cx:a,cy:o,r:0,id:q(),opacity:b.opacity/2}});break;case"ellipse":Je=!0,k({element:"ellipse",curStyles:!0,attr:{cx:a,cy:o,rx:0,ry:0,id:q(),opacity:b.opacity/2}});break;case"text":Je=!0,k({element:"text",curStyles:!0,attr:{x:a,y:o,id:q(),fill:We.fill,"stroke-width":We.stroke_width,"font-size":We.font_size,"font-family":We.font_family,"text-anchor":"middle","xml:space":"preserve",opacity:b.opacity}});break;case"path":case"pathedit":Lt*=y,Vt*=y,N.mouseDown(e,l,Lt,Vt),Je=!0;break;case"textedit":Lt*=y,Vt*=y,Kt.mouseDown(e,l,Lt,Vt),Je=!0;break;case"rotate":Je=!0,u.undoMgr.beginUndoableChange("transform",w)}var O=yt("mouseDown",{event:e,start_x:Lt,start_y:Vt,selectedElements:w},!0);tn.each(O,(function(e,t){t&&t.started&&(Je=!0)}))}})).mousemove((function(e){if(Je&&1!==e.button&&!u.spaceKey){var t,r,n,i,a,o,l,d,m,f,g=w[0],p=se(e.pageX,e.pageY,It),v=p.x*y,x=p.y*y,S=rt(K()),_=v/y,b=_,A=x/y,k=A;switch(s.gridSnapping&&(b=at(b),k=at(k)),e.preventDefault(),lt){case"select":if(null!==w[0]&&(a=b-Lt,o=k-Vt,s.gridSnapping&&(a=at(a),o=at(o)),0!==a||0!==o)){for(l=w.length,t=0;t<l&&(g=w[t],!ot(g));++t){var C=c.createSVGTransform();f=Z(g),C.setTranslate(a,o),f.numberOfItems?f.replaceItem(C,0):f.appendItem(C),z.requestSelector(g).resize()}Y("transition",w)}break;case"multiselect":_*=y,A*=y,nt(mt,{x:Math.min(Ot,_),y:Math.min(Mt,A),width:Math.abs(_-Ot),height:Math.abs(A-Mt)});var E=w.slice(),G=[],I=vt();for(l=I.length,t=0;t<l;++t){var P=I[t];w.includes(P)||G.push(P);var T=E.indexOf(P);-1!==T&&E.splice(T,1)}E.length>0&&u.removeFromSelection(E),G.length>0&&u.addToSelection(G);break;case"resize":f=Z(g);var L=le(f),V=(m=L?Rt:Be(g)).x,O=m.y,M=m,R=M.width,B=M.height;if(a=b-Lt,o=k-Vt,s.gridSnapping&&(a=at(a),o=at(o),B=at(B),R=at(R)),d=et(g)){var U=Math.sqrt(a*a+o*o),j=Math.atan2(o,a)-d*Math.PI/180;a=U*Math.cos(j),o=U*Math.sin(j)}ct.includes("n")||ct.includes("s")||(o=0),ct.includes("e")||ct.includes("w")||(a=0);var H=0,F=0,D=B?(B+o)/B:1,q=R?(R+a)/R:1;ct.includes("n")&&(D=B?(B-o)/B:1,F=B),ct.includes("w")&&(q=R?(R-a)/R:1,H=R);var Q=c.createSVGTransform(),W=c.createSVGTransform(),X=c.createSVGTransform();if(s.gridSnapping&&(V=at(V),H=at(H),O=at(O),F=at(F)),Q.setTranslate(-(V+H),-(O+F)),e.shiftKey&&(1===q?q=D:D=q),W.setScale(q,D),X.setTranslate(V+H,O+F),L){var $=d?1:0;f.replaceItem(Q,2+$),f.replaceItem(W,1+$),f.replaceItem(X,Number($))}else{var J=f.numberOfItems;f.replaceItem(X,J-3),f.replaceItem(W,J-2),f.replaceItem(Q,J-1)}z.requestSelector(g).resize(),Y("transition",w);break;case"zoom":_*=y,A*=y,nt(mt,{x:Math.min(Ot*y,_),y:Math.min(Mt*y,A),width:Math.abs(_-Ot*y),height:Math.abs(A-Mt*y)});break;case"text":nt(S,{x:b,y:k});break;case"line":s.gridSnapping&&(b=at(b),k=at(k));var ee=b,te=k;e.shiftKey&&(ee=(r=me(Lt,Vt,ee,te)).x,te=r.y),S.setAttribute("x2",ee),S.setAttribute("y2",te);break;case"foreignObject":case"square":case"rect":case"image":var re,ne,ie="square"===lt||e.shiftKey,ae=Math.abs(b-Lt),oe=Math.abs(k-Vt);ie?(ae=oe=Math.max(ae,oe),re=Lt<b?Lt:Lt-ae,ne=Vt<k?Vt:Vt-oe):(re=Math.min(Lt,b),ne=Math.min(Vt,k)),s.gridSnapping&&(ae=at(ae),oe=at(oe),re=at(re),ne=at(ne)),nt(S,{width:ae,height:oe,x:re,y:ne});break;case"circle":var ue=tn(S).attr(["cx","cy"]);n=ue.cx,i=ue.cy;var ce=Math.sqrt((b-n)*(b-n)+(k-i)*(k-i));s.gridSnapping&&(ce=at(ce)),S.setAttribute("r",ce);break;case"ellipse":var he=tn(S).attr(["cx","cy"]);n=he.cx,i=he.cy,s.gridSnapping&&(b=at(b),n=at(n),k=at(k),i=at(i)),S.setAttribute("rx",Math.abs(b-n));var fe=Math.abs(e.shiftKey?b-n:k-i);S.setAttribute("ry",fe);break;case"fhellipse":case"fhrect":Tt.minx=Math.min(_,Tt.minx),Tt.maxx=Math.max(_,Tt.maxx),Tt.miny=Math.min(A,Tt.miny),Tt.maxy=Math.max(A,Tt.maxy);case"fhpath":if(Dt.x=_,Dt.y=A,Ut.x&&Ut.y)for(t=0;t<9;t++)if(Pt=t/10,zt=Qt((t+1)/10),qt=zt,zt=Qt(Pt),(Bt+=Math.sqrt((qt.x-zt.x)*(qt.x-zt.x)+(qt.y-zt.y)*(qt.y-zt.y)))>.8){Bt-=.8;var ge=h.createSVGPoint();ge.x=zt.x,ge.y=zt.y,S.points.appendItem(ge)}Ut={x:jt.x,y:jt.y},jt={x:Ht.x,y:Ht.y},Ht={x:Dt.x,y:Dt.y};break;case"path":case"pathedit":if(b*=y,k*=y,s.gridSnapping&&(b=at(b),k=at(k),Lt=at(Lt),Vt=at(Vt)),e.shiftKey){var pe,ye,ve=At;ve?(pe=ve.dragging?ve.dragging[0]:Lt,ye=ve.dragging?ve.dragging[1]:Vt):(pe=Lt,ye=Vt);var xe=r=me(pe,ye,b,k);b=xe.x,k=xe.y}mt&&"none"!==mt.getAttribute("display")&&(_*=y,A*=y,nt(mt,{x:Math.min(Ot*y,_),y:Math.min(Mt*y,A),width:Math.abs(_-Ot*y),height:Math.abs(A-Mt*y)})),N.mouseMove(b,k);break;case"textedit":b*=y,k*=y,Kt.mouseMove(v,x);break;case"rotate":n=(m=Be(g)).x+m.width/2,i=m.y+m.height/2;var Se=de(g),_e=se(n,i,Se);n=_e.x,i=_e.y,d=(Math.atan2(i-k,n-b)*(180/Math.PI)-90)%360,s.gridSnapping&&(d=at(d)),e.shiftKey&&(d=45*Math.round(d/45)),u.setRotationAngle(d<-180?360+d:d,!0),Y("transition",w)}yt("mouseMove",{event:e,mouse_x:v,mouse_y:x,selected:g})}})).click((function(e){return e.preventDefault(),!1})).dblclick((function(e){var t=e.target.parentNode,r=pe(e),n=r.tagName;if("text"===n&&"textedit"!==lt){var i=se(e.pageX,e.pageY,It);Kt.select(r,i.x,i.y)}t!==v&&("g"!==n&&"a"!==n||!et(r)||(dr(r),r=w[0],$(!0)),v&&Gr(),"g"!==t.tagName&&"a"!==t.tagName||t===g().getCurrentLayer()||r===z.selectorParentGroup||Ir(r))})).mouseup((function(e){if(2!==e.button){var t=dt;if(dt=null,Je){var r,n,i=se(e.pageX,e.pageY,It),a=i.x*y,o=i.y*y,l=a/y,c=o/y,h=rt(K()),d=!1,m=l,f=c;switch(Je=!1,lt){case"resize":case"multiselect":ot(mt)||(mt.setAttribute("display","none"),ft=[]),lt="select";case"select":if(!ot(w[0])){if(ot(w[1])){var p=w[0];switch(p.tagName){case"g":case"use":case"image":case"foreignObject":break;default:ht.fill=p.getAttribute("fill"),ht.fill_opacity=p.getAttribute("fill-opacity"),ht.stroke=p.getAttribute("stroke"),ht.stroke_opacity=p.getAttribute("stroke-opacity"),ht.stroke_width=p.getAttribute("stroke-width"),ht.stroke_dasharray=p.getAttribute("stroke-dasharray"),ht.stroke_linejoin=p.getAttribute("stroke-linejoin"),ht.stroke_linecap=p.getAttribute("stroke-linecap")}"text"===p.tagName&&(We.font_size=p.getAttribute("font-size"),We.font_family=p.getAttribute("font-family")),z.requestSelector(p).showGrips(!0)}if(Et(),m!==Ot||f!==Mt)for(var v=w.length,x=0;x<v&&!ot(w[x]);++x)w[x].firstChild||z.requestSelector(w[x]).resize();else n=e.target,"path"===w[0].nodeName&&ot(w[1])?N.select(w[0]):e.shiftKey&&t!==n&&u.removeFromSelection([n]);if(D()){var S=w[0];S&&(S.removeAttribute("style"),Pe(S,(function(e){e.removeAttribute("style")})))}}return;case"zoom":ot(mt)||mt.setAttribute("display","none");var _=e.shiftKey?.5:2;return void Y("zoomed",{x:Math.min(Ot,m),y:Math.min(Mt,f),width:Math.abs(m-Ot),height:Math.abs(f-Mt),factor:_});case"fhpath":Bt=0,Ut={x:0,y:0},jt={x:0,y:0},Ht={x:0,y:0},Dt={x:0,y:0};var A=h.getAttribute("points"),C=A.indexOf(",");(d=C>=0?A.includes(",",C+1):A.includes(" ",A.indexOf(" ")+1))&&(h=N.smoothPolylineIntoPath(h));break;case"line":r=tn(h).attr(["x1","x2","y1","y2"]),d=r.x1!==r.x2||r.y1!==r.y2;break;case"foreignObject":case"square":case"rect":case"image":r=tn(h).attr(["width","height"]),d=r.width||r.height||"image"===lt;break;case"circle":d="0"!==h.getAttribute("r");break;case"ellipse":r=tn(h).attr(["rx","ry"]),d=r.rx||r.ry;break;case"fhellipse":Tt.maxx-Tt.minx>0&&Tt.maxy-Tt.miny>0&&(h=k({element:"ellipse",curStyles:!0,attr:{cx:(Tt.minx+Tt.maxx)/2,cy:(Tt.miny+Tt.maxy)/2,rx:(Tt.maxx-Tt.minx)/2,ry:(Tt.maxy-Tt.miny)/2,id:K()}}),Y("changed",[h]),d=!0);break;case"fhrect":Tt.maxx-Tt.minx>0&&Tt.maxy-Tt.miny>0&&(h=k({element:"rect",curStyles:!0,attr:{x:Tt.minx,y:Tt.miny,width:Tt.maxx-Tt.minx,height:Tt.maxy-Tt.miny,id:K()}}),Y("changed",[h]),d=!0);break;case"text":d=!0,Nt([h]),Kt.start(h);break;case"path":h=null,Je=!0;var E=N.mouseUp(e,h,a,o);h=E.element,d=E.keep;break;case"pathedit":d=!0,h=null,N.mouseUp(e);break;case"textedit":d=!1,h=null,Kt.mouseUp(e,a,o);break;case"rotate":d=!0,h=null,lt="select";var G=u.undoMgr.finishUndoableChange();G.isEmpty()||M(G),Et(),Y("changed",w)}var I=yt("mouseUp",{event:e,mouse_x:a,mouse_y:o},!0);if(tn.each(I,(function(e,t){t&&(d=t.keep||d,h=t.element,Je=t.started||Je)})),d||ot(h)){if(!ot(h)){u.addedNew=!0;var P,T=.2;if(Ue.beginElement&&Number.parseFloat(h.getAttribute("opacity"))!==b.opacity){P=tn(Ue).clone().attr({to:b.opacity,dur:T}).appendTo(h);try{P[0].beginElement()}catch(e){}}else T=0;setTimeout((function(){P&&P.remove(),h.setAttribute("opacity",b.opacity),h.setAttribute("style","pointer-events:inherit"),it(h),"path"===lt?N.toEditMode(h):s.selectNew&&Nt([h],!0),M(new nn(h)),Y("changed",[h])}),1e3*T)}}else{for(g().releaseId(K()),h.remove(),h=null,n=e.target;n&&n.parentNode&&n.parentNode.parentNode&&"g"===n.parentNode.parentNode.tagName;)n=n.parentNode;"path"===lt&&Wt||!n||!n.parentNode||"selectorParentGroup"===n.parentNode.id||"svgcanvas"===n.id||"svgroot"===n.id||(u.setMode("select"),Nt([n],!0))}ut=null}}})),tn(i).bind("mousewheel DOMMouseScroll",(function(e){if(e.shiftKey){e.preventDefault();var t=e.originalEvent;It=tn("#svgcontent g")[0].getScreenCTM().inverse();var r=tn("#workarea"),n=s.showRulers?16:0,i=se(t.pageX,t.pageY,It),a=r.width(),o=r.height(),l=a-15-n,c=o-15-n,h=l*It.a,d=c*It.d,m=r.offset(),f=m.left+n,g=m.top+n,p=t.wheelDelta?t.wheelDelta:t.detail?-t.detail:0;if(p){var v,x,S=Math.max(3/4,Math.min(4/3,p));S>1?(v=Math.ceil(l/h*S*100)/100,x=Math.ceil(c/d*S*100)/100):(v=Math.floor(l/h*S*100)/100,x=Math.floor(c/d*S*100)/100);var _=Math.min(v,x);if((_=Math.min(10,Math.max(.01,_)))!==y){S=_/y;var b=se(f,g,It),w={x:(i.x-(i.x-b.x)/S)*_-n+a/2,y:(i.y-(i.y-b.y)/S)*_-n+o/2};u.setZoom(_),tn("#zoom").val((100*_).toFixed(1)),Y("updateCanvas",{center:!1,newCtr:w}),Y("zoomDone")}}}}));var Xt,Kt=u.textActions=function(){var e,t,r,n,i,a,s,o,l,h,d=[];function m(e){var s=""===t.value;if(tn(t).focus(),!arguments.length)if(s)e=0;else{if(t.selectionEnd!==t.selectionStart)return;e=t.selectionEnd}var o=d[e];s||t.setSelectionRange(e,e),(r=rt("text_cursor"))||(r=document.createElementNS(x.SVG,"line"),nt(r,{id:"text_cursor",stroke:"#333","stroke-width":1}),r=rt("selectorParentGroup").appendChild(r)),i||(i=setInterval((function(){var e="none"===r.getAttribute("display");r.setAttribute("display",e?"inline":"none")}),600));var u=_(o.x,a.y),l=_(o.x,a.y+a.height);nt(r,{x1:u.x,y1:u.y,x2:l.x,y2:l.y,visibility:"visible",display:"inline"}),n&&n.setAttribute("d","")}function f(e,i,s){if(e!==i){s||t.setSelectionRange(e,i),(n=rt("text_selectblock"))||(n=document.createElementNS(x.SVG,"path"),nt(n,{id:"text_selectblock",fill:"green",opacity:.5,style:"pointer-events:none"}),rt("selectorParentGroup").append(n));var o=d[e],u=d[i];r.setAttribute("visibility","hidden");var l=_(o.x,a.y),c=_(o.x+(u.x-o.x),a.y),h=_(o.x,a.y+a.height),f=_(o.x+(u.x-o.x),a.y+a.height),g="M"+l.x+","+l.y+" L"+c.x+","+c.y+" "+f.x+","+f.y+" "+h.x+","+h.y+"z";nt(n,{d:g,display:"inline"})}else m(i)}function g(t,r){var n=c.createSVGPoint();if(n.x=t,n.y=r,1===d.length)return 0;var i=e.getCharNumAtPosition(n);i<0?(i=d.length-2,t<=d[0].x&&(i=0)):i>=d.length-2&&(i=d.length-2);var a=d[i];return t>a.x+a.width/2&&i++,i}function p(e,t){m(g(e,t))}function v(e,r,n){var i=t.selectionStart,a=g(e,r);f(Math.min(i,a),Math.max(i,a),!n)}function S(e,t){var r={x:e,y:t};if(r.x/=y,r.y/=y,s){var n=se(r.x,r.y,s.inverse());r.x=n.x,r.y=n.y}return r}function _(e,t){var r={x:e,y:t};if(s){var n=se(r.x,r.y,s);r.x=n.x,r.y=n.y}return r.x*=y,r.y*=y,r}function b(t){f(0,e.textContent.length),tn(this).unbind(t)}function A(t){if(h&&e){var r=se(t.pageX,t.pageY,It),n=S(r.x*y,r.y*y),i=g(n.x,n.y),a=e.textContent,s=a.substr(0,i).replace(/[a-z\d]+$/i,"").length,o=a.substr(i).match(/^[a-z\d]+/i);f(s,(o?o[0].length:0)+i),tn(t.target).click(b),setTimeout((function(){tn(t.target).unbind("click",b)}),300)}}return{select:function(t,r,n){e=t,Kt.toEditMode(r,n)},start:function(t){e=t,Kt.toEditMode()},mouseDown:function(e,r,n,i){var a=S(n,i);t.focus(),p(a.x,a.y),o=n,l=i},mouseMove:function(e,t){var r=S(e,t);v(r.x,r.y)},mouseUp:function(t,r,n){var i=S(r,n);v(i.x,i.y,!0),t.target!==e&&r<o+2&&r>o-2&&n<l+2&&n>l-2&&Kt.toSelectMode(!0)},setCursor:m,toEditMode:function(t,r){if(h=!1,lt="textedit",z.requestSelector(e).showGrips(!1),z.requestSelector(e),Kt.init(),tn(e).css("cursor","text"),arguments.length){var n=S(t,r);p(n.x,n.y)}else m();setTimeout((function(){h=!0}),300)},toSelectMode:function(a){lt="select",clearInterval(i),i=null,n&&tn(n).attr("display","none"),r&&tn(r).attr("visibility","hidden"),tn(e).css("cursor","move"),a&&($(),tn(e).css("cursor","move"),Y("selected",[e]),ne([e],!0)),e&&!e.textContent.length&&u.deleteSelectedElements(),tn(t).blur(),e=!1},setInputElem:function(e){t=e},clear:function(){"textedit"===lt&&Kt.toSelectMode()},init:function(r){if(e){var n,i;e.parentNode||(e=w[0],z.requestSelector(e).showGrips(!1));var o=e.textContent.length,l=e.getAttribute("transform");for(a=Be(e),s=l?de(e):null,(d=[]).length=o,t.focus(),tn(e).unbind("dblclick",A).dblclick(A),o||(i={x:a.x+a.width/2,width:0}),n=0;n<o;n++){var c=e.getStartPositionOfChar(n);if(i=e.getEndPositionOfChar(n),!V){var h=u.contentW*y;c.x-=h,i.x-=h,c.x/=y,i.x/=y}d[n]={x:c.x,y:a.y,width:i.x-c.x,height:a.height}}d.push({x:i.x,width:0}),f(t.selectionStart,t.selectionEnd,!0)}}}}(),Zt=this.removeUnusedDefElems=function(){var e=h.getElementsByTagNameNS(x.SVG,"defs");if(!e||!e.length)return 0;var t,r,n=[],i=0,a=["fill","stroke","filter","marker-start","marker-mid","marker-end"],s=a.length,o=h.getElementsByTagNameNS(x.SVG,"*"),u=o.length;for(t=0;t<u;t++){var l=o[t];for(r=0;r<s;r++){var c=Te(l.getAttribute(a[r]));c&&n.push(c.substr(1))}var d=Le(l);d&&d.startsWith("#")&&n.push(d.substr(1))}var m=tn(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");for(t=m.length;t--;){var f=m[t],g=f.id;n.includes(g)||(Ke[g]=f,f.remove(),i++)}return i};function Yt(){$();var e=[],t=[],r={feGaussianBlur:ye.exportNoBlur,foreignObject:ye.exportNoforeignObject,"[stroke-dasharray]":ye.exportNoDashArray},n=tn(h);return"font"in tn("<canvas>")[0].getContext("2d")||(r.text=ye.exportNoText),tn.each(r,(function(r,i){n.find(r).length&&(t.push(r),e.push(i))})),{issues:e,issueCodes:t}}this.svgCanvasToString=function(){for(;Zt()>0;);N.clear(!0),tn.each(h.childNodes,(function(e,t){e&&8===t.nodeType&&t.data.includes("Created with")&&h.firstChild.before(t)})),v&&(Gr(),Nt([v]));var e=[];tn(h).find("g:data(gsvg)").each((function(){for(var t=this.attributes,r=t.length,n=0;n<r;n++)"id"!==t[n].nodeName&&"style"!==t[n].nodeName||r--;if(r<=0){var i=this.firstChild;e.push(i),tn(this).replaceWith(i)}}));var t=this.svgToString(h,0);return e.length&&tn(e).each((function(){_t(this)})),t},this.svgToString=function(e,t){var r=[],n=s.baseUnit,i=new RegExp("^-?[\\d\\.]+"+n+"$");if(e){it(e);var a=m(e.attributes),o=e.childNodes;a.sort((function(e,t){return e.name>t.name?-1:1}));for(var u=0;u<t;u++)r.push(" ");if(r.push("<"),r.push(e.nodeName),"svgcontent"===e.id){var l=ir();"px"!==n&&(l.w=re(l.w,n)+n,l.h=re(l.h,n)+n),r.push(' width="'+l.w+'" height="'+l.h+'" xmlns="'+x.SVG+'"');var c={};tn(e).find("*").andSelf().each((function(){var e=this.namespaceURI;e&&!c[e]&&L[e]&&"xmlns"!==L[e]&&"xml"!==L[e]&&(c[e]=!0,r.push(" xmlns:"+L[e]+'="'+e+'"')),tn.each(this.attributes,(function(e,t){var n=t.namespaceURI;n&&!c[n]&&"xmlns"!==L[n]&&"xml"!==L[n]&&(c[n]=!0,r.push(" xmlns:"+L[n]+'="'+n+'"'))}))}));for(var h=a.length,d=["width","height","xmlns","x","y","viewBox","id","overflow"];h--;){var f=a[h],g=we(f.value);f.nodeName.startsWith("xmlns:")||(""===g||d.includes(f.localName)||f.namespaceURI&&!L[f.namespaceURI]||(r.push(" "),r.push(f.nodeName),r.push('="'),r.push(g),r.push('"')))}}else{if("defs"===e.nodeName&&!e.firstChild)return"";for(var p=["-moz-math-font-style","_moz-math-font-style"],y=a.length-1;y>=0;y--){var v=a[y],S=we(v.value);if(!p.includes(v.localName)){if("null"===S){var _=v.localName.replace(/-[a-z]/g,(function(e){return e[1].toUpperCase()}));if(Object.prototype.hasOwnProperty.call(e.style,_))continue}if(""!==S){if(S.startsWith("pointer-events"))continue;if("class"===v.localName&&S.startsWith("se_"))continue;if(r.push(" "),"d"===v.localName&&(S=N.convertPath(e,!0)),isNaN(S)?i.test(S)&&(S=te(S)+n):S=te(S),qe.apply&&"image"===e.nodeName&&"href"===v.localName&&qe.images&&"embed"===qe.images){var b=ze[S];b&&(S=b)}v.namespaceURI&&v.namespaceURI!==x.SVG&&!L[v.namespaceURI]||(r.push(v.nodeName),r.push('="'),r.push(S),r.push('"'))}}}}if(e.hasChildNodes()){r.push(">"),t++;for(var w=!1,A=0;A<o.length;A++){var k=o.item(A);switch(k.nodeType){case 1:r.push("\n"),r.push(this.svgToString(k,t));break;case 3:var C=k.nodeValue.replace(/^\s+|\s+$/g,"");""!==C&&(w=!0,r.push(String(we(C))));break;case 4:r.push("\n"),r.push(new Array(t+1).join(" ")),r.push("<![CDATA["),r.push(k.nodeValue),r.push("]]>");break;case 8:r.push("\n"),r.push(new Array(t+1).join(" ")),r.push("\x3c!--"),r.push(k.data),r.push("--\x3e")}}if(t--,!w){r.push("\n");for(var E=0;E<t;E++)r.push(" ")}r.push("</"),r.push(e.nodeName),r.push(">")}else r.push("/>")}return r.join("")},this.embedImage=function(e){return new Promise((function(t,r){tn(new Image).load((function(n,i,a){if("error"!==i){var s=document.createElement("canvas");s.width=this.width,s.height=this.height,s.getContext("2d").drawImage(this,0,0);try{var o=";svgedit_url="+encodeURIComponent(e);o=s.toDataURL().replace(";base64",o+";base64"),ze[e]=o}catch(t){ze[e]=!1}Ze=e,t(ze[e])}else r(new Error("Error loading image: "+a.status+" "+a.statusText))})).attr("src",e)}))},this.setGoodImage=function(e){Ze=e},this.open=function(){},this.save=function(e){$(),e&&tn.extend(qe,e),qe.apply=!0;var t=this.svgCanvasToString();Y("saved",t)},this.rasterExport=function(){var e=r(regeneratorRuntime.mark((function e(t,r,n){var i,a,o,l,c,h,d,m,f,g=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=g.length>3&&void 0!==g[3]?g[3]:{},o="image/"+(a="ICO"===t?"BMP":t||"PNG").toLowerCase(),l=Yt(),c=l.issues,h=l.issueCodes,d=this.svgCanvasToString(),Xt){e.next=10;break}return e.next=8,Mr(s.canvgPath+"canvg.js",{global:"canvg"});case 8:m=e.sent,Xt=m.canvg;case 10:return tn("#export_canvas").length||tn("<canvas>",{id:"export_canvas"}).hide().appendTo("body"),(f=tn("#export_canvas")[0]).width=u.contentW,f.height=u.contentH,e.next=16,Xt(f,d);case 16:return e.abrupt("return",new Promise((function(e,s){var u,l=a.toLowerCase(),m=r?f.toDataURL("image/"+l,r):f.toDataURL("image/"+l);function g(){var a={datauri:m,bloburl:u,svg:d,issues:c,issueCodes:h,type:t,mimeType:o,quality:r,exportWindowName:n};i.avoidEvent||Y("exported",a),e(a)}f.toBlob?f.toBlob((function(e){u=Ie(e),g()}),o,r):(u=Ge(m),g())})));case 17:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),this.exportPDF=function(){var e=r(regeneratorRuntime.mark((function e(t){var r,n,i,a,o,u,l,c,h,d,m,f,g=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=g.length>1&&void 0!==g[1]?g[1]:F()?"save":void 0,window.jsPDF){e.next=7;break}return e.next=4,Br(["jspdf/underscore-min.js","../../svgedit-myfix/editor/jspdf/jspdf-1.0.150.debug.js"]);case 4:return n=!("svgEditor"in window)||!window.svgEditor||!1!==window.svgEditor.modules,e.next=7,Br(s.jspdfPath+"jspdf.plugin.svgToPdf.js",{type:n?"module":"text/javascript"});case 7:return i=ir(),a=i.w>i.h?"landscape":"portrait",o="pt",u=jsPDF({orientation:a,unit:o,format:[i.w,i.h]}),l=ar(),u.setProperties({title:l}),c=Yt(),h=c.issues,d=c.issueCodes,m=this.svgCanvasToString(),u.addSVG(m,0,0),(f={svg:m,issues:h,issueCodes:d,exportWindowName:t,outputType:r=r||"dataurlstring"}).output=u.output(r,"save"===r?t||"svg.pdf":void 0),Y("exportedPDF",f),e.abrupt("return",f);case 21:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),this.getSvgString=function(){return qe.apply=!1,this.svgCanvasToString()},this.randomizeIds=function(e){pr(!(arguments.length>0&&!1===e),g())};var $t=this.uniquifyElems=function(e){var t={},r=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];for(var n in Pe(e,(function(e){if(1===e.nodeType){e.id&&(e.id in t||(t[e.id]={elem:null,attrs:[],hrefs:[]}),t[e.id].elem=e),tn.each(Ee,(function(r,n){var i=e.getAttributeNode(n);if(i){var a=Te(i.value),s=a?a.substr(1):null;s&&(s in t||(t[s]={elem:null,attrs:[],hrefs:[]}),t[s].attrs.push(i))}}));var n=Le(e);if(n&&r.includes(e.nodeName)){var i=n.substr(1);i&&(i in t||(t[i]={elem:null,attrs:[],hrefs:[]}),t[i].hrefs.push(e))}}})),t)if(n){var i=t[n].elem;if(i){var a=q();i.id=a;for(var s=t[n].attrs,o=s.length;o--;){var u=s[o];u.ownerElement.setAttribute(u.name,"url(#"+a+")")}for(var l=t[n].hrefs,c=l.length;c--;){var h=l[c];Ve(h,"#"+a)}}}},er=this.setUseData=function(e){var t=tn(e);"use"!==e.tagName&&(t=t.find("use")),t.each((function(){var e=Le(this).substr(1),t=rt(e);t&&(tn(this).data("ref",t),"symbol"!==t.tagName&&"svg"!==t.tagName||tn(this).data("symbol",t).data("ref",t))}))},tr=this.convertGradients=function(e){var t=tn(e).find("linearGradient, radialGradient");!t.length&&U()&&(t=tn(e).find("*").filter((function(){return this.tagName.includes("Gradient")}))),t.each((function(){if("userSpaceOnUse"===tn(this).attr("gradientUnits")){var e=tn(h).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(!e.length)return;var t=Be(e[0]);if(!t)return;if("linearGradient"===this.tagName){var r=tn(this).attr(["x1","y1","x2","y2"]),n=this.gradientTransform.baseVal;if(n&&n.numberOfItems>0){var i=he(n).matrix,a=se(r.x1,r.y1,i),s=se(r.x2,r.y2,i);r.x1=a.x,r.y1=a.y,r.x2=s.x,r.y2=s.y,this.removeAttribute("gradientTransform")}tn(this).attr({x1:(r.x1-t.x)/t.width,y1:(r.y1-t.y)/t.height,x2:(r.x2-t.x)/t.width,y2:(r.y2-t.y)/t.height}),this.removeAttribute("gradientUnits")}}}))},rr=this.convertToGroup=function(e){e||(e=w[0]);var t,r=tn(e),n=new on;if(r.data("gsvg")){var i=e.firstChild,a=tn(i).attr(["x","y"]);tn(e.firstChild.firstChild).unwrap(),tn(e).removeData("gsvg");var s=Z(e),o=c.createSVGTransform();o.setTranslate(a.x,a.y),s.appendItem(o),Zr(e),Y("selected",[e])}else if(r.data("symbol")){e=r.data("symbol"),t=r.attr("transform");var u=r.attr(["x","y"]),d=e.getAttribute("viewBox");if(d){var m=d.split(" ");u.x-=Number(m[0]),u.y-=Number(m[1])}t+=" translate("+(u.x||0)+","+(u.y||0)+")";var f=r.prev();n.addSubCommand(new an(r[0],r[0].nextSibling,r[0].parentNode)),r.remove();var g,p=tn(h).find("use:data(symbol)").length,y=l.createElementNS(x.SVG,"g"),v=e.childNodes;for(g=0;g<v.length;g++)y.append(v[g].cloneNode(!0));if(j()){var S=tn(Oe()).children("linearGradient,radialGradient,pattern").clone();tn(y).append(S)}t&&y.setAttribute("transform",t);var _=e.parentNode;if($t(y),j()&&tn(Oe()).append(tn(y).find("linearGradient,radialGradient,pattern")),y.id=q(),f.after(y),_){if(!p){var b=e.nextSibling;e.remove(),n.addSubCommand(new an(e,b,_))}n.addSubCommand(new nn(y))}er(y),j()?tr(Oe()):tr(y),function(e,t){if(e&&1===e.nodeType){for(var r=e.childNodes.length;r--;)Pe(e.childNodes.item(r),t);t(e)}}(y,(function(e){try{Zr(e)}catch(e){console.log(e)}})),tn(y).find(Ce).each((function(){this.id||(this.id=q())})),Nt([y]);var A=dr(y,!0);A&&n.addSubCommand(A),M(n)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e,t){try{var r=Ne(e);if(r.firstElementChild&&r.firstElementChild.namespaceURI!==x.SVG)return!1;this.prepareSvg(r);var n=new on("Change Source"),i=h.nextSibling;h.remove();var a=h;n.addSubCommand(new an(a,i,c)),h=l.adoptNode?l.adoptNode(r.documentElement):l.importNode(r.documentElement,!0),c.append(h);var o=tn(h);u.current_drawing_=new gr(h,f);var d=g().getNonce();d?Y("setnonce",d):Y("unsetnonce"),o.find("image").each((function(){var e=this;st(e);var t=Le(this);if(t){if(t.startsWith("data:")){var r=t.match(/svgedit_url=(.*?);/);if(r){var n=decodeURIComponent(r[1]);tn(new Image).load((function(){e.setAttributeNS(x.XLINK,"xlink:href",n)})).attr("src",n)}}u.embedImage(t)}})),o.find("svg").each((function(){if(!tn(this).closest("defs").length){$t(this);var e=this.parentNode;1===e.childNodes.length&&"g"===e.nodeName?(tn(e).data("gsvg",this),e.id=e.id||q()):_t(this)}})),j()&&o.find("linearGradient, radialGradient, pattern").appendTo(Oe()),er(o),tr(o[0]);var m={id:"svgcontent",overflow:s.show_outside_canvas?"visible":"hidden"},p=!1;if(o.attr("viewBox")){var v=o.attr("viewBox").split(" ");m.width=v[2],m.height=v[3]}else tn.each(["width","height"],(function(e,t){var r=o.attr(t)||"100%";"%"===String(r).substr(-1)?p=!0:m[t]=ie(t,r)}));if(yr(),o.children().find(Ce).each((function(){this.id||(this.id=q())})),p){var S=$e();m.width=S.width+S.x,m.height=S.height+S.y}m.width<=0&&(m.width=100),m.height<=0&&(m.height=100),o.attr(m),this.contentW=m.width,this.contentH=m.height,n.addSubCommand(new nn(h));var _=o.attr(["width","height"]);n.addSubCommand(new sn(c,_)),y=1,W={},$(),wt={},c.append(z.selectorParentGroup),t||M(n),Y("changed",[h])}catch(e){return console.log(e),!1}return!0},this.importSvgString=function(e){var t,r,n;try{var i=Ae(e.length+e).substr(0,32),a=!1;Qe[i]&&tn(Qe[i].symbol).parents("#svgroot").length&&(a=!0);var s,o=new on("Import Image");if(a)s=Qe[i].symbol,r=Qe[i].xform;else{var u,c=Ne(e);this.prepareSvg(c),u=l.adoptNode?l.adoptNode(c.documentElement):l.importNode(c.documentElement,!0),$t(u);var d=ie("width",u.getAttribute("width")),m=ie("height",u.getAttribute("height")),f=u.getAttribute("viewBox"),y=f?f.split(" "):[0,0,d,m];for(t=0;t<4;++t)y[t]=Number(y[t]);var S=Number(h.getAttribute("height"));r="translate(0) "+(r=m>d?"scale("+S/3/y[3]+")":"scale("+S/3/y[2]+")")+" translate(0)",s=l.createElementNS(x.SVG,"symbol");var _=Oe();for(j()&&tn(u).find("linearGradient, radialGradient, pattern").appendTo(_);u.firstChild;){var b=u.firstChild;s.append(b)}var w,A=p(u.attributes);try{for(A.s();!(w=A.n()).done;){var k=w.value;s.setAttribute(k.nodeName,k.value)}}catch(e){A.e(e)}finally{A.f()}s.id=q(),Qe[i]={symbol:s,xform:r},Oe().append(s),o.addSubCommand(new nn(s))}(n=l.createElementNS(x.SVG,"use")).id=q(),Ve(n,"#"+s.id),(v||g().getCurrentLayer()).append(n),o.addSubCommand(new nn(n)),$(),n.setAttribute("transform",r),Zr(n),tn(n).data("symbol",s).data("ref",s),ne([n]),M(o),Y("changed",[h])}catch(e){return console.log(e),null}return n};var nr={identifyLayers:yr,createLayer:vr,cloneLayer:xr,deleteCurrentLayer:Sr,setCurrentLayer:_r,renameCurrentLayer:br,setCurrentLayerPosition:wr,setLayerVisibility:Ar,moveSelectedToLayer:kr,mergeLayer:Cr,mergeAllLayers:Er,leaveContext:Gr,setContext:Ir};Object.entries(nr).forEach((function(e){var t=d(e,2),r=t[0],n=t[1];u[r]=n})),function(e){fr=e}({pathActions:N,getCurrentGroup:function(){return v},setCurrentGroup:function(e){v=e},getSelectedElements:I,getSVGContent:G,undoMgr:O,elData:Re,getCurrentDrawing:g,clearSelection:$,call:Y,addCommandToHistory:M,changeSVGContent:function(){Y("changed",[h])}}),this.clear=function(){N.clear(),$(),u.clearSvgContentElement(),u.current_drawing_=new gr(h),u.createLayer("Layer 1"),u.undoMgr.resetUndoStack(),z.initGroup(),mt=z.getRubberBandBox(),Y("cleared")},this.linkControlPoints=N.linkControlPoints,this.getContentElem=function(){return h},this.getRootElem=function(){return c};var ir=this.getResolution=function(){return{w:h.getAttribute("width")/y,h:h.getAttribute("height")/y,zoom:y}};this.getSnapToGrid=function(){return s.gridSnapping},this.getVersion=function(){return"svgcanvas.js ($Rev$)"},this.setUiStrings=function(t){Object.assign(ye,t.notification),tn=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.ok,i=void 0===n?"Ok":n,a=r.cancel,s=void 0===a?"Cancel":a;t("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"}).css("position","absolute");var o=t("#dialog_box"),u=t("#dialog_buttons"),l=t("#dialog_content");function c(r,n,a,c,h,d){l.html("<p>"+n.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt","prompt"===r),u.empty();var m=t('<input type="button" data-ok="" value="'+i+'">').appendTo(u);return new Promise((function(i,f){var g,p;if("alert"!==r&&t('<input type="button" value="'+s+'">').appendTo(u).click((function(){o.hide(),i(!1)})),"prompt"===r)(g=t('<input type="text">').prependTo(u)).val(a||""),g.bind("keydown","return",(function(){m.click()}));else if("select"===r){var y=t('<div style="text-align:center;">');if(g=t('<select aria-label="'.concat(n,'">')).appendTo(y),d){var v=t("<label>").text(d.label);(p=t('<input type="checkbox">').appendTo(v)).val(d.value),d.tooltip&&v.attr("title",d.tooltip),p.prop("checked",Boolean(d.checked)),y.append(t("<div>").append(v))}t.each(c||[],(function(r,n){"object"===e(n)?g.append(t("<option>").val(n.value).html(n.text)):g.append(t("<option>").html(n))})),l.append(y),a&&g.val(a),h&&g.bind("change","return",h),g.bind("keydown","return",(function(){m.click()}))}else"process"===r&&m.hide();o.show(),m.click((function(){o.hide();var e="prompt"!==r&&"select"!==r||g.val();i(p?{response:e,checked:p.prop("checked")}:e)})).focus(),"prompt"!==r&&"select"!==r||g.focus()}))}return t.alert=function(e){return c("alert",e)},t.confirm=function(e){return c("confirm",e)},t.process_cancel=function(e){return c("process",e)},t.prompt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return c("prompt",e,t)},t.select=function(e,t,r,n,i){return c("select",e,n,t,r,i)},t}(tn,t.common),St(t)},this.setConfig=function(e){Object.assign(s,e)},this.getTitle=function(e){if(e=e||w[0]){var t,r=p((e=tn(e).data("gsvg")||tn(e).data("symbol")||e).childNodes);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("title"===n.nodeName)return n.textContent}}catch(e){r.e(e)}finally{r.f()}return""}},this.setGroupTitle=function(e){var t=w[0];t=tn(t).data("gsvg")||t;var r,n=tn(t).children("title"),i=new on("Set Label");if(e.length)n.length?(r=n[0],i.addSubCommand(new sn(r,{"#text":r.textContent})),r.textContent=e):((r=l.createElementNS(x.SVG,"title")).textContent=e,tn(t).prepend(r),i.addSubCommand(new nn(r)));else{var a=n.nextSibling;i.addSubCommand(new an(n[0],a,t)),n.remove()}M(i)};var ar=this.getDocumentTitle=function(){return u.getTitle(h)};this.setDocumentTitle=function(e){var t,r=h.childNodes,n=!1,i="",a=new on("Change Image Title"),s=p(r);try{for(s.s();!(t=s.n()).done;){var o=t.value;if("title"===o.nodeName){i=(n=o).textContent;break}}}catch(e){s.e(e)}finally{s.f()}n||(n=l.createElementNS(x.SVG,"title"),h.insertBefore(n,h.firstChild)),e.length?n.textContent=e:n.remove(),a.addSubCommand(new sn(n,{"#text":i})),M(a)},this.getEditorNS=function(e){return e&&h.setAttribute("xmlns:se",x.SE),x.SE},this.setResolution=function(e,t){var r,n=ir(),i=n.w,a=n.h;if("fit"===e){var s=$e();if(!s)return!1;r=new on("Fit Canvas to Content");var o=Ye();ne(o);var l=[],c=[];tn.each(o,(function(e,t){l.push(-1*s.x),c.push(-1*s.y)}));var d=u.moveSelectedElements(l,c,!0);r.addSubCommand(d),$(),e=Math.round(s.width),t=Math.round(s.height)}return e===i&&t===a||(r||(r=new on("Change Image Dimensions")),e=ie("width",e),t=ie("height",t),h.setAttribute("width",e),h.setAttribute("height",t),this.contentW=e,this.contentH=t,r.addSubCommand(new sn(h,{width:i,height:a})),h.setAttribute("viewBox",[0,0,e/y,t/y].join(" ")),r.addSubCommand(new sn(h,{viewBox:["0 0",i,a].join(" ")})),M(r),Y("changed",[h])),!0},this.getOffset=function(){return tn(h).attr(["x","y"])},this.setBBoxZoom=function(t,r,n){var i,a=.85,s=function(e){if(!e)return!1;var t=Math.round(r/e.width*100*a)/100,i=Math.round(n/e.height*100*a)/100,s=Math.min(t,i);return u.setZoom(s),{zoom:s,bbox:e}};if("object"===e(t)){if(0===(i=t).width||0===i.height){var o=i.zoom?i.zoom:y*i.factor;return u.setZoom(o),{zoom:y,bbox:i}}return s(i)}switch(t){case"selection":if(!w[0])return;var l=tn.map(w,(function(e){if(e)return e}));i=$e(l);break;case"canvas":var c=ir();a=.95,i={width:c.w,height:c.h,x:0,y:0};break;case"content":i=$e();break;case"layer":i=$e(Ye(g().getCurrentLayer()));break;default:return}return s(i)},this.setZoom=function(e){var t=ir();h.setAttribute("viewBox","0 0 "+t.w/e+" "+t.h/e),y=e,tn.each(w,(function(e,t){t&&z.requestSelector(t).resize()})),N.zoomChange(),yt("zoomChanged",e)},this.getMode=function(){return lt},this.setMode=function(e){N.clear(!0),Kt.clear(),ht=w[0]&&"text"===w[0].nodeName?We:b,lt=e},this.getColor=function(e){return ht[e]},this.setColor=function(e,t,r){b[e]=t,ht[e+"_paint"]={type:"solidColor"};var n=[];function i(e){"g"!==e.nodeName&&n.push(e)}for(var a=w.length;a--;){var s=w[a];s&&("g"===s.tagName?Pe(s,i):"fill"===e?"polyline"!==s.tagName&&"line"!==s.tagName&&n.push(s):n.push(s))}n.length>0&&(r?ur(e,t,n):(lr(e,t,n),Y("changed",n)))};var sr=this.setGradient=function(e){if(ht[e+"_paint"]&&"solidColor"!==ht[e+"_paint"].type){var t=u[e+"Grad"],r=or(t),n=Oe();r?t=r:(t=n.appendChild(l.importNode(t,!0))).id=q(),u.setColor(e,"url(#"+t.id+")")}},or=function(e){for(var t=Oe(),r=tn(t).find("linearGradient, radialGradient"),n=r.length,i=["r","cx","cy","fx","fy"];n--;){var a=r[n];if("linearGradient"===e.tagName){if(e.getAttribute("x1")!==a.getAttribute("x1")||e.getAttribute("y1")!==a.getAttribute("y1")||e.getAttribute("x2")!==a.getAttribute("x2")||e.getAttribute("y2")!==a.getAttribute("y2"))continue}else if("continue"===function(){var t=tn(e).attr(i),r=tn(a).attr(i),n=!1;if(tn.each(i,(function(e,i){t[i]!==r[i]&&(n=!0)})),n)return"continue"}())continue;var s=e.getElementsByTagNameNS(x.SVG,"stop"),o=a.getElementsByTagNameNS(x.SVG,"stop");if(s.length===o.length){for(var u=s.length;u--;){var l=s[u],c=o[u];if(l.getAttribute("offset")!==c.getAttribute("offset")||l.getAttribute("stop-opacity")!==c.getAttribute("stop-opacity")||l.getAttribute("stop-color")!==c.getAttribute("stop-color"))break}if(-1===u)return a}}return null};this.setPaint=function(e,t){var r=new tn.jGraduate.Paint(t);switch(this.setPaintOpacity(e,r.alpha/100,!0),ht[e+"_paint"]=r,r.type){case"solidColor":this.setColor(e,"none"!==r.solidColor?"#"+r.solidColor:"none");break;case"linearGradient":case"radialGradient":u[e+"Grad"]=r[r.type],sr(e)}},this.setStrokePaint=function(e){this.setPaint("stroke",e)},this.setFillPaint=function(e){this.setPaint("fill",e)},this.getStrokeWidth=function(){return ht.stroke_width},this.setStrokeWidth=function(e){if(0===e&&["line","path"].includes(lt))u.setStrokeWidth(1);else{ht.stroke_width=e;for(var t=[],r=w.length;r--;){var n=w[r];n&&("g"===n.tagName?Pe(n,i):t.push(n))}t.length>0&&(lr("stroke-width",e,t),Y("changed",w))}function i(e){"g"!==e.nodeName&&t.push(e)}},this.setStrokeAttr=function(e,t){b[e.replace("-","_")]=t;for(var r=[],n=w.length;n--;){var i=w[n];i&&("g"===i.tagName?Pe(i,(function(e){"g"!==e.nodeName&&r.push(e)})):r.push(i))}r.length>0&&(lr(e,t,r),Y("changed",w))},this.getStyle=function(){return b},this.getOpacity=ae,this.setOpacity=function(e){b.opacity=e,lr("opacity",e)},this.getFillOpacity=function(){return b.fill_opacity},this.getStrokeOpacity=function(){return b.stroke_opacity},this.setPaintOpacity=function(e,t,r){b[e+"_opacity"]=t,r?ur(e+"-opacity",t):lr(e+"-opacity",t)},this.getPaintOpacity=function(e){return"fill"===e?this.getFillOpacity():this.getStrokeOpacity()},this.getBlur=function(e){var t=0;if(e&&e.getAttribute("filter")){var r=rt(e.id+"_blur");r&&(t=r.firstChild.getAttribute("stdDeviation"))}return t},function(){var e=null,t=null,r=!1;function n(){var r=u.undoMgr.finishUndoableChange();e.addSubCommand(r),M(e),e=null,t=null}u.setBlurNoUndo=function(e){if(t)if(0===e)ur("filter",""),r=!0;else{var n=w[0];r&&ur("filter","url(#"+n.id+"_blur)"),U()&&(n.removeAttribute("filter"),n.setAttribute("filter","url(#"+n.id+"_blur)")),ur("stdDeviation",e,[t.firstChild]),u.setBlurOffsets(t,e)}else u.setBlur(e)},u.setBlurOffsets=function(e,t){t>3?nt(e,{x:"-50%",y:"-50%",width:"200%",height:"200%"}):U()||(e.removeAttribute("x"),e.removeAttribute("y"),e.removeAttribute("width"),e.removeAttribute("height"))},u.setBlur=function(r,i){if(e)n();else{var a=w[0],s=a.id;t=rt(s+"_blur"),r-=0;var o=new on;if(t)0===r&&(t=null);else{var l=k({element:"feGaussianBlur",attr:{in:"SourceGraphic",stdDeviation:r}});(t=k({element:"filter",attr:{id:s+"_blur"}})).append(l),Oe().append(t),o.addSubCommand(new nn(t))}var c={filter:a.getAttribute("filter")};if(0===r)return a.removeAttribute("filter"),void o.addSubCommand(new sn(a,c));lr("filter","url(#"+s+"_blur)"),o.addSubCommand(new sn(a,c)),u.setBlurOffsets(t,r),e=o,u.undoMgr.beginUndoableChange("stdDeviation",[t?t.firstChild:null]),i&&(u.setBlurNoUndo(r),n())}}}(),this.getBold=function(){var e=w[0];return!(ot(e)||"text"!==e.tagName||!ot(w[1]))&&"bold"===e.getAttribute("font-weight")},this.setBold=function(e){var t=w[0];!ot(t)&&"text"===t.tagName&&ot(w[1])&&lr("font-weight",e?"bold":"normal"),w[0].textContent||Kt.setCursor()},this.getItalic=function(){var e=w[0];return!(ot(e)||"text"!==e.tagName||!ot(w[1]))&&"italic"===e.getAttribute("font-style")},this.setItalic=function(e){var t=w[0];!ot(t)&&"text"===t.tagName&&ot(w[1])&&lr("font-style",e?"italic":"normal"),w[0].textContent||Kt.setCursor()},this.getFontFamily=function(){return We.font_family},this.setFontFamily=function(e){We.font_family=e,lr("font-family",e),w[0]&&!w[0].textContent&&Kt.setCursor()},this.setFontColor=function(e){We.fill=e,lr("fill",e)},this.getFontColor=function(){return We.fill},this.getFontSize=function(){return We.font_size},this.setFontSize=function(e){We.font_size=e,lr("font-size",e),w[0].textContent||Kt.setCursor()},this.getText=function(){var e=w[0];return ot(e)?"":e.textContent},this.setTextContent=function(e){lr("#text",e),Kt.init(e),Kt.setCursor()},this.setImageURL=function(e){var t=w[0];if(t){var r=tn(t).attr(["width","height"]),n=!r.width||!r.height,i=Le(t);if(i!==e||n){var a=new on("Change Image URL");Ve(t,e),a.addSubCommand(new sn(t,{"#href":i})),tn(new Image).load((function(){var e=tn(t).attr(["width","height"]);tn(t).attr({width:this.width,height:this.height}),z.requestSelector(t).resize(),a.addSubCommand(new sn(t,e)),M(a),Y("changed",[t])})).attr("src",e)}}},this.setLinkURL=function(e){var t=w[0];if(t){if("a"!==t.tagName){var r=tn(t).parents("a");if(!r.length)return;t=r[0]}var n=Le(t);if(n!==e){var i=new on("Change Link URL");Ve(t,e),i.addSubCommand(new sn(t,{"#href":n})),M(i)}}},this.setRectRadius=function(e){var t=w[0];if(!ot(t)&&"rect"===t.tagName){var r=t.getAttribute("rx");r!==String(e)&&(t.setAttribute("rx",e),t.setAttribute("ry",e),M(new sn(t,{rx:r,ry:r},"Radius")),Y("changed",[t]))}},this.makeHyperlink=function(e){u.groupSelectedElements("a",e)},this.removeHyperlink=function(){u.ungroupSelectedElement()},this.setSegType=function(e){N.setSegType(e)},this.convertToPath=function(e,t){if(!ot(e))return t?Fe(e,k,N):function(e,t,r,n,i,a,s,o){var u=new s.BatchCommand("Convert element to Path"),l=r({element:"path",attr:t=ge.extend({},t,He(e))}),c=e.getAttribute("transform");c&&l.setAttribute("transform",c);var h=e.id,d=e.parentNode;e.nextSibling?e.before(l):d.append(l);var m=je(e);if(m){if(l.setAttribute("d",m),c){var f=Z(l);le(f)&&n.resetOrientation(l)}var g=e.nextSibling;return u.addSubCommand(new s.RemoveElementCommand(e,g,parent)),u.addSubCommand(new s.InsertElementCommand(l)),i(),e.remove(),l.setAttribute("id",h),l.removeAttribute("visibility"),a([l],!0),o(u),l}return l.remove(),null}(e,{fill:b.fill,"fill-opacity":b.fill_opacity,stroke:b.stroke,"stroke-width":b.stroke_width,"stroke-dasharray":b.stroke_dasharray,"stroke-linejoin":b.stroke_linejoin,"stroke-linecap":b.stroke_linecap,"stroke-opacity":b.stroke_opacity,opacity:b.opacity,visibility:"hidden"},k,N,$,ne,pt,M);var r=w;tn.each(r,(function(e,t){t&&u.convertToPath(t)}))};var ur=function(e,t,r){"pathedit"===lt&&N.moveNode(e,t);for(var n=(r=r||w).length,i=["g","polyline","path"],a=function(){var a=r[n];if(ot(a))return"continue";if(("x"===e||"y"===e)&&i.includes(a.tagName)){var s=$e([a]),o="x"===e?t-s.x:0,l="y"===e?t-s.y:0;return u.moveSelectedElements(o*y,l*y,!0),"continue"}var h="#text"===e?a.textContent:a.getAttribute(e);if(ot(h)&&(h=""),h!==String(t)){"#text"===e?(a.textContent=t,/rotate/.test(a.getAttribute("transform"))&&(a=kt(a))):"#href"===e?Ve(a,t):a.setAttribute(e,t),"textedit"===lt&&"#text"!==e&&a.textContent.length&&Kt.toSelectMode(a),j()&&"text"===a.nodeName&&/rotate/.test(a.getAttribute("transform"))&&(String(t).startsWith("url")||["font-size","font-family","x","y"].includes(e)&&a.textContent)&&(a=kt(a)),w.includes(a)&&setTimeout((function(){a.parentNode&&z.requestSelector(a).resize()}),0);var d=et(a);if(0!==d&&"transform"!==e)for(var m=Z(a),f=m.numberOfItems;f--;){if(4===m.getItem(f).type){m.removeItem(f);var g=Be(a),p=se(g.x+g.width/2,g.y+g.height/2,he(m).matrix),v=p.x,x=p.y,S=c.createSVGTransform();S.setRotate(d,v,x),m.insertItemBefore(S,f);break}}}};n--;)a()},lr=this.changeSelectedAttribute=function(e,t,r){r=r||w,u.undoMgr.beginUndoableChange(e,r),ur(e,t,r);var n=u.undoMgr.finishUndoableChange();n.isEmpty()||M(n)};this.deleteSelectedElements=function(){for(var e=new on("Delete Elements"),t=w.length,r=[],n=0;n<t;++n){var i=w[n];if(ot(i))break;var a=i.parentNode,s=i;z.releaseSelector(s),Ft(s.id),"a"===a.tagName&&1===a.childNodes.length&&(s=a,a=a.parentNode);var o=s.nextSibling;s.remove();var u=s;r.push(i),e.addSubCommand(new an(u,o,a))}w=[],e.isEmpty()||M(e),Y("changed",r),$()},this.cutSelectedElements=function(){u.copySelectedElements(),u.deleteSelectedElements()};var cr="svgedit_clipboard";function hr(){var e=sessionStorage.getItem(cr);localStorage.setItem(cr,e),setTimeout((function(){localStorage.removeItem(cr)}),1)}window.addEventListener("storage",(function(e){e.newValue&&(e.key===cr+"_startup"?(localStorage.removeItem(cr+"_startup"),hr()):e.key===cr&&sessionStorage.setItem(cr,e.newValue))}),!1),localStorage.setItem(cr+"_startup",Math.random()),this.copySelectedElements=function(){var e=JSON.stringify(w.map((function(e){return A(e)})));sessionStorage.setItem(cr,e),hr();var t=tn("#cmenu_canvas");t.enableContextMenuItems&&t.enableContextMenuItems("#paste,#paste_in_place")},this.pasteElements=function(e,t,r){var n=JSON.parse(sessionStorage.getItem(cr));if(n){var i=n.length;if(i){var a=[],s=new on("Paste elements"),o={};for(n.forEach((function(e){return function e(t){t.attr&&t.attr.id&&(o[t.attr.id]=q(),t.attr.id=o[t.attr.id]),t.children&&t.children.forEach((function(t){return e(t)}))}(e)})),yt("IDsUpdated",{elems:n,changes:o},!0).forEach((function(e){e&&"remove"in e&&e.remove.forEach((function(e){n=n.filter((function(t){return t.attr.id!==e}))}))}));i--;){var l=n[i];if(l){var c=k(l);a.push(c),s.addSubCommand(new nn(c)),De(c)}}if(Nt(a),"in_place"!==e){var h,d;e?"point"===e&&(h=t,d=r):(h=gt.x,d=gt.y);var m=$e(a),f=h-(m.x+m.width/2),g=d-(m.y+m.height/2),p=[],y=[];tn.each(a,(function(e,t){p.push(f),y.push(g)}));var v=u.moveSelectedElements(p,y,!1);v&&s.addSubCommand(v)}M(s),Y("changed",a)}}},this.groupSelectedElements=function(e,t){e||(e="g");var r,n="";switch(e){case"a":n="Make hyperlink",r=t||"";break;default:e="g",n="Group Elements"}var i=new on(n),a=k({element:e,attr:{id:q()}});"a"===e&&Ve(a,r),i.addSubCommand(new nn(a));for(var s=w.length;s--;){var o=w[s];if(!ot(o)){"a"===o.parentNode.tagName&&1===o.parentNode.childNodes.length&&(o=o.parentNode);var u=o.nextSibling,l=o.parentNode;a.append(o),i.addSubCommand(new rn(o,u,l))}}i.isEmpty()||M(i),Nt([a],!0)};var dr=this.pushGroupProperties=function(e,t){for(var r,n,i,a=e.childNodes,s=a.length,o=e.getAttribute("transform"),l=Z(e),h=he(l).matrix,d=new on("Push group properties"),m=et(e),f=tn(e).attr(["filter","opacity"]),p=g(),y=0;y<s;y++){var v=a[y];if(1===v.nodeType){if(null!==f.opacity&&1!==f.opacity){var x=Math.round((v.getAttribute("opacity")||1)*f.opacity*100)/100;lr("opacity",x,[v])}if(f.filter){var S=this.getBlur(v),_=S;n||(n=this.getBlur(e)),S?S=Number(n)+Number(S):0===S&&(S=n),_?r=tt(v.getAttribute("filter")):r?(r=p.copyElem(r),Oe().append(r)):r=tt(f.filter);var b="feGaussianBlur"===r.firstChild.tagName?"blur":"filter";r.id=v.id+"_"+b,lr("filter","url(#"+r.id+")",[v]),S&&(lr("stdDeviation",S,[r.firstChild]),u.setBlurOffsets(r,S))}var w=Z(v);if(v.tagName.includes("Gradient")&&(w=null),w&&"defs"!==v.tagName&&l.numberOfItems){if(m&&1===l.numberOfItems){var A=l.getItem(0).matrix,k=c.createSVGMatrix(),C=et(v);C&&(k=w.getItem(0).matrix);var E=Be(v),G=he(w).matrix,I=se(E.x+E.width/2,E.y+E.height/2,G),N=m+C,P=c.createSVGTransform();P.setRotate(N,I.x,I.y);var T=ue(A,k,P.matrix.inverse());if(C&&w.removeItem(0),N&&(w.numberOfItems?w.insertItemBefore(P,0):w.appendItem(P)),T.e||T.f){var L=c.createSVGTransform();L.setTranslate(T.e,T.f),w.numberOfItems?w.insertItemBefore(L,0):w.appendItem(L)}}else{var V=v.getAttribute("transform");(i={}).transform=V||"";var O=c.createSVGTransform(),M=he(w).matrix,R=M.inverse(),B=ue(R,h,M);O.setMatrix(B),w.appendItem(O)}var U=Zr(v);U&&d.addSubCommand(U)}}}if(o&&((i={}).transform=o,e.setAttribute("transform",""),e.removeAttribute("transform"),d.addSubCommand(new sn(e,i))),t&&!d.isEmpty())return d};this.ungroupSelectedElement=function(){var e=w[0];if(e)if(tn(e).data("gsvg")||tn(e).data("symbol"))rr(e);else{if("use"===e.tagName){var t=rt(Le(e).substr(1));return tn(e).data("symbol",t).data("ref",t),void rr(e)}var r=tn(e).parents("a");if(r.length&&(e=r[0]),"g"===e.tagName||"a"===e.tagName){var n=new on("Ungroup Elements"),i=dr(e,!0);i&&n.addSubCommand(i);for(var a=e.parentNode,s=e.nextSibling,o=new Array(e.childNodes.length),u=0;e.firstChild;){var l=e.firstChild,c=l.nextSibling,h=l.parentNode;if("title"!==l.tagName)s?s.before(l):e.after(l),o[u++]=l,n.addSubCommand(new rn(l,c,h));else{var d=l.nextSibling;n.addSubCommand(new an(l,d,h)),l.remove()}}$();var m=e.nextSibling;e.remove(),n.addSubCommand(new an(e,m,a)),n.isEmpty()||M(n),ne(o)}}},this.moveToTopSelectedElement=function(){var e=d(w,1)[0];if(!ot(e)){var t=e,r=t.parentNode,n=t.nextSibling;n!==(t=t.parentNode.appendChild(t)).nextSibling&&(M(new rn(t,n,r,"top")),Y("changed",[t]))}},this.moveToBottomSelectedElement=function(){var e=d(w,1)[0];if(!ot(e)){var t=e,r=t.parentNode,n=t.nextSibling,i=t.parentNode.firstChild;"title"===i.tagName&&(i=i.nextSibling),"defs"===i.tagName&&(i=i.nextSibling),n!==(t=t.parentNode.insertBefore(t,i)).nextSibling&&(M(new rn(t,n,r,"bottom")),Y("changed",[t]))}},this.moveUpDownSelected=function(e){var t=w[0];if(t){var r,n;ft=[];var i=tn(vt($e([t]))).toArray();if("Down"===e&&i.reverse(),tn.each(i,(function(){return n?(r=this,!1):(this===t&&(n=!0),!0)})),r){var a=t,s=a.parentNode,o=a.nextSibling;tn(r)["Down"===e?"before":"after"](a),o!==a.nextSibling&&(M(new rn(a,o,s,"Move "+e)),Y("changed",[a]))}}},this.moveSelectedElements=function(e,t,r){e.constructor!==Array&&(e/=y,t/=y),r=r||!0;for(var n=new on("position"),i=w.length;i--;){var a=w[i];if(!ot(a)){var s=c.createSVGTransform(),o=Z(a);e.constructor===Array?s.setTranslate(e[i],t[i]):s.setTranslate(e,t),o.numberOfItems?o.insertItemBefore(s,0):o.appendItem(s);var u=Zr(a);u&&n.addSubCommand(u),z.requestSelector(a).resize()}}if(!n.isEmpty())return r&&M(n),Y("changed",w),n},this.cloneSelectedElements=function(e,t){var r,n,i=new on("Clone Elements"),a=w.length;for(w.sort((function(e,t){return tn(t).index()-tn(e).index()})),r=0;r<a&&(n=w[r],!ot(n));++r);var s=w.slice(0,r);this.clearSelection(!0);var o=g();for(r=s.length;r--;)n=s[r]=o.copyElem(s[r]),(v||o.getCurrentLayer()).append(n),i.addSubCommand(new nn(n));i.isEmpty()||(ne(s.reverse()),this.moveSelectedElements(e,t,!1),M(i))},this.alignSelectedElements=function(e,t){var r=[],n=w.length;if(n){for(var i=Number.MAX_VALUE,a=Number.MIN_VALUE,s=Number.MAX_VALUE,o=Number.MIN_VALUE,l=Number.MIN_VALUE,c=Number.MIN_VALUE,h=0;h<n&&!ot(w[h]);++h){var d=w[h];switch(r[h]=$e([d]),t){case"smallest":(("l"===e||"c"===e||"r"===e)&&(l===Number.MIN_VALUE||l>r[h].width)||("t"===e||"m"===e||"b"===e)&&(c===Number.MIN_VALUE||c>r[h].height))&&(i=r[h].x,s=r[h].y,a=r[h].x+r[h].width,o=r[h].y+r[h].height,l=r[h].width,c=r[h].height);break;case"largest":(("l"===e||"c"===e||"r"===e)&&(l===Number.MIN_VALUE||l<r[h].width)||("t"===e||"m"===e||"b"===e)&&(c===Number.MIN_VALUE||c<r[h].height))&&(i=r[h].x,s=r[h].y,a=r[h].x+r[h].width,o=r[h].y+r[h].height,l=r[h].width,c=r[h].height);break;default:r[h].x<i&&(i=r[h].x),r[h].y<s&&(s=r[h].y),r[h].x+r[h].width>a&&(a=r[h].x+r[h].width),r[h].y+r[h].height>o&&(o=r[h].y+r[h].height)}}"page"===t&&(i=0,s=0,a=u.contentW,o=u.contentH);for(var m=new Array(n),f=new Array(n),g=0;g<n&&!ot(w[g]);++g){var p=r[g];switch(m[g]=0,f[g]=0,e){case"l":m[g]=i-p.x;break;case"c":m[g]=(i+a)/2-(p.x+p.width/2);break;case"r":m[g]=a-(p.x+p.width);break;case"t":f[g]=s-p.y;break;case"m":f[g]=(s+o)/2-(p.y+p.height/2);break;case"b":f[g]=o-(p.y+p.height)}}this.moveSelectedElements(m,f)}},this.contentW=ir().w,this.contentH=ir().h,this.updateCanvas=function(e,t){c.setAttribute("width",e),c.setAttribute("height",t);var r=tn("#canvasBackground")[0],n=h.getAttribute("x"),i=h.getAttribute("y"),a=(e-this.contentW*y)/2,s=(t-this.contentH*y)/2;nt(h,{width:this.contentW*y,height:this.contentH*y,x:a,y:s,viewBox:"0 0 "+this.contentW+" "+this.contentH}),nt(r,{width:h.getAttribute("width"),height:h.getAttribute("height"),x:a,y:s});var o=rt("background_image");return o&&nt(o,{width:"100%",height:"100%"}),z.selectorParentGroup.setAttribute("transform","translate("+a+","+s+")"),yt("canvasUpdated",{new_x:a,new_y:s,old_x:n,old_y:i,d_x:a-n,d_y:s-i}),{x:a,y:s,old_x:n,old_y:i,d_x:a-n,d_y:s-i}},this.setBackground=function(e,t){var r=rt("canvasBackground"),n=tn(r).find("rect")[0],i=rt("background_image"),a=rt("background_pattern");if(n.setAttribute("fill","chessboard"===e?"#fff":e),"chessboard"===e){if(!a){a=l.createElementNS(x.SVG,"foreignObject"),nt(a,{id:"background_pattern",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"});var s=document.createElement("div");nt(s,{style:"pointer-events:none;width:100%;height:100%;background-image:url(data:image/gif;base64,R0lGODlhEAAQAIAAAP///9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG+gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);"}),a.appendChild(s),r.append(a)}}else a&&a.remove();t?(i||(i=l.createElementNS(x.SVG,"image"),nt(i,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})),Ve(i,t),r.append(i)):i&&i.remove()},this.cycleElement=function(e){var t,r=w[0],n=!1,i=Ye(v||g().getCurrentLayer());if(i.length){if(ot(r))n=i[t=e?i.length-1:0];else for(var a=i.length;a--;)if(i[a]===r){(t=e?a-1:a+1)>=i.length?t=0:t<0&&(t=i.length-1),n=i[t];break}Nt([n],!0),Y("selected",w)}},this.clear(),this.getPrivateMethods=function(){return{addCommandToHistory:M,BatchCommand:on,ChangeElementCommand:sn,decode64:ke,dropXMLInternalSubset:be,encode64:Ae,ffClone:kt,findDefs:Oe,findDuplicateGradient:or,getElem:rt,getPathBBox:Me,getTypeMap:ee,getUrlFromAttr:Te,identifyLayers:yr,InsertElementCommand:nn,isChrome:F,isIdentity:oe,isIE:H,logMatrix:Gt,MoveElementCommand:rn,NS:x,preventClickDefault:st,RemoveElementCommand:an,SVGEditTransformList:X,text2xml:Ne,transformBox:ce,transformPoint:se,walkTree:Pe}}}}();
//# sourceMappingURL=svgcanvas-iife.min.js.map