', { class: 'flyout_arrow_horiz' }));
refBtn.before(showBtn);
-
// Create a flyout div
flyoutHolder = makeFlyoutHolder(_tlsId, refBtn);
}
@@ -28215,7 +28253,7 @@ editor.init = function () {
fn: btn.events.click,
icon: btn.id,
key: btn.key,
- isDefault: btn.includeWith ? btn.includeWith.isDefault : 0
+ isDefault: Boolean(btn.includeWith && btn.includeWith.isDefault)
}, refData];
// {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'}
@@ -28269,26 +28307,27 @@ editor.init = function () {
});
if (svgicons) {
- $$b.svgIcons(svgicons, {
- w: 24, h: 24,
- id_match: false,
- no_img: !isWebkit(),
- fallback: fallbackObj,
- placement: placementObj,
- callback: function callback(icons) {
- // Non-ideal hack to make the icon match the current size
- // if (curPrefs.iconsize && curPrefs.iconsize !== 'm') {
- if ($$b.pref('iconsize') !== 'm') {
- prepResize();
+ return new Promise(function (resolve, reject) {
+ $$b.svgIcons(svgicons, {
+ w: 24, h: 24,
+ id_match: false,
+ no_img: !isWebkit(),
+ fallback: fallbackObj,
+ placement: placementObj,
+ callback: function callback(icons) {
+ // Non-ideal hack to make the icon match the current size
+ // if (curPrefs.iconsize && curPrefs.iconsize !== 'm') {
+ if ($$b.pref('iconsize') !== 'm') {
+ prepResize();
+ }
+ runCallback();
+ resolve();
}
- runCallback();
- }
+ });
});
}
}
- if (!svgicons) {
- runCallback();
- }
+ return runCallback();
};
var getPaint = function getPaint(color, opac, type) {
@@ -28341,9 +28380,9 @@ editor.init = function () {
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas
* @returns {undefined}
*/
- function (win, _ref10) {
- var center = _ref10.center,
- newCtr = _ref10.newCtr;
+ function (win, _ref14) {
+ var center = _ref14.center,
+ newCtr = _ref14.newCtr;
updateCanvas(center, newCtr);
});
@@ -29950,8 +29989,11 @@ editor.init = function () {
changeSidePanelWidth(deltaX);
};
- // if width is non-zero, then fully close it, otherwise fully open it
- // the optional close argument forces the side panel closed
+ /**
+ * If width is non-zero, then fully close it, otherwise fully open it
+ * @param {boolean} close Forces the side panel closed
+ * @returns {undefined}
+ */
var toggleSidePanel = function toggleSidePanel(close) {
var w = $$b('#sidepanels').width();
var deltaX = (w > 2 || close ? 2 : SIDEPANEL_OPENWIDTH) - w;
@@ -30071,20 +30113,46 @@ editor.init = function () {
// Prevent browser from erroneously repopulating fields
$$b('input,select').attr('autocomplete', 'off');
- // Associate all button actions as well as non-button keyboard shortcuts
+ /**
+ * Associate all button actions as well as non-button keyboard shortcuts
+ * @namespace {PlainObject} module:SVGEditor~Actions
+ */
var Actions = function () {
- // sel:'selector', fn:function, evt:'event', key:[key, preventDefault, NoDisableInInput]
- var toolButtons = [{ sel: '#tool_select', fn: clickSelect, evt: 'click', key: ['V', true] }, { sel: '#tool_fhpath', fn: clickFHPath, evt: 'click', key: ['Q', true] }, { sel: '#tool_line', fn: clickLine, evt: 'click', key: ['L', true] }, { sel: '#tool_rect', fn: clickRect, evt: 'mouseup', key: ['R', true], parent: '#tools_rect', icon: 'rect' }, { sel: '#tool_square', fn: clickSquare, evt: 'mouseup', parent: '#tools_rect', icon: 'square' }, { sel: '#tool_fhrect', fn: clickFHRect, evt: 'mouseup', parent: '#tools_rect', icon: 'fh_rect' }, { sel: '#tool_ellipse', fn: clickEllipse, evt: 'mouseup', key: ['E', true], parent: '#tools_ellipse', icon: 'ellipse' }, { sel: '#tool_circle', fn: clickCircle, evt: 'mouseup', parent: '#tools_ellipse', icon: 'circle' }, { sel: '#tool_fhellipse', fn: clickFHEllipse, evt: 'mouseup', parent: '#tools_ellipse', icon: 'fh_ellipse' }, { sel: '#tool_path', fn: clickPath, evt: 'click', key: ['P', true] }, { sel: '#tool_text', fn: clickText, evt: 'click', key: ['T', true] }, { sel: '#tool_image', fn: clickImage, evt: 'mouseup' }, { sel: '#tool_zoom', fn: clickZoom, evt: 'mouseup', key: ['Z', true] }, { sel: '#tool_clear', fn: clickClear, evt: 'mouseup', key: ['N', true] }, { sel: '#tool_save', fn: function fn() {
+ /**
+ * @typedef {PlainObject} module:SVGEditor.ToolButton
+ * @property {string} sel The CSS selector for the tool
+ * @property {external:jQuery.Function} fn A handler to be attached to the `evt`
+ * @property {string} evt The event for which the `fn` listener will be added
+ * @property {module:SVGEditor.Key} [key] [key, preventDefault, NoDisableInInput]
+ * @property {string} [parent] Selector
+ * @property {boolean} [hidekey] Whether to show key value in title
+ * @property {string} [icon] The button ID
+ * @property {boolean} isDefault For flyout holders
+ */
+ /**
+ *
+ * @name module:SVGEditor~ToolButtons
+ * @type {module:SVGEditor.ToolButton[]}
+ */
+ var toolButtons = [{ sel: '#tool_select', fn: clickSelect, evt: 'click', key: ['V', true] }, { sel: '#tool_fhpath', fn: clickFHPath, evt: 'click', key: ['Q', true] }, { sel: '#tool_line', fn: clickLine, evt: 'click', key: ['L', true], parent: '#tools_line', prepend: true }, { sel: '#tool_rect', fn: clickRect, evt: 'mouseup',
+ key: ['R', true], parent: '#tools_rect', icon: 'rect' }, { sel: '#tool_square', fn: clickSquare, evt: 'mouseup',
+ parent: '#tools_rect', icon: 'square' }, { sel: '#tool_fhrect', fn: clickFHRect, evt: 'mouseup',
+ parent: '#tools_rect', icon: 'fh_rect' }, { sel: '#tool_ellipse', fn: clickEllipse, evt: 'mouseup',
+ key: ['E', true], parent: '#tools_ellipse', icon: 'ellipse' }, { sel: '#tool_circle', fn: clickCircle, evt: 'mouseup',
+ parent: '#tools_ellipse', icon: 'circle' }, { sel: '#tool_fhellipse', fn: clickFHEllipse, evt: 'mouseup',
+ parent: '#tools_ellipse', icon: 'fh_ellipse' }, { sel: '#tool_path', fn: clickPath, evt: 'click', key: ['P', true] }, { sel: '#tool_text', fn: clickText, evt: 'click', key: ['T', true] }, { sel: '#tool_image', fn: clickImage, evt: 'mouseup' }, { sel: '#tool_zoom', fn: clickZoom, evt: 'mouseup', key: ['Z', true] }, { sel: '#tool_clear', fn: clickClear, evt: 'mouseup', key: ['N', true] }, { sel: '#tool_save', fn: function fn() {
if (editingsource) {
saveSourceEditor();
} else {
clickSave();
}
},
- evt: 'mouseup', key: ['S', true] }, { sel: '#tool_export', fn: clickExport, evt: 'mouseup' }, { sel: '#tool_open', fn: clickOpen, evt: 'mouseup', key: ['O', true] }, { sel: '#tool_import', fn: clickImport, evt: 'mouseup' }, { sel: '#tool_source', fn: showSourceEditor, evt: 'click', key: ['U', true] }, { sel: '#tool_wireframe', fn: clickWireframe, evt: 'click', key: ['F', true] }, { sel: '#tool_source_cancel,.overlay,#tool_docprops_cancel,#tool_prefs_cancel', fn: cancelOverlays, evt: 'click', key: ['esc', false, false], hidekey: true }, { sel: '#tool_source_save', fn: saveSourceEditor, evt: 'click' }, { sel: '#tool_docprops_save', fn: saveDocProperties, evt: 'click' }, { sel: '#tool_docprops', fn: showDocProperties, evt: 'mouseup' }, { sel: '#tool_prefs_save', fn: savePreferences, evt: 'click' }, { sel: '#tool_prefs_option', fn: function fn() {
+ evt: 'mouseup', key: ['S', true] }, { sel: '#tool_export', fn: clickExport, evt: 'mouseup' }, { sel: '#tool_open', fn: clickOpen, evt: 'mouseup', key: ['O', true] }, { sel: '#tool_import', fn: clickImport, evt: 'mouseup' }, { sel: '#tool_source', fn: showSourceEditor, evt: 'click', key: ['U', true] }, { sel: '#tool_wireframe', fn: clickWireframe, evt: 'click', key: ['F', true] }, { sel: '#tool_source_cancel,.overlay,#tool_docprops_cancel,#tool_prefs_cancel',
+ fn: cancelOverlays, evt: 'click', key: ['esc', false, false], hidekey: true }, { sel: '#tool_source_save', fn: saveSourceEditor, evt: 'click' }, { sel: '#tool_docprops_save', fn: saveDocProperties, evt: 'click' }, { sel: '#tool_docprops', fn: showDocProperties, evt: 'mouseup' }, { sel: '#tool_prefs_save', fn: savePreferences, evt: 'click' }, { sel: '#tool_prefs_option', fn: function fn() {
showPreferences();return false;
},
- evt: 'mouseup' }, { sel: '#tool_delete,#tool_delete_multi', fn: deleteSelected, evt: 'click', key: ['del/backspace', true] }, { sel: '#tool_reorient', fn: reorientPath, evt: 'click' }, { sel: '#tool_node_link', fn: linkControlPoints, evt: 'click' }, { sel: '#tool_node_clone', fn: clonePathNode, evt: 'click' }, { sel: '#tool_node_delete', fn: deletePathNode, evt: 'click' }, { sel: '#tool_openclose_path', fn: opencloseSubPath, evt: 'click' }, { sel: '#tool_add_subpath', fn: addSubPath, evt: 'click' }, { sel: '#tool_move_top', fn: moveToTopSelected, evt: 'click', key: 'ctrl+shift+]' }, { sel: '#tool_move_bottom', fn: moveToBottomSelected, evt: 'click', key: 'ctrl+shift+[' }, { sel: '#tool_topath', fn: convertToPath$$1, evt: 'click' }, { sel: '#tool_make_link,#tool_make_link_multi', fn: makeHyperlink, evt: 'click' }, { sel: '#tool_undo', fn: clickUndo, evt: 'click' }, { sel: '#tool_redo', fn: clickRedo, evt: 'click' }, { sel: '#tool_clone,#tool_clone_multi', fn: clickClone, evt: 'click', key: ['D', true] }, { sel: '#tool_group_elements', fn: clickGroup, evt: 'click', key: ['G', true] }, { sel: '#tool_ungroup', fn: clickGroup, evt: 'click' }, { sel: '#tool_unlink_use', fn: clickGroup, evt: 'click' }, { sel: '[id^=tool_align]', fn: clickAlign, evt: 'click' },
+ evt: 'mouseup' }, { sel: '#tool_delete,#tool_delete_multi', fn: deleteSelected,
+ evt: 'click', key: ['del/backspace', true] }, { sel: '#tool_reorient', fn: reorientPath, evt: 'click' }, { sel: '#tool_node_link', fn: linkControlPoints, evt: 'click' }, { sel: '#tool_node_clone', fn: clonePathNode, evt: 'click' }, { sel: '#tool_node_delete', fn: deletePathNode, evt: 'click' }, { sel: '#tool_openclose_path', fn: opencloseSubPath, evt: 'click' }, { sel: '#tool_add_subpath', fn: addSubPath, evt: 'click' }, { sel: '#tool_move_top', fn: moveToTopSelected, evt: 'click', key: 'ctrl+shift+]' }, { sel: '#tool_move_bottom', fn: moveToBottomSelected, evt: 'click', key: 'ctrl+shift+[' }, { sel: '#tool_topath', fn: convertToPath$$1, evt: 'click' }, { sel: '#tool_make_link,#tool_make_link_multi', fn: makeHyperlink, evt: 'click' }, { sel: '#tool_undo', fn: clickUndo, evt: 'click' }, { sel: '#tool_redo', fn: clickRedo, evt: 'click' }, { sel: '#tool_clone,#tool_clone_multi', fn: clickClone, evt: 'click', key: ['D', true] }, { sel: '#tool_group_elements', fn: clickGroup, evt: 'click', key: ['G', true] }, { sel: '#tool_ungroup', fn: clickGroup, evt: 'click' }, { sel: '#tool_unlink_use', fn: clickGroup, evt: 'click' }, { sel: '[id^=tool_align]', fn: clickAlign, evt: 'click' },
// these two lines are required to make Opera work properly with the flyout mechanism
// {sel: '#tools_rect_show', fn: clickRect, evt: 'click'},
// {sel: '#tools_ellipse_show', fn: clickEllipse, evt: 'click'},
@@ -30179,6 +30247,10 @@ editor.init = function () {
};
return {
+ /** @lends module:SVGEditor~Actions */
+ /**
+ * @returns {undefined}
+ */
setAll: function setAll() {
var flyouts = {};
@@ -30203,8 +30275,10 @@ editor.init = function () {
if (!fH.length) {
fH = makeFlyoutHolder(opts.parent.substr(1));
}
-
- fH.append(btn);
+ if (opts.prepend) {
+ btn[0].style.margin = 'initial';
+ }
+ fH[opts.prepend ? 'prepend' : 'append'](btn);
if (!Array.isArray(flyouts[opts.parent])) {
flyouts[opts.parent] = [];
@@ -30281,6 +30355,10 @@ editor.init = function () {
$$b('#tool_zoom').dblclick(dblclickZoom);
},
+
+ /**
+ * @returns {undefined}
+ */
setTitles: function setTitles() {
$$b.each(keyAssocs, function (keyval, sel) {
var menu = $$b(sel).parents('#main_menu').length;
@@ -30311,20 +30389,19 @@ editor.init = function () {
});
});
},
+
+ /**
+ * @param {string} sel Selector to match
+ * @returns {module:SVGEditor.ToolButton}
+ */
getButtonData: function getButtonData(sel) {
- var b = void 0;
- $$b.each(toolButtons, function (i, btn) {
- if (btn.sel === sel) {
- b = btn;
- }
+ return Object.values(toolButtons).find(function (btn) {
+ return btn.sel === sel;
});
- return b;
}
};
}();
- Actions.setAll();
-
// Select given tool
editor.ready(function () {
var tool = void 0;
@@ -30917,9 +30994,9 @@ var messageQueue = [];
* @fires module:svgcanvas.SvgCanvas#event:message
* @returns {undefined}
*/
-var messageListener = function messageListener(_ref11) {
- var data = _ref11.data,
- origin = _ref11.origin;
+var messageListener = function messageListener(_ref15) {
+ var data = _ref15.data,
+ origin = _ref15.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = { data: data, origin: origin };
diff --git a/dist/index-es.min.js b/dist/index-es.min.js
index 97c36a76..75fbbde3 100644
--- a/dist/index-es.min.js
+++ b/dist/index-es.min.js
@@ -1,2 +1,2 @@
-function touchHandler(e){var t=e.changedTouches,n=t[0],a="";switch(e.type){case"touchstart":a="mousedown";break;case"touchmove":a="mousemove";break;case"touchend":a="mouseup";break;default:return}var r=n.screenX,i=n.screenY,o=n.clientX,s=n.clientY,l=new MouseEvent(a,{bubbles:!0,cancelable:!0,view:window,detail:1,screenX:r,screenY:i,clientX:o,clientY:s,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null});t.length<2&&(n.target.dispatchEvent(l),e.preventDefault())}document.addEventListener("touchstart",touchHandler,!0),document.addEventListener("touchmove",touchHandler,!0),document.addEventListener("touchend",touchHandler,!0),document.addEventListener("touchcancel",touchHandler,!0);var _typeof="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},asyncToGenerator=function(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function a(r,i){try{var o=t[r](i),s=o.value}catch(e){return void n(e)}if(!o.done)return Promise.resolve(s).then(function(e){a("next",e)},function(e){a("throw",e)});e(s)}("next")})}},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var n=0;n
t.getTotalLength())break;n--}while(n>0);return n}),window.SVGPathSeg=e,window.SVGPathSegClosePath=t,window.SVGPathSegMovetoAbs=n,window.SVGPathSegMovetoRel=a,window.SVGPathSegLinetoAbs=r,window.SVGPathSegLinetoRel=i,window.SVGPathSegCurvetoCubicAbs=o,window.SVGPathSegCurvetoCubicRel=s,window.SVGPathSegCurvetoQuadraticAbs=l,window.SVGPathSegCurvetoQuadraticRel=c,window.SVGPathSegArcAbs=u,window.SVGPathSegArcRel=d,window.SVGPathSegLinetoHorizontalAbs=h,window.SVGPathSegLinetoHorizontalRel=g,window.SVGPathSegLinetoVerticalAbs=p,window.SVGPathSegLinetoVerticalRel=f,window.SVGPathSegCurvetoCubicSmoothAbs=v,window.SVGPathSegCurvetoCubicSmoothRel=m,window.SVGPathSegCurvetoQuadraticSmoothAbs=_,window.SVGPathSegCurvetoQuadraticSmoothRel=b}if(!("SVGPathSegList"in window&&"appendItem"in SVGPathSegList.prototype)){var y=function(){function e(t){classCallCheck(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 createClass(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,n=function(){function e(){classCallCheck(this,e),this.pathSegList=[]}return createClass(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),a=function(){function e(t){classCallCheck(this,e),this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return createClass(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="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,n=1,a=0,r=1,i=1,o=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex"9")&&"."!==this._string.charAt(this._currentIndex))){for(var s=this._currentIndex;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!==s)for(var l=this._currentIndex-1,c=1;l>=s;)t+=c*(this._string.charAt(l--)-"0"),c*=10;if(this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)n*=10,a+=(this._string.charAt(this._currentIndex)-"0")/n,this._currentIndex+=1}if(this._currentIndex!==o&&this._currentIndex+1=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)e*=10,e+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var u=t+a;if(u*=r,e&&(u*=Math.pow(10,i*e)),o!==this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),u}}},{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],n=this._pathSegTypeFromChar(e);if(n===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if((n=this._nextCommandHelper(e,this._previousCommand))===SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=n,n){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 a={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(t,a.x,a.y,a.x1,a.y1,a.x2,a.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var r={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(t,r.x,r.y,r.x1,r.y1,r.x2,r.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:var i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(t,i.x,i.y,i.x2,i.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:var o={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(t,o.x,o.y,o.x2,o.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var s={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(t,s.x,s.y,s.x1,s.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:var l={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(t,l.x,l.y,l.x1,l.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 c={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,c.x,c.y,c.x1,c.y1,c.arcAngle,c.arcLarge,c.arcSweep);case SVGPathSeg.PATHSEG_ARC_ABS:var u={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,u.x,u.y,u.x1,u.y1,u.arcAngle,u.arcLarge,u.arcSweep);default:throw new Error("Unknown path seg type.")}}}]),e}(),r=new n,i=new a(e);if(!i.initialCommandIsMoveTo())return[];for(;i.hasMoreData();){var o=i.parseSegment();if(!o)return[];r.appendSegment(o)}return r.pathSegList}}]),e}();y.prototype.classname="SVGPathSegList",Object.defineProperty(y.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),y._pathSegArrayAsString=function(e){var t="",n=!0;return e.forEach(function(e){n?(n=!1,t+=e._asPathString()):t+=" "+e._asPathString()}),t},Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get:function(){return this._pathSegList||(this._pathSegList=new y(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=y}}();var $=jQuery,supportsSVG_=!!document.createElementNS&&!!document.createElementNS(NS.SVG,"svg").createSVGRect,_navigator=navigator,userAgent=_navigator.userAgent,svg=document.createElementNS(NS.SVG,"svg"),isOpera_=!!window.opera,isWebkit_=userAgent.includes("AppleWebKit"),isGecko_=userAgent.includes("Gecko/"),isIE_=userAgent.includes("MSIE"),isChrome_=userAgent.includes("Chrome/"),isWindows_=userAgent.includes("Windows"),isMac_=userAgent.includes("Macintosh"),isTouch_="ontouchstart"in window,supportsSelectors_=!!svg.querySelector,supportsXpath_=!!document.evaluate,supportsPathReplaceItem_=function(){var e=document.createElementNS(NS.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.replaceItem(n,1),!0}catch(e){}return!1}(),supportsPathInsertItemBefore_=function(){var e=document.createElementNS(NS.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.insertItemBefore(n,1),!0}catch(e){}return!1}(),supportsGoodTextCharPos_=function(){var e=document.createElementNS(NS.SVG,"svg"),t=document.createElementNS(NS.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var n=document.createElementNS(NS.SVG,"text");n.textContent="a",t.append(n);var a=n.getStartPositionOfChar(0).x;return e.remove(),0===a}(),supportsPathBBox_=function(){var e=document.createElementNS(NS.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(NS.SVG,"path");t.setAttribute("d","M0,0 C0,0 10,10 10,0"),e.append(t);var n=t.getBBox();return e.remove(),n.height>4&&n.height<5}(),supportsHVLineContainerBBox_=function(){var e=document.createElementNS(NS.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(NS.SVG,"path");t.setAttribute("d","M0,0 10,0");var n=document.createElementNS(NS.SVG,"path");n.setAttribute("d","M5,0 15,0");var a=document.createElementNS(NS.SVG,"g");a.append(t,n),e.append(a);var r=a.getBBox();return e.remove(),15===r.width}(),supportsGoodDecimals_=function(){var e=document.createElementNS(NS.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");return t||$.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the latest version in which the problems have been fixed.'),t}(),supportsNonScalingStroke_=function(){var e=document.createElementNS(NS.SVG,"rect");return e.setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===e.style.vectorEffect}(),supportsNativeSVGTransformLists_=function(){var e=document.createElementNS(NS.SVG,"rect").transform.baseVal,t=svg.createSVGTransform();e.appendItem(t);var n=e.getItem(0);return n instanceof SVGTransform&&t instanceof SVGTransform&&n.type===t.type&&n.angle===t.angle&&n.matrix.a===t.matrix.a&&n.matrix.b===t.matrix.b&&n.matrix.c===t.matrix.c&&n.matrix.d===t.matrix.d&&n.matrix.e===t.matrix.e&&n.matrix.f===t.matrix.f}(),isOpera=function(){return isOpera_},isWebkit=function(){return isWebkit_},isGecko=function(){return isGecko_},isIE=function(){return isIE_},isChrome=function(){return isChrome_},isMac=function(){return isMac_},isTouch=function(){return isTouch_},supportsSelectors=function(){return supportsSelectors_},supportsXpath=function(){return supportsXpath_},supportsPathReplaceItem=function(){return supportsPathReplaceItem_},supportsPathInsertItemBefore=function(){return supportsPathInsertItemBefore_},supportsPathBBox=function(){return supportsPathBBox_},supportsHVLineContainerBBox=function(){return supportsHVLineContainerBBox_},supportsGoodTextCharPos=function(){return supportsGoodTextCharPos_},supportsNonScalingStroke=function(){return supportsNonScalingStroke_},supportsNativeTransformLists=function(){return supportsNativeSVGTransformLists_};function jqPluginSVG(e){var t=e.fn.attr;return e.fn.attr=function(e,n){var a=this.length;if(!a)return t.apply(this,arguments);for(var r=0;r=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 n=null;if(t>=0)if(t=0&&(this._removeFromOtherLists(e),this._xforms[t]=e,n=e,this._list._update()),n}},{key:"removeItem",value:function(e){if(e=0){var t=this._xforms[e],n=new Array(this.numberOfItems-1),a=void 0;for(a=0;a=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var n=this.stack[t].elements(),a=n.length;a--;)e.includes(n[a])||e.push(n[a]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),t}();BatchCommand.type=BatchCommand.prototype.type;var UndoManager=function(){function e(t){classCallCheck(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return createClass(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.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}},{key:"redo",value:function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}},{key:"addCommandToHistory",value:function(e){this.undoStackPointer0&&(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 n=++this.undoChangeStackPointer,a=t.length,r=new Array(a),i=new Array(a);a--;){var o=t[a];null!=o&&(i[a]=o,r[a]=o.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:r,elements:i}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],n=t.attrName,a=new BatchCommand("Change "+n),r=t.elements.length;r--;){var i=t.elements[r];if(null!=i){var o={};o[n]=t.oldValues[r],o[n]!==i.getAttribute(n)&&a.addSubCommand(new ChangeElementCommand(i,o,n))}}return this.undoableChangeStack[e]=null,a}}]),e}(),history=Object.freeze({HistoryEventTypes:HistoryEventTypes,MoveElementCommand:MoveElementCommand,InsertElementCommand:InsertElementCommand,RemoveElementCommand:RemoveElementCommand,ChangeElementCommand:ChangeElementCommand,BatchCommand:BatchCommand,UndoManager:UndoManager}),NEAR_ZERO=1e-14,svg$1=document.createElementNS(NS.SVG,"svg"),transformPoint=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},isIdentity=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},matrixMultiply=function(){for(var e=arguments.length,t=Array(e),n=0;n(n=parseInt(n,10))){var a=n;n=t,t=a}for(var r=svg$1.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},$$1=jQuery,segData={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"]},uiStrings={},setUiStrings=function(e){Object.assign(uiStrings,e.ui)},pathFuncs=[],linkControlPts=!0,pathData={},setLinkControlPoints=function(e){linkControlPts=e},path=null,editorContext_=null,init$1=function(e){editorContext_=e,pathFuncs=[0,"ClosePath"];$$1.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(e,t){pathFuncs.push(t+"Abs"),pathFuncs.push(t+"Rel")})},insertItemBefore=function(e,t,n){var a=e.pathSegList;if(supportsPathInsertItemBefore())a.insertItemBefore(t,n);else{for(var r=a.numberOfItems,i=[],o=0;o0?(f=g element");this.elem=t,this.segs=[],this.selected_pts=[],path=this,this.init()}return createClass(e,[{key:"init",value:function(){$$1(getGripContainer()).find("*").each(function(){$$1(this).attr("display","none")});var e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(var n=0;n=t?null:i[s+1],u=s-1<0?null:i[s-1];if(2===l.type){if(u&&1!==u.type){var d=i[o];d.next=i[o+1],d.next.prev=d,d.addGrip()}o=s}else if(c&&1===c.type)l.next=i[o+1],l.next.prev=l,l.mate=i[o],l.addGrip(),null==this.first_seg&&(this.first_seg=l);else if(c)1!==l.type&&(l.addGrip(),c&&2!==c.type&&(l.next=c,l.next.prev=l));else if(1!==l.type){var h=i[o];h.next=i[o+1],h.next.prev=h,h.addGrip(),l.addGrip(),this.first_seg||(this.first_seg=i[o])}}return this}},{key:"eachSeg",value:function(e){for(var t=this.segs.length,n=0;n=0&&this.selected_pts.push(n)}this.selected_pts.sort();var a=this.selected_pts.length,r=[];for(r.length=a;a--;){var i=this.selected_pts[a],o=this.segs[i];o.select(!0),r[a]=o.ptgrip}var s=this.subpathIsClosed(this.selected_pts[0]);editorContext_.addPtsToSelection({grips:r,closedSubpath:s})}}]),e}(),getPath_=function(e){var t=pathData[e.id];return t||(t=pathData[e.id]=new Path(e)),t},removePath_=function(e){e in pathData&&delete pathData[e]},newcx=void 0,newcy=void 0,oldcx=void 0,oldcy=void 0,angle=void 0,getRotVals=function(e,t){var n=e-oldcx,a=t-oldcy,r=Math.sqrt(n*n+a*a),i=Math.atan2(a,n)+angle;return n=r*Math.cos(i)+oldcx,a=r*Math.sin(i)+oldcy,n-=newcx,a-=newcy,r=Math.sqrt(n*n+a*a),i=Math.atan2(a,n)-angle,{x:r*Math.cos(i)+newcx,y:r*Math.sin(i)+newcy}},recalcRotatedPath=function(){var e=path.elem;if(angle=getRotationAngle(e,!0)){var t=path.oldbbox;oldcx=t.x+t.width/2,oldcy=t.y+t.height/2;var n=getBBox(e);newcx=n.x+n.width/2,newcy=n.y+n.height/2;var a=newcx-oldcx,r=newcy-oldcy,i=Math.sqrt(a*a+r*r),o=Math.atan2(r,a)+angle;newcx=i*Math.cos(o)+oldcx,newcy=i*Math.sin(o)+oldcy;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=getRotVals(c.x,c.y),h=[d.x,d.y];if(null!=c.x1&&null!=c.x2){var g=getRotVals(c.x1,c.y1),p=getRotVals(c.x2,c.y2);h.splice(h.length,0,g.x,g.y,p.x,p.y)}replacePathSeg(u,l,h)}}n=getBBox(e);var f=editorContext_.getSVGRoot().createSVGTransform(),v=getTransformList(e);f.setRotate(180*angle/Math.PI,newcx,newcy),v.replaceItem(f,0)}},clearData=function(){pathData={}},reorientGrads=function(e,t){for(var n=getBBox(e),a=0;a<2;a++){var r=0===a?"fill":"stroke",i=e.getAttribute(r);if(i&&i.startsWith("url(")){var o=getRefElem(i);if("linearGradient"===o.tagName){var s=o.getAttribute("x1")||0,l=o.getAttribute("y1")||0,c=o.getAttribute("x2")||1,u=o.getAttribute("y2")||0;s=n.width*s+n.x,l=n.height*l+n.y,c=n.width*c+n.x,u=n.height*u+n.y;var d=transformPoint(s,l,t),h=transformPoint(c,u,t),g={};g.x1=(d.x-n.x)/n.width,g.y1=(d.y-n.y)/n.height,g.x2=(h.x-n.x)/n.width,g.y2=(h.y-n.y)/n.height;var p=o.cloneNode(!0);$$1(p).attr(g),p.id=editorContext_.getNextId(),findDefs().append(p),e.setAttribute(r,"url(#"+p.id+")")}}}},pathMap=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],convertPath=function(e,t){for(var n=e.pathSegList,a=n.numberOfItems,r=0,i=0,o="",s=null,l=0;l=k-S&&v<=k+S&&m>=A-S&&m<=A+S){w=!0;break}}o=editorContext_.getId(),removePath_(o);var E=getElem(o),P=void 0,T=void 0,G=x.numberOfItems;if(w){if(C<=1&&G>=2){var N=x.getItem(0).x,L=x.getItem(0).y;P=4===(T=_.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(N,L):y.createSVGPathSegCurvetoCubicAbs(N,L,T.x1/f,T.y1/f,N,L);var I=y.createSVGPathSegClosePath();x.appendItem(P),x.appendItem(I)}else if(G<3)return!1;if($$1(_).remove(),y=editorContext_.setDrawnPath(null),editorContext_.setStarted(!1),e){path.matrix&&editorContext_.remapElement(E,{},path.matrix.inverse());var M=E.getAttribute("d"),R=$$1(path.elem).attr("d");return $$1(path.elem).attr("d",R+M),$$1(E).remove(),path.matrix&&recalcRotatedPath(),init$1(),pathActions.toEditMode(path.elem),path.selectPt(),!1}}else{if(!$$1.contains(editorContext_.getContainer(),editorContext_.getMouseTarget(n)))return console.log("Clicked outside canvas"),!1;var O=y.pathSegList.numberOfItems,V=y.pathSegList.getItem(O-1),B=V.x,j=V.y;if(n.shiftKey){var D=snapToAngle(B,j,v,m);v=D.x,m=D.y}P=4===(T=_.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(editorContext_.round(v),editorContext_.round(m)):y.createSVGPathSegCurvetoCubicAbs(editorContext_.round(v),editorContext_.round(m),T.x1/f,T.y1/f,T.x2/f,T.y2/f),y.pathSegList.appendItem(P),v*=f,m*=f,_.setAttribute("d",["M",v,m,v,m].join(" ")),b=O,e&&(b+=path.segs.length),addPointGrip(b,v,m)}}else{var F="M"+v+","+m+" ";y=editorContext_.setDrawnPath(editorContext_.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:F,id:editorContext_.getNextId(),opacity:editorContext_.getOpacity()/2}})),_.setAttribute("d",["M",g,p,g,p].join(" ")),b=e?path.segs.length:0,addPointGrip(b,g,p)}}},mouseMove:function(e,a){var i=editorContext_.getCurrentZoom();r=!0;var o=editorContext_.getDrawnPath();if("path"!==editorContext_.getCurrentMode())if(path.dragging){var s=getPointFromGrip({x:path.dragging[0],y:path.dragging[1]},path),l=getPointFromGrip({x:e,y:a},path),c=l.x-s.x,u=l.y-s.y;path.dragging=[e,a],path.dragctrl?path.moveCtrl(c,u):path.movePts(c,u)}else path.selected_pts=[],path.eachSeg(function(e){if(this.next||this.prev){var t=editorContext_.getRubberBox().getBBox(),n=getGripPt(this),a={x:n.x,y:n.y,width:0,height:0},r=rectsIntersect(t,a);this.select(r),r&&path.selected_pts.push(this.index)}});else{if(!o)return;var d=o.pathSegList,h=d.numberOfItems-1;if(t){var g=addCtrlGrip("1c1"),p=addCtrlGrip("0c2");g.setAttribute("cx",e),g.setAttribute("cy",a),g.setAttribute("display","inline");var f=t[0],v=t[1],m=f+(f-e/i),_=v+(v-a/i);p.setAttribute("cx",m*i),p.setAttribute("cy",_*i),p.setAttribute("display","inline");var b=getCtrlLine(1);if(assignAttributes(b,{x1:e,y1:a,x2:m*i,y2:_*i,display:"inline"}),0===h)n=[e,a];else{var y=d.getItem(h-1),x=y.x,C=y.y;6===y.pathSegType?(x+=x-y.x2,C+=C-y.y2):n&&(x=n[0]/i,C=n[1]/i),replacePathSeg(6,h,[f,v,x,C,m,_],o)}}else{var S=getElem("path_stretch_line");if(S){var w=d.getItem(h);if(6===w.pathSegType){var $=w.x+(w.x-w.x2),k=w.y+(w.y-w.y2);replacePathSeg(6,1,[e,a,$*i,k*i,e,a],S)}else n?replacePathSeg(6,1,[e,a,n[0],n[1],e,a],S):replacePathSeg(4,1,[e,a],S)}}}},mouseUp:function(e,a,i,o){var s=editorContext_.getDrawnPath();if("path"===editorContext_.getCurrentMode())return t=null,s||(a=getElem(editorContext_.getId()),editorContext_.setStarted(!1),n=null),{keep:!0,element:a};var l=editorContext_.getRubberBox();if(path.dragging){var c=path.cur_pt;path.dragging=!1,path.dragctrl=!1,path.update(),r&&path.endChanges("Move path point(s)"),e.shiftKey||r||path.selectPt(c)}else l&&"none"!==l.getAttribute("display")?(l.setAttribute("display","none"),l.getAttribute("width")<=2&&l.getAttribute("height")<=2&&pathActions.toSelectMode(e.target)):pathActions.toSelectMode(e.target);r=!1},toEditMode:function(t){path=getPath_(t),editorContext_.setCurrentMode("pathedit"),editorContext_.clearSelection(),path.show(!0).update(),path.oldbbox=getBBox(path.elem),e=!1},toSelectMode:function(e){var t=e===path.elem;editorContext_.setCurrentMode("select"),path.show(!1),a=!1,editorContext_.clearSelection(),path.matrix&&recalcRotatedPath(),t&&(editorContext_.call("selected",[e]),editorContext_.addToSelection([e],!0))},addSubPath:function(t){t?(editorContext_.setCurrentMode("path"),e=!0):(pathActions.clear(!0),pathActions.toEditMode(path.elem))},select:function(e){a===e?(pathActions.toEditMode(e),editorContext_.setCurrentMode("pathedit")):a=e},reorient:function(){var e=editorContext_.getSelectedElements()[0];if(e&&0!==getRotationAngle(e)){var t=new BatchCommand("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new ChangeElementCommand(e,n)),editorContext_.clearSelection(),this.resetOrientation(e),editorContext_.addCommandToHistory(t),getPath_(e).show(!1).matrix=null,this.clear(),editorContext_.addToSelection([e],!0),editorContext_.call("changed",editorContext_.getSelectedElements())}},clear:function(e){var t=editorContext_.getDrawnPath();if(a=null,t){var r=getElem(editorContext_.getId());$$1(getElem("path_stretch_line")).remove(),$$1(r).remove(),$$1(getElem("pathpointgrip_container")).find("*").attr("display","none"),n=null,editorContext_.setDrawnPath(null),editorContext_.setStarted(!1)}else"pathedit"===editorContext_.getCurrentMode()&&this.toSelectMode();path&&path.init().show(!1)},resetOrientation:function(e){if(null==e||"path"!==e.nodeName)return!1;var t=getTransformList(e),n=transformListToTransform(t).matrix;t.clear(),e.removeAttribute("transform");for(var a=e.pathSegList,r=a.numberOfItems,i=function(t){var r=a.getItem(t),i=r.pathSegType;if(1===i)return"continue";var o=[];$$1.each(["",1,2],function(e,t){var a=r["x"+t],i=r["y"+t];if(void 0!==a&&void 0!==i){var s=transformPoint(a,i,n);o.splice(o.length,0,s.x,s.y)}}),replacePathSeg(i,t,o,e)},o=0;o0){var s=t.getItem(n-1).pathSegType;if(2===s){a(n-1,1),e();break}if(1===s&&t.numberOfItems-1===n){a(n,1),e();break}}}return!1}(),path.elem.pathSegList.numberOfItems<=1)return pathActions.toSelectMode(path.elem),void editorContext_.canvas.deleteSelectedElements();if(path.init(),path.clearSelection(),window.opera){var a=$$1(path.elem);a.attr("d",a.attr("d"))}path.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t=void 0,n=e.points,a=n.numberOfItems;if(a>=4){var r=n.getItem(0),i=null,o=[];for(o.push(["M",r.x,",",r.y," C"].join("")),t=1;t<=a-4;t+=3){var s=n.getItem(t),l=n.getItem(t+1),c=n.getItem(t+2);if(i){var u=smoothControlPoints(i,s,r);if(u&&2===u.length){var d=o[o.length-1].split(",");d[2]=u[0].x,d[3]=u[0].y,o[o.length-1]=d.join(","),s=u[1]}}o.push([s.x,s.y,l.x,l.y,c.x,c.y].join(",")),r=c,i=l}for(o.push("L");t/g,">").replace(/"/g,""").replace(/'/,"'")},encode64=function(e){if(e=encodeUTF8(e),window.btoa)return window.btoa(e);var t=[];t.length=4*Math.floor((e.length+2)/3);var n=0,a=0;do{var r=e.charCodeAt(n++),i=e.charCodeAt(n++),o=e.charCodeAt(n++),s=r>>2,l=(3&r)<<4|i>>4,c=(15&i)<<2|o>>6,u=63&o;isNaN(i)?c=u=64:isNaN(o)&&(u=64),t[a++]=KEYSTR.charAt(s),t[a++]=KEYSTR.charAt(l),t[a++]=KEYSTR.charAt(c),t[a++]=KEYSTR.charAt(u)}while(n>4,l=(15&r)<<4|i>>2,c=(3&i)<<6|o;t+=String.fromCharCode(s),64!==i&&(t+=String.fromCharCode(l)),64!==o&&(t+=String.fromCharCode(c))}while(nSVG-edit