!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.svgEditor=t()}(this,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,n,r,a,i,o){try{var s=e[i](o),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(a,i){var o=e.apply(n,r);function s(e){t(o,a,i,s,l,"next",e)}function l(e){t(o,a,i,s,l,"throw",e)}s(void 0)})}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;nt.getTotalLength())break;n--}while(n>0);return n}),window.SVGPathSeg=e,window.SVGPathSegClosePath=t,window.SVGPathSegMovetoAbs=n,window.SVGPathSegMovetoRel=a,window.SVGPathSegLinetoAbs=o,window.SVGPathSegLinetoRel=c,window.SVGPathSegCurvetoCubicAbs=d,window.SVGPathSegCurvetoCubicRel=h,window.SVGPathSegCurvetoQuadraticAbs=f,window.SVGPathSegCurvetoQuadraticRel=p,window.SVGPathSegArcAbs=g,window.SVGPathSegArcRel=m,window.SVGPathSegLinetoHorizontalAbs=v,window.SVGPathSegLinetoHorizontalRel=_,window.SVGPathSegLinetoVerticalAbs=y,window.SVGPathSegLinetoVerticalRel=b,window.SVGPathSegCurvetoCubicSmoothAbs=x,window.SVGPathSegCurvetoCubicSmoothRel=w,window.SVGPathSegCurvetoQuadraticSmoothAbs=S,window.SVGPathSegCurvetoQuadraticSmoothRel=k}if(!("SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype)){var C=function(){function e(t){r(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 i(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(){r(this,e),this.pathSegList=[]}return i(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),a=function(){function e(t){r(this,e),this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return i(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,r=0,a=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,r+=(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+r;if(u*=a,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 r={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(t,r.x,r.y,r.x1,r.y1,r.x2,r.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var a={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(t,a.x,a.y,a.x1,a.y1,a.x2,a.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}(),o=new n,s=new a(e);if(!s.initialCommandIsMoveTo())return[];for(;s.hasMoreData();){var l=s.parseSegment();if(!l)return[];o.appendSegment(l)}return o.pathSegList}}]),e}();C.prototype.classname="SVGPathSegList",Object.defineProperty(C.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),C._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 C(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=C}}();var m,v=jQuery,_=(!!document.createElementNS&&document.createElementNS(p.SVG,"svg").createSVGRect,navigator.userAgent),y=document.createElementNS(p.SVG,"svg"),b=!!window.opera,x=_.includes("AppleWebKit"),w=_.includes("Gecko/"),S=_.includes("MSIE"),k=_.includes("Chrome/"),C=(_.includes("Windows"),_.includes("Macintosh")),A="ontouchstart"in window,E=!!y.querySelector,G=!!document.evaluate,P=function(){var e=document.createElementNS(p.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}(),I=function(){var e=document.createElementNS(p.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}(),T=function(){var e=document.createElementNS(p.SVG,"svg"),t=document.createElementNS(p.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var n=document.createElementNS(p.SVG,"text");n.textContent="a",t.append(n);try{return 0===n.getStartPositionOfChar(0).x}catch(e){return!1}finally{e.remove()}}(),N=function(){var e=document.createElementNS(p.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(p.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}(),L=function(){var e=document.createElementNS(p.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(p.SVG,"path");t.setAttribute("d","M0,0 10,0");var n=document.createElementNS(p.SVG,"path");n.setAttribute("d","M5,0 15,0");var r=document.createElementNS(p.SVG,"g");r.append(t,n),e.append(r);var a=r.getBBox();return e.remove(),15===a.width}(),M=(function(){var e=document.createElementNS(p.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");t||v.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.')}(),(m=document.createElementNS(p.SVG,"rect")).setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===m.style.vectorEffect),O=function(){var e=document.createElementNS(p.SVG,"rect").transform.baseVal,t=y.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}(),V=function(){return b},j=function(){return x},R=function(){return w},B=function(){return S},D=function(){return k},U=function(){return C},F=function(){return A},H=function(){return L},z=function(){return M};function q(t){var n=t.fn.attr;return t.fn.attr=function(t,r){var a=this.length;if(!a)return n.apply(this,arguments);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(ce.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}}]),t}();ge.type=ge.prototype.type;var me,ve,_e,ye,be,xe=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];null!=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 ge("Change "+n),a=t.elements.length;a--;){var i=t.elements[a];if(null!=i){var o={};o[n]=t.oldValues[a],o[n]!==i.getAttribute(n)&&r.addSubCommand(new pe(i,o,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),we=Object.freeze({HistoryEventTypes:ce,MoveElementCommand:de,InsertElementCommand:he,RemoveElementCommand:fe,ChangeElementCommand:pe,BatchCommand:ge,UndoManager:xe}),Se=document.createElementNS(p.SVG,"svg"),ke=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Ce=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},Ae=function(){for(var e=arguments.length,t=new Array(e),n=0;n(n=parseInt(n,10))){var r=n;n=t,t=r}for(var a=Se.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},Le=jQuery,Me={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"]},Oe={},Ve=function(e){Object.assign(Oe,e.ui)},je=[],Re=!0,Be={},De=null,Ue=null,Fe=function(e){Ue=e,je=[0,"ClosePath"];Le.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(e,t){je.push(t+"Abs"),je.push(t+"Rel")})},He=function(e,t,n){var r=e.pathSegList;if(I)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(){Le(We()).find("*").each(function(){Le(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 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=this.subpathIsClosed(this.selected_pts[0]);Ue.addPtsToSelection({grips:a,closedSubpath:s})}}]),e}(),nt=function(e){var t=Be[e.id];return t||(t=Be[e.id]=new tt(e)),t},rt=function(e){e in Be&&delete Be[e]},at=function(e,t){var n=e-_e,r=t-ye,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+be;return n=a*Math.cos(i)+_e,r=a*Math.sin(i)+ye,n-=me,r-=ve,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-be,{x:a*Math.cos(i)+me,y:a*Math.sin(i)+ve}},it=function(){var e=De.elem;if(be=Kt(e,!0)){var t=De.oldbbox;_e=t.x+t.width/2,ye=t.y+t.height/2;var n=Bt(e);me=n.x+n.width/2,ve=n.y+n.height/2;var r=me-_e,a=ve-ye,i=Math.sqrt(r*r+a*a),o=Math.atan2(a,r)+be;me=i*Math.cos(o)+_e,ve=i*Math.sin(o)+ye;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=at(c.x,c.y),h=[d.x,d.y];if(null!=c.x1&&null!=c.x2){var f=at(c.x1,c.y1),p=at(c.x2,c.y2);h.splice(h.length,0,f.x,f.y,p.x,p.y)}Ze(u,l,h)}}Bt(e);var g=Ue.getSVGRoot().createSVGTransform(),m=$(e);g.setRotate(180*be/Math.PI,me,ve),m.replaceItem(g,0)}},ot=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],st=function(e,t){for(var n=e.pathSegList,r=n.numberOfItems,a=0,i=0,o="",s=null,l=0;l=C-w&&g<=C+w&&m>=A-w&&m<=A+w){S=!0;break}}a=Ue.getId(),rt(a);var E,G,P=$t(a),I=b.numberOfItems;if(S){if(x<=1&&I>=2){var T=b.getItem(0).x,N=b.getItem(0).y;E=4===(G=v.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(T,N):y.createSVGPathSegCurvetoCubicAbs(T,N,G.x1/f,G.y1/f,T,N);var L=y.createSVGPathSegClosePath();b.appendItem(E),b.appendItem(L)}else if(I<3)return!1;if(Le(v).remove(),Ue.setDrawnPath(null),Ue.setStarted(!1),dt){De.matrix&&Ue.remapElement(P,{},De.matrix.inverse());var M=P.getAttribute("d"),O=Le(De.elem).attr("d");return Le(De.elem).attr("d",O+M),Le(P).remove(),De.matrix&&it(),Fe(),pt.toEditMode(De.elem),De.selectPt(),!1}}else{if(!Le.contains(Ue.getContainer(),Ue.getMouseTarget(e)))return console.log("Clicked outside canvas"),!1;var V=y.pathSegList.numberOfItems,j=y.pathSegList.getItem(V-1),R=j.x,B=j.y;if(e.shiftKey){var D=Te(R,B,g,m);g=D.x,m=D.y}E=4===(G=v.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(Ue.round(g),Ue.round(m)):y.createSVGPathSegCurvetoCubicAbs(Ue.round(g),Ue.round(m),G.x1/f,G.y1/f,G.x2/f,G.y2/f),y.pathSegList.appendItem(E),g*=f,m*=f,v.setAttribute("d",["M",g,m,g,m].join(" ")),_=V,dt&&(_+=De.segs.length),Ye(_,g,m)}}else{var U="M"+g+","+m+" ";Ue.setDrawnPath(Ue.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:U,id:Ue.getNextId(),opacity:Ue.getOpacity()/2}})),v.setAttribute("d",["M",d,h,d,h].join(" ")),_=dt?De.segs.length:0,Ye(_,d,h)}}},mouseMove:function(e,t){var n=Ue.getCurrentZoom();ft=!0;var r=Ue.getDrawnPath();if("path"!==Ue.getCurrentMode())if(De.dragging){var a=qe({x:De.dragging[0],y:De.dragging[1]},De),i=qe({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=Ue.getRubberBox().getBBox(),n=ze(this),r={x:n.x,y:n.y,width:0,height:0},a=Ne(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(ct){var u=Xe("1c1"),d=Xe("0c2");u.setAttribute("cx",e),u.setAttribute("cy",t),u.setAttribute("display","inline");var h=ct[0],f=ct[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=Qe(1);if(Jt(m,{x1:e,y1:t,x2:p*n,y2:g*n,display:"inline"}),0===c)ut=[e,t];else{var v=l.getItem(c-1),_=v.x,y=v.y;6===v.pathSegType?(_+=_-v.x2,y+=y-v.y2):ut&&(_=ut[0]/n,y=ut[1]/n),Ze(6,c,[h,f,_,y,p,g],r)}}else{var b=$t("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);Ze(6,1,[e,t,w*n,S*n,e,t],b)}else ut?Ze(6,1,[e,t,ut[0],ut[1],e,t],b):Ze(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,r){var a=Ue.getDrawnPath();if("path"===Ue.getCurrentMode())return ct=null,a||(t=$t(Ue.getId()),Ue.setStarted(!1),ut=null),{keep:!0,element:t};var i=Ue.getRubberBox();if(De.dragging){var o=De.cur_pt;De.dragging=!1,De.dragctrl=!1,De.update(),ft&&De.endChanges("Move path point(s)"),e.shiftKey||ft||De.selectPt(o)}else i&&"none"!==i.getAttribute("display")?(i.setAttribute("display","none"),i.getAttribute("width")<=2&&i.getAttribute("height")<=2&&pt.toSelectMode(e.target)):pt.toSelectMode(e.target);ft=!1},toEditMode:function(e){De=nt(e),Ue.setCurrentMode("pathedit"),Ue.clearSelection(),De.show(!0).update(),De.oldbbox=Bt(De.elem),dt=!1},toSelectMode:function(e){var t=e===De.elem;Ue.setCurrentMode("select"),De.show(!1),ht=!1,Ue.clearSelection(),De.matrix&&it(),t&&(Ue.call("selected",[e]),Ue.addToSelection([e],!0))},addSubPath:function(e){e?(Ue.setCurrentMode("path"),dt=!0):(pt.clear(!0),pt.toEditMode(De.elem))},select:function(e){ht===e?(pt.toEditMode(e),Ue.setCurrentMode("pathedit")):ht=e},reorient:function(){var e=Ue.getSelectedElements()[0];if(e&&0!==Kt(e)){var t=new ge("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new pe(e,n)),Ue.clearSelection(),this.resetOrientation(e),Ue.addCommandToHistory(t),nt(e).show(!1).matrix=null,this.clear(),Ue.addToSelection([e],!0),Ue.call("changed",Ue.getSelectedElements())}},clear:function(e){var t=Ue.getDrawnPath();if(ht=null,t){var n=$t(Ue.getId());Le($t("path_stretch_line")).remove(),Le(n).remove(),Le($t("pathpointgrip_container")).find("*").attr("display","none"),ut=null,Ue.setDrawnPath(null),Ue.setStarted(!1)}else"pathedit"===Ue.getCurrentMode()&&this.toSelectMode();De&&De.init().show(!1)},resetOrientation:function(e){if(null==e||"path"!==e.nodeName)return!1;var t=$(e),n=Pe(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=[];Le.each(["",1,2],function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var s=ke(r,i,n);o.splice(o.length,0,s.x,s.y)}}),Ze(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 pt.toSelectMode(De.elem),void Ue.canvas.deleteSelectedElements();if(De.init(),De.clearSelection(),window.opera){var r=Le(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=Je(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")},St=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")},kt=function(e){if(e=Et(e),window.btoa)return window.btoa(e);var t=[];t.length=4*Math.floor((e.length+2)/3);var 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;isNaN(i)?c=u=64:isNaN(o)&&(u=64),t[r++]=mt.charAt(s),t[r++]=mt.charAt(l),t[r++]=mt.charAt(c),t[r++]=mt.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 Pt(e)}(),Tt=function(e){var t,n;e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(p.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},jt=function(e){for(var t=e.pathSegList,n=t.numberOfItems,r=[[],[]],a=t.getItem(0),i=[a.x,a.y],o=0;o0&&u<1&&r[a].push(o(u)),"continue"}var d=Math.pow(s,2)-4*c*l;if(d<0)return"continue";var h=(-s+Math.sqrt(d))/(2*l);h>0&&h<1&&r[a].push(o(h));var f=(-s-Math.sqrt(d))/(2*l);f>0&&f<1&&r[a].push(o(f))},o=0;o<2;o++)a(o);i=n}():(r[0].push(s.x),r[1].push(s.y)))}var l=Math.min.apply(null,r[0]),c=Math.max.apply(null,r[0])-l,u=Math.min.apply(null,r[1]);return{x:l,y:u,width:c,height:Math.max.apply(null,r[1])-u}};function Rt(e){if(H())try{return e.getBBox()}catch(e){}var t,n,r=gt.data(e,"ref"),a=null;r?(n=gt(r).children().clone().attr("visibility","hidden"),gt(xt).append(n),a=n.filter("line, path")):a=gt(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:gt(e).children();t=Yt(o)}else t=e.getBBox();else t=e.getBBox();return r&&n.remove(),t}var Bt=function(e){var t=e||_t.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":N?t.getBBox&&(a=t.getBBox()):a=jt(t);break;case"g":case"a":a=Rt(t);break;default:if("use"===r&&(a=Rt(t)),"use"===r||"foreignObject"===r&&j()){if(a||(a=t.getBBox()),!j()){var i={};i.width=a.width,i.height=a.height,i.x=a.x+parseFloat(t.getAttribute("x")||0),i.y=a.y+parseFloat(t.getAttribute("y")||0),a=i}}else if(vt.includes(r))if(t)try{a=t.getBBox()}catch(e){var o=t.getExtentOfChar(0),s=t.getComputedTextLength();a={x:o.x,y:o.y,width:s,height:o.height}}else{var l=gt(t).closest("foreignObject");l.length&&l[0].getBBox&&(a=l[0].getBBox())}}return a&&(a={x:(n=a).x,y:n.y,width:n.width,height:n.height}),a},Dt=function(e){var t="";return gt.each(e,function(e,n){var r=d(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=Ht(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=s=Ht(e,t,n))}}if(!s){var u=Pe(a).matrix;r=Ge(r.x,r.y,r.width,r.height,u).aabox}}return r};function qt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var Yt=function(e,t,n){if(!e||!e.length)return!1;var r;if(gt.each(e,function(){r||this.parentNode&&(r=zt(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=qt(e[0]);o-=l,s-=l,a+=l,i+=l}else gt.each(e,function(e,r){var l=zt(r,t,n);if(l){var c=qt(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},Wt=function(e){e||(e=gt(_t.getSVGContent()).children());var t=[];return gt(e).children().each(function(e,n){n.getBBox&&t.push(n)}),t.reverse()},Xt=function(e){return e||(e=Wt()),Yt(e,_t.addSVGElementFromJson,_t.pathActions)},Qt=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r");var t=e.shortcut||"";rn("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")};function sn(e,t){["id","class","type"].forEach(function(n){n in t&&(e[n]=t[n])})}function ln(e,t){return cn.apply(this,arguments)}function cn(){return(cn=n(regeneratorRuntime.mark(function e(t,n){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",un(t,o({},n,{returnDefault:!0})));case 1:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function un(e,t){return dn.apply(this,arguments)}function dn(){return(dn=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",fn(t,void 0,{returnDefault:a}));case 4:return e.next=6,hn(t);case 6:return e.abrupt("return",window[r]);case 7:case"end":return e.stop()}},e,this)}))).apply(this,arguments)}function hn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map(function(e){return hn(e,t)})):new Promise(function(n,r){var a=document.createElement("script"),i=function(){a.onerror=null,a.onload=null,a.remove(),a.src=""};a.defer="defer",sn(a,t),a.onerror=function(){r(new Error("Failed to import: ".concat(e))),i()},a.onload=function(){n(),i()},a.src=e,document.head.append(a)})}function fn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).returnDefault,r=void 0!==n&&n;return Array.isArray(e)?Promise.all(e.map(function(e){return fn(e,t)})):new Promise(function(n,a){var i="$importModule$"+Math.random().toString(32).slice(2),o=document.createElement("script"),s=function(){delete window[i],o.onerror=null,o.onload=null,o.remove(),URL.revokeObjectURL(o.src),o.src=""};sn(o,t),o.defer="defer",o.type="module",o.onerror=function(){a(new Error("Failed to import: ".concat(e))),s()},o.onload=function(){n(window[i]),s()};var l=function(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}(e),c="import * as m from '".concat(l.replace(/'/g,"\\'"),"'; window.").concat(i," = ").concat(r?"m.default || ":"","m;"),u=new Blob([c],{type:"text/javascript"});o.src=URL.createObjectURL(u),document.head.append(o)})}var pn=jQuery,gn=function(){function e(t,n,a){if(r(this,e),this.name_=t,this.group_=a?null:n,a){var i=a.ownerDocument;this.group_=i.createElementNS(p.SVG,"g");var o=i.createElementNS(p.SVG,"title");o.textContent=t,this.group_.append(o),n?pn(n).after(this.group_):a.append(this.group_)}mn(this.group_),Nt(this.group_,function(e){e.setAttribute("style","pointer-events:inherit")}),this.group_.setAttribute("style",a?"pointer-events:all":"pointer-events:none")}return i(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 null==e?1:parseFloat(e)}},{key:"setOpacity",value:function(e){"number"==typeof e&&e>=0&&e<=1&&this.group_.setAttribute("opacity",e)}},{key:"appendChildren",value:function(e){for(var t=0;t element");this.svgElem_=t,this.obj_num=0,this.idPrefix=n||"svg_",this.releasedNums=[],this.all_layers=[],this.layer_map={},this.current_layer=null,this.nonce_="";var a=this.svgElem_.getAttributeNS(p.SE,"nonce");a&&xn!==bn.NEVER_RANDOMIZE?this.nonce_=a:xn===bn.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(100001*Math.random()))}return i(e,[{key:"getElem_",value:function(e){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+e):_n(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(p.XMLNS,"xmlns:se",p.SE),this.svgElem_.setAttributeNS(p.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 n=this.getId();this.getElem_(n);)t&&(this.obj_num=e,t=!1),this.obj_num++,n=this.getId();return t&&(this.obj_num=e),n}},{key:"releaseId",value:function(e){var t=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if("string"!=typeof e||!e.startsWith(t))return!1;var n=parseInt(e.substr(t.length),10);return!("number"!=typeof n||n<=0||this.releasedNums.includes(n))&&(this.releasedNums.push(n),!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=n)return null;for(t=0;tt?e0){var s=this.current_layer.getName();this.current_layer=this.all_layers[o-1],this.all_layers.splice(o,1),delete this.layer_map[s]}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,t=this.svgElem_.childNodes.length,n=[],r=[],a=null,i=!1,o=0;o0||!i?((a=new gn(kn(r),null,this.svgElem_)).appendChildren(n),this.all_layers.push(a),this.layer_map[name]=a):a.activate(),this.current_layer=a}},{key:"createLayer",value:function(e,t){this.current_layer&&this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=kn(Object.keys(this.layer_map)));var n=new gn(e,null,this.svgElem_);return t&&(t.startBatchCommand("Create Layer"),t.insertElement(n.getGroup()),t.endBatchCommand()),this.all_layers.push(n),this.layer_map[e]=n,this.current_layer=n,n.getGroup()}},{key:"cloneLayer",value:function(e,t){if(!this.current_layer)return null;this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=kn(Object.keys(this.layer_map)));for(var n=this.current_layer.getGroup(),r=new gn(e,n,this.svgElem_),a=r.getGroup(),i=n.childNodes,o=0;o=0?this.all_layers.splice(l+1,0,r):this.all_layers.push(r),this.layer_map[e]=r,this.current_layer=r,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 n=this.layer_map[e];return n?(n.setVisible(t),n.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 n=this.layer_map[e];n&&n.setOpacity(t)}}},{key:"copyElem",value:function(e){var t=this;return function e(t,n){var r=document.createElementNS(t.namespaceURI,t.nodeName);if(gt.each(t.attributes,function(e,t){"-moz-math-font-style"!==t.localName&&r.setAttributeNS(t.namespaceURI,t.nodeName,t.value)}),r.removeAttribute("id"),r.id=n(),j()&&"path"===t.nodeName){var a=st(t);r.setAttribute("d",a)}if(gt.each(t.childNodes,function(t,a){switch(a.nodeType){case 1:r.append(e(a,n));break;case 3:r.textContent=a.nodeValue}}),gt(t).data("gsvg"))gt(r).data("gsvg",r.firstChild);else if(gt(t).data("symbol")){var i=gt(t).data("symbol");gt(r).data("ref",i).data("symbol",i)}else"image"===r.tagName&&nn(r);return r}(e,function(){return t.getNextId()})}}]),e}(),En=function(e,t){(xn=!1===e?bn.NEVER_RANDOMIZE:bn.ALWAYS_RANDOMIZE)!==bn.ALWAYS_RANDOMIZE||t.getNonce()?xn===bn.NEVER_RANDOMIZE&&t.getNonce()&&t.clearNonce():t.setNonce(Math.floor(100001*Math.random()))},Gn=function(e){Cn=e},Pn=function(){In(),Cn.getCurrentDrawing().identifyLayers()},In=function(){var e=wn.length;if(e){for(var t=0;t0){for(var a=r.numberOfItems,i=a;a--;){var o=r.getItem(a);if(0===o.type)r.removeItem(a);else if(1===o.type){if(Ce(o.matrix)){if(1===i)return t.removeAttribute("transform"),null;r.removeItem(a)}}else 4===o.type&&0===o.angle&&r.removeItem(a)}if(1===r.numberOfItems&&Kt(t))return null}if(!r||0===r.numberOfItems)return t.setAttribute("transform",""),t.removeAttribute("transform"),null;if(r){for(var s=[],l=r.numberOfItems;l--;){var c=r.getItem(l);1===c.type?s.push([c.matrix,l]):s.length&&(s=[])}if(2===s.length){var u=n.createSVGTransformFromMatrix(Ae(s[1][0],s[0][0]));r.removeItem(s[0][1]),r.removeItem(s[1][1]),r.insertItemBefore(u,s[1][1])}if((l=r.numberOfItems)>=2&&1===r.getItem(l-2).type&&2===r.getItem(l-1).type){var d=n.createSVGTransform(),h=Ae(r.getItem(l-2).matrix,r.getItem(l-1).matrix);d.setMatrix(h),r.removeItem(l-2),r.removeItem(l-2),r.appendItem(d)}}switch(t.tagName){case"line":case"polyline":case"polygon":case"path":break;default:if(1===r.numberOfItems&&1===r.getItem(0).type||2===r.numberOfItems&&1===r.getItem(0).type&&4===r.getItem(0).type)return null}var f,g,m=qn(t).data("gsvg"),v=new ge("Transform"),_={},y=null,b=[];switch(t.tagName){case"line":b=["x1","y1","x2","y2"];break;case"circle":b=["cx","cy","r"];break;case"ellipse":b=["cx","cy","rx","ry"];break;case"foreignObject":case"rect":case"image":b=["width","height","x","y"];break;case"use":case"text":case"tspan":b=["x","y"];break;case"polygon":case"polyline":(y={}).points=t.getAttribute("points");var x=t.points,w=x.numberOfItems;_.points=new Array(w);for(var S=0;S1e-10?Math.sin(G)/(1-Math.cos(G)):2/G;for(var P=0;P=3&&3===r.getItem(M-2).type&&2===r.getItem(M-3).type&&2===r.getItem(M-1).type){R=3;for(var B=r.getItem(M-3).matrix,D=r.getItem(M-2).matrix,U=r.getItem(M-1).matrix,F=t.childNodes,H=F.length;H--;){var z=F.item(H);if(O=0,V=0,1===z.nodeType){var q=$(z);if(!q)continue;var Y=Pe(q).matrix,W=Kt(z);if(L=Vn.getStartTransform(),Vn.setStartTransform(z.getAttribute("transform")),W||Ee(q)){var X=n.createSVGTransform();X.setMatrix(Ae(B,D,U,Y)),q.clear(),q.appendItem(X)}else{var Q=Ae(Y.inverse(),U,Y),K=n.createSVGMatrix();K.e=-Q.e,K.f=-Q.f;var Z=Ae(K.inverse(),Y.inverse(),B,D,U,Y,Q.inverse()),J=n.createSVGTransform(),ee=n.createSVGTransform(),te=n.createSVGTransform();J.setTranslate(Q.e,Q.f),ee.setScale(Z.a,Z.d),te.setTranslate(K.e,K.f),q.appendItem(te),q.appendItem(ee),q.appendItem(J)}v.addSubCommand(e(z)),Vn.setStartTransform(L)}}r.removeItem(M-1),r.removeItem(M-2),r.removeItem(M-3)}else if(M>=3&&1===r.getItem(M-1).type){R=3;var ne=Pe(r).matrix,re=n.createSVGTransform();re.setMatrix(ne),r.clear(),r.appendItem(re)}else if((1===M||M>1&&3!==r.getItem(1).type)&&2===r.getItem(0).type){R=2;var ae=Pe(r).matrix;r.removeItem(0);var ie=Pe(r).matrix.inverse(),oe=Ae(ie,ae);if(O=oe.e,V=oe.f,0!==O||0!==V){for(var le=t.childNodes,ce=le.length,ue=[];ce--;){var de=le.item(ce);if(1===de.nodeType){if(de.getAttribute("clip-path")){var he=de.getAttribute("clip-path");ue.includes(he)||(Yn(he,O,V),ue.push(he))}L=Vn.getStartTransform(),Vn.setStartTransform(de.getAttribute("transform"));var fe=$(de);if(fe){var me=n.createSVGTransform();me.setTranslate(O,V),fe.numberOfItems?fe.insertItemBefore(me,0):fe.appendItem(me),v.addSubCommand(e(de));for(var ve=t.getElementsByTagNameNS(p.SVG,"use"),_e="#"+de.id,ye=ve.length;ye--;){var be=ve.item(ye);if(_e===Mt(be)){var xe=n.createSVGTransform();xe.setTranslate(-O,-V),$(be).insertItemBefore(xe,0),v.addSubCommand(e(be))}}Vn.setStartTransform(L)}}}Vn.setStartTransform(L)}}else{if(1!==M||1!==r.getItem(0).type||A){if(A){var we=n.createSVGTransform();we.setRotate(A,g.x,g.y),r.numberOfItems?r.insertItemBefore(we,0):r.appendItem(we)}return 0===r.numberOfItems&&t.removeAttribute("transform"),null}R=1;for(var Se=r.getItem(0).matrix,Ge=t.childNodes,Ie=Ge.length;Ie--;){var Te=Ge.item(Ie);if(1===Te.nodeType){L=Vn.getStartTransform(),Vn.setStartTransform(Te.getAttribute("transform"));var Ne=$(Te);if(!Ne)continue;var Le=Ae(Se,Pe(Ne).matrix),Me=n.createSVGTransform();Me.setMatrix(Le),Ne.clear(),Ne.appendItem(Me,0),v.addSubCommand(e(Te)),Vn.setStartTransform(L);var Oe=Te.getAttribute("stroke-width");if("none"!==Te.getAttribute("stroke")&&!isNaN(Oe)){var Ve=(Math.abs(Le.a)+Math.abs(Le.d))/2;Te.setAttribute("stroke-width",Oe*Ve)}}}r.clear()}if(2===R){if(A){g={x:f.x+N.e,y:f.y+N.f};var je=n.createSVGTransform();je.setRotate(A,g.x,g.y),r.numberOfItems?r.insertItemBefore(je,0):r.appendItem(je)}}else if(3===R){var Re=Pe(r).matrix,Be=n.createSVGTransform();Be.setRotate(A,f.x,f.y);var De=Be.matrix,Ue=n.createSVGTransform();Ue.setRotate(A,g.x,g.y);var Fe=Ue.matrix.inverse(),He=Re.inverse(),ze=Ae(He,Fe,De,Re);if(O=ze.e,V=ze.f,0!==O||0!==V)for(var qe=t.childNodes,Ye=qe.length;Ye--;){var We=qe.item(Ye);if(1===We.nodeType){L=Vn.getStartTransform(),Vn.setStartTransform(We.getAttribute("transform"));var Xe=$(We),Qe=n.createSVGTransform();Qe.setTranslate(O,V),Xe.numberOfItems?Xe.insertItemBefore(Qe,0):Xe.appendItem(Qe),v.addSubCommand(e(We)),Vn.setStartTransform(L)}}A&&(r.numberOfItems?r.insertItemBefore(Ue,0):r.appendItem(Ue))}}else{var Ke,Ze=Bt(t);if(!Ze&&"path"!==t.tagName)return null;var $e=Kt(t);if($e){f={x:Ze.x+Ze.width/2,y:Ze.y+Ze.height/2},g=ke(Ze.x+Ze.width/2,Ze.y+Ze.height/2,Pe(r).matrix);for(var Je=$e*Math.PI/180,et=Math.abs(Je)>1e-10?Math.sin(Je)/(1-Math.cos(Je)):2/Je,tt=0;tt=3&&3===r.getItem(it-2).type&&2===r.getItem(it-3).type&&2===r.getItem(it-1).type)at=3,Ke=Pe(r,it-3,it-1).matrix,r.removeItem(it-1),r.removeItem(it-2),r.removeItem(it-3);else if(4===it&&1===r.getItem(it-1).type){at=3,Ke=Pe(r).matrix;var ht=n.createSVGTransform();ht.setMatrix(Ke),r.clear(),r.appendItem(ht),Ke=n.createSVGMatrix()}else if((1===it||it>1&&3!==r.getItem(1).type)&&2===r.getItem(0).type){at=2;var ft=r.getItem(0).matrix,pt=Pe(r,1).matrix,gt=pt.inverse();Ke=Ae(gt,ft,pt),r.removeItem(0)}else{if(1!==it||1!==r.getItem(0).type||$e){if($e){var mt=n.createSVGTransform();mt.setRotate($e,g.x,g.y),r.numberOfItems?r.insertItemBefore(mt,0):r.appendItem(mt)}return 0===r.numberOfItems&&t.removeAttribute("transform"),null}switch(Ke=Pe(r).matrix,t.tagName){case"line":_=qn(t).attr(["x1","y1","x2","y2"]);case"polyline":case"polygon":if(_.points=t.getAttribute("points"),_.points){var vt=t.points,_t=vt.numberOfItems;_.points=new Array(_t);for(var yt=0;yt<_t;++yt){var bt=vt.getItem(yt);_.points[yt]={x:bt.x,y:bt.y}}}case"path":_.d=t.getAttribute("d"),at=1,r.clear()}}if(1!==at&&2!==at&&3!==at||zn(t,_,Ke),2===at){if($e){Ee(r)||(g={x:f.x+Ke.e,y:f.y+Ke.f});var xt=n.createSVGTransform();xt.setRotate($e,g.x,g.y),r.numberOfItems?r.insertItemBefore(xt,0):r.appendItem(xt)}if("text"===t.tagName)for(var wt=t.childNodes,St=wt.length;St--;){var kt=wt.item(St);if("tspan"===kt.tagName){var Ct={x:qn(kt).attr("x")||0,y:qn(kt).attr("y")||0};zn(kt,Ct,Ke)}}}else if(3===at&&$e){var At=Pe(r).matrix,Et=n.createSVGTransform();Et.setRotate($e,f.x,f.y);var Gt=Et.matrix,Pt=n.createSVGTransform();Pt.setRotate($e,g.x,g.y);var It=Pt.matrix.inverse(),Tt=At.inverse(),Nt=Ae(Tt,It,Gt,At);zn(t,_,Nt),$e&&(r.numberOfItems?r.insertItemBefore(Pt,0):r.appendItem(Pt))}}return 0===r.numberOfItems&&t.removeAttribute("transform"),v.addSubCommand(new pe(t,y)),v},Xn=jQuery,Qn=F()?10:4,Kn=function(){function e(t,n,a){r(this,e),this.id=t,this.selectedElement=n,this.locked=!0,this.selectorGroup=jn.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}}),this.selectorRect=this.selectorGroup.appendChild(jn.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,a)}return i(e,[{key:"reset",value:function(e,t){this.locked=!0,this.selectedElement=e,this.resize(t),this.selectorGroup.setAttribute("display","inline")}},{key:"updateGripCursors",value:function(e){var t,n=[],r=Math.round(e/45);for(t in r<0&&(r+=8),Bn.selectorGrips)n.push(t);for(;r>0;)n.push(n.shift()),r--;var a=0;for(t in Bn.selectorGrips)Bn.selectorGrips[t].setAttribute("style","cursor:"+n[a]+"-resize"),a++}},{key:"showGrips",value:function(e){var t=e?"inline":"none";Bn.selectorGripsGroup.setAttribute("display",t);var n=this.selectedElement;this.hasGrips=e,n&&e&&(this.selectorGroup.append(Bn.selectorGripsGroup),this.updateGripCursors(Kt(n)))}},{key:"resize",value:function(e){var t=this.selectorRect,n=Bn,r=n.selectorGrips,a=this.selectedElement,i=a.getAttribute("stroke-width"),o=jn.getCurrentZoom(),s=1/o;"none"===a.getAttribute("stroke")||isNaN(i)||(s+=i/2);var l=a.tagName;"text"===l&&(s+=2/o);var c=$(a),u=Pe(c).matrix;if(u.e*=o,u.f*=o,e||(e=Bt(a)),"g"===l&&!Xn.data(a,"gsvg")){var d=Yt([a.childNodes]);d&&(e=d)}var h=e.x,f=e.y,p=e.width,g=e.height;s*=o;var m=Ge(h*o,f*o,p*o,g*o,u),v=m.aabox,_=v.x-s,y=v.y-s,b=v.width+2*s,x=v.height+2*s,w=_+b/2,S=y+x/2,k=Kt(a);if(k){var C=jn.svgRoot().createSVGTransform();C.setRotate(-k,w,S);var A=C.matrix;m.tl=ke(m.tl.x,m.tl.y,A),m.tr=ke(m.tr.x,m.tr.y,A),m.bl=ke(m.bl.x,m.bl.y,A),m.br=ke(m.br.x,m.br.y,A);var E=m.tl,G=E.x,P=E.y,I=E.x,T=E.y,N=Math.min,L=Math.max;_=G=N(G,N(m.tr.x,N(m.bl.x,m.br.x)))-s,y=P=N(P,N(m.tr.y,N(m.bl.y,m.br.y)))-s,b=(I=L(I,L(m.tr.x,L(m.bl.x,m.br.x)))+s)-G,x=(T=L(T,L(m.tr.y,L(m.bl.y,m.br.y)))+s)-P}var M="M"+_+","+y+" L"+(_+b)+","+y+" "+(_+b)+","+(y+x)+" "+_+","+(y+x)+"z";t.setAttribute("d",M);var O=k?"rotate("+[k,w,S].join(",")+")":"";for(var V in this.selectorGroup.setAttribute("transform",O),this.gripCoords={nw:[_,y],ne:[_+b,y],sw:[_,y+x],se:[_+b,y+x],n:[_+b/2,y],w:[_,y+x/2],e:[_+b,y+x/2],s:[_+b/2,y+x]},this.gripCoords){var j=this.gripCoords[V];r[V].setAttribute("cx",j[0]),r[V].setAttribute("cy",j[1])}n.rotateGripConnector.setAttribute("x1",_+b/2),n.rotateGripConnector.setAttribute("y1",y),n.rotateGripConnector.setAttribute("x2",_+b/2),n.rotateGripConnector.setAttribute("y2",y-5*Qn),n.rotateGrip.setAttribute("cx",_+b/2),n.rotateGrip.setAttribute("cy",y-5*Qn)}}]),e}(),Zn=function(){function t(){r(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 i(t,[{key:"initGroup",value:function(){for(var e in this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.remove(),this.selectorParentGroup=jn.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}}),this.selectorGripsGroup=jn.createSVGElement({element:"g",attr:{display:"none"}}),this.selectorParentGroup.append(this.selectorGripsGroup),jn.svgRoot().append(this.selectorParentGroup),this.selectorMap={},this.selectors=[],this.rubberBandBox=null,this.selectorGrips){var t=jn.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+e,fill:"#22C",r:Qn,style:"cursor:"+e+"-resize","stroke-width":2,"pointer-events":"all"}});Xn.data(t,"dir",e),Xn.data(t,"type","resize"),this.selectorGrips[e]=this.selectorGripsGroup.appendChild(t)}if(this.rotateGripConnector=this.selectorGripsGroup.appendChild(jn.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}})),this.rotateGrip=this.selectorGripsGroup.appendChild(jn.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:Qn,stroke:"#22C","stroke-width":2,style:"cursor:url("+Rn.imgPath+"rotate.png) 12 12, auto;"}})),Xn.data(this.rotateGrip,"type","rotate"),!Xn("#canvasBackground").length){var n=d(Rn.dimensions,2),r=n[0],a=n[1],i=jn.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:r,height:a,x:0,y:0,overflow:j()?"none":"visible",style:"pointer-events:none"}}),o=jn.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(o),jn.svgRoot().insertBefore(i,jn.svgContent())}}},{key:"requestSelector",value:function(t,n){if(null==t)return null;var r=this.selectors.length;if("object"===e(this.selectorMap[t.id]))return this.selectorMap[t.id].locked=!0,this.selectorMap[t.id];for(var a=0;a').documentElement,!0);a.append(u);var f=c.createElementNS(p.SVG,"svg");(l.clearSvgContentElement=function(){$n(f).empty(),$n(f).attr({id:"svgcontent",width:s[0],height:s[1],x:s[0],y:s[1],overflow:o.show_outside_canvas?"visible":"hidden",xmlns:p.SVG,"xmlns:se":p.SE,"xmlns:xlink":p.XLINK}).appendTo(u);var e=c.createComment(" Created with SVG-edit - https://github.com/SVG-Edit/svgedit");f.append(e)})();var m="svg_";l.setIdPrefix=function(e){m=e},l.current_drawing_=new An(f,m);var v=l.getCurrentDrawing=function(){return l.current_drawing_},_=1,y=null,b={shape:{fill:("none"===o.initFill.color?"":"#")+o.initFill.color,fill_paint:null,fill_opacity:o.initFill.opacity,stroke:"#"+o.initStroke.color,stroke_paint:null,stroke_opacity:o.initStroke.opacity,stroke_width:o.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:o.initOpacity}};b.text=$n.extend(!0,{},b.shape),$n.extend(b.text,{fill:"#000000",stroke_width:o.text&&o.text.stroke_width,font_size:o.text&&o.text.font_size,font_family:o.text&&o.text.font_family});var x=b.shape,w=[],S=this.getJsonFromSvgElement=function(e){if(3===e.nodeType)return e.nodeValue;for(var t,n={element:e.tagName,attr:{},children:[]},r=0;t=e.attributes[r];r++)n.attr[t.name]=t.value;for(var a,i=0;a=e.childNodes[i];i++)n.children[i]=S(a);return n},k=this.addSVGElementFromJson=function(e){if("string"==typeof e)return c.createTextNode(e);var t=$t(e.attr.id),n=v().getCurrentLayer();if(t&&e.element!==t.tagName&&(t.remove(),t=null),!t){var r=e.namespace||p.SVG;t=c.createElementNS(r,e.element),n&&(y||n).append(t)}return e.curStyles&&Jt(t,{fill:x.fill,stroke:x.stroke,"stroke-width":x.stroke_width,"stroke-dasharray":x.stroke_dasharray,"stroke-linejoin":x.stroke_linejoin,"stroke-linecap":x.stroke_linecap,"stroke-opacity":x.stroke_opacity,"fill-opacity":x.fill_opacity,opacity:x.opacity/2,style:"pointer-events:inherit"},100),Jt(t,e.attr,100),en(t),e.children&&e.children.forEach(function(e){t.append(k(e))}),t};l.getTransformList=$,l.matrixMultiply=Ae,l.hasMatrixTransform=Ee,l.transformListToTransform=Pe;var C=function(){return o.baseUnit};!function(e){X=e;var t=document.createElementNS(p.SVG,"svg");document.body.append(t);var n=document.createElementNS(p.SVG,"rect");n.setAttribute("width","1em"),n.setAttribute("height","1ex"),n.setAttribute("x","1in"),t.append(n);var r=n.getBBox();t.remove();var a=r.x;ne={em:r.width,ex:r.height,in:a,cm:a/2.54,mm:a/25.4,pt:a/72,pc:a/6,px:1,"%":0}}({getBaseUnit:C,getElement:$t,getHeight:function(){return f.getAttribute("height")/_},getWidth:function(){return f.getAttribute("width")/_},getRoundDigits:function(){return fe.round_digits}}),l.convertToNum=se;var A,E=function(){return f},G=this.getSelectedElems=function(){return w},P=pt,I=function(){return u};_t=A={pathActions:P,getSVGContent:E,addSVGElementFromJson:k,getSelectedElements:G,getDOMDocument:function(){return c},getDOMContainer:function(){return a},getSVGRoot:I,getBaseUnit:C,getSnappingStep:function(){return o.snappingStep}},yt=A.getDOMDocument(),bt=A.getDOMContainer(),xt=A.getSVGRoot(),l.findDefs=Vt,l.getUrlFromAttr=Lt,l.getHref=Mt,l.setHref=Ot,l.getBBox=Bt,l.getRotationAngle=Kt,l.getElem=$t,l.getRefElem=Zt,l.assignAttributes=Jt,this.cleanupElement=en;var N=function(){return o.gridSnapping};!function(e){Hn=e}({getDrawing:function(){return v()},getSVGRoot:I,getGridSnapping:N}),this.remapElement=zn,function(e){Vn=e}({getSVGRoot:I,getStartTransform:function(){return be},setStartTransform:function(e){be=e}}),this.recalculateDimensions=Wn;var L=g();l.sanitizeSvg=Dn;var M=l.undoMgr=new ar({handleHistoryEvent:function(e,t){var n=ir;if(e===n.BEFORE_UNAPPLY||e===n.BEFORE_APPLY)l.clearSelection();else if(e===n.AFTER_APPLY||e===n.AFTER_UNAPPLY){var r=t.elements();l.pathActions.clear(),Y("changed",r);var a=t.type(),i=e===n.AFTER_APPLY;if(a===Jn.type())(i?t.newParent:t.oldParent)===f&&Pn();else if(a===er.type()||a===tr.type())t.parent===f&&Pn(),a===er.type()?i&&de(t.elem):i||de(t.elem),"use"===t.elem.tagName&&Dt(t.elem);else if(a===nr.type()){"title"===t.elem.tagName&&t.elem.parentNode.parentNode===f&&Pn();var o=i?t.newValues:t.oldValues;o.stdDeviation&&l.setBlurOffsets(t.elem.parentNode,o.stdDeviation)}}}}),O=function(e){l.undoMgr.addCommandToHistory(e)},V=this.getZoom=function(){return _},U=this.round=function(e){return parseInt(e*_,10)/_};!function(e,t){Rn=e,jn=t,Bn=new Zn}(o,{createSVGElement:function(e){return l.addSVGElementFromJson(e)},svgRoot:function(){return u},svgContent:function(){return f},getCurrentZoom:V});var F=this.selectorManager=Bn,H=l.getNextId=function(){return v().getNextId()},q=l.getId=function(){return v().getId()},Y=function(e,t){if(Ye[e])return Ye[e](window,t)},W=this.clearSelection=function(e){w.forEach(function(e){null!=e&&F.releaseSelector(e)}),w=[],e||Y("selected",w)},Z=this.addToSelection=function(e,t){if(e.length){for(var n=0;n1&&o.showGrips(!1)}}}for(Y("selected",w),t||1===w.length?F.requestSelector(w[0]).showGrips(!0):F.requestSelector(w[0]).showGrips(!1),w.sort(function(e,t){return e&&t&&e.compareDocumentPosition?3-(6&t.compareDocumentPosition(e)):null==e?1:void 0});null==w[0];)w.shift(0)}},J=function(){return x.opacity},ee=this.getMouseTarget=function(e){if(null==e)return null;var t=e.target;if(t.correspondingUseElement&&(t=t.correspondingUseElement),[p.MATH,p.HTML].includes(t.namespaceURI)&&"svgcanvas"!==t.id)for(;"foreignObject"!==t.nodeName;)if(!(t=t.parentNode))return u;var n=v().getCurrentLayer();if([u,a,f,n].includes(t))return u;if($n(t).closest("#selectorParentGroup").length)return F.selectorParentGroup;for(;t.parentNode!==(y||n);)t=t.parentNode;return t};l.pathActions=P,Fe({selectorManager:F,canvas:l,call:Y,resetD:function(e){e.setAttribute("d",P.convertPath(e))},round:U,clearSelection:W,addToSelection:Z,addCommandToHistory:O,remapElement:zn,addSVGElementFromJson:k,getGridSnapping:N,getOpacity:J,getSelectedElements:G,getContainer:function(){return a},setStarted:function(e){ye=e},getRubberBox:function(){return Oe},setRubberBox:function(e){return Oe=e},addPtsToSelection:function(e){var t=e.closedSubpath,n=e.grips;P.canDeleteNodes=!0,P.closed_subpath=t,Y("pointsAdded",{closedSubpath:t,grips:n}),Y("selected",n)},endChanges:function(e){var t=e.cmd,n=e.elem;O(t),Y("changed",[n])},getCurrentZoom:V,getId:q,getNextId:H,getMouseTarget:ee,getCurrentMode:function(){return xe},setCurrentMode:function(e){return xe=e},getDrawnPath:function(){return mt},setDrawnPath:function(e){return mt=e},getSVGRoot:I});var te={},oe="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use",le=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],ce=$n.data,ue=document.createElementNS(p.SVG,"animate");$n(ue).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(u);var de=function e(t){var n=$n(t).attr(le);for(var r in n){var a=n[r];if(a&&a.startsWith("url(")){var i=Lt(a).substr(1);$t(i)||(Vt().append(ve[i]),delete ve[i])}}var o=t.getElementsByTagName("*");if(o.length)for(var s=0,l=o.length;s0&&(4===s.getItem(0).type&&s.removeItem(0));if(0!==e){var l=ke(i,o,Pe(s).matrix),c=u.createSVGTransform();c.setRotate(e,l.x,l.y),s.numberOfItems?s.insertItemBefore(c,0):s.appendItem(c)}else 0===s.numberOfItems&&n.removeAttribute("transform");if(!t){var d=n.getAttribute("transform");n.setAttribute("transform",r),sn("transform",d,w),Y("changed",w)}var h=F.requestSelector(w[0]);h.resize(),h.updateGripCursors(e)};var Xe=this.recalculateAllSelectedDimensions=function(){for(var e=new rr("none"===Se?"position":"size"),t=w.length;t--;){var n=w[t],r=Wn(n);r&&e.addSubCommand(r)}e.isEmpty()||(O(e),Y("changed",w))},Qe=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},Ke=null,Ze=this.selectOnly=function(e,t){W(!0),Z(e,t)};this.removeFromSelection=function(e){if(null!=w[0]&&e.length){for(var t=[],n=w.length,r=0;r0&&l.removeFromSelection(E),G.length>0&&l.addToSelection(G);break;case"resize":p=$(g);var L=Ee(p),M=(h=L?it:Bt(g)).x,O=h.y,V=h,j=V.width,R=V.height;if(i=S-et,s=C-tt,o.gridSnapping&&(i=tn(i),s=tn(s),R=tn(R),j=tn(j)),d=Kt(g)){var B=Math.sqrt(i*i+s*s),D=Math.atan2(s,i)-d*Math.PI/180;i=B*Math.cos(D),s=B*Math.sin(D)}Se.includes("n")||Se.includes("s")||(s=0),Se.includes("e")||Se.includes("w")||(i=0);var U=0,H=0,z=R?(R+s)/R:1,W=j?(j+i)/j:1;Se.includes("n")&&(z=R?(R-s)/R:1,H=R),Se.includes("w")&&(W=j?(j-i)/j:1,U=j);var X=u.createSVGTransform(),Q=u.createSVGTransform(),K=u.createSVGTransform();if(o.gridSnapping&&(M=tn(M),U=tn(U),O=tn(O),H=tn(H)),X.setTranslate(-(M+U),-(O+H)),e.shiftKey&&(1===W?W=z:z=W),Q.setScale(W,z),K.setTranslate(M+U,O+H),L){var Z=d?1:0;p.replaceItem(X,2+Z),p.replaceItem(Q,1+Z),p.replaceItem(K,Number(Z))}else{var J=p.numberOfItems;p.replaceItem(K,J-3),p.replaceItem(Q,J-2),p.replaceItem(X,J-1)}F.requestSelector(g).resize(),Y("transition",w);break;case"zoom":x*=_,k*=_,Jt(Oe,{x:Math.min(nt*_,x),y:Math.min(at*_,k),width:Math.abs(x-nt*_),height:Math.abs(k-at*_)},100);break;case"text":Jt(b,{x:S,y:C},1e3);break;case"line":o.gridSnapping&&(S=tn(S),C=tn(C));var ee=S,te=C;e.shiftKey&&(ee=(n=Te(et,tt,ee,te)).x,te=n.y),b.setAttribute("x2",ee),b.setAttribute("y2",te);break;case"foreignObject":case"square":case"rect":case"image":var ne,re,ae="square"===xe||e.shiftKey,ie=Math.abs(S-et),oe=Math.abs(C-tt);ae?(ie=oe=Math.max(ie,oe),ne=et.8){ot-=.8;var de=f.createSVGPoint();de.x=dt.x,de.y=dt.y,b.points.appendItem(de)}st={x:lt.x,y:lt.y},lt={x:ct.x,y:ct.y},ct={x:ut.x,y:ut.y};break;case"path":case"pathedit":if(S*=_,C*=_,o.gridSnapping&&(S=tn(S),C=tn(C),et=tn(et),tt=tn(tt)),e.shiftKey){var he,fe,pe=De;pe?(he=pe.dragging?pe.dragging[0]:et,fe=pe.dragging?pe.dragging[1]:tt):(he=et,fe=tt);var ge=n=Te(he,fe,S,C);S=ge.x,C=ge.y}Oe&&"none"!==Oe.getAttribute("display")&&(x*=_,k*=_,Jt(Oe,{x:Math.min(nt*_,x),y:Math.min(at*_,k),width:Math.abs(x-nt*_),height:Math.abs(k-at*_)},100)),P.mouseMove(S,C);break;case"textedit":S*=_,C*=_,At.mouseMove(v,y);break;case"rotate":r=(h=Bt(g)).x+h.width/2,a=h.y+h.height/2;var me=Ie(g),ve=ke(r,a,me);r=ve.x,a=ve.y,d=(Math.atan2(a-C,r-S)*(180/Math.PI)-90)%360,o.gridSnapping&&(d=tn(d)),e.shiftKey&&(d=45*Math.round(d/45)),l.setRotationAngle(d<-180?360+d:d,!0),Y("transition",w)}Ue("mouseMove",{event:e,mouse_x:v,mouse_y:y,selected:g})}}).click(function(e){return e.preventDefault(),!1}).dblclick(function(e){var t=e.target.parentNode;if(t!==y){var n=ee(e),r=n.tagName;if("text"===r&&"textedit"!==xe){var a=ke(e.pageX,e.pageY,Ke);At.select(n,a.x,a.y)}"g"!==r&&"a"!==r||!Kt(n)||(ln(n),n=w[0],W(!0)),y&&In(),"g"!==t.tagName&&"a"!==t.tagName||t===v().getCurrentLayer()||n===F.selectorParentGroup||Tn(n)}}).mouseup(function(e){if(2!==e.button){var t=Me;if(Me=null,ye){var n,r,a=ke(e.pageX,e.pageY,Ke),i=a.x*_,s=a.y*_,c=i/_,u=s/_,d=$t(q()),h=!1,f=c,p=u;switch(ye=!1,xe){case"resize":case"multiselect":null!=Oe&&(Oe.setAttribute("display","none"),je=[]),xe="select";case"select":if(null!=w[0]){if(null==w[1]){var g=w[0];switch(g.tagName){case"g":case"use":case"image":case"foreignObject":break;default:Le.fill=g.getAttribute("fill"),Le.fill_opacity=g.getAttribute("fill-opacity"),Le.stroke=g.getAttribute("stroke"),Le.stroke_opacity=g.getAttribute("stroke-opacity"),Le.stroke_width=g.getAttribute("stroke-width"),Le.stroke_dasharray=g.getAttribute("stroke-dasharray"),Le.stroke_linejoin=g.getAttribute("stroke-linejoin"),Le.stroke_linecap=g.getAttribute("stroke-linecap")}"text"===g.tagName&&(ge.font_size=g.getAttribute("font-size"),ge.font_family=g.getAttribute("font-family")),F.requestSelector(g).showGrips(!0)}if(Xe(),f!==nt||p!==at)for(var m=w.length,y=0;y=0?C.indexOf(",",A+1)>=0:C.indexOf(" ",C.indexOf(" ")+1)>=0)&&(d=P.smoothPolylineIntoPath(d));break;case"line":n=$n(d).attr(["x1","x2","y1","y2"]),h=n.x1!==n.x2||n.y1!==n.y2;break;case"foreignObject":case"square":case"rect":case"image":n=$n(d).attr(["width","height"]),h=n.width||n.height||"image"===xe;break;case"circle":h="0"!==d.getAttribute("r");break;case"ellipse":n=$n(d).attr(["rx","ry"]),h=n.rx||n.ry;break;case"fhellipse":Je.maxx-Je.minx>0&&Je.maxy-Je.miny>0&&(d=k({element:"ellipse",curStyles:!0,attr:{cx:(Je.minx+Je.maxx)/2,cy:(Je.miny+Je.maxy)/2,rx:(Je.maxx-Je.minx)/2,ry:(Je.maxy-Je.miny)/2,id:q()}}),Y("changed",[d]),h=!0);break;case"fhrect":Je.maxx-Je.minx>0&&Je.maxy-Je.miny>0&&(d=k({element:"rect",curStyles:!0,attr:{x:Je.minx,y:Je.miny,width:Je.maxx-Je.minx,height:Je.maxy-Je.miny,id:q()}}),Y("changed",[d]),h=!0);break;case"text":h=!0,Ze([d]),At.start(d);break;case"path":d=null,ye=!0;var E=P.mouseUp(e,d,i,s);d=E.element,h=E.keep;break;case"pathedit":h=!0,d=null,P.mouseUp(e);break;case"textedit":h=!1,d=null,At.mouseUp(e,i,s);break;case"rotate":h=!0,d=null,xe="select";var G=l.undoMgr.finishUndoableChange();G.isEmpty()||O(G),Xe(),Y("changed",w)}var I=Ue("mouseUp",{event:e,mouse_x:i,mouse_y:s},!0);if($n.each(I,function(e,t){t&&(h=t.keep||h,d=t.element,ye=t.started||ye)}),h||null==d){if(null!=d){l.addedNew=!0;var T,N=.2;if(ue.beginElement&&parseFloat(d.getAttribute("opacity"))!==x.opacity){T=$n(ue).clone().attr({to:x.opacity,dur:N}).appendTo(d);try{T[0].beginElement()}catch(e){}}else N=0;setTimeout(function(){T&&T.remove(),d.setAttribute("opacity",x.opacity),d.setAttribute("style","pointer-events:inherit"),en(d),"path"===xe?P.toEditMode(d):o.selectNew&&Ze([d],!0),O(new er(d)),Y("changed",[d])},1e3*N)}}else{for(v().releaseId(q()),d.remove(),d=null,r=e.target;r&&r.parentNode&&r.parentNode.parentNode&&"g"===r.parentNode.parentNode.tagName;)r=r.parentNode;"path"===xe&&mt||!r||!r.parentNode||"selectorParentGroup"===r.parentNode.id||"svgcanvas"===r.id||"svgroot"===r.id||(l.setMode("select"),Ze([r],!0))}be=null}}}),$n(a).bind("mousewheel DOMMouseScroll",function(e){if(e.shiftKey){e.preventDefault();var t=e.originalEvent;Ke=$n("#svgcontent g")[0].getScreenCTM().inverse();var n=$n("#workarea"),r=o.showRulers?16:0,a=ke(t.pageX,t.pageY,Ke),i=n.width(),s=n.height(),c=i-15-r,u=s-15-r,d=c*Ke.a,h=u*Ke.d,f=n.offset(),p=f.left+r,g=f.top+r,m=t.wheelDelta?t.wheelDelta:t.detail?-t.detail:0;if(m){var v,y,b=Math.max(.75,Math.min(4/3,m));b>1?(v=Math.ceil(c/d*b*100)/100,y=Math.ceil(u/h*b*100)/100):(v=Math.floor(c/d*b*100)/100,y=Math.floor(u/h*b*100)/100);var x=Math.min(v,y);if((x=Math.min(10,Math.max(.01,x)))!==_){b=x/_;var w=ke(p,g,Ke),S={x:(a.x-(a.x-w.x)/b)*x-r+i/2,y:(a.y-(a.y-w.y)/b)*x-r+s/2};l.setZoom(x),$n("#zoom").val((100*x).toFixed(1)),Y("updateCanvas",{center:!1,newCtr:S}),Y("zoomDone")}}}});var vt,At=l.textActions=function(){var e,t,n,r,a,i,o,s,c,d,h=[];function f(e){var o=""===t.value;if($n(t).focus(),!arguments.length)if(o)e=0;else{if(t.selectionEnd!==t.selectionStart)return;e=t.selectionEnd}var s=h[e];o||t.setSelectionRange(e,e),(n=$t("text_cursor"))||(n=document.createElementNS(p.SVG,"line"),Jt(n,{id:"text_cursor",stroke:"#333","stroke-width":1}),n=$t("selectorParentGroup").appendChild(n)),a||(a=setInterval(function(){var e="none"===n.getAttribute("display");n.setAttribute("display",e?"inline":"none")},600));var l=x(s.x,i.y),c=x(s.x,i.y+i.height);Jt(n,{x1:l.x,y1:l.y,x2:c.x,y2:c.y,visibility:"visible",display:"inline"}),r&&r.setAttribute("d","")}function g(e,a,o){if(e!==a){o||t.setSelectionRange(e,a),(r=$t("text_selectblock"))||(r=document.createElementNS(p.SVG,"path"),Jt(r,{id:"text_selectblock",fill:"green",opacity:.5,style:"pointer-events:none"}),$t("selectorParentGroup").append(r));var s=h[e],l=h[a];n.setAttribute("visibility","hidden");var c=x(s.x,i.y),u=x(s.x+(l.x-s.x),i.y),d=x(s.x,i.y+i.height),g=x(s.x+(l.x-s.x),i.y+i.height),m="M"+c.x+","+c.y+" L"+u.x+","+u.y+" "+g.x+","+g.y+" "+d.x+","+d.y+"z";Jt(r,{d:m,display:"inline"})}else f(a)}function m(t,n){var r=u.createSVGPoint();if(r.x=t,r.y=n,1===h.length)return 0;var a=e.getCharNumAtPosition(r);a<0?(a=h.length-2,t<=h[0].x&&(a=0)):a>=h.length-2&&(a=h.length-2);var i=h[a];return t>i.x+i.width/2&&a++,a}function v(e,t){f(m(e,t))}function y(e,n,r){var a=t.selectionStart,i=m(e,n);g(Math.min(a,i),Math.max(a,i),!r)}function b(e,t){var n={x:e,y:t};if(n.x/=_,n.y/=_,o){var r=ke(n.x,n.y,o.inverse());n.x=r.x,n.y=r.y}return n}function x(e,t){var n={x:e,y:t};if(o){var r=ke(n.x,n.y,o);n.x=r.x,n.y=r.y}return n.x*=_,n.y*=_,n}function S(t){g(0,e.textContent.length),$n(this).unbind(t)}function k(t){if(d&&e){var n=ke(t.pageX,t.pageY,Ke),r=b(n.x*_,n.y*_),a=m(r.x,r.y),i=e.textContent,o=i.substr(0,a).replace(/[a-z0-9]+$/i,"").length,s=i.substr(a).match(/^[a-z0-9]+/i);g(o,(s?s[0].length:0)+a),$n(t.target).click(S),setTimeout(function(){$n(t.target).unbind("click",S)},300)}}return{select:function(t,n,r){e=t,At.toEditMode(n,r)},start:function(t){e=t,At.toEditMode()},mouseDown:function(e,n,r,a){var i=b(r,a);t.focus(),v(i.x,i.y),s=r,c=a},mouseMove:function(e,t){var n=b(e,t);y(n.x,n.y)},mouseUp:function(t,n,r){var a=b(n,r);y(a.x,a.y,!0),t.target!==e&&ns-2&&rc-2&&At.toSelectMode(!0)},setCursor:f,toEditMode:function(t,n){if(d=!1,xe="textedit",F.requestSelector(e).showGrips(!1),F.requestSelector(e),At.init(),$n(e).css("cursor","text"),arguments.length){var r=b(t,n);v(r.x,r.y)}else f();setTimeout(function(){d=!0},300)},toSelectMode:function(i){xe="select",clearInterval(a),a=null,r&&$n(r).attr("display","none"),n&&$n(n).attr("visibility","hidden"),$n(e).css("cursor","move"),i&&(W(),$n(e).css("cursor","move"),Y("selected",[e]),Z([e],!0)),e&&!e.textContent.length&&l.deleteSelectedElements(),$n(t).blur(),e=!1},setInputElem:function(e){t=e},clear:function(){"textedit"===xe&&At.toSelectMode()},init:function(n){if(e){var r,a;e.parentNode||(e=w[0],F.requestSelector(e).showGrips(!1));var s=e.textContent.length,c=e.getAttribute("transform");for(i=Bt(e),o=c?Ie(e):null,(h=[]).length=s,t.focus(),$n(e).unbind("dblclick",k).dblclick(k),s||(a={x:i.x+i.width/2,width:0}),r=0;r")[0].getContext("2d")||(n.text=te.exportNoText),$n.each(n,function(n,a){r.find(n).length&&(t.push(n),e.push(a))}),{issues:e,issueCodes:t}}this.svgCanvasToString=function(){for(;Et()>0;);P.clear(!0),$n.each(f.childNodes,function(e,t){e&&8===t.nodeType&&t.data.includes("Created with")&&f.firstChild.before(t)}),y&&(In(),Ze([y]));var e=[];$n(f).find("g:data(gsvg)").each(function(){for(var t=this.attributes,n=t.length,r=0;rt.name?-1:1}),i=0;i=0;i--){var m=s[i],v=St(m.value);if(!g.includes(m.localName)&&""!==v){if(v.startsWith("pointer-events"))continue;if("class"===m.localName&&v.startsWith("se_"))continue;if(n.push(" "),"d"===m.localName&&(v=P.convertPath(e,!0)),isNaN(v)?a.test(v)&&(v=ae(v)+r):v=ae(v),fe.apply&&"image"===e.nodeName&&"href"===m.localName&&fe.images&&"embed"===fe.images){var _=he[v];_&&(v=_)}m.namespaceURI&&m.namespaceURI!==p.SVG&&!L[m.namespaceURI]||(n.push(m.nodeName),n.push('="'),n.push(v),n.push('"'))}}}if(e.hasChildNodes()){n.push(">"),t++;var y=!1;for(i=0;i");break;case 8:n.push("\n"),n.push(new Array(t+1).join(" ")),n.push("\x3c!--"),n.push(b.data),n.push("--\x3e")}}if(t--,!y)for(n.push("\n"),i=0;i")}else n.push("/>")}return n.join("")},this.embedImage=function(e,t){return new Promise(function(n,r){$n(new Image).load(function(a,i,o){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 l=";svgedit_url="+encodeURIComponent(e);l=s.toDataURL().replace(";base64",l+";base64"),he[e]=l}catch(t){he[e]=!1}_e=e,t&&t(he[e]),n(he[e])}else r(new Error("Error loading image: "+o.status+" "+o.statusText))}).attr("src",e)})},this.setGoodImage=function(e){_e=e},this.open=function(){},this.save=function(e){W(),e&&$n.extend(fe,e),fe.apply=!0;var t=this.svgCanvasToString();Y("saved",t)},this.rasterExport=function(e,t,r,a){var i="ICO"===e?"BMP":e||"PNG",s="image/"+i.toLowerCase(),c=It(),u=c.issues,d=c.issueCodes,h=this.svgCanvasToString();return new Promise(function(){var c=n(regeneratorRuntime.mark(function n(c,f){var p,g,m,v,_,y;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(y=function(){var n={datauri:v,bloburl:_,svg:h,issues:u,issueCodes:d,type:e,mimeType:s,quality:t,exportWindowName:r};Y("exported",n),a&&a(n),c(n)},vt){n.next=6;break}return n.next=4,un(o.canvgPath+"canvg.js",{global:"canvg"});case 4:p=n.sent,vt=p.canvg;case 6:return $n("#export_canvas").length||$n("",{id:"export_canvas"}).hide().appendTo("body"),(g=$n("#export_canvas")[0]).width=l.contentW,g.height=l.contentH,n.next=12,vt(g,h);case 12:if(m=i.toLowerCase(),v=t?g.toDataURL("image/"+m,t):g.toDataURL("image/"+m),!g.toBlob){n.next=17;break}return g.toBlob(function(e){_=Pt(e),y()},s,t),n.abrupt("return");case 17:_=Gt(v),y();case 19:case"end":return n.stop()}},n,this)}));return function(e,t){return c.apply(this,arguments)}}())},this.exportPDF=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D()?"save":void 0,r=arguments.length>2?arguments[2]:void 0,a=this;return new Promise(function(){var i=n(regeneratorRuntime.mark(function n(i,s){var l,c,u,d,h,f,p,g,m,v;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(window.jsPDF){n.next=6;break}return n.next=3,hn(["jspdf/underscore-min.js","jspdf/jspdf.min.js"]);case 3:return l=!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules),n.next=6,hn(o.jspdfPath+"jspdf.plugin.svgToPdf.js",{type:l?"module":"text/javascript"});case 6:c=Yt(),u=c.w>c.h?"landscape":"portrait","pt",d=jsPDF({orientation:u,unit:"pt",format:[c.w,c.h]}),h=Qt(),d.setProperties({title:h}),f=It(),p=f.issues,g=f.issueCodes,m=a.svgCanvasToString(),d.addSVG(m,0,0),(v={svg:m,issues:p,issueCodes:g,exportWindowName:e,outputType:t=t||"dataurlstring"}).output=d.output(t,"save"===t?e||"svg.pdf":void 0),r&&r(v),i(v),Y("exportedPDF",v);case 21:case"end":return n.stop()}},n,this)}));return function(e,t){return i.apply(this,arguments)}}())},this.getSvgString=function(){return fe.apply=!1,this.svgCanvasToString()},this.randomizeIds=function(e){arguments.length>0&&!1===e?En(!1,v()):En(!0,v())};var Rt=this.uniquifyElems=function(e){var t={},n=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];for(var r in Nt(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),$n.each(le,function(n,r){var a=e.getAttributeNode(r);if(a){var i=Lt(a.value),o=i?i.substr(1):null;o&&(o in t||(t[o]={elem:null,attrs:[],hrefs:[]}),t[o].attrs.push(a))}});var r=Mt(e);if(r&&n.includes(e.nodeName)){var a=r.substr(1);a&&(a in t||(t[a]={elem:null,attrs:[],hrefs:[]}),t[a].hrefs.push(e))}}}),t)if(r){var a=t[r].elem;if(a){var i=H();a.id=i;for(var o=t[r].attrs,s=o.length;s--;){var l=o[s];l.ownerElement.setAttribute(l.name,"url(#"+i+")")}for(var c=t[r].hrefs,u=c.length;u--;){var d=c[u];Ot(d,"#"+i)}}}},Dt=this.setUseData=function(e){var t=$n(e);"use"!==e.tagName&&(t=t.find("use")),t.each(function(){var e=Mt(this).substr(1),t=$t(e);t&&($n(this).data("ref",t),"symbol"!==t.tagName&&"svg"!==t.tagName||$n(this).data("symbol",t).data("ref",t))})},zt=this.convertGradients=function(e){var t=$n(e).find("linearGradient, radialGradient");!t.length&&j()&&(t=$n(e).find("*").filter(function(){return this.tagName.includes("Gradient")})),t.each(function(){if("userSpaceOnUse"===$n(this).attr("gradientUnits")){var e=$n(f).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(!e.length)return;var t=Bt(e[0]);if(!t)return;if("linearGradient"===this.tagName){var n=$n(this).attr(["x1","y1","x2","y2"]),r=this.gradientTransform.baseVal;if(r&&r.numberOfItems>0){var a=Pe(r).matrix,i=ke(n.x1,n.y1,a),o=ke(n.x2,n.y2,a);n.x1=i.x,n.y1=i.y,n.x2=o.x,n.y2=o.y,this.removeAttribute("gradientTransform")}$n(this).attr({x1:(n.x1-t.x)/t.width,y1:(n.y1-t.y)/t.height,x2:(n.x2-t.x)/t.width,y2:(n.y2-t.y)/t.height}),this.removeAttribute("gradientUnits")}}})},qt=this.convertToGroup=function(e){e||(e=w[0]);var t,n=$n(e),r=new rr;if(n.data("gsvg")){var a=e.firstChild,i=$n(a).attr(["x","y"]);$n(e.firstChild.firstChild).unwrap(),$n(e).removeData("gsvg");var o=$(e),s=u.createSVGTransform();s.setTranslate(i.x,i.y),o.appendItem(s),Wn(e),Y("selected",[e])}else if(n.data("symbol")){e=n.data("symbol"),t=n.attr("transform");var l=n.attr(["x","y"]),d=e.getAttribute("viewBox");if(d){var h=d.split(" ");l.x-=+h[0],l.y-=+h[1]}t+=" translate("+(l.x||0)+","+(l.y||0)+")";var g=n.prev();r.addSubCommand(new tr(n[0],n[0].nextSibling,n[0].parentNode)),n.remove();var m,v=$n(f).find("use:data(symbol)").length,_=c.createElementNS(p.SVG,"g"),y=e.childNodes;for(m=0;md?"scale("+_/3/m[3]+")":"scale("+_/3/m[2]+")")+" translate(0)",o=c.createElementNS(p.SVG,"symbol");var b=Vt();for(R()&&$n(l).find("linearGradient, radialGradient, pattern").appendTo(b);l.firstChild;){var x=l.firstChild;o.append(x)}for(var w=l.attributes,S=0;S0&&(n?on(e,t,r):(sn(e,t,r),Y("changed",r)))};var rn=this.setGradient=function(e){if(Le[e+"_paint"]&&"solidColor"!==Le[e+"_paint"].type){var t=l[e+"Grad"],n=an(t),r=Vt();n?t=n:(t=r.appendChild(c.importNode(t,!0))).id=H(),l.setColor(e,"url(#"+t.id+")")}},an=function(e){for(var t=Vt(),n=$n(t).find("linearGradient, radialGradient"),r=n.length,a=["r","cx","cy","fx","fy"];r--;){var i=n[r];if("linearGradient"===e.tagName){if(e.getAttribute("x1")!==i.getAttribute("x1")||e.getAttribute("y1")!==i.getAttribute("y1")||e.getAttribute("x2")!==i.getAttribute("x2")||e.getAttribute("y2")!==i.getAttribute("y2"))continue}else if("continue"===function(){var t=$n(e).attr(a),n=$n(i).attr(a),r=!1;if($n.each(a,function(e,a){t[a]!==n[a]&&(r=!0)}),r)return"continue"}())continue;var o=e.getElementsByTagNameNS(p.SVG,"stop"),s=i.getElementsByTagNameNS(p.SVG,"stop");if(o.length===s.length){for(var l=o.length;l--;){var c=o[l],u=s[l];if(c.getAttribute("offset")!==u.getAttribute("offset")||c.getAttribute("stop-opacity")!==u.getAttribute("stop-opacity")||c.getAttribute("stop-color")!==u.getAttribute("stop-color"))break}if(-1===l)return i}}return null};this.setPaint=function(e,t){var n=new $n.jGraduate.Paint(t);switch(this.setPaintOpacity(e,n.alpha/100,!0),Le[e+"_paint"]=n,n.type){case"solidColor":this.setColor(e,"none"!==n.solidColor?"#"+n.solidColor:"none");break;case"linearGradient":case"radialGradient":l[e+"Grad"]=n[n.type],rn(e)}},this.setStrokePaint=function(e){this.setPaint("stroke",e)},this.setFillPaint=function(e){this.setPaint("fill",e)},this.getStrokeWidth=function(){return Le.stroke_width},this.setStrokeWidth=function(e){if(0===e&&["line","path"].includes(xe))l.setStrokeWidth(1);else{Le.stroke_width=e;for(var t=[],n=w.length;n--;){var r=w[n];r&&("g"===r.tagName?Nt(r,a):t.push(r))}t.length>0&&(sn("stroke-width",e,t),Y("changed",w))}function a(e){"g"!==e.nodeName&&t.push(e)}},this.setStrokeAttr=function(e,t){x[e.replace("-","_")]=t;for(var n=[],r=w.length;r--;){var a=w[r];a&&("g"===a.tagName?Nt(a,function(e){"g"!==e.nodeName&&n.push(e)}):n.push(a))}n.length>0&&(sn(e,t,n),Y("changed",w))},this.getStyle=function(){return x},this.getOpacity=J,this.setOpacity=function(e){x.opacity=e,sn("opacity",e)},this.getFillOpacity=function(){return x.fill_opacity},this.getStrokeOpacity=function(){return x.stroke_opacity},this.setPaintOpacity=function(e,t,n){x[e+"_opacity"]=t,n?on(e+"-opacity",t):sn(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 n=$t(e.id+"_blur");n&&(t=n.firstChild.getAttribute("stdDeviation"))}return t},function(){var e=null,t=null,n=!1;function r(){var n=l.undoMgr.finishUndoableChange();e.addSubCommand(n),O(e),e=null,t=null}l.setBlurNoUndo=function(e){if(t)if(0===e)on("filter",""),n=!0;else{var r=w[0];n&&on("filter","url(#"+r.id+"_blur)"),j()&&(console.log("e",r),r.removeAttribute("filter"),r.setAttribute("filter","url(#"+r.id+"_blur)")),on("stdDeviation",e,[t.firstChild]),l.setBlurOffsets(t,e)}else l.setBlur(e)},l.setBlurOffsets=function(e,t){t>3?Jt(e,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100):j()||(e.removeAttribute("x"),e.removeAttribute("y"),e.removeAttribute("width"),e.removeAttribute("height"))},l.setBlur=function(n,a){if(e)r();else{var i=w[0],o=i.id;t=$t(o+"_blur"),n-=0;var s=new rr;if(t)0===n&&(t=null);else{var c=k({element:"feGaussianBlur",attr:{in:"SourceGraphic",stdDeviation:n}});(t=k({element:"filter",attr:{id:o+"_blur"}})).append(c),Vt().append(t),s.addSubCommand(new er(t))}var u={filter:i.getAttribute("filter")};if(0===n)return i.removeAttribute("filter"),void s.addSubCommand(new nr(i,u));sn("filter","url(#"+o+"_blur)"),s.addSubCommand(new nr(i,u)),l.setBlurOffsets(t,n),e=s,l.undoMgr.beginUndoableChange("stdDeviation",[t?t.firstChild:null]),a&&(l.setBlurNoUndo(n),r())}}}(),this.getBold=function(){var e=w[0];return null!=e&&"text"===e.tagName&&null==w[1]&&"bold"===e.getAttribute("font-weight")},this.setBold=function(e){var t=w[0];null!=t&&"text"===t.tagName&&null==w[1]&&sn("font-weight",e?"bold":"normal"),w[0].textContent||At.setCursor()},this.getItalic=function(){var e=w[0];return null!=e&&"text"===e.tagName&&null==w[1]&&"italic"===e.getAttribute("font-style")},this.setItalic=function(e){var t=w[0];null!=t&&"text"===t.tagName&&null==w[1]&&sn("font-style",e?"italic":"normal"),w[0].textContent||At.setCursor()},this.getFontFamily=function(){return ge.font_family},this.setFontFamily=function(e){ge.font_family=e,sn("font-family",e),w[0]&&!w[0].textContent&&At.setCursor()},this.setFontColor=function(e){ge.fill=e,sn("fill",e)},this.getFontColor=function(){return ge.fill},this.getFontSize=function(){return ge.font_size},this.setFontSize=function(e){ge.font_size=e,sn("font-size",e),w[0].textContent||At.setCursor()},this.getText=function(){var e=w[0];return null==e?"":e.textContent},this.setTextContent=function(e){sn("#text",e),At.init(e),At.setCursor()},this.setImageURL=function(e){var t=w[0];if(t){var n=$n(t).attr(["width","height"]),r=!n.width||!n.height,a=Mt(t);if(a!==e||r){var i=new rr("Change Image URL");Ot(t,e),i.addSubCommand(new nr(t,{"#href":a})),$n(new Image).load(function(){var e=$n(t).attr(["width","height"]);$n(t).attr({width:this.width,height:this.height}),F.requestSelector(t).resize(),i.addSubCommand(new nr(t,e)),O(i),Y("changed",[t])}).attr("src",e)}}},this.setLinkURL=function(e){var t=w[0];if(t){if("a"!==t.tagName){var n=$n(t).parents("a");if(!n.length)return;t=n[0]}var r=Mt(t);if(r!==e){var a=new rr("Change Link URL");Ot(t,e),a.addSubCommand(new nr(t,{"#href":r})),O(a)}}},this.setRectRadius=function(e){var t=w[0];if(null!=t&&"rect"===t.tagName){var n=t.getAttribute("rx");n!==String(e)&&(t.setAttribute("rx",e),t.setAttribute("ry",e),O(new nr(t,{rx:n,ry:n},"Radius")),Y("changed",[t]))}},this.makeHyperlink=function(e){l.groupSelectedElements("a",e)},this.removeHyperlink=function(){l.ungroupSelectedElement()},this.setSegType=function(e){P.setSegType(e)},this.convertToPath=function(e,t){if(null!=e)return t?Ht(e,k,P):function(e,t,n,r,a,i,o,s){var l=new o.BatchCommand("Convert element to Path"),c=n({element:"path",attr:t=gt.extend({},t,Ft(e))}),u=e.getAttribute("transform");u&&c.setAttribute("transform",u);var d=e.id,h=e.parentNode;e.nextSibling?e.before(c):h.append(c);var f=Ut(e);if(f){if(c.setAttribute("d",f),u){var p=$(c);Ee(p)&&r.resetOrientation(c)}var g=e.nextSibling;return l.addSubCommand(new o.RemoveElementCommand(e,g,h)),l.addSubCommand(new o.InsertElementCommand(c)),a(),e.remove(),c.setAttribute("id",d),c.removeAttribute("visibility"),i([c],!0),s(l),c}return c.remove(),null}(e,{fill:x.fill,"fill-opacity":x.fill_opacity,stroke:x.stroke,"stroke-width":x.stroke_width,"stroke-dasharray":x.stroke_dasharray,"stroke-linejoin":x.stroke_linejoin,"stroke-linecap":x.stroke_linecap,"stroke-opacity":x.stroke_opacity,opacity:x.opacity,visibility:"hidden"},k,P,W,Z,we,O);var n=w;$n.each(n,function(e,t){t&&l.convertToPath(t)})};var on=function(e,t,n){"pathedit"===xe&&P.moveNode(e,t);for(var r=(n=n||w).length,a=["g","polyline","path"],i=["transform","opacity","filter"],o=function(){var o=n[r];if(null==o)return"continue";if(("x"===e||"y"===e)&&a.includes(o.tagName)){var s=Xt([o]),c="x"===e?t-s.x:0,d="y"===e?t-s.y:0;return l.moveSelectedElements(c*_,d*_,!0),"continue"}"g"===o.tagName&&i.includes(e);var h="#text"===e?o.textContent:o.getAttribute(e);if(null==h&&(h=""),h!==String(t)){"#text"===e?(o.textContent=t,/rotate/.test(o.getAttribute("transform"))&&(o=We(o))):"#href"===e?Ot(o,t):o.setAttribute(e,t),"textedit"===xe&&"#text"!==e&&o.textContent.length&&At.toSelectMode(o),R()&&"text"===o.nodeName&&/rotate/.test(o.getAttribute("transform"))&&(String(t).startsWith("url")||["font-size","font-family","x","y"].includes(e)&&o.textContent)&&(o=We(o)),w.includes(o)&&setTimeout(function(){o.parentNode&&F.requestSelector(o).resize()},0);var f=Kt(o);if(0!==f&&"transform"!==e)for(var p=$(o),g=p.numberOfItems;g--;){if(4===p.getItem(g).type){p.removeItem(g);var m=Bt(o),v=ke(m.x+m.width/2,m.y+m.height/2,Pe(p).matrix),y=v.x,b=v.y,x=u.createSVGTransform();x.setRotate(f,y,b),p.insertItemBefore(x,g);break}}}};r--;)o()},sn=this.changeSelectedAttribute=function(e,t,n){n=n||w,l.undoMgr.beginUndoableChange(e,n),on(e,t,n);var r=l.undoMgr.finishUndoableChange();r.isEmpty()||O(r)};this.deleteSelectedElements=function(){for(var e=new rr("Delete Elements"),t=w.length,n=[],r=0;rn[d].width)||("t"===e||"m"===e||"b"===e)&&(u===Number.MIN_VALUE||u>n[d].height))&&(a=n[d].x,o=n[d].y,i=n[d].x+n[d].width,s=n[d].y+n[d].height,c=n[d].width,u=n[d].height);break;case"largest":(("l"===e||"c"===e||"r"===e)&&(c===Number.MIN_VALUE||ci&&(i=n[d].x+n[d].width),n[d].y+n[d].height>s&&(s=n[d].y+n[d].height)}}"page"===t&&(a=0,o=0,i=l.contentW,s=l.contentH);for(var f=new Array(r),p=new Array(r),g=0;g=a.length?t=0:t<0&&(t=a.length-1),r=a[t];break}Ze([r],!0),Y("selected",w)}},this.clear(),this.getPrivateMethods=function(){return{addCommandToHistory:O,BatchCommand:rr,ChangeElementCommand:nr,decode64:Ct,dropXMLInteralSubset:wt,encode64:kt,ffClone:We,findDefs:Vt,findDuplicateGradient:an,getElem:$t,getPathBBox:jt,getTypeMap:re,getUrlFromAttr:Lt,identifyLayers:Pn,InsertElementCommand:er,isChrome:D,isIdentity:Ce,isIE:B,logMatrix:Qe,MoveElementCommand:Jn,NS:p,preventClickDefault:nn,RemoveElementCommand:tr,SVGEditTransformList:K,text2xml:Tt,transformBox:Ge,transformPoint:ke,walkTree:Nt}}};var sr={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};function lr(e,t){return void 0===t&&(t=0),Math.round(e*Math.pow(10,t))/Math.pow(10,t)}window.console||(window.console={log:function(e){},dir:function(e){}});var cr,ur,dr=jQuery,hr=function(e,t,n){var r=dr("#svg_editor").parent();Object.entries(t).forEach(function(t){var a=d(t,2),i=a[0],o=a[1];if(o||console.log(i),n&&(i="#"+i),r.find(i).length){var s=r.find(i)[0];switch(e){case"content":h(s.childNodes).some(function(e){if(3===e.nodeType&&e.textContent.trim())return e.textContent=o,!0});break;case"title":s.title=o}}else console.log("Missing: "+i)})},fr=function(){var e=n(regeneratorRuntime.mark(function e(t){var n,r,a,i,o,s,l,c,u;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ur.addLangData(cr);case 2:if(n=e.sent,dr.each(n,function(e,n){n.data&&(t=dr.merge(t,n.data))}),t.tools){e.next=6;break}return e.abrupt("return");case 6:return a=(r=t).tools,i=r.properties,o=r.config,s=r.layers,l=r.common,c=r.ui,hr("content",{curve_segments:i.curve_segments,fitToContent:a.fitToContent,fit_to_all:a.fit_to_all,fit_to_canvas:a.fit_to_canvas,fit_to_layer_content:a.fit_to_layer_content,fit_to_sel:a.fit_to_sel,icon_large:o.icon_large,icon_medium:o.icon_medium,icon_small:o.icon_small,icon_xlarge:o.icon_xlarge,image_opt_embed:o.image_opt_embed,image_opt_ref:o.image_opt_ref,includedImages:o.included_images,largest_object:a.largest_object,layersLabel:s.layers,page:a.page,relativeToLabel:a.relativeTo,selLayerLabel:s.move_elems_to,selectedPredefined:o.select_predefined,selected_objects:a.selected_objects,smallest_object:a.smallest_object,straight_segments:i.straight_segments,svginfo_bg_url:o.editor_img_url+":",svginfo_bg_note:o.editor_bg_note,svginfo_change_background:o.background,svginfo_dim:o.doc_dims,svginfo_editor_prefs:o.editor_prefs,svginfo_height:l.height,svginfo_icons:o.icon_size,svginfo_image_props:o.image_props,svginfo_lang:o.language,svginfo_title:o.doc_title,svginfo_width:l.width,tool_docprops_cancel:l.cancel,tool_docprops_save:l.ok,tool_source_cancel:l.cancel,tool_source_save:l.ok,tool_prefs_cancel:l.cancel,tool_prefs_save:l.ok,sidepanel_handle:s.layers.split("").join(" "),tool_clear:a.new_doc,tool_docprops:a.docprops,tool_export:a.export_img,tool_import:a.import_doc,tool_open:a.open_doc,tool_save:a.save_doc,svginfo_units_rulers:o.units_and_rulers,svginfo_rulers_onoff:o.show_rulers,svginfo_unit:o.base_unit,svginfo_grid_settings:o.grid,svginfo_snap_onoff:o.snapping_onoff,svginfo_snap_step:o.snapping_stepsize,svginfo_grid_color:o.grid_color},!0),u={},dr.each(["cut","copy","paste","paste_in_place","delete","group","ungroup","move_front","move_up","move_down","move_back"],function(){u['#cmenu_canvas a[href="#'+this+'"]']=a[this]}),dr.each(["dupe","merge_down","merge_all"],function(){u['#cmenu_layers a[href="#'+this+'"]']=s[this]}),u['#cmenu_layers a[href="#delete"]']=s.del,hr("content",u),hr("title",{align_relative_to:a.align_relative_to,circle_cx:i.circle_cx,circle_cy:i.circle_cy,circle_r:i.circle_r,cornerRadiusLabel:i.corner_radius,ellipse_cx:i.ellipse_cx,ellipse_cy:i.ellipse_cy,ellipse_rx:i.ellipse_rx,ellipse_ry:i.ellipse_ry,fill_color:i.fill_color,font_family:i.font_family,idLabel:i.id,image_height:i.image_height,image_url:i.image_url,image_width:i.image_width,layer_delete:s.del,layer_down:s.move_down,layer_new:s.new,layer_rename:s.rename,layer_moreopts:l.more_opts,layer_up:s.move_up,line_x1:i.line_x1,line_x2:i.line_x2,line_y1:i.line_y1,line_y2:i.line_y2,linecap_butt:i.linecap_butt,linecap_round:i.linecap_round,linecap_square:i.linecap_square,linejoin_bevel:i.linejoin_bevel,linejoin_miter:i.linejoin_miter,linejoin_round:i.linejoin_round,main_icon:a.main_menu,palette:c.palette_info,zoom_panel:c.zoom_level,path_node_x:i.node_x,path_node_y:i.node_y,rect_height_tool:i.rect_height,rect_width_tool:i.rect_width,seg_type:i.seg_type,selLayerNames:s.move_selected,selected_x:i.pos_x,selected_y:i.pos_y,stroke_color:i.stroke_color,stroke_style:i.stroke_style,stroke_width:i.stroke_width,svginfo_title:o.doc_title,text:i.text_contents,toggle_stroke_tools:c.toggle_stroke_tools,tool_add_subpath:a.add_subpath,tool_alignbottom:a.align_bottom,tool_aligncenter:a.align_center,tool_alignleft:a.align_left,tool_alignmiddle:a.align_middle,tool_alignright:a.align_right,tool_aligntop:a.align_top,tool_angle:i.angle,tool_blur:i.blur,tool_bold:i.bold,tool_circle:a.mode_circle,tool_clone:a.clone,tool_clone_multi:a.clone,tool_delete:a.del,tool_delete_multi:a.del,tool_ellipse:a.mode_ellipse,tool_fhellipse:a.mode_fhellipse,tool_fhpath:a.mode_fhpath,tool_fhrect:a.mode_fhrect,tool_font_size:i.font_size,tool_group_elements:a.group_elements,tool_make_link:a.make_link,tool_link_url:a.set_link_url,tool_image:a.mode_image,tool_italic:i.italic,tool_line:a.mode_line,tool_move_bottom:a.move_bottom,tool_move_top:a.move_top,tool_node_clone:a.node_clone,tool_node_delete:a.node_delete,tool_node_link:a.node_link,tool_opacity:i.opacity,tool_openclose_path:a.openclose_path,tool_path:a.mode_path,tool_position:a.align_to_page,tool_rect:a.mode_rect,tool_redo:a.redo,tool_reorient:a.reorient_path,tool_select:a.mode_select,tool_source:a.source_save,tool_square:a.mode_square,tool_text:a.mode_text,tool_topath:a.to_path,tool_undo:a.undo,tool_ungroup:a.ungroup,tool_wireframe:a.wireframe_mode,tool_zoom:a.mode_zoom,url_notice:a.no_embed},!0),e.abrupt("return",{langParam:cr,langData:t});case 15:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}(),pr=function(){var e=n(regeneratorRuntime.mark(function e(t,n,r){var a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t?cr=t:((cr=dr.pref("lang"))||(navigator.userLanguage?cr=navigator.userLanguage:navigator.language&&(cr=navigator.language)),console.log("Lang: "+cr),n.includes(cr)||"test"===cr||(cr="en")),a=r.langPath+"lang."+cr+".js",e.t0=fr,e.next=5,ln(a,{global:"svgEditorLang_"+cr.replace(/-/g,"_")});case 5:return e.t1=e.sent,e.abrupt("return",(0,e.t0)(e.t1));case 7:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}();var gr={},mr=[function(e){function t(t){if("string"==typeof t.data){var n=t.handler,r=t.data.toLowerCase().split(" ");t.handler=function(t){if(this===t.target||27===t.which||!/textarea|select/i.test(t.target.nodeName)&&"text"!==t.target.type){var a="keypress"!==t.type&&e.hotkeys.specialKeys[t.which],i=String.fromCharCode(t.which).toLowerCase(),o="",s={};t.altKey&&"alt"!==a&&(o+="alt+"),t.ctrlKey&&"ctrl"!==a&&(o+="ctrl+"),t.metaKey&&!t.ctrlKey&&"meta"!==a&&(o+="meta+"),t.shiftKey&&"shift"!==a&&(o+="shift+"),a?s[o+a]=!0:(s[o+i]=!0,s[o+e.hotkeys.shiftNums[i]]=!0,"shift+"===o&&(s[e.hotkeys.shiftNums[i]]=!0));for(var l=0,c=r.length;l","/":"?","\\":"|"}},e.each(["keydown","keyup","keypress"],function(){e.event.special[this]={add:t}}),e},function(t){return function(t,n){var r,a,i,o,s,l,c,u,d=Array.prototype.slice,h=decodeURIComponent,f=t.param,p=t.bbq=t.bbq||{},g=t.event.special,m="hashchange",v="querystring",_="fragment",y="elemUrlAttr",b="location",x="href",w="src",S=/^.*\?|#.*$/g,k=/^.*\#/,C={};function A(e){return"string"==typeof e}function E(e){var t=d.call(arguments,1);return function(){return e.apply(this,t.concat(d.call(arguments)))}}function G(e,a,o,s,l){var c,d,p,g,m;return s!==r?(m=(p=o.match(e?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/))[3]||"",2===l&&A(s)?d=s.replace(e?k:S,""):(g=i(p[2]),s=A(s)?i[e?_:v](s):s,d=2===l?s:1===l?t.extend({},s,g):t.extend({},g,s),d=f(d),e&&(d=d.replace(u,h))),c=p[1]+(e?"#":d||!p[1]?"?":"")+d+m):c=a(o!==r?o:n[b][x]),c}function P(e,t,n){return t===r||"boolean"==typeof t?(n=t,t=f[e?_:v]()):t=A(t)?t.replace(e?k:S,""):t,i(t,n)}function I(n,a,i,o){return A(i)||"object"===e(i)||(o=i,i=a,a=r),this.each(function(){var e=t(this),r=a||c()[(this.nodeName||"").toLowerCase()]||"",s=r&&e.attr(r)||"";e.attr(r,f[n](s,i,o))})}f[v]=E(G,0,function(e){return e.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}),f[_]=a=E(G,1,function(e){return e.replace(/^[^#]*#?(.*)$/,"$1")}),a.noEscape=function(e){e=e||"";var n=t.map(e.split(""),encodeURIComponent);u=new RegExp(n.join("|"),"g")},a.noEscape(",/"),t.deparam=i=function(e,n){var a={},i={true:!0,false:!1,null:null};return t.each(e.replace(/\+/g," ").split("&"),function(e,o){var s,l=o.split("="),c=h(l[0]),u=a,d=0,f=c.split("]["),p=f.length-1;if(/\[/.test(f[0])&&/\]$/.test(f[p])?(f[p]=f[p].replace(/\]$/,""),p=(f=f.shift().split("[").concat(f)).length-1):p=0,2===l.length)if(s=h(l[1]),n&&(s=s&&!isNaN(s)?+s:"undefined"===s?r:i[s]!==r?i[s]:s),p)for(;d<=p;d++)u=u[c=""===f[d]?u.length:f[d]]=d').hide().insertAfter("body")[0].contentWindow,s=function(){return v(i.document[u][h])},(o=function(e,t){if(e!==t){var n=i.document;n.open().close(),n[u].hash="#"+e}})(v()))),function r(){var i=v(),l=s(n);i!==n?(o(n=i,l),e(t).trigger(d)):l!==n&&(t[u][h]=t[u][h].replace(/#.*/,"")+"#"+l),a=setTimeout(r,e[d+"Delay"])}()}},l.stop=function(){i||(a&&clearTimeout(a),a=0)},r=l}(t,window),t},function(e){var t,n={};return e.svgIcons=function(r){var a,i,o,s,l,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u="http://www.w3.org/2000/svg",d="http://www.w3.org/1999/xlink",h=c.w||24,f=c.h||24,p=!1,g=!1,m=0,v=!!window.opera,_="data:image/svg+xml;charset=utf-8;base64,";if(c.svgz){s=e('').appendTo("body").hide();try{i=s[0].contentDocument,s.load(b),b(0,!0)}catch(e){k()}}else{var y=new DOMParser;e.ajax({url:r,dataType:"string",success:function(t){t?(i=y.parseFromString(t,"text/xml"),e(function(){b("ajax")})):e(k)},error:function(t){window.opera?e(function(){k()}):t.responseText?((i=y.parseFromString(t.responseText,"text/xml")).childNodes.length||e(k),e(function(){b("ajax")})):e(k)}})}function b(t,n){if("ajax"!==t){if(g)return;var r=(i=s[0].contentDocument)&&i.getElementById("svg_eof");if(!(r||n&&r))return void(++m<50?setTimeout(b,20):(k(),g=!0));g=!0}if(a=e(i.firstChild).children(),c.no_img)setTimeout(function(){p||S()},500);else{var l=_+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";o=e(new Image).attr({src:l,width:0,height:0}).appendTo("body").load(function(){S(!0)}).error(function(){S()})}}function x(e,t,n,r){if(v&&t.css("visibility","hidden"),c.replace){r&&t.attr("id",n);var a=e.attr("class");a&&t.attr("class","svg_icon "+a),e.replaceWith(t)}else e.append(t);v&&setTimeout(function(){t.removeAttr("style")},1)}function w(e,t){void 0!==c.id_match&&!1===c.id_match||x(l,e,t,!0),n[t]=e}function S(r,i){if(!p){var g;if(c.no_img&&(r=!1),r&&(g=e(document.createElement("div"))).hide().appendTo("body"),i){var m=c.fallback_path||"";e.each(i,function(t,n){l=e("#"+t),w(e(new Image).attr({class:"svg_icon",src:m+n,width:h,height:f,alt:"icon"}),t)})}else for(var y=a.length,b=0;b0&&!r&&(o=t(o,a,!0)),x(e(this),o,i)})}),i||(r&&g.remove(),s&&s.remove(),o&&o.remove()),c.resize&&e.resizeSvgIcons(c.resize),p=!0,c.callback&&c.callback(n)}}function k(){if(r.includes(".svgz")){var t=r.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg"),e.svgIcons(t,c)}else c.fallback&&S(!1,c.fallback)}function C(e){if(window.btoa)return window.btoa(e);var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=new Array(4*Math.floor((e.length+2)/3)),r=0,a=0;do{var i=e.charCodeAt(r++),o=e.charCodeAt(r++),s=e.charCodeAt(r++),l=i>>2,c=(3&i)<<4|o>>4,u=(15&o)<<2|s>>6,d=63&s;isNaN(o)?u=d=64:isNaN(s)&&(d=64),n[a++]=t.charAt(l),n[a++]=t.charAt(c),n[a++]=t.charAt(u),n[a++]=t.charAt(d)}while(r
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var p=t(c+"> .jGraduate_colPick"),g=t(c+"> .jGraduate_gradPick");g.html('

    '+s.window.pickerTitle+'


    ');var m=256,v=m-0,_=m-0,y={};t(".jGraduate_SliderBar").width(145);var b,x=t("#"+l+"_jGraduate_GradContainer")[0],w=a("svg",{id:l+"_jgraduate_svg",width:m,height:m,xmlns:sr.svg},x),S=o.paint.type,k=o.paint[S],C=k,A=o.paint.alpha,E="solidColor"===S;switch(S){case"solidColor":case"linearGradient":if(E||(C.id=l+"_lg_jgraduate_grad",k=C=w.appendChild(C)),a("radialGradient",{id:l+"_rg_jgraduate_grad"},w),"linearGradient"===S)break;case"radialGradient":E||(C.id=l+"_rg_jgraduate_grad",k=C=w.appendChild(C)),a("linearGradient",{id:l+"_lg_jgraduate_grad"},w)}if(E){k=C=t("#"+l+"_lg_jgraduate_grad")[0],Me(0,"#"+(h=o.paint[S]),1);var G=e(s.newstop);if("string"===G)switch(s.newstop){case"same":Me(1,"#"+h,1);break;case"inverse":for(var P="",I=0;I<6;I+=2){var T=(255-parseInt(h.substr(I,2),16)).toString(16);T.length<2&&(T=0+T),P+=T}Me(1,"#"+P,1);break;case"white":Me(1,"#ffffff",1);break;case"black":Me(1,"#000000",1)}else if("object"===G){var N="opac"in s.newstop?s.newstop.opac:1;Me(1,s.newstop.color||"#"+h,N)}}var L,M=parseFloat(k.getAttribute("x1")||0),O=parseFloat(k.getAttribute("y1")||0),V=parseFloat(k.getAttribute("x2")||1),j=parseFloat(k.getAttribute("y2")||0),R=parseFloat(k.getAttribute("cx")||.5),B=parseFloat(k.getAttribute("cy")||.5),D=parseFloat(k.getAttribute("fx")||R),U=parseFloat(k.getAttribute("fy")||B),F=a("rect",{id:l+"_jgraduate_rect",x:0,y:0,width:v,height:_,fill:"url(#"+l+"_jgraduate_grad)","fill-opacity":A/100},w),H=t("
    ").attr({class:"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:O*m,left:M*m}).data("coord","start").appendTo(x),z=H.clone().text(2).css({top:j*m,left:V*m}).attr("title","End stop").data("coord","end").appendTo(x),q=t("
    ").attr({class:"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:B*m,left:R*m}).data("coord","center").appendTo(x),Y=q.clone().text("F").css({top:U*m,left:D*m,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(x);Y[0].id=l+"_jGraduate_focusCoord",t.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(e,n){var r=isNaN(n[1]),a=C.getAttribute(n);a||(a=r?"0.5":"x2"===n?"1.0":"0.0"),y[n]=t("#"+l+"_jGraduate_"+n).val(a).change(function(){isNaN(parseFloat(this.value))||this.value<0?this.value=0:this.value>1&&(this.value=1),("f"!==n[0]||L)&&(r&&"radialGradient"===S||!r&&"linearGradient"===S)&&C.setAttribute(n,this.value);var e=r?"c"===n[0]?q:Y:"1"===n[1]?H:z,t=n.includes("x")?"left":"top";e.css(t,this.value*m)}).change()});var W,X,Q,K,Z=t("#"+l+"_jGraduate_StopSlider"),$=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},void 0),J=1,ee=1,te=0,ne=R,re=B,ae=a("svg",{width:"100%",height:45},Z[0]),ie=a("pattern",{width:16,height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},ae),oe=a("image",{width:16,height:16},ie),se=s.images.clientPath+"map-opacity.png";oe.setAttributeNS(sr.xlink,"xlink:href",se),t(ae).click(function(e){if(K=Z.offset(),"path"!==e.target.tagName){var t=e.pageX-K.left-8;Me((t=t<10?10:t>m+10?m+10:t)/m,0,0,!0),e.stopPropagation()}}),t(ae).mouseover(function(){ae.append($)}),b=a("g",{},ae),a("line",{x1:10,y1:15,x2:m+10,y2:15,"stroke-width":2,stroke:"#000"},ae);var le,ce,ue,de,he=g.find(".jGraduate_spreadMethod").change(function(){C.setAttribute("spreadMethod",t(this).val())}),fe=null,pe=function(e){var t=e.pageX-le.left,n=e.pageY-le.top;t=t<0?0:t>m?m:t,n=n<0?0:n>m?m:n,fe.css("left",t).css("top",n);var r=t/v,a=n/_,i=fe.data("coord"),o=C;switch(i){case"start":y.x1.val(r),y.y1.val(a),o.setAttribute("x1",r),o.setAttribute("y1",a);break;case"end":y.x2.val(r),y.y2.val(a),o.setAttribute("x2",r),o.setAttribute("y2",a);break;case"center":y.cx.val(r),y.cy.val(a),o.setAttribute("cx",r),o.setAttribute("cy",a),ne=r,re=a,je();break;case"focus":y.fx.val(r),y.fy.val(a),o.setAttribute("fx",r),o.setAttribute("fy",a),je()}e.preventDefault()},ge=function e(){fe=null,f.unbind("mousemove",pe).unbind("mouseup",e)},me=(W=C.getElementsByTagNameNS(sr.svg,"stop")).length;if(me<2){for(;me<2;)C.append(document.createElementNS(sr.svg,"stop")),++me;W=C.getElementsByTagNameNS(sr.svg,"stop")}for(var ve=0;ve99.5&&(n=99.5),n>0?ee=1-n/100:J=-n/100-1,a=(n+100)/2*145/100,t&&je();break;case"angle":a=(te=n)/180,a+=.5,a*=145,t&&je()}a>145?a=145:a<0&&(a=0),r.css({"margin-left":a-5})}).change()});for(var Pe=function(e){!function(e){var t=de.offset,n=de.parent,r=e.pageX-t.left-parseInt(n.css("border-left-width"));r>145&&(r=145),r<=0&&(r=0);var a=r-5;switch(r/=145,de.type){case"radius":(r=Math.pow(2*r,2.5))>.98&&r<1.02&&(r=1),r<=.01&&(r=.01),C.setAttribute("r",r);break;case"opacity":o.paint.alpha=parseInt(100*r),F.setAttribute("fill-opacity",r);break;case"ellip":J=1,ee=1,r<.5?J=(r/=.5)<=0?.01:r:r>.5&&(ee=(r=2-(r/=.5))<=0?.01:r),je(),ee===1+(r-=1)&&(r=Math.abs(r));break;case"angle":r-=.5,te=r*=180,je(),r/=100}de.elem.css({"margin-left":a}),r=Math.round(100*r),de.input.val(r)}(e),e.preventDefault()},Ie=function e(t){f.unbind("mousemove",Pe).unbind("mouseup",e),de=null},Te=(255*o.paint.alpha/100).toString(16);Te.length<2;)Te="0"+Te;Te=Te.split(".")[0],h="none"===o.paint.solidColor?"":o.paint.solidColor+Te,E||(h=W[0].getAttribute("stop-color")),t.extend(t.fn.jPicker.defaults.window,{alphaSupport:!0,effects:{type:"show",speed:0}}),p.jPicker({window:{title:s.window.pickerTitle},images:{clientPath:s.images.clientPath},color:{active:h,alphaSupport:!0}},function(e){o.paint.type="solidColor",o.paint.alpha=e.val("ahex")?Math.round(e.val("a")/255*100):100,o.paint.solidColor=e.val("hex")?e.val("hex"):"none",o.paint.radialGradient=null,u()},null,function(){d()});var Ne,Le=t(c+" .jGraduate_tabs li");switch(Le.click(function(){Le.removeClass("jGraduate_tab_current"),t(this).addClass("jGraduate_tab_current"),t(c+" > div").hide();var e=t(this).attr("data-type");if(t(c+" .jGraduate_gradPick").show(),"rg"===e||"lg"===e){t(".jGraduate_"+e+"_field").show(),t(".jGraduate_"+("lg"===e?"rg":"lg")+"_field").hide(),t("#"+l+"_jgraduate_rect")[0].setAttribute("fill","url(#"+l+"_"+e+"_jgraduate_grad)"),S="lg"===e?"linearGradient":"radialGradient",t("#"+l+"_jGraduate_OpacInput").val(o.paint.alpha).change();var n=t("#"+l+"_"+e+"_jgraduate_grad")[0];if(C!==n){var r=t(C).find("stop");t(n).empty().append(r),C=n;var a=he.val();C.setAttribute("spreadMethod",a)}L="rg"===e&&null!=C.getAttribute("fx")&&!(R===D&&B===U),t("#"+l+"_jGraduate_focusCoord").toggle(L),L&&(t("#"+l+"_jGraduate_match_ctr")[0].checked=!1)}else t(c+" .jGraduate_gradPick").hide(),t(c+" .jGraduate_colPick").show()}),t(c+" > div").hide(),Le.removeClass("jGraduate_tab_current"),o.paint.type){case"linearGradient":Ne=t(c+" .jGraduate_tab_lingrad");break;case"radialGradient":Ne=t(c+" .jGraduate_tab_radgrad");break;default:Ne=t(c+" .jGraduate_tab_color")}o.show(),setTimeout(function(){Ne.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.");function Me(e,n,r,i,o){var c=o||a("stop",{"stop-color":n,"stop-opacity":r,offset:e},C);o?(n=o.getAttribute("stop-color"),r=o.getAttribute("stop-opacity"),e=o.getAttribute("offset")):C.append(c),null===r&&(r=1);var u="M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",d=a("path",{d:u,fill:"url(#jGraduate_trans)",transform:"translate("+(10+e*m)+", 26)"},b),h=a("path",{d:u,fill:n,"fill-opacity":r,transform:"translate("+(10+e*m)+", 26)",stroke:"#000","stroke-width":1.5},b);return t(h).mousedown(function(e){return Oe(this),Q=X,f.mousemove(Re).mouseup(Ve),K=Z.offset(),e.preventDefault(),!1}).data("stop",c).data("bg",d).dblclick(function(){t("div.jGraduate_LightBox").show();for(var e=this,r=+c.getAttribute("stop-opacity")||1,a=c.getAttribute("stop-color")||1,i=(255*parseFloat(r)).toString(16);i.length<2;)i="0"+i;n=a.substr(1)+i,t("#"+l+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:s.images.clientPath},color:{active:n,alphaSupport:!0}},function(n,i){a=n.val("hex")?"#"+n.val("hex"):"none",r=null!==n.val("a")?n.val("a")/256:1,e.setAttribute("fill",a),e.setAttribute("fill-opacity",r),c.setAttribute("stop-color",a),c.setAttribute("stop-opacity",r),t("div.jGraduate_LightBox").hide(),t("#"+l+"_jGraduate_stopPicker").hide()},null,function(){t("div.jGraduate_LightBox").hide(),t("#"+l+"_jGraduate_stopPicker").hide()})}),t(C).find("stop").each(function(){var r=t(this);if(+this.getAttribute("offset")>e){if(!n){var a=this.getAttribute("stop-color"),i=this.getAttribute("stop-opacity");c.setAttribute("stop-color",a),h.setAttribute("fill",a),c.setAttribute("stop-opacity",null===i?1:i),h.setAttribute("fill-opacity",null===i?1:i)}return r.before(c),!1}}),i&&Oe(h),c}function Oe(e){X&&X.setAttribute("stroke","#000"),e.setAttribute("stroke","blue"),(X=e).parentNode.append(X)}function Ve(){f.unbind("mousemove",Re),"none"!==$.getAttribute("display")&&function(){$.setAttribute("display","none");var e=t(X),n=e.data("stop"),r=e.data("bg");t([X,n,r]).remove()}(),Q=null}function je(){var e=te?"rotate("+te+","+ne+","+re+") ":"";if(1===J&&1===ee)C.removeAttribute("gradientTransform");else{var t=-ne*(J-1),n=-re*(ee-1);C.setAttribute("gradientTransform",e+"translate("+t+","+n+") scale("+J+","+ee+")")}}function Re(e){var n=e.pageX-K.left,r=e.pageY-K.top,a="translate("+(n=n<10?10:n>m+10?m+10:n)+", 26)";r<-60||r>130?($.setAttribute("display","block"),$.setAttribute("transform",a)):$.setAttribute("display","none"),Q.setAttribute("transform",a),t.data(Q,"bg").setAttribute("transform",a);var i=t.data(Q,"stop"),o=(n-10)/m;i.setAttribute("offset",o);var s=0;t(C).find("stop").each(function(e){var n=this.getAttribute("offset"),r=t(this);nn(o,"offsetLeft")+o.offsetWidth*s-this.spinCfg._btn_width?i=120?this.adjustValue(this.spinCfg.step):e.wheelDelta<=-120&&this.adjustValue(-this.spinCfg.step),e.preventDefault()}).change(function(e){this.adjustValue(0)}),this.addEventListener&&this.addEventListener("DOMMouseScroll",function(e){e.detail>0?this.adjustValue(-this.spinCfg.step):e.detail<0&&this.adjustValue(this.spinCfg.step),e.preventDefault()},!1)})},e},q,function(e){var t=e(window),n=e(document);return e.extend(e.fn,{contextMenu:function(r,a){return void 0!==r.menu&&(void 0===r.inSpeed&&(r.inSpeed=150),void 0===r.outSpeed&&(r.outSpeed=75),0===r.inSpeed&&(r.inSpeed=-1),0===r.outSpeed&&(r.outSpeed=-1),e(this).each(function(){var i=e(this),o=e(i).offset(),s=e("#"+r.menu);s.addClass("contextMenu"),e(this).bind("mousedown",function(l){var c=l;e(this).mouseup(function(l){var u=e(this);if(u.unbind("mouseup"),2===c.button||r.allowLeft||c.ctrlKey&&U()){if(l.stopPropagation(),e(".contextMenu").hide(),i.hasClass("disabled"))return!1;var d=l.pageX,h=l.pageY,f=t.width()-s.width(),p=t.height()-s.height();d>f-15&&(d=f-15),h>p-30&&(h=p-30),n.unbind("click"),s.css({top:h,left:d}).fadeIn(r.inSpeed),s.find("A").mouseover(function(){s.find("LI.hover").removeClass("hover"),e(this).parent().addClass("hover")}).mouseout(function(){s.find("LI.hover").removeClass("hover")}),n.keypress(function(e){switch(e.keyCode){case 38:s.find("LI.hover").length?(s.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover"),s.find("LI.hover").length||s.find("LI:last").addClass("hover")):s.find("LI:last").addClass("hover");break;case 40:s.find("LI.hover").length?(s.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover"),s.find("LI.hover").length||s.find("LI:first").addClass("hover")):s.find("LI:first").addClass("hover");break;case 13:s.find("LI.hover A").trigger("click");break;case 27:n.trigger("click")}}),s.find("A").unbind("mouseup"),s.find("LI:not(.disabled) A").mouseup(function(){return n.unbind("click").unbind("keypress"),e(".contextMenu").hide(),a&&a(e(this).attr("href").substr(1),e(u),{x:d-o.left,y:h-o.top,docX:d,docY:h}),!1}),setTimeout(function(){n.click(function(){return n.unbind("click").unbind("keypress"),s.fadeOut(r.outSpeed),!1})},0)}})}),e.browser.mozilla?e("#"+r.menu).each(function(){e(this).css({MozUserSelect:"none"})}):e.browser.msie?e("#"+r.menu).each(function(){e(this).bind("selectstart.disableTextSelect",function(){return!1})}):e("#"+r.menu).each(function(){e(this).bind("mousedown.disableTextSelect",function(){return!1})}),e(i).add(e("UL.contextMenu")).bind("contextmenu",function(){return!1})}),e(this))},disableContextMenuItems:function(t){return void 0===t?(e(this).find("LI").addClass("disabled"),e(this)):(e(this).each(function(){if(void 0!==t)for(var n=t.split(","),r=0;rn&&(i=n),o<0?o=0:o>a&&(o=a),l.call(r,"xy",{x:i/n*m+p,y:o/a*y+v})}function l(e,t,n){if(void 0===t)switch(void 0!==e&&null!=e||(e="xy"),e.toLowerCase()){case"x":return h;case"y":return f;case"xy":default:return{x:h,y:f}}if(null==n||n!==r){var a,i,o=!1;switch(null==e&&(e="xy"),e.toLowerCase()){case"x":a=t&&(t.x&&0|t.x||0|t)||0;break;case"y":i=t&&(t.y&&0|t.y||0|t)||0;break;case"xy":default:a=t&&t.x&&0|t.x||0,i=t&&t.y&&0|t.y||0}null!=a&&(ag&&(a=g),h!==a&&(h=a,o=!0)),null!=i&&(i_&&(i=_),f!==i&&(f=i,o=!0)),o&&function(e){for(var t=0;t0&&(i=h===g?t:h/m*t|0),y>0&&(o=f===_?n:f/y*n|0),r>=t?i=(t>>1)-(r>>1):i-=r>>1,a>=n?o=(n>>1)-(a>>1):o-=a>>1,b.css({left:i+"px",top:o+"px"})},0)})}function r(e,n,r,a){var i=this,o=e.find("td.Text input");function s(e){if(""!==e.target.value||e.target===b.get(0)||(null==r||e.target===r.get(0))&&null!=r){if(!u(e))return e;switch(e.target){case f.get(0):switch(e.keyCode){case 38:return f.val(d.call(i,1+(f.val()<<0),0,255)),n.val("r",f.val(),e.target),!1;case 40:return f.val(d.call(i,(f.val()<<0)-1,0,255)),n.val("r",f.val(),e.target),!1}break;case p.get(0):switch(e.keyCode){case 38:return p.val(d.call(i,1+(p.val()<<0),0,255)),n.val("g",p.val(),e.target),!1;case 40:return p.val(d.call(i,(p.val()<<0)-1,0,255)),n.val("g",p.val(),e.target),!1}break;case g.get(0):switch(e.keyCode){case 38:return g.val(d.call(i,1+(g.val()<<0),0,255)),n.val("b",g.val(),e.target),!1;case 40:return g.val(d.call(i,(g.val()<<0)-1,0,255)),n.val("b",g.val(),e.target),!1}break;case m&&m.get(0):switch(e.keyCode){case 38:return m.val(d.call(i,parseFloat(m.val())+1,0,100)),n.val("a",lr(255*m.val()/100,a),e.target),!1;case 40:return m.val(d.call(i,parseFloat(m.val())-1,0,100)),n.val("a",lr(255*m.val()/100,a),e.target),!1}break;case v.get(0):switch(e.keyCode){case 38:return v.val(d.call(i,1+(v.val()<<0),0,360)),n.val("h",v.val(),e.target),!1;case 40:return v.val(d.call(i,(v.val()<<0)-1,0,360)),n.val("h",v.val(),e.target),!1}break;case _.get(0):switch(e.keyCode){case 38:return _.val(d.call(i,1+(_.val()<<0),0,100)),n.val("s",_.val(),e.target),!1;case 40:return _.val(d.call(i,(_.val()<<0)-1,0,100)),n.val("s",_.val(),e.target),!1}break;case y.get(0):switch(e.keyCode){case 38:return y.val(d.call(i,1+(y.val()<<0),0,100)),n.val("v",y.val(),e.target),!1;case 40:return y.val(d.call(i,(y.val()<<0)-1,0,100)),n.val("v",y.val(),e.target),!1}}}}function l(e){if(""!==e.target.value||e.target===b.get(0)||(null==r||e.target===r.get(0))&&null!=r){if(!u(e))return e;switch(e.target){case f.get(0):f.val(d.call(i,f.val(),0,255)),n.val("r",f.val(),e.target);break;case p.get(0):p.val(d.call(i,p.val(),0,255)),n.val("g",p.val(),e.target);break;case g.get(0):g.val(d.call(i,g.val(),0,255)),n.val("b",g.val(),e.target);break;case m&&m.get(0):m.val(d.call(i,m.val(),0,100)),n.val("a",lr(255*m.val()/100,a),e.target);break;case v.get(0):v.val(d.call(i,v.val(),0,360)),n.val("h",v.val(),e.target);break;case _.get(0):_.val(d.call(i,_.val(),0,100)),n.val("s",_.val(),e.target);break;case y.get(0):y.val(d.call(i,y.val(),0,100)),n.val("v",y.val(),e.target);break;case b.get(0):b.val(b.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6)),r&&r.val(b.val()),n.val("hex",""!==b.val()?b.val():null,e.target);break;case r&&r.get(0):r.val(r.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6)),b.val(r.val()),n.val("hex",""!==r.val()?r.val():null,e.target);break;case x&&x.get(0):x.val(x.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2)),n.val("a",null!=x.val()?parseInt(x.val(),16):null,e.target)}}}function c(e){if(null!=n.val())switch(e.target){case f.get(0):f.val(n.val("r"));break;case p.get(0):p.val(n.val("g"));break;case g.get(0):g.val(n.val("b"));break;case m&&m.get(0):m.val(lr(100*n.val("a")/255,a));break;case v.get(0):v.val(n.val("h"));break;case _.get(0):_.val(n.val("s"));break;case y.get(0):y.val(n.val("v"));break;case b.get(0):case r&&r.get(0):b.val(n.val("hex")),r&&r.val(n.val("hex"));break;case x&&x.get(0):x.val(n.val("ahex").substring(6))}}function u(e){switch(e.keyCode){case 9:case 16:case 29:case 37:case 39:return!1;case"c".charCodeAt():case"v".charCodeAt():if(e.ctrlKey)return!1}return!0}function d(e,t,n){return""===e||isNaN(e)?t:e>n?n:e7?o.eq(6):null,v=o.eq(0),_=o.eq(1),y=o.eq(2),b=o.eq(o.length>7?7:6),x=o.length>7?o.eq(8):null;t.extend(!0,i,{destroy:function(){f.add(p).add(g).add(m).add(v).add(_).add(y).add(b).add(r).add(x).unbind("keyup",l).unbind("blur",c),f.add(p).add(g).add(m).add(v).add(_).add(y).unbind("keydown",s),n.unbind(h),f=null,p=null,g=null,m=null,v=null,_=null,y=null,b=null,x=null}}),f.add(p).add(g).add(m).add(v).add(_).add(y).add(b).add(r).add(x).bind("keyup",l).bind("blur",c),f.add(p).add(g).add(m).add(v).add(_).add(y).bind("keydown",s),n.bind(h)}t.loadingStylesheets.includes("jgraduate/css/jPicker.css")||t.loadingStylesheets.push("jgraduate/css/jPicker.css"),t.jPicker={List:[],Color:function(n){var r=this;function a(e){for(var t=0;t255&&(x.r=255),o!==x.r&&(o=x.r,y=!0);break;case"g":if(S)continue;w=!0,x.g=n&&n.g&&0|n.g||n&&0|n||0,x.g<0?x.g=0:x.g>255&&(x.g=255),l!==x.g&&(l=x.g,y=!0);break;case"b":if(S)continue;w=!0,x.b=n&&n.b&&0|n.b||n&&0|n||0,x.b<0?x.b=0:x.b>255&&(x.b=255),c!==x.b&&(c=x.b,y=!0);break;case"a":x.a=n&&null!=n.a?0|n.a:0|n,x.a<0?x.a=0:x.a>255&&(x.a=255),u!==x.a&&(u=x.a,y=!0);break;case"h":if(w)continue;S=!0,x.h=n&&n.h&&0|n.h||n&&0|n||0,x.h<0?x.h=0:x.h>360&&(x.h=360),d!==x.h&&(d=x.h,y=!0);break;case"s":if(w)continue;S=!0,x.s=null!=n.s?0|n.s:0|n,x.s<0?x.s=0:x.s>100&&(x.s=100),h!==x.s&&(h=x.s,y=!0);break;case"v":if(w)continue;S=!0,x.v=null!=n.v?0|n.v:0|n,x.v<0?x.v=0:x.v>100&&(x.v=100),f!==x.v&&(f=x.v,y=!0)}if(y){if(w){o=o||0,l=l||0,c=c||0;var C=s.rgbToHsv({r:o,g:l,b:c});d=C.h,h=C.s,f=C.v}else if(S){d=d||0,h=null!=h?h:100,f=null!=f?f:100;var A=s.hsvToRgb({h:d,s:h,v:f});o=A.r,l=A.g,c=A.b}u=null!=u?u:255,a.call(r,p||r)}}}}var o,l,c,u,d,h,f,p=[];t.extend(!0,r,{val:i,bind:function(e){"function"==typeof e&&p.push(e)},unbind:function(e){if("function"==typeof e)for(var t;t=p.includes(e);)p.splice(t,1)},destroy:function(){p=null}}),n&&(null!=n.ahex?i("ahex",n):null!=n.hex?i((null!=n.a?"a":"")+"hex",null!=n.a?{ahex:n.hex+s.intToHex(n.a)}:n):null!=n.r&&null!=n.g&&null!=n.b?i("rgb"+(null!=n.a?"a":""),n):null!=n.h&&null!=n.s&&null!=n.v&&i("hsv"+(null!=n.a?"a":""),n))},ColorMethods:{hexToRgba:function(e){if(""===e||"none"===e)return{r:null,g:null,b:null,a:null};var t="00",n="00",r="00",a="255";return 6===(e=this.validateHex(e)).length&&(e+="ff"),e.length>6?(t=e.substring(0,2),n=e.substring(2,4),r=e.substring(4,6),a=e.substring(6,e.length)):(e.length>4&&(t=e.substring(4,e.length),e=e.substring(0,4)),e.length>2&&(n=e.substring(2,e.length),e=e.substring(0,2)),e.length>0&&(r=e.substring(0,e.length))),{r:this.hexToInt(t),g:this.hexToInt(n),b:this.hexToInt(r),a:this.hexToInt(a)}},validateHex:function(e){return(e=e.toLowerCase().replace(/[^a-f0-9]/g,"")).length>8&&(e=e.substring(0,8)),e},rgbaToHex:function(e){return this.intToHex(e.r)+this.intToHex(e.g)+this.intToHex(e.b)+this.intToHex(e.a)},intToHex:function(e){var t=(0|e).toString(16);return 1===t.length&&(t="0"+t),t.toLowerCase()},hexToInt:function(e){return parseInt(e,16)},rgbToHsv:function(e){var t,n=e.r/255,r=e.g/255,a=e.b/255,i={h:0,s:0,v:0},o=0,s=0;return n>=r&&n>=a?(s=n,o=r>a?a:r):r>=a&&r>=n?(s=r,o=n>a?a:n):(s=a,o=r>n?n:r),i.v=s,i.s=s?(s-o)/s:0,i.s?(t=s-o,i.h=n===s?(r-a)/t:r===s?2+(a-n)/t:4+(n-r)/t,i.h=parseInt(60*i.h),i.h<0&&(i.h+=360)):i.h=0,i.s=100*i.s|0,i.v=100*i.v|0,i},hsvToRgb:function(e){var t={r:0,g:0,b:0,a:100},n=e.h,r=e.s,a=e.v;if(0===r)t.r=t.g=t.b=0===a?0:255*a/100|0;else{360===n&&(n=0);var i=0|(n/=60),o=n-i,s=(a/=100)*(1-(r/=100)),l=a*(1-r*o),c=a*(1-r*(1-o));switch(i){case 0:t.r=a,t.g=c,t.b=s;break;case 1:t.r=l,t.g=a,t.b=s;break;case 2:t.r=s,t.g=a,t.b=c;break;case 3:t.r=s,t.g=l,t.b=a;break;case 4:t.r=c,t.g=s,t.b=a;break;case 5:t.r=a,t.g=s,t.b=l}t.r=255*t.r|0,t.g=255*t.g|0,t.b=255*t.b|0}return t}}};var a=t.jPicker,i=a.Color,o=a.List,s=a.ColorMethods;return t.fn.jPicker=function(a){var l=arguments;return this.each(function(){var c=this,u=t.extend(!0,{},t.fn.jPicker.defaults,a);"input"===t(c).get(0).nodeName.toLowerCase()&&(t.extend(!0,u,{window:{bindToInput:!0,expandable:!0,input:t(c)}}),""===t(c).val()?(u.color.active=new i({hex:null}),u.color.current=new i({hex:null})):s.validateHex(t(c).val())&&(u.color.active=new i({hex:t(c).val(),a:u.color.active.val("a")}),u.color.current=new i({hex:t(c).val(),a:u.color.active.val("a")}))),u.window.expandable?t(c).after('    '):u.window.liveUpdate=!1;var d=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters;function h(e){var t,n,r=V.active,a=r.val("hex");switch(u.color.mode=e,e){case"h":if(setTimeout(function(){m.call(c,F,"transparent"),_.call(c,z,0),y.call(c,z,100),_.call(c,q,260),y.call(c,q,100),m.call(c,H,"transparent"),_.call(c,W,0),y.call(c,W,100),_.call(c,X,260),y.call(c,X,100),_.call(c,Q,260),y.call(c,Q,100),_.call(c,K,260),y.call(c,K,100),_.call(c,$,260),y.call(c,$,100)},0),J.range("all",{minX:0,maxX:100,minY:0,maxY:100}),ee.range("rangeY",{minY:0,maxY:360}),null==r.val("ahex"))break;J.val("xy",{x:r.val("s"),y:100-r.val("v")},J),ee.val("y",360-r.val("h"),ee);break;case"s":if(setTimeout(function(){m.call(c,F,"transparent"),_.call(c,z,-260),_.call(c,q,-520),_.call(c,W,-260),_.call(c,X,-520),_.call(c,$,260),y.call(c,$,100)},0),J.range("all",{minX:0,maxX:360,minY:0,maxY:100}),ee.range("rangeY",{minY:0,maxY:100}),null==r.val("ahex"))break;J.val("xy",{x:r.val("h"),y:100-r.val("v")},J),ee.val("y",100-r.val("s"),ee);break;case"v":if(setTimeout(function(){m.call(c,F,"000000"),_.call(c,z,-780),_.call(c,q,260),m.call(c,H,a),_.call(c,W,-520),_.call(c,X,260),y.call(c,X,100),_.call(c,$,260),y.call(c,$,100)},0),J.range("all",{minX:0,maxX:360,minY:0,maxY:100}),ee.range("rangeY",{minY:0,maxY:100}),null==r.val("ahex"))break;J.val("xy",{x:r.val("h"),y:100-r.val("s")},J),ee.val("y",100-r.val("v"),ee);break;case"r":if(t=-1040,n=-780,J.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ee.range("rangeY",{minY:0,maxY:255}),null==r.val("ahex"))break;J.val("xy",{x:r.val("b"),y:255-r.val("g")},J),ee.val("y",255-r.val("r"),ee);break;case"g":if(t=-1560,n=-1820,J.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ee.range("rangeY",{minY:0,maxY:255}),null==r.val("ahex"))break;J.val("xy",{x:r.val("b"),y:255-r.val("r")},J),ee.val("y",255-r.val("g"),ee);break;case"b":if(t=-2080,n=-2860,J.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ee.range("rangeY",{minY:0,maxY:255}),null==r.val("ahex"))break;J.val("xy",{x:r.val("r"),y:255-r.val("g")},J),ee.val("y",255-r.val("b"),ee);break;case"a":if(setTimeout(function(){m.call(c,F,"transparent"),_.call(c,z,-260),_.call(c,q,-520),_.call(c,W,260),_.call(c,X,260),y.call(c,X,100),_.call(c,$,0),y.call(c,$,100)},0),J.range("all",{minX:0,maxX:360,minY:0,maxY:100}),ee.range("rangeY",{minY:0,maxY:255}),null==r.val("ahex"))break;J.val("xy",{x:r.val("h"),y:100-r.val("v")},J),ee.val("y",255-r.val("a"),ee);break;default:throw new Error("Invalid Mode")}switch(e){case"h":break;case"s":case"v":case"a":setTimeout(function(){y.call(c,z,100),y.call(c,W,100),_.call(c,Q,260),y.call(c,Q,100),_.call(c,K,260),y.call(c,K,100)},0);break;case"r":case"g":case"b":setTimeout(function(){m.call(c,F,"transparent"),m.call(c,H,"transparent"),y.call(c,W,100),y.call(c,z,100),_.call(c,z,t),_.call(c,q,t-260),_.call(c,W,n-780),_.call(c,X,n-520),_.call(c,Q,n),_.call(c,K,n-260),_.call(c,$,260),y.call(c,$,100)},0)}null!=r.val("ahex")&&f.call(c,r)}function f(e,t){(null==t||t!==ee&&t!==J)&&function(e,t){if(t!==J)switch(u.color.mode){case"h":var n=e.val("sv");J.val("xy",{x:null!=n?n.s:100,y:100-(null!=n?n.v:100)},t);break;case"s":case"a":var r=e.val("hv");J.val("xy",{x:r&&r.h||0,y:100-(null!=r?r.v:100)},t);break;case"v":var a=e.val("hs");J.val("xy",{x:a&&a.h||0,y:100-(null!=a?a.s:100)},t);break;case"r":var i=e.val("bg");J.val("xy",{x:i&&i.b||0,y:255-(i&&i.g||0)},t);break;case"g":var o=e.val("br");J.val("xy",{x:o&&o.b||0,y:255-(o&&o.r||0)},t);break;case"b":var s=e.val("rg");J.val("xy",{x:s&&s.r||0,y:255-(s&&s.g||0)},t)}if(t!==ee)switch(u.color.mode){case"h":ee.val("y",360-(e.val("h")||0),t);break;case"s":var l=e.val("s");ee.val("y",100-(null!=l?l:100),t);break;case"v":var c=e.val("v");ee.val("y",100-(null!=c?c:100),t);break;case"r":ee.val("y",255-(e.val("r")||0),t);break;case"g":ee.val("y",255-(e.val("g")||0),t);break;case"b":ee.val("y",255-(e.val("b")||0),t);break;case"a":var d=e.val("a");ee.val("y",255-(null!=d?d:255),t)}}.call(c,e,t),setTimeout(function(){(function(e){try{var t=e.val("all");ne.css({backgroundColor:t&&"#"+t.hex||"transparent"}),y.call(c,ne,t&&lr(100*t.a/255,4)||0)}catch(e){}}).call(c,e),function(e){switch(u.color.mode){case"h":m.call(c,F,new i({h:e.val("h")||0,s:100,v:100}).val("hex"));break;case"s":case"a":var t=e.val("s");y.call(c,q,100-(null!=t?t:100));break;case"v":var n=e.val("v");y.call(c,z,null!=n?n:100);break;case"r":y.call(c,q,lr((e.val("r")||0)/255*100,4));break;case"g":y.call(c,q,lr((e.val("g")||0)/255*100,4));break;case"b":y.call(c,q,lr((e.val("b")||0)/255*100))}var r=e.val("a");y.call(c,Y,lr(100*(255-(r||0))/255,4))}.call(c,e),function(e){switch(u.color.mode){case"h":var t=e.val("a");y.call(c,Z,lr(100*(255-(t||0))/255,4));break;case"s":var n=e.val("hva"),r=new i({h:n&&n.h||0,s:100,v:null!=n?n.v:100});m.call(c,H,r.val("hex")),y.call(c,X,100-(null!=n?n.v:100)),y.call(c,Z,lr(100*(255-(n&&n.a||0))/255,4));break;case"v":var a=e.val("hsa"),o=new i({h:a&&a.h||0,s:null!=a?a.s:100,v:100});m.call(c,H,o.val("hex")),y.call(c,Z,lr(100*(255-(a&&a.a||0))/255,4));break;case"r":case"g":case"b":var s=e.val("rgba"),l=0,d=0;"r"===u.color.mode?(l=s&&s.b||0,d=s&&s.g||0):"g"===u.color.mode?(l=s&&s.b||0,d=s&&s.r||0):"b"===u.color.mode&&(l=s&&s.r||0,d=s&&s.g||0);var h=d>l?l:d;y.call(c,X,l>d?lr((l-d)/(255-d)*100,4):0),y.call(c,Q,d>l?lr((d-l)/(255-l)*100,4):0),y.call(c,K,lr(h/255*100,4)),y.call(c,Z,lr(100*(255-(s&&s.a||0))/255,4));break;case"a":var f=e.val("a");m.call(c,H,e.val("hex")||"000000"),y.call(c,Z,null!=f?0:100),y.call(c,$,null!=f?100:0)}}.call(c,e)},0)}function p(e,t){var n=V.active;if(t===J||null!=n.val()){var r=e.val("all");switch(u.color.mode){case"h":n.val("sv",{s:r.x,v:100-r.y},t);break;case"s":case"a":n.val("hv",{h:r.x,v:100-r.y},t);break;case"v":n.val("hs",{h:r.x,s:100-r.y},t);break;case"r":n.val("gb",{g:255-r.y,b:r.x},t);break;case"g":n.val("rb",{r:255-r.y,b:r.x},t);break;case"b":n.val("rg",{r:r.x,g:255-r.y},t)}}}function g(e,t){var n=V.active;if(t===ee||null!=n.val())switch(u.color.mode){case"h":n.val("h",{h:360-e.val("y")},t);break;case"s":n.val("s",{s:100-e.val("y")},t);break;case"v":n.val("v",{v:100-e.val("y")},t);break;case"r":n.val("r",{r:255-e.val("y")},t);break;case"g":n.val("g",{g:255-e.val("y")},t);break;case"b":n.val("b",{b:255-e.val("y")},t);break;case"a":n.val("a",255-e.val("y"),t)}}function m(e,t){e.css({backgroundColor:t&&6===t.length&&"#"+t||"transparent"})}function v(e,t){d&&(t.includes("AlphaBar.png")||t.includes("Bars.png")||t.includes("Maps.png"))?(e.attr("pngSrc",t),e.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+t+"', sizingMethod='scale')"})):e.css({backgroundImage:"url('"+t+"')"})}function _(e,t){e.css({top:t+"px"})}function y(e,t){if(e.css({visibility:t>0?"visible":"hidden"}),t>0&&t<100)if(d){var n=e.attr("pngSrc");null!=n&&(n.includes("AlphaBar.png")||n.includes("Bars.png")||n.includes("Maps.png"))?e.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+n+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+t+")"}):e.css({opacity:lr(t/100,4)})}else e.css({opacity:lr(t/100,4)});else if(0===t||100===t)if(d){var r=e.attr("pngSrc");null!=r&&(r.includes("AlphaBar.png")||r.includes("Bars.png")||r.includes("Maps.png"))?e.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+r+"', sizingMethod='scale')"}):e.css({opacity:""})}else e.css({opacity:""})}function b(){V.active.val("ahex",V.current.val("ahex"))}function x(e){t(this).parents("tbody:first").find('input:radio[value!="'+e.target.value+'"]').removeAttr("checked"),h.call(c,e.target.value)}function w(){b.call(c)}function S(){b.call(c),u.window.expandable&&L.call(c),"function"==typeof fe&&fe.call(c,V.active,ie)}function k(){(function(){V.current.val("ahex",V.active.val("ahex"))}).call(c),u.window.expandable&&L.call(c),"function"==typeof de&&de.call(c,V.active,ae)}function C(){N.call(c)}function A(e,t){var n=e.val("hex");re.css({backgroundColor:n&&"#"+n||"transparent"}),y.call(c,re,lr(100*(e.val("a")||0)/255,4))}function E(e,t){var n=e.val("hex"),r=e.val("va");se.css({backgroundColor:n&&"#"+n||"transparent"}),y.call(c,le,lr(100*(255-(r&&r.a||0))/255,4)),u.window.bindToInput&&u.window.updateInputColor&&u.window.input.css({backgroundColor:n&&"#"+n||"transparent",color:null==r||r.v>75?"#000000":"#ffffff"})}function G(e){j=parseInt(U.css("left")),R=parseInt(U.css("top")),B=e.pageX,D=e.pageY,t(document).bind("mousemove",P).bind("mouseup",I),e.preventDefault()}function P(e){return U.css({left:j-(B-e.pageX)+"px",top:R-(D-e.pageY)+"px"}),u.window.expandable&&!t.support.boxModel&&U.prev().css({left:U.css("left"),top:U.css("top")}),e.stopPropagation(),e.preventDefault(),!1}function I(e){return t(document).unbind("mousemove",P).unbind("mouseup",I),e.stopPropagation(),e.preventDefault(),!1}function T(e){return e.preventDefault(),e.stopPropagation(),V.active.val("ahex",t(this).attr("title")||null,e.target),!1}function N(){function e(){if(u.window.expandable&&!t.support.boxModel){var e=U.find("table:first");U.before("