diff --git a/dist/extensions/ext-connector.js b/dist/extensions/ext-connector.js index 27df4c92..69fcca25 100644 --- a/dist/extensions/ext-connector.js +++ b/dist/extensions/ext-connector.js @@ -597,15 +597,16 @@ var svgEditorExtension_connector = (function () { }, elementChanged: function elementChanged(opts) { var elem = opts.elems[0]; + if (!elem) return; - if (elem && elem.tagName === 'svg' && elem.id === 'svgcontent') { + if (elem.tagName === 'svg' && elem.id === 'svgcontent') { // Update svgcontent (can change on import) svgcontent = elem; init(); } // Has marker, so change offset - if (elem && (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end'))) { + if (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end')) { var start = elem.getAttribute('marker-start'); var mid = elem.getAttribute('marker-mid'); var end = elem.getAttribute('marker-end'); diff --git a/dist/extensions/imagelib/openclipart.js b/dist/extensions/imagelib/openclipart.js index 94299bfc..3206b4c2 100644 --- a/dist/extensions/imagelib/openclipart.js +++ b/dist/extensions/imagelib/openclipart.js @@ -2570,13 +2570,15 @@ }); function _typeof$1(obj) { - if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") { - _typeof$1 = function _typeof$1(obj) { - return _typeof(obj); + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof$1 = function _typeof(obj) { + return typeof obj; }; } else { - _typeof$1 = function _typeof$1(obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj); + _typeof$1 = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } @@ -2584,21 +2586,15 @@ } function _slicedToArray$1(arr, i) { - return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _nonIterableRest$1(); + return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1(); } function _toConsumableArray$1(arr) { - return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _nonIterableSpread$1(); + return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1(); } function _arrayWithoutHoles$1(arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { - arr2[i] = arr[i]; - } - - return arr2; - } + if (Array.isArray(arr)) return _arrayLikeToArray$1(arr); } function _arrayWithHoles$1(arr) { @@ -2606,14 +2602,11 @@ } function _iterableToArray$1(iter) { - if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } function _iterableToArrayLimit$1(arr, i) { - if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { - return; - } - + if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; @@ -2639,12 +2632,31 @@ return _arr; } + function _unsupportedIterableToArray$1(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); + } + + function _arrayLikeToArray$1(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) { + arr2[i] = arr[i]; + } + + return arr2; + } + function _nonIterableSpread$1() { - throw new TypeError("Invalid attempt to spread non-iterable instance"); + 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 _nonIterableRest$1() { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); + 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 convertToString(content, type) { @@ -2733,7 +2745,8 @@ case 'string': { - var div = document.createElement('div'); + var div = document.createElement('div'); // eslint-disable-next-line no-unsanitized/property + div.innerHTML = content; return div.firstElementChild || div.firstChild; } diff --git a/dist/index-es.js b/dist/index-es.js index 875050e7..15e90a7b 100644 --- a/dist/index-es.js +++ b/dist/index-es.js @@ -4117,7 +4117,7 @@ var InsertElementCommand = /*#__PURE__*/function (_Command2) { } this.parent = this.elem.parentNode; - this.elem = this.elem.remove(); + this.elem.remove(); if (handler) { handler.handleHistoryEvent(HistoryEventTypes.AFTER_UNAPPLY, this); @@ -4194,7 +4194,7 @@ var RemoveElementCommand = /*#__PURE__*/function (_Command3) { removeElementFromListMap(this.elem); this.parent = this.elem.parentNode; - this.elem = this.elem.remove(); + this.elem.remove(); if (handler) { handler.handleHistoryEvent(HistoryEventTypes.AFTER_APPLY, this); @@ -10250,7 +10250,8 @@ var Layer = /*#__PURE__*/function () { }, { key: "removeGroup", value: function removeGroup() { - var group = this.group_.remove(); + var group = this.group_; + this.group_.remove(); this.group_ = undefined; return group; } @@ -14223,7 +14224,7 @@ function SvgCanvas(container, config) { restoreRefElems(cmd.elem); } - if (cmd.elem.tagName === 'use') { + if (cmd.elem && cmd.elem.tagName === 'use') { setUseData(cmd.elem); } } else if (cmdType === ChangeElementCommand$1.type()) { @@ -14428,10 +14429,8 @@ function SvgCanvas(container, config) { call('selected', selectedElements); - if (showGrips || selectedElements.length === 1) { - selectorManager.requestSelector(selectedElements[0]).showGrips(true); - } else { - selectorManager.requestSelector(selectedElements[0]).showGrips(false); + if (selectedElements.length === 1) { + selectorManager.requestSelector(selectedElements[0]).showGrips(showGrips); } // make sure the elements are in the correct order // See: https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-compareDocumentPosition @@ -16945,12 +16944,7 @@ function SvgCanvas(container, config) { var dblClick = function dblClick(evt) { var evtTarget = evt.target; - var parent = evtTarget.parentNode; // Do nothing if already in current group - - if (parent === currentGroup) { - return; - } - + var parent = evtTarget.parentNode; var mouseTarget = getMouseTarget(evt); var _mouseTarget = mouseTarget, tagName = _mouseTarget.tagName; @@ -16958,6 +16952,11 @@ function SvgCanvas(container, config) { if (tagName === 'text' && currentMode !== 'textedit') { var pt = transformPoint(evt.pageX, evt.pageY, rootSctm); textActions.select(mouseTarget, pt.x, pt.y); + } // Do nothing if already in current group + + + if (parent === currentGroup) { + return; } if ((tagName === 'g' || tagName === 'a') && getRotationAngle(mouseTarget)) { diff --git a/dist/index-es.min.js b/dist/index-es.min.js index e7e4d795..eec3ef25 100644 --- a/dist/index-es.min.js +++ b/dist/index-es.min.js @@ -10,13 +10,13 @@ var y={HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/Mat * @module jQueryAttr * @license MIT */ -function W(t){var n=t.fn.attr;return t.fn.attr=function(t,r){var a=this.length;if(!a)return n.call(this,t,r);for(var i=0;i=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,n=this._xforms[e],r=new Array(this.numberOfItems-1);for(t=0;t=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(de.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var n=this.stack[t].elements(),r=n.length;r--;)e.includes(n[r])||e.push(n[r]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),n}();ve.type=ve.prototype.type;var ye,_e,be,xe,we,Se=function(){function e(t){r(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return i(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,r=t.length,a=new Array(r),i=new Array(r);r--;){var o=t[r];sn(o)||(i[r]=o,a[r]=o.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:a,elements:i}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],n=t.attrName,r=new ve("Change "+n),a=t.elements.length;a--;){var i=t.elements[a];if(!sn(i)){var o={};o[n]=t.oldValues[a],o[n]!==i.getAttribute(n)&&r.addSubCommand(new me(i,o,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),ke=Object.freeze({__proto__:null,HistoryEventTypes:de,MoveElementCommand:fe,InsertElementCommand:pe,RemoveElementCommand:ge,ChangeElementCommand:me,BatchCommand:ve,UndoManager:Se}),Ce=document.createElementNS(y.SVG,"svg"),Ae=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Ee=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},Ge=function(){for(var e=arguments.length,t=new Array(e),n=0;n(n=Number.parseInt(n))){var r=n;n=t,t=r}for(var a=Ce.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},Oe=jQuery,je={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"]},Ve={},Re=function(e){Object.assign(Ve,e.ui)},Be=[],Ue=!0,Fe={},De=null,He=null,ze=function(e){He=e,Be=[0,"ClosePath"];Oe.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){Be.push(t+"Abs"),Be.push(t+"Rel")}))},qe=function(e,t,n){var r=e.pathSegList;if(M)r.insertItemBefore(t,n);else{for(var a=r.numberOfItems,i=[],o=0;o0?(f=g element");this.elem=t,this.segs=[],this.selected_pts=[],De=this,this.init()}return i(e,[{key:"init",value:function(){Oe(Ke()).find("*").each((function(){Oe(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(),sn(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&&n.selected_pts.push(e)})),this.selected_pts.sort();var r=this.selected_pts.length,a=[];for(a.length=r;r--;){var i=this.selected_pts[r],o=this.segs[i];o.select(!0),a[r]=o.ptgrip}var s=e.subpathIsClosed(this.selected_pts[0]);He.addPtsToSelection({grips:a,closedSubpath:s})}}],[{key:"subpathIsClosed",value:function(e){var t=!1;return De.eachSeg((function(n){return n<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}]),e}(),it=function(e){var t=Fe[e.id];return t||(t=Fe[e.id]=new at(e)),t},ot=function(e){e in Fe&&delete Fe[e]},st=function(e,t){var n=e-be,r=t-xe,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+we;return n=a*Math.cos(i)+be,r=a*Math.sin(i)+xe,n-=ye,r-=_e,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-we,{x:a*Math.cos(i)+ye,y:a*Math.sin(i)+_e}},lt=function(){var e=De.elem;if(we=Jt(e,!0)){var t=De.oldbbox;be=t.x+t.width/2,xe=t.y+t.height/2;var n=Dt(e);ye=n.x+n.width/2,_e=n.y+n.height/2;var r=ye-be,a=_e-xe,i=Math.sqrt(r*r+a*a),o=Math.atan2(a,r)+we;ye=i*Math.cos(o)+be,_e=i*Math.sin(o)+xe;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=st(c.x,c.y),h=[d.x,d.y];if(!sn(c.x1)&&!sn(c.x2)){var f=st(c.x1,c.y1),p=st(c.x2,c.y2);h.splice(h.length,0,f.x,f.y,p.x,p.y)}et(u,l,h)}}Dt(e);var g=He.getSVGRoot().createSVGTransform(),m=ee(e);g.setRotate(180*we/Math.PI,ye,_e),m.replaceItem(g,0)}},ct=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],ut=function(e,t){for(var n=e.pathSegList,r=n.numberOfItems,a=0,i=0,o="",s=null,l=0;l=k-x&&f<=k+x&&p>=C-x&&p<=C+x){w=!0;break}}a=He.getId(),ot(a);var A,E,G=tn(a),P=_.numberOfItems;if(w){if(b<=1&&P>=2){var N=_.getItem(0).x,I=_.getItem(0).y;A=4===(E=g.pathSegList.getItem(1)).pathSegType?v.createSVGPathSegLinetoAbs(N,I):v.createSVGPathSegCurvetoCubicAbs(N,I,E.x1/u,E.y1/u,N,I);var T=v.createSVGPathSegClosePath();_.appendItem(A),_.appendItem(T)}else if(P<3)return!1;if(Oe(g).remove(),He.setDrawnPath(null),He.setStarted(!1),pt){De.matrix&&He.remapElement(G,{},De.matrix.inverse());var L=G.getAttribute("d"),M=Oe(De.elem).attr("d");return Oe(De.elem).attr("d",M+L),Oe(G).remove(),De.matrix&<(),ze(),vt.toEditMode(De.elem),De.selectPt(),!1}}else{if(!Oe.contains(He.getContainer(),He.getMouseTarget(e)))return!1;var O=v.pathSegList.numberOfItems,j=v.pathSegList.getItem(O-1),V=j.x,R=j.y;if(e.shiftKey){var B=Le(V,R,f,p);f=B.x,p=B.y}A=4===(E=g.pathSegList.getItem(1)).pathSegType?v.createSVGPathSegLinetoAbs(He.round(f),He.round(p)):v.createSVGPathSegCurvetoCubicAbs(He.round(f),He.round(p),E.x1/u,E.y1/u,E.x2/u,E.y2/u),v.pathSegList.appendItem(A),f*=u,p*=u,g.setAttribute("d",["M",f,p,f,p].join(" ")),m=O,pt&&(m+=De.segs.length),Qe(m,f,p)}}else{var U="M"+f+","+p+" ";He.setDrawnPath(He.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:U,id:He.getNextId(),opacity:He.getOpacity()/2}})),g.setAttribute("d",["M",d,h,d,h].join(" ")),m=pt?De.segs.length:0,Qe(m,d,h)}}},mouseMove:function(e,t){var n=He.getCurrentZoom();mt=!0;var r=He.getDrawnPath();if("path"!==He.getCurrentMode())if(De.dragging){var a=Xe({x:De.dragging[0],y:De.dragging[1]},De),i=Xe({x:e,y:t},De),o=i.x-a.x,s=i.y-a.y;De.dragging=[e,t],De.dragctrl?De.moveCtrl(o,s):De.movePts(o,s)}else De.selected_pts=[],De.eachSeg((function(e){if(this.next||this.prev){var t=He.getRubberBox().getBBox(),n=We(this),r={x:n.x,y:n.y,width:0,height:0},a=Me(t,r);this.select(a),a&&De.selected_pts.push(this.index)}}));else{if(!r)return;var l=r.pathSegList,c=l.numberOfItems-1;if(ht){var u=Ze("1c1"),d=Ze("0c2");u.setAttribute("cx",e),u.setAttribute("cy",t),u.setAttribute("display","inline");var h=ht[0],f=ht[1],p=h+(h-e/n),g=f+(f-t/n);d.setAttribute("cx",p*n),d.setAttribute("cy",g*n),d.setAttribute("display","inline");var m=$e(1);if(nn(m,{x1:e,y1:t,x2:p*n,y2:g*n,display:"inline"}),0===c)ft=[e,t];else{var v=l.getItem(c-1),y=v.x,_=v.y;6===v.pathSegType?(y+=y-v.x2,_+=_-v.y2):ft&&(y=ft[0]/n,_=ft[1]/n),et(6,c,[h,f,y,_,p,g],r)}}else{var b=tn("path_stretch_line");if(b){var x=l.getItem(c);if(6===x.pathSegType){var w=x.x+(x.x-x.x2),S=x.y+(x.y-x.y2);et(6,1,[e,t,w*n,S*n,e,t],b)}else ft?et(6,1,[e,t,ft[0],ft[1],e,t],b):et(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,r){var a=He.getDrawnPath();if("path"===He.getCurrentMode())return ht=null,a||(t=tn(He.getId()),He.setStarted(!1),ft=null),{keep:!0,element:t};var i=He.getRubberBox();if(De.dragging){var o=De.cur_pt;De.dragging=!1,De.dragctrl=!1,De.update(),mt&&De.endChanges("Move path point(s)"),e.shiftKey||mt||De.selectPt(o)}else i&&"none"!==i.getAttribute("display")?(i.setAttribute("display","none"),i.getAttribute("width")<=2&&i.getAttribute("height")<=2&&vt.toSelectMode(e.target)):vt.toSelectMode(e.target);mt=!1},toEditMode:function(e){De=it(e),He.setCurrentMode("pathedit"),He.clearSelection(),De.show(!0).update(),De.oldbbox=Dt(De.elem),pt=!1},toSelectMode:function(e){var t=e===De.elem;He.setCurrentMode("select"),De.show(!1),gt=!1,He.clearSelection(),De.matrix&<(),t&&(He.call("selected",[e]),He.addToSelection([e],!0))},addSubPath:function(e){e?(He.setCurrentMode("path"),pt=!0):(vt.clear(!0),vt.toEditMode(De.elem))},select:function(e){gt===e?(vt.toEditMode(e),He.setCurrentMode("pathedit")):gt=e},reorient:function(){var e=He.getSelectedElements()[0];if(e&&0!==Jt(e)){var t=new ve("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new me(e,n)),He.clearSelection(),this.resetOrientation(e),He.addCommandToHistory(t),it(e).show(!1).matrix=null,this.clear(),He.addToSelection([e],!0),He.call("changed",He.getSelectedElements())}},clear:function(e){var t=He.getDrawnPath();if(gt=null,t){var n=tn(He.getId());Oe(tn("path_stretch_line")).remove(),Oe(n).remove(),Oe(tn("pathpointgrip_container")).find("*").attr("display","none"),ft=null,He.setDrawnPath(null),He.setStarted(!1)}else"pathedit"===He.getCurrentMode()&&this.toSelectMode();De&&De.init().show(!1)},resetOrientation:function(e){if(sn(e)||"path"!==e.nodeName)return!1;var t=ee(e),n=Ie(t).matrix;t.clear(),e.removeAttribute("transform");for(var r=e.pathSegList,a=r.numberOfItems,i=function(t){var a=r.getItem(t),i=a.pathSegType;if(1===i)return"continue";var o=[];Oe.each(["",1,2],(function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var s=Ae(r,i,n);o.splice(o.length,0,s.x,s.y)}})),et(i,t,o,e)},o=0;o0){var s=t.getItem(n-1).pathSegType;if(2===s){r(n-1,1),e();break}if(1===s&&t.numberOfItems-1===n){r(n,1),e();break}}}return!1}(),De.elem.pathSegList.numberOfItems<=1)return vt.toSelectMode(De.elem),void He.canvas.deleteSelectedElements();if(De.init(),De.clearSelection(),window.opera){var r=Oe(De.elem);r.attr("d",r.attr("d"))}De.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t,n=e.points,r=n.numberOfItems;if(r>=4){var a=n.getItem(0),i=null,o=[];for(o.push(["M",a.x,",",a.y," C"].join("")),t=1;t<=r-4;t+=3){var s=n.getItem(t),l=n.getItem(t+1),c=n.getItem(t+2);if(i){var u=nt(i,s,a);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(",")),a=c,i=l}for(o.push("L");t)/,"$1$2")},At=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function Et(e){if(e=Nt(e),window.btoa)return window.btoa(e);var t=new Array(4*Math.floor((e.length+2)/3)),n=0,r=0;do{var a=e.charCodeAt(n++),i=e.charCodeAt(n++),o=e.charCodeAt(n++),s=a>>2,l=(3&a)<<4|i>>4,c=(15&i)<<2|o>>6,u=63&o;Number.isNaN(i)?(c=64,u=64):Number.isNaN(o)&&(u=64),t[r++]=_t.charAt(s),t[r++]=_t.charAt(l),t[r++]=_t.charAt(c),t[r++]=_t.charAt(u)}while(n>4,l=(15&a)<<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 "],{type:"text/html"});return Tt(e)}(),Mt=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(y.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},Ut=function(e){for(var t=e.pathSegList,n=t.numberOfItems,r=[[],[]],a=t.getItem(0),i=[a.x,a.y],o=function(e,t,n,r){return function(a){return 1-Math.pow(a,3)*i[e]+3-Math.pow(a,2)*a*t[e]+3*(1-a)*Math.pow(a,2)*n[e]+Math.pow(a,3)*r[e]}},s=0;s0&&y<1&&r[h].push(f(y));var _=(-p-Math.sqrt(v))/(2*g);_>0&&_<1&&r[h].push(f(_))}}else{if(0===p)continue;var b=-m/p;b>0&&b<1&&r[h].push(f(b))}}i=d}else r[0].push(l.x),r[1].push(l.y)}var x=Math.min.apply(null,r[0]),w=Math.max.apply(null,r[0])-x,S=Math.min.apply(null,r[1]);return{x:x,y:S,width:w,height:Math.max.apply(null,r[1])-S}};function Ft(e){if(V)try{return e.getBBox()}catch(e){}var t,n,r=yt.data(e,"ref"),a=null;r?(n=yt(r).children().clone().attr("visibility","hidden"),yt(kt).append(n),a=n.filter("line, path")):a=yt(e).find("line, path");var i=!1;if(a.length)if(a.each((function(){var e=this.getBBox();e.width&&e.height||(i=!0)})),i){var o=r?n:yt(e).children();t=Qt(o)}else t=e.getBBox();else t=e.getBBox();return r&&n.remove(),t}var Dt=function(e){var t=e||xt.geSelectedElements()[0];if(1!==e.nodeType)return null;var n,r=t.nodeName,a=null;switch(r){case"text":""===t.textContent?(t.textContent="a",a=t.getBBox(),t.textContent=""):t.getBBox&&(a=t.getBBox());break;case"path":j?t.getBBox&&(a=t.getBBox()):a=Ut(t);break;case"g":case"a":a=Ft(t);break;default:if("use"===r&&(a=Ft(t)),"use"===r||"foreignObject"===r&&U()){if(a||(a=t.getBBox()),!U()){var i=a,o=i.x,s=i.y;a={width:i.width,height:i.height,x:o+Number.parseFloat(t.getAttribute("x")||0),y:s+Number.parseFloat(t.getAttribute("y")||0)}}}else if(bt.includes(r))if(t)try{a=t.getBBox()}catch(e){var l=t.getExtentOfChar(0),c=t.getComputedTextLength();a={x:l.x,y:l.y,width:c,height:l.height}}else{var u=yt(t).closest("foreignObject");u.length&&u[0].getBBox&&(a=u[0].getBBox())}}return a&&(a={x:(n=a).x,y:n.y,width:n.width,height:n.height}),a},Ht=function(e){var t="";return yt.each(e,(function(e,n){var r=h(n,2),a=r[0],i=r[1];t+=a;for(var o=0;o-.001&&n<.001||(n<-89.99||n>89.99))}(i,o)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))r=s=Yt(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=s=Yt(e,t,n))}}if(!s){var u=Ie(a).matrix;r=Ne(r.x,r.y,r.width,r.height,u).aabox}}return r};function Xt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var Qt=function(e,t,n){if(!e||!e.length)return!1;var r;if(yt.each(e,(function(){r||this.parentNode&&(r=Wt(this,t,n))})),void 0===r)return null;var a=r.x+r.width,i=r.y+r.height,o=r.x,s=r.y;if(1===e.length){var l=Xt(e[0]);o-=l,s-=l,a+=l,i+=l}else yt.each(e,(function(e,r){var l=Wt(r,t,n);if(l){var c=Xt(r);o=Math.min(o,l.x-c),s=Math.min(s,l.y-c),1===r.nodeType&&(a=Math.max(a,l.x+l.width+c),i=Math.max(i,l.y+l.height+c))}}));return r.x=o,r.y=s,r.width=a-o,r.height=i-s,r},Kt=function(e){e||(e=yt(xt.getSVGContent()).children());var t=[];return yt(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},Zt=function(e){return e||(e=Kt()),Qt(e,xt.addSVGElementFromJson,xt.pathActions)},$t=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r");var t=e.shortcut||"";ln("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")}(e)}))}; +function W(t){var n=t.fn.attr;return t.fn.attr=function(t,r){var a=this.length;if(!a)return n.call(this,t,r);for(var i=0;i=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,n=this._xforms[e],r=new Array(this.numberOfItems-1);for(t=0;t=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(de.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var n=this.stack[t].elements(),r=n.length;r--;)e.includes(n[r])||e.push(n[r]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),n}();ve.type=ve.prototype.type;var ye,_e,be,xe,we,Se=function(){function e(t){r(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return i(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,r=t.length,a=new Array(r),i=new Array(r);r--;){var o=t[r];sn(o)||(i[r]=o,a[r]=o.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:a,elements:i}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],n=t.attrName,r=new ve("Change "+n),a=t.elements.length;a--;){var i=t.elements[a];if(!sn(i)){var o={};o[n]=t.oldValues[a],o[n]!==i.getAttribute(n)&&r.addSubCommand(new me(i,o,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),ke=Object.freeze({__proto__:null,HistoryEventTypes:de,MoveElementCommand:fe,InsertElementCommand:pe,RemoveElementCommand:ge,ChangeElementCommand:me,BatchCommand:ve,UndoManager:Se}),Ce=document.createElementNS(y.SVG,"svg"),Ae=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Ee=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},Ge=function(){for(var e=arguments.length,t=new Array(e),n=0;n(n=Number.parseInt(n))){var r=n;n=t,t=r}for(var a=Ce.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},Oe=jQuery,je={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"]},Ve={},Re=function(e){Object.assign(Ve,e.ui)},Be=[],Ue=!0,Fe={},De=null,He=null,ze=function(e){He=e,Be=[0,"ClosePath"];Oe.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){Be.push(t+"Abs"),Be.push(t+"Rel")}))},qe=function(e,t,n){var r=e.pathSegList;if(M)r.insertItemBefore(t,n);else{for(var a=r.numberOfItems,i=[],o=0;o0?(f=g element");this.elem=t,this.segs=[],this.selected_pts=[],De=this,this.init()}return i(e,[{key:"init",value:function(){Oe(Ke()).find("*").each((function(){Oe(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(),sn(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&&n.selected_pts.push(e)})),this.selected_pts.sort();var r=this.selected_pts.length,a=[];for(a.length=r;r--;){var i=this.selected_pts[r],o=this.segs[i];o.select(!0),a[r]=o.ptgrip}var s=e.subpathIsClosed(this.selected_pts[0]);He.addPtsToSelection({grips:a,closedSubpath:s})}}],[{key:"subpathIsClosed",value:function(e){var t=!1;return De.eachSeg((function(n){return n<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}]),e}(),it=function(e){var t=Fe[e.id];return t||(t=Fe[e.id]=new at(e)),t},ot=function(e){e in Fe&&delete Fe[e]},st=function(e,t){var n=e-be,r=t-xe,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+we;return n=a*Math.cos(i)+be,r=a*Math.sin(i)+xe,n-=ye,r-=_e,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-we,{x:a*Math.cos(i)+ye,y:a*Math.sin(i)+_e}},lt=function(){var e=De.elem;if(we=Jt(e,!0)){var t=De.oldbbox;be=t.x+t.width/2,xe=t.y+t.height/2;var n=Dt(e);ye=n.x+n.width/2,_e=n.y+n.height/2;var r=ye-be,a=_e-xe,i=Math.sqrt(r*r+a*a),o=Math.atan2(a,r)+we;ye=i*Math.cos(o)+be,_e=i*Math.sin(o)+xe;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=st(c.x,c.y),h=[d.x,d.y];if(!sn(c.x1)&&!sn(c.x2)){var f=st(c.x1,c.y1),p=st(c.x2,c.y2);h.splice(h.length,0,f.x,f.y,p.x,p.y)}et(u,l,h)}}Dt(e);var g=He.getSVGRoot().createSVGTransform(),m=ee(e);g.setRotate(180*we/Math.PI,ye,_e),m.replaceItem(g,0)}},ct=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],ut=function(e,t){for(var n=e.pathSegList,r=n.numberOfItems,a=0,i=0,o="",s=null,l=0;l=k-x&&f<=k+x&&p>=C-x&&p<=C+x){w=!0;break}}a=He.getId(),ot(a);var A,E,G=tn(a),P=_.numberOfItems;if(w){if(b<=1&&P>=2){var N=_.getItem(0).x,I=_.getItem(0).y;A=4===(E=g.pathSegList.getItem(1)).pathSegType?v.createSVGPathSegLinetoAbs(N,I):v.createSVGPathSegCurvetoCubicAbs(N,I,E.x1/u,E.y1/u,N,I);var T=v.createSVGPathSegClosePath();_.appendItem(A),_.appendItem(T)}else if(P<3)return!1;if(Oe(g).remove(),He.setDrawnPath(null),He.setStarted(!1),pt){De.matrix&&He.remapElement(G,{},De.matrix.inverse());var L=G.getAttribute("d"),M=Oe(De.elem).attr("d");return Oe(De.elem).attr("d",M+L),Oe(G).remove(),De.matrix&<(),ze(),vt.toEditMode(De.elem),De.selectPt(),!1}}else{if(!Oe.contains(He.getContainer(),He.getMouseTarget(e)))return!1;var O=v.pathSegList.numberOfItems,j=v.pathSegList.getItem(O-1),V=j.x,R=j.y;if(e.shiftKey){var B=Le(V,R,f,p);f=B.x,p=B.y}A=4===(E=g.pathSegList.getItem(1)).pathSegType?v.createSVGPathSegLinetoAbs(He.round(f),He.round(p)):v.createSVGPathSegCurvetoCubicAbs(He.round(f),He.round(p),E.x1/u,E.y1/u,E.x2/u,E.y2/u),v.pathSegList.appendItem(A),f*=u,p*=u,g.setAttribute("d",["M",f,p,f,p].join(" ")),m=O,pt&&(m+=De.segs.length),Qe(m,f,p)}}else{var U="M"+f+","+p+" ";He.setDrawnPath(He.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:U,id:He.getNextId(),opacity:He.getOpacity()/2}})),g.setAttribute("d",["M",d,h,d,h].join(" ")),m=pt?De.segs.length:0,Qe(m,d,h)}}},mouseMove:function(e,t){var n=He.getCurrentZoom();mt=!0;var r=He.getDrawnPath();if("path"!==He.getCurrentMode())if(De.dragging){var a=Xe({x:De.dragging[0],y:De.dragging[1]},De),i=Xe({x:e,y:t},De),o=i.x-a.x,s=i.y-a.y;De.dragging=[e,t],De.dragctrl?De.moveCtrl(o,s):De.movePts(o,s)}else De.selected_pts=[],De.eachSeg((function(e){if(this.next||this.prev){var t=He.getRubberBox().getBBox(),n=We(this),r={x:n.x,y:n.y,width:0,height:0},a=Me(t,r);this.select(a),a&&De.selected_pts.push(this.index)}}));else{if(!r)return;var l=r.pathSegList,c=l.numberOfItems-1;if(ht){var u=Ze("1c1"),d=Ze("0c2");u.setAttribute("cx",e),u.setAttribute("cy",t),u.setAttribute("display","inline");var h=ht[0],f=ht[1],p=h+(h-e/n),g=f+(f-t/n);d.setAttribute("cx",p*n),d.setAttribute("cy",g*n),d.setAttribute("display","inline");var m=$e(1);if(nn(m,{x1:e,y1:t,x2:p*n,y2:g*n,display:"inline"}),0===c)ft=[e,t];else{var v=l.getItem(c-1),y=v.x,_=v.y;6===v.pathSegType?(y+=y-v.x2,_+=_-v.y2):ft&&(y=ft[0]/n,_=ft[1]/n),et(6,c,[h,f,y,_,p,g],r)}}else{var b=tn("path_stretch_line");if(b){var x=l.getItem(c);if(6===x.pathSegType){var w=x.x+(x.x-x.x2),S=x.y+(x.y-x.y2);et(6,1,[e,t,w*n,S*n,e,t],b)}else ft?et(6,1,[e,t,ft[0],ft[1],e,t],b):et(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,r){var a=He.getDrawnPath();if("path"===He.getCurrentMode())return ht=null,a||(t=tn(He.getId()),He.setStarted(!1),ft=null),{keep:!0,element:t};var i=He.getRubberBox();if(De.dragging){var o=De.cur_pt;De.dragging=!1,De.dragctrl=!1,De.update(),mt&&De.endChanges("Move path point(s)"),e.shiftKey||mt||De.selectPt(o)}else i&&"none"!==i.getAttribute("display")?(i.setAttribute("display","none"),i.getAttribute("width")<=2&&i.getAttribute("height")<=2&&vt.toSelectMode(e.target)):vt.toSelectMode(e.target);mt=!1},toEditMode:function(e){De=it(e),He.setCurrentMode("pathedit"),He.clearSelection(),De.show(!0).update(),De.oldbbox=Dt(De.elem),pt=!1},toSelectMode:function(e){var t=e===De.elem;He.setCurrentMode("select"),De.show(!1),gt=!1,He.clearSelection(),De.matrix&<(),t&&(He.call("selected",[e]),He.addToSelection([e],!0))},addSubPath:function(e){e?(He.setCurrentMode("path"),pt=!0):(vt.clear(!0),vt.toEditMode(De.elem))},select:function(e){gt===e?(vt.toEditMode(e),He.setCurrentMode("pathedit")):gt=e},reorient:function(){var e=He.getSelectedElements()[0];if(e&&0!==Jt(e)){var t=new ve("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new me(e,n)),He.clearSelection(),this.resetOrientation(e),He.addCommandToHistory(t),it(e).show(!1).matrix=null,this.clear(),He.addToSelection([e],!0),He.call("changed",He.getSelectedElements())}},clear:function(e){var t=He.getDrawnPath();if(gt=null,t){var n=tn(He.getId());Oe(tn("path_stretch_line")).remove(),Oe(n).remove(),Oe(tn("pathpointgrip_container")).find("*").attr("display","none"),ft=null,He.setDrawnPath(null),He.setStarted(!1)}else"pathedit"===He.getCurrentMode()&&this.toSelectMode();De&&De.init().show(!1)},resetOrientation:function(e){if(sn(e)||"path"!==e.nodeName)return!1;var t=ee(e),n=Ie(t).matrix;t.clear(),e.removeAttribute("transform");for(var r=e.pathSegList,a=r.numberOfItems,i=function(t){var a=r.getItem(t),i=a.pathSegType;if(1===i)return"continue";var o=[];Oe.each(["",1,2],(function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var s=Ae(r,i,n);o.splice(o.length,0,s.x,s.y)}})),et(i,t,o,e)},o=0;o0){var s=t.getItem(n-1).pathSegType;if(2===s){r(n-1,1),e();break}if(1===s&&t.numberOfItems-1===n){r(n,1),e();break}}}return!1}(),De.elem.pathSegList.numberOfItems<=1)return vt.toSelectMode(De.elem),void He.canvas.deleteSelectedElements();if(De.init(),De.clearSelection(),window.opera){var r=Oe(De.elem);r.attr("d",r.attr("d"))}De.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t,n=e.points,r=n.numberOfItems;if(r>=4){var a=n.getItem(0),i=null,o=[];for(o.push(["M",a.x,",",a.y," C"].join("")),t=1;t<=r-4;t+=3){var s=n.getItem(t),l=n.getItem(t+1),c=n.getItem(t+2);if(i){var u=nt(i,s,a);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(",")),a=c,i=l}for(o.push("L");t)/,"$1$2")},At=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")};function Et(e){if(e=Nt(e),window.btoa)return window.btoa(e);var t=new Array(4*Math.floor((e.length+2)/3)),n=0,r=0;do{var a=e.charCodeAt(n++),i=e.charCodeAt(n++),o=e.charCodeAt(n++),s=a>>2,l=(3&a)<<4|i>>4,c=(15&i)<<2|o>>6,u=63&o;Number.isNaN(i)?(c=64,u=64):Number.isNaN(o)&&(u=64),t[r++]=_t.charAt(s),t[r++]=_t.charAt(l),t[r++]=_t.charAt(c),t[r++]=_t.charAt(u)}while(n>4,l=(15&a)<<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 "],{type:"text/html"});return Tt(e)}(),Mt=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(y.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},Ut=function(e){for(var t=e.pathSegList,n=t.numberOfItems,r=[[],[]],a=t.getItem(0),i=[a.x,a.y],o=function(e,t,n,r){return function(a){return 1-Math.pow(a,3)*i[e]+3-Math.pow(a,2)*a*t[e]+3*(1-a)*Math.pow(a,2)*n[e]+Math.pow(a,3)*r[e]}},s=0;s0&&y<1&&r[h].push(f(y));var _=(-p-Math.sqrt(v))/(2*g);_>0&&_<1&&r[h].push(f(_))}}else{if(0===p)continue;var b=-m/p;b>0&&b<1&&r[h].push(f(b))}}i=d}else r[0].push(l.x),r[1].push(l.y)}var x=Math.min.apply(null,r[0]),w=Math.max.apply(null,r[0])-x,S=Math.min.apply(null,r[1]);return{x:x,y:S,width:w,height:Math.max.apply(null,r[1])-S}};function Ft(e){if(V)try{return e.getBBox()}catch(e){}var t,n,r=yt.data(e,"ref"),a=null;r?(n=yt(r).children().clone().attr("visibility","hidden"),yt(kt).append(n),a=n.filter("line, path")):a=yt(e).find("line, path");var i=!1;if(a.length)if(a.each((function(){var e=this.getBBox();e.width&&e.height||(i=!0)})),i){var o=r?n:yt(e).children();t=Qt(o)}else t=e.getBBox();else t=e.getBBox();return r&&n.remove(),t}var Dt=function(e){var t=e||xt.geSelectedElements()[0];if(1!==e.nodeType)return null;var n,r=t.nodeName,a=null;switch(r){case"text":""===t.textContent?(t.textContent="a",a=t.getBBox(),t.textContent=""):t.getBBox&&(a=t.getBBox());break;case"path":j?t.getBBox&&(a=t.getBBox()):a=Ut(t);break;case"g":case"a":a=Ft(t);break;default:if("use"===r&&(a=Ft(t)),"use"===r||"foreignObject"===r&&U()){if(a||(a=t.getBBox()),!U()){var i=a,o=i.x,s=i.y;a={width:i.width,height:i.height,x:o+Number.parseFloat(t.getAttribute("x")||0),y:s+Number.parseFloat(t.getAttribute("y")||0)}}}else if(bt.includes(r))if(t)try{a=t.getBBox()}catch(e){var l=t.getExtentOfChar(0),c=t.getComputedTextLength();a={x:l.x,y:l.y,width:c,height:l.height}}else{var u=yt(t).closest("foreignObject");u.length&&u[0].getBBox&&(a=u[0].getBBox())}}return a&&(a={x:(n=a).x,y:n.y,width:n.width,height:n.height}),a},Ht=function(e){var t="";return yt.each(e,(function(e,n){var r=h(n,2),a=r[0],i=r[1];t+=a;for(var o=0;o-.001&&n<.001||(n<-89.99||n>89.99))}(i,o)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))r=s=Yt(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=s=Yt(e,t,n))}}if(!s){var u=Ie(a).matrix;r=Ne(r.x,r.y,r.width,r.height,u).aabox}}return r};function Xt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var Qt=function(e,t,n){if(!e||!e.length)return!1;var r;if(yt.each(e,(function(){r||this.parentNode&&(r=Wt(this,t,n))})),void 0===r)return null;var a=r.x+r.width,i=r.y+r.height,o=r.x,s=r.y;if(1===e.length){var l=Xt(e[0]);o-=l,s-=l,a+=l,i+=l}else yt.each(e,(function(e,r){var l=Wt(r,t,n);if(l){var c=Xt(r);o=Math.min(o,l.x-c),s=Math.min(s,l.y-c),1===r.nodeType&&(a=Math.max(a,l.x+l.width+c),i=Math.max(i,l.y+l.height+c))}}));return r.x=o,r.y=s,r.width=a-o,r.height=i-s,r},Kt=function(e){e||(e=yt(xt.getSVGContent()).children());var t=[];return yt(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},Zt=function(e){return e||(e=Kt()),Qt(e,xt.addSVGElementFromJson,xt.pathActions)},$t=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r");var t=e.shortcut||"";ln("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")}(e)}))}; /** * Adapted from {@link https://github.com/uupaa/dynamic-import-polyfill/blob/master/importModule.js}. * @module importModule * @license MIT */ -function dn(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}function hn(e,t){["id","class","type"].forEach((function(n){n in t&&(e[n]=t[n])}))}function fn(e,t){return pn(e,o({},t,{returnDefault:!0}))}function pn(e,t){return gn.apply(this,arguments)}function gn(){return(gn=n(regeneratorRuntime.mark((function e(t,n){var r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.global,a=n.returnDefault,!(!("svgEditor"in window)||!window.svgEditor||!1!==window.svgEditor.modules)){e.next=4;break}return e.abrupt("return",vn(t,void 0,{returnDefault:a}));case 4:return e.next=6,mn(t);case 6:return e.abrupt("return",window[r]);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function mn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map((function(e){return mn(e,t)}))):new Promise((function(n,r){var a=document.createElement("script");function i(){r(new Error("Failed to import: ".concat(e))),s()}function o(){n(),s()}var s=function(){a.removeEventListener("error",i),a.removeEventListener("load",o),a.remove(),a.src=""};a.defer="defer",hn(a,t),a.addEventListener("error",i),a.addEventListener("load",o),a.src=e,document.head.append(a)}))}function vn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.returnDefault,a=void 0!==r&&r;return Array.isArray(e)?Promise.all(e.map((function(e){return vn(e,t)}))):new Promise((function(n,r){var i="$importModule$"+Math.random().toString(32).slice(2),o=document.createElement("script");function s(){r(new Error("Failed to import: ".concat(e))),c()}function l(){n(window[i]),c()}var c=function(){delete window[i],o.removeEventListener("error",s),o.removeEventListener("load",l),o.remove(),URL.revokeObjectURL(o.src),o.src=""};hn(o,t),o.defer="defer",o.type="module",o.addEventListener("error",s),o.addEventListener("load",l);var u=dn(e),d="import * as m from '".concat(u.replace(/'/g,"\\'"),"'; window.").concat(i," = ").concat(a?"m.default || ":"","m;"),h=new Blob([d],{type:"text/javascript"});o.src=URL.createObjectURL(h),document.head.append(o)}))}var yn={true:!0,false:!1,null:null};function _n(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ok:"Ok",cancel:"Cancel"};t("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"}).css("position","absolute");var r=t("#dialog_box"),a=t("#dialog_buttons"),i=t("#dialog_content");function o(o,s,l,c,u,d){i.html("

    "+s.replace(/\n/g,"

    ")+"

    ").toggleClass("prompt","prompt"===o),a.empty();var h=t('').appendTo(a);return new Promise((function(f,p){var g,m;if("alert"!==o&&t('').appendTo(a).click((function(){r.hide(),f(!1)})),"prompt"===o)(g=t('').prependTo(a)).val(l||""),g.bind("keydown","return",(function(){h.click()}));else if("select"===o){var v=t('
    ');if(g=t('').appendTo(y)).val(d.value),d.tooltip&&y.attr("title",d.tooltip),m.prop("checked",Boolean(d.checked)),v.append(t("
    ").append(y))}t.each(c||[],(function(n,r){"object"===e(r)?g.append(t("