!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(e){var t=e.changedTouches,n=t[0],r="";switch(e.type){case"touchstart":r="mousedown";break;case"touchmove":r="mousemove";break;case"touchend":r="mouseup";break;default:return}var a=n.screenX,i=n.screenY,o=n.clientX,s=n.clientY,l=new MouseEvent(r,{bubbles:!0,cancelable:!0,view:window,detail:1,screenX:a,screenY:i,clientX:o,clientY:s,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null});t.length<2&&(n.target.dispatchEvent(l),e.preventDefault())}document.addEventListener("touchstart",e,!0),document.addEventListener("touchmove",e,!0),document.addEventListener("touchend",e,!0),document.addEventListener("touchcancel",e,!0);var t="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},n=function(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){return function r(a,i){try{var o=t[a](i),s=o.value}catch(e){return void n(e)}if(!o.done)return Promise.resolve(s).then(function(e){r("next",e)},function(e){r("throw",e)});e(s)}("next")})}},r=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},a=function(){function e(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=i,window.SVGPathSegLinetoAbs=l,window.SVGPathSegLinetoRel=c,window.SVGPathSegCurvetoCubicAbs=u,window.SVGPathSegCurvetoCubicRel=d,window.SVGPathSegCurvetoQuadraticAbs=h,window.SVGPathSegCurvetoQuadraticRel=p,window.SVGPathSegArcAbs=f,window.SVGPathSegArcRel=g,window.SVGPathSegLinetoHorizontalAbs=v,window.SVGPathSegLinetoHorizontalRel=m,window.SVGPathSegLinetoVerticalAbs=_,window.SVGPathSegLinetoVerticalRel=y,window.SVGPathSegCurvetoCubicSmoothAbs=b,window.SVGPathSegCurvetoCubicSmoothRel=x,window.SVGPathSegCurvetoQuadraticSmoothAbs=w,window.SVGPathSegCurvetoQuadraticSmoothRel=S}if(!("SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype)){var k=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 a(e,[{key:"_checkPathSynchronizedToList",value:function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())}},{key:"_updateListFromPathMutations",value:function(e){if(this._pathElement){var t=!1;e.forEach(function(e){"d"===e.attributeName&&(t=!0)}),t&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}}},{key:"_writeListToPath",value:function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",e._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}},{key:"segmentChanged",value:function(e){this._writeListToPath()}},{key:"clear",value:function(){this._checkPathSynchronizedToList(),this._list.forEach(function(e){e._owningPathSegList=null}),this._list=[],this._writeListToPath()}},{key:"initialize",value:function(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_checkValidIndex",value:function(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw new Error("INDEX_SIZE_ERR")}},{key:"getItem",value:function(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]}},{key:"insertItemBefore",value:function(e,t){return this._checkPathSynchronizedToList(),t>this.numberOfItems&&(t=this.numberOfItems),e._owningPathSegList&&(e=e.clone()),this._list.splice(t,0,e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"replaceItem",value:function(e,t){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._checkValidIndex(t),this._list[t]=e,e._owningPathSegList=this,this._writeListToPath(),e}},{key:"removeItem",value:function(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);var t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t}},{key:"appendItem",value:function(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_parsePath",value:function(e){if(!e||!e.length)return[];var t=this,n=function(){function e(){r(this,e),this.pathSegList=[]}return a(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),i=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 a(e,[{key:"_isCurrentSpace",value:function(){var e=this._string[this._currentIndex];return e<=" "&&(" "===e||"\n"===e||"\t"===e||"\r"===e||"\f"===e)}},{key:"_skipOptionalSpaces",value:function(){for(;this._currentIndex="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 i(e);if(!s.initialCommandIsMoveTo())return[];for(;s.hasMoreData();){var l=s.parseSegment();if(!l)return[];o.appendSegment(l)}return o.pathSegList}}]),e}();k.prototype.classname="SVGPathSegList",Object.defineProperty(k.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),k._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 k(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=k}}();var h,p=jQuery,f=(!!document.createElementNS&&document.createElementNS(u.SVG,"svg").createSVGRect,navigator.userAgent),g=document.createElementNS(u.SVG,"svg"),v=!!window.opera,m=f.includes("AppleWebKit"),_=f.includes("Gecko/"),y=f.includes("MSIE"),b=f.includes("Chrome/"),x=(f.includes("Windows"),f.includes("Macintosh")),w="ontouchstart"in window,S=!!g.querySelector,k=!!document.evaluate,C=function(){var e=document.createElementNS(u.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}(),A=function(){var e=document.createElementNS(u.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}(),E=function(){var e=document.createElementNS(u.SVG,"svg"),t=document.createElementNS(u.SVG,"svg");document.documentElement.append(e),t.setAttribute("x",5),e.append(t);var n=document.createElementNS(u.SVG,"text");n.textContent="a",t.append(n);var r=n.getStartPositionOfChar(0).x;return e.remove(),0===r}(),G=function(){var e=document.createElementNS(u.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(u.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}(),P=function(){var e=document.createElementNS(u.SVG,"svg");document.documentElement.append(e);var t=document.createElementNS(u.SVG,"path");t.setAttribute("d","M0,0 10,0");var n=document.createElementNS(u.SVG,"path");n.setAttribute("d","M5,0 15,0");var r=document.createElementNS(u.SVG,"g");r.append(t,n),e.append(r);var a=r.getBBox();return e.remove(),15===a.width}(),N=(function(){var e=document.createElementNS(u.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");t||p.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.')}(),(h=document.createElementNS(u.SVG,"rect")).setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===h.style.vectorEffect),I=function(){var e=document.createElementNS(u.SVG,"rect").transform.baseVal,t=g.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}(),T=function(){return v},L=function(){return m},M=function(){return _},O=function(){return y},V=function(){return b},j=function(){return x},R=function(){return w},B=function(){return P},D=function(){return N};function U(e){var n=e.fn.attr;return e.fn.attr=function(e,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=this._xforms[e],n=new Array(this.numberOfItems-1),r=void 0;for(r=0;r=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(ie.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}();de.type=de.prototype.type;var he=function(){function e(t){r(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return a(e,[{key:"resetUndoStack",value:function(){this.undoStack=[],this.undoStackPointer=0}},{key:"getUndoStackSize",value:function(){return this.undoStackPointer}},{key:"getRedoStackSize",value:function(){return this.undoStack.length-this.undoStackPointer}},{key:"getNextUndoCommandText",value:function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""}},{key:"getNextRedoCommandText",value:function(){return this.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 de("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 ue(i,o,n))}}return this.undoableChangeStack[e]=null,r}}]),e}(),pe=Object.freeze({HistoryEventTypes:ie,MoveElementCommand:se,InsertElementCommand:le,RemoveElementCommand:ce,ChangeElementCommand:ue,BatchCommand:de,UndoManager:he}),fe=document.createElementNS(u.SVG,"svg"),ge=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},ve=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},me=function(){for(var e=arguments.length,t=Array(e),n=0;n(n=parseInt(n,10))){var r=n;n=t,t=r}for(var a=fe.createSVGMatrix(),i=t;i<=n;++i){var o=i>=0&&ie.x&&t.ye.y},ke=jQuery,Ce={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"]},Ae={},Ee=function(e){Object.assign(Ae,e.ui)},Ge=[],Pe=!0,Ne={},Ie=null,Te=null,Le=function(e){Te=e,Ge=[0,"ClosePath"];ke.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(e,t){Ge.push(t+"Abs"),Ge.push(t+"Rel")})},Me=function(e,t,n){var r=e.pathSegList;if(A)r.insertItemBefore(t,n);else{for(var a=r.numberOfItems,i=[],o=0;o0?(g=p element");this.elem=t,this.segs=[],this.selected_pts=[],Ie=this,this.init()}return a(e,[{key:"init",value:function(){ke(Re()).find("*").each(function(){ke(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]);Te.addPtsToSelection({grips:a,closedSubpath:s})}}]),e}(),We=function(e){var t=Ne[e.id];return t||(t=Ne[e.id]=new Ye(e)),t},Xe=function(e){e in Ne&&delete Ne[e]},Qe=void 0,Ke=void 0,Ze=void 0,$e=void 0,Je=void 0,et=function(e,t){var n=e-Ze,r=t-$e,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)+Je;return n=a*Math.cos(i)+Ze,r=a*Math.sin(i)+$e,n-=Qe,r-=Ke,a=Math.sqrt(n*n+r*r),i=Math.atan2(r,n)-Je,{x:a*Math.cos(i)+Qe,y:a*Math.sin(i)+Ke}},tt=function(){var e=Ie.elem;if(Je=qt(e,!0)){var t=Ie.oldbbox;Ze=t.x+t.width/2,$e=t.y+t.height/2;var n=Mt(e);Qe=n.x+n.width/2,Ke=n.y+n.height/2;var r=Qe-Ze,a=Ke-$e,i=Math.sqrt(r*r+a*a),o=Math.atan2(a,r)+Je;Qe=i*Math.cos(o)+Ze,Ke=i*Math.sin(o)+$e;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var c=s.getItem(l),u=c.pathSegType;if(1!==u){var d=et(c.x,c.y),h=[d.x,d.y];if(null!=c.x1&&null!=c.x2){var p=et(c.x1,c.y1),f=et(c.x2,c.y2);h.splice(h.length,0,p.x,p.y,f.x,f.y)}Fe(u,l,h)}}n=Mt(e);var g=Te.getSVGRoot().createSVGTransform(),v=W(e);g.setRotate(180*Je/Math.PI,Qe,Ke),v.replaceItem(g,0)}},nt=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],rt=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&&v>=A-w&&v<=A+w){S=!0;break}}a=Te.getId(),Xe(a);var E=Wt(a),G=void 0,P=void 0,N=b.numberOfItems;if(S){if(x<=1&&N>=2){var I=b.getItem(0).x,T=b.getItem(0).y;G=4===(P=m.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(I,T):y.createSVGPathSegCurvetoCubicAbs(I,T,P.x1/f,P.y1/f,I,T);var L=y.createSVGPathSegClosePath();b.appendItem(G),b.appendItem(L)}else if(N<3)return!1;if(ke(m).remove(),y=Te.setDrawnPath(null),Te.setStarted(!1),it){Ie.matrix&&Te.remapElement(E,{},Ie.matrix.inverse());var M=E.getAttribute("d"),O=ke(Ie.elem).attr("d");return ke(Ie.elem).attr("d",O+M),ke(E).remove(),Ie.matrix&&tt(),Le(),ut.toEditMode(Ie.elem),Ie.selectPt(),!1}}else{if(!ke.contains(Te.getContainer(),Te.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=we(R,B,g,v);g=D.x,v=D.y}G=4===(P=m.pathSegList.getItem(1)).pathSegType?y.createSVGPathSegLinetoAbs(Te.round(g),Te.round(v)):y.createSVGPathSegCurvetoCubicAbs(Te.round(g),Te.round(v),P.x1/f,P.y1/f,P.x2/f,P.y2/f),y.pathSegList.appendItem(G),g*=f,v*=f,m.setAttribute("d",["M",g,v,g,v].join(" ")),_=V,it&&(_+=Ie.segs.length),je(_,g,v)}}else{var U="M"+g+","+v+" ";y=Te.setDrawnPath(Te.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:U,id:Te.getNextId(),opacity:Te.getOpacity()/2}})),m.setAttribute("d",["M",h,p,h,p].join(" ")),_=it?Ie.segs.length:0,je(_,h,p)}}},mouseMove:function(e,t){var n=Te.getCurrentZoom();ct=!0;var r=Te.getDrawnPath();if("path"!==Te.getCurrentMode())if(Ie.dragging){var a=Ve({x:Ie.dragging[0],y:Ie.dragging[1]},Ie),i=Ve({x:e,y:t},Ie),o=i.x-a.x,s=i.y-a.y;Ie.dragging=[e,t],Ie.dragctrl?Ie.moveCtrl(o,s):Ie.movePts(o,s)}else Ie.selected_pts=[],Ie.eachSeg(function(e){if(this.next||this.prev){var t=Te.getRubberBox().getBBox(),n=Oe(this),r={x:n.x,y:n.y,width:0,height:0},a=Se(t,r);this.select(a),a&&Ie.selected_pts.push(this.index)}});else{if(!r)return;var l=r.pathSegList,c=l.numberOfItems-1;if(ot){var u=Be("1c1"),d=Be("0c2");u.setAttribute("cx",e),u.setAttribute("cy",t),u.setAttribute("display","inline");var h=ot[0],p=ot[1],f=h+(h-e/n),g=p+(p-t/n);d.setAttribute("cx",f*n),d.setAttribute("cy",g*n),d.setAttribute("display","inline");var v=De(1);if(Xt(v,{x1:e,y1:t,x2:f*n,y2:g*n,display:"inline"}),0===c)st=[e,t];else{var m=l.getItem(c-1),_=m.x,y=m.y;6===m.pathSegType?(_+=_-m.x2,y+=y-m.y2):st&&(_=st[0]/n,y=st[1]/n),Fe(6,c,[h,p,_,y,f,g],r)}}else{var b=Wt("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);Fe(6,1,[e,t,w*n,S*n,e,t],b)}else st?Fe(6,1,[e,t,st[0],st[1],e,t],b):Fe(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,r){var a=Te.getDrawnPath();if("path"===Te.getCurrentMode())return ot=null,a||(t=Wt(Te.getId()),Te.setStarted(!1),st=null),{keep:!0,element:t};var i=Te.getRubberBox();if(Ie.dragging){var o=Ie.cur_pt;Ie.dragging=!1,Ie.dragctrl=!1,Ie.update(),ct&&Ie.endChanges("Move path point(s)"),e.shiftKey||ct||Ie.selectPt(o)}else i&&"none"!==i.getAttribute("display")?(i.setAttribute("display","none"),i.getAttribute("width")<=2&&i.getAttribute("height")<=2&&ut.toSelectMode(e.target)):ut.toSelectMode(e.target);ct=!1},toEditMode:function(e){Ie=We(e),Te.setCurrentMode("pathedit"),Te.clearSelection(),Ie.show(!0).update(),Ie.oldbbox=Mt(Ie.elem),it=!1},toSelectMode:function(e){var t=e===Ie.elem;Te.setCurrentMode("select"),Ie.show(!1),lt=!1,Te.clearSelection(),Ie.matrix&&tt(),t&&(Te.call("selected",[e]),Te.addToSelection([e],!0))},addSubPath:function(e){e?(Te.setCurrentMode("path"),it=!0):(ut.clear(!0),ut.toEditMode(Ie.elem))},select:function(e){lt===e?(ut.toEditMode(e),Te.setCurrentMode("pathedit")):lt=e},reorient:function(){var e=Te.getSelectedElements()[0];if(e&&0!==qt(e)){var t=new de("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new ue(e,n)),Te.clearSelection(),this.resetOrientation(e),Te.addCommandToHistory(t),We(e).show(!1).matrix=null,this.clear(),Te.addToSelection([e],!0),Te.call("changed",Te.getSelectedElements())}},clear:function(e){var t=Te.getDrawnPath();if(lt=null,t){var n=Wt(Te.getId());ke(Wt("path_stretch_line")).remove(),ke(n).remove(),ke(Wt("pathpointgrip_container")).find("*").attr("display","none"),st=null,Te.setDrawnPath(null),Te.setStarted(!1)}else"pathedit"===Te.getCurrentMode()&&this.toSelectMode();Ie&&Ie.init().show(!1)},resetOrientation:function(e){if(null==e||"path"!==e.nodeName)return!1;var t=W(e),n=be(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=[];ke.each(["",1,2],function(e,t){var r=a["x"+t],i=a["y"+t];if(void 0!==r&&void 0!==i){var s=ge(r,i,n);o.splice(o.length,0,s.x,s.y)}}),Fe(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}(),Ie.elem.pathSegList.numberOfItems<=1)return ut.toSelectMode(Ie.elem),void Te.canvas.deleteSelectedElements();if(Ie.init(),Ie.clearSelection(),window.opera){var r=ke(Ie.elem);r.attr("d",r.attr("d"))}Ie.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t=void 0,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=ze(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/g,">").replace(/"/g,""").replace(/'/,"'")},yt=function(e){if(e=wt(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++]=ht.charAt(s),t[r++]=ht.charAt(l),t[r++]=ht.charAt(c),t[r++]=ht.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 kt(e)}(),At=function(e){e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(u.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.append(t)),t},Tt=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 p=(-s-Math.sqrt(d))/(2*l);p>0&&p<1&&r[a].push(o(p))},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 Lt(e){if(B())try{return e.getBBox()}catch(e){}var t=dt.data(e,"ref"),n=null,r=void 0,a=void 0;t?(a=dt(t).children().clone().attr("visibility","hidden"),dt(mt).append(a),n=a.filter("line, path")):n=dt(e).find("line, path");var i=!1;if(n.length)if(n.each(function(){var e=this.getBBox();e.width&&e.height||(i=!0)}),i){var o=t?a:dt(e).children();r=Ut(o)}else r=e.getBBox();else r=e.getBBox();return t&&a.remove(),r}var Mt=function(e){var t=e||ft.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":G?t.getBBox&&(a=t.getBBox()):a=Tt(t);break;case"g":case"a":a=Lt(t);break;default:if("use"===r&&(a=Lt(t)),"use"===r||"foreignObject"===r&&L()){if(a||(a=t.getBBox()),!L()){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(pt.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=dt(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},Ot=function(e){var t="";return dt.each(e,function(e,n){var r=l(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=Rt(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),c=e.getAttribute("ry");(l||c)&&(r=s=Rt(e,t,n))}}if(!s){var u=be(a).matrix;r=ye(r.x,r.y,r.width,r.height,u).aabox}}return r};function Dt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var Ut=function(e,t,n){if(!e||!e.length)return!1;var r=void 0;if(dt.each(e,function(){r||this.parentNode&&(r=Bt(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=Dt(e[0]);o-=l,s-=l,a+=l,i+=l}else dt.each(e,function(e,r){var l=Bt(r,t,n);if(l){var c=Dt(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},Ft=function(e){e||(e=dt(ft.getSVGContent()).children());var t=[];return dt(e).children().each(function(e,n){n.getBBox&&t.push(n)}),t.reverse()},Ht=function(e){return e||(e=Ft()),Ut(e,ft.addSVGElementFromJson,ft.pathActions)},zt=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,r=0;r");var t=e.shortcut||"";$t("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")};function tn(e,t){["id","class","type"].forEach(function(n){n in t&&(e[n]=t[n])})}var nn,rn,an=(nn=n(regeneratorRuntime.mark(function e(t,n){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",on(t,i({},n,{returnDefault:!0})));case 1:case"end":return e.stop()}},e,this)})),function(e,t){return nn.apply(this,arguments)}),on=(rn=n(regeneratorRuntime.mark(function e(t,n){var r=n.global,a=n.returnDefault;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules)){e.next=3;break}return e.abrupt("return",ln(t,void 0,{returnDefault:a}));case 3:return e.next=5,sn(t);case 5:return e.abrupt("return",window[r]);case 6:case"end":return e.stop()}},e,this)})),function(e,t){return rn.apply(this,arguments)});function sn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Array.isArray(e)?Promise.all(e.map(function(e){return sn(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",tn(a,t),a.onerror=function(){r(new Error("Failed to import: "+e)),i()},a.onload=function(){n(),i()},a.src=e,document.head.append(a)})}function ln(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 ln(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=""};tn(o,t),o.defer="defer",o.type="module",o.onerror=function(){a(new Error("Failed to import: "+e)),s()},o.onload=function(){n(window[i]),s()};var l="import * as m from '"+function(e){var t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}(e).replace(/'/g,"\\'")+"'; window."+i+" = "+(r?"m.default || ":"")+"m;",c=new Blob([l],{type:"text/javascript"});o.src=URL.createObjectURL(c),document.head.append(o)})}var cn=jQuery,un=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(u.SVG,"g");var o=i.createElementNS(u.SVG,"title");o.textContent=t,this.group_.append(o),n?cn(n).after(this.group_):a.append(this.group_)}dn(this.group_),Et(this.group_,function(e){e.setAttribute("style","pointer-events:inherit")}),this.group_.setAttribute("style",a?"pointer-events:all":"pointer-events:none")}return a(e,[{key:"getName",value:function(){return this.name_}},{key:"getGroup",value:function(){return this.group_}},{key:"activate",value:function(){this.group_.setAttribute("style","pointer-events:all")}},{key:"deactivate",value:function(){this.group_.setAttribute("style","pointer-events:none")}},{key:"setVisible",value:function(e){var t=void 0===e||e?"inline":"none";this.group_.getAttribute("display")!==t&&this.group_.setAttribute("display",t)}},{key:"isVisible",value:function(){return"none"!==this.group_.getAttribute("display")}},{key:"getOpacity",value:function(){var e=this.group_.getAttribute("opacity");return 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(u.SE,"nonce");a&&vn!==gn.NEVER_RANDOMIZE?this.nonce_=a:vn===gn.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(100001*Math.random()))}return a(e,[{key:"getElem_",value:function(e){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+e):pn(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(u.XMLNS,"xmlns:se",u.SE),this.svgElem_.setAttributeNS(u.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=t)return null;var n=void 0;for(n=0;nn?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 un(yn(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=yn(Object.keys(this.layer_map)));var n=new un(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=yn(Object.keys(this.layer_map)));for(var n=this.current_layer.getGroup(),r=new un(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(dt.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(),L()&&"path"===t.nodeName){var a=rt(t);r.setAttribute("d",a)}if(dt.each(t.childNodes,function(t,a){switch(a.nodeType){case 1:r.append(e(a,n));break;case 3:r.textContent=a.nodeValue}}),dt(t).data("gsvg"))dt(r).data("gsvg",r.firstChild);else if(dt(t).data("symbol")){var i=dt(t).data("symbol");dt(r).data("ref",i).data("symbol",i)}else"image"===r.tagName&&Zt(r);return r}(e,function(){return t.getNextId()})}}]),e}(),xn=function(e,t){(vn=!1===e?gn.NEVER_RANDOMIZE:gn.ALWAYS_RANDOMIZE)!==gn.ALWAYS_RANDOMIZE||t.getNonce()?vn===gn.NEVER_RANDOMIZE&&t.getNonce()&&t.clearNonce():t.setNonce(Math.floor(100001*Math.random()))},wn=void 0,Sn=function(e){wn=e},kn=function(){Cn(),wn.getCurrentDrawing().identifyLayers()},Cn=function(){var e=mn.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(ve(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&&qt(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 d=n.createSVGTransformFromMatrix(me(s[1][0],s[0][0]));r.removeItem(s[0][1]),r.removeItem(s[1][1]),r.insertItemBefore(d,s[1][1])}if((l=r.numberOfItems)>=2&&1===r.getItem(l-2).type&&2===r.getItem(l-1).type){var h=n.createSVGTransform(),p=me(r.getItem(l-2).matrix,r.getItem(l-1).matrix);h.setMatrix(p),r.removeItem(l-2),r.removeItem(l-2),r.appendItem(h)}}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=Vn(t).data("gsvg"),g=new de("Transform"),v={},m=null,_=[];switch(t.tagName){case"line":_=["x1","y1","x2","y2"];break;case"circle":_=["cx","cy","r"];break;case"ellipse":_=["cx","cy","rx","ry"];break;case"foreignObject":case"rect":case"image":_=["width","height","x","y"];break;case"use":case"text":case"tspan":_=["x","y"];break;case"polygon":case"polyline":(m={}).points=t.getAttribute("points");var y=t.points,b=y.numberOfItems;v.points=new Array(b);for(var x=0;x1e-10?Math.sin(G)/(1-Math.cos(G)):2/G;for(var N=0;N=3&&3===r.getItem(M-2).type&&2===r.getItem(M-3).type&&2===r.getItem(M-1).type){j=3;for(var D=r.getItem(M-3).matrix,U=r.getItem(M-2).matrix,F=r.getItem(M-1).matrix,H=t.childNodes,z=H.length;z--;){var q=H.item(z);if(O=0,V=0,1===q.nodeType){var Y=W(q);if(!Y)continue;var X=be(Y).matrix,Q=qt(q);if(B=jn.getStartTransform(),jn.setStartTransform(q.getAttribute("transform")),Q||_e(Y)){var K=n.createSVGTransform();K.setMatrix(me(D,U,F,X)),Y.clear(),Y.appendItem(K)}else{var Z=me(X.inverse(),F,X),$=n.createSVGMatrix();$.e=-Z.e,$.f=-Z.f;var J=me($.inverse(),X.inverse(),D,U,F,X,Z.inverse()),ee=n.createSVGTransform(),te=n.createSVGTransform(),ne=n.createSVGTransform();ee.setTranslate(Z.e,Z.f),te.setScale(J.a,J.d),ne.setTranslate($.e,$.f),Y.appendItem(ne),Y.appendItem(te),Y.appendItem(ee)}g.addSubCommand(e(q)),jn.setStartTransform(B)}}r.removeItem(M-1),r.removeItem(M-2),r.removeItem(M-3)}else if(M>=3&&1===r.getItem(M-1).type){j=3,A=be(r).matrix;var ae=n.createSVGTransform();ae.setMatrix(A),r.clear(),r.appendItem(ae)}else if((1===M||M>1&&3!==r.getItem(1).type)&&2===r.getItem(0).type){j=2;var ie=be(r).matrix;r.removeItem(0);var oe=be(r).matrix.inverse(),se=me(oe,ie);if(O=se.e,V=se.f,0!==O||0!==V){for(var le=t.childNodes,ce=le.length,he=[];ce--;){var pe=le.item(ce);if(1===pe.nodeType){if(pe.getAttribute("clip-path")){var fe=pe.getAttribute("clip-path");he.includes(fe)||(Rn(fe,O,V),he.push(fe))}B=jn.getStartTransform(),jn.setStartTransform(pe.getAttribute("transform"));var ye=W(pe);if(ye){var xe=n.createSVGTransform();xe.setTranslate(O,V),ye.numberOfItems?ye.insertItemBefore(xe,0):ye.appendItem(xe),g.addSubCommand(e(pe));for(var we=t.getElementsByTagNameNS(u.SVG,"use"),Se="#"+pe.id,ke=we.length;ke--;){var Ce=we.item(ke);if(Se===Pt(Ce)){var Ae=n.createSVGTransform();Ae.setTranslate(-O,-V),W(Ce).insertItemBefore(Ae,0),g.addSubCommand(e(Ce))}}jn.setStartTransform(B)}}}he=[],jn.setStartTransform(B)}}else{if(1!==M||1!==r.getItem(0).type||E){if(E){var Ee=n.createSVGTransform();Ee.setRotate(E,k.x,k.y),r.numberOfItems?r.insertItemBefore(Ee,0):r.appendItem(Ee)}return 0===r.numberOfItems&&t.removeAttribute("transform"),null}j=1;for(var Ge=r.getItem(0).matrix,Pe=t.childNodes,Ne=Pe.length;Ne--;){var Ie=Pe.item(Ne);if(1===Ie.nodeType){B=jn.getStartTransform(),jn.setStartTransform(Ie.getAttribute("transform"));var Te=W(Ie);if(!Te)continue;var Le=me(Ge,be(Te).matrix),Me=n.createSVGTransform();Me.setMatrix(Le),Te.clear(),Te.appendItem(Me,0),g.addSubCommand(e(Ie)),jn.setStartTransform(B);var Oe=Ie.getAttribute("stroke-width");if("none"!==Ie.getAttribute("stroke")&&!isNaN(Oe)){var Ve=(Math.abs(Le.a)+Math.abs(Le.d))/2;Ie.setAttribute("stroke-width",Oe*Ve)}}}r.clear()}if(2===j){if(E){k={x:S.x+R.e,y:S.y+R.f};var je=n.createSVGTransform();je.setRotate(E,k.x,k.y),r.numberOfItems?r.insertItemBefore(je,0):r.appendItem(je)}}else if(3===j){var Re=be(r).matrix,Be=n.createSVGTransform();Be.setRotate(E,S.x,S.y);var De=Be.matrix,Ue=n.createSVGTransform();Ue.setRotate(E,k.x,k.y);var Fe=Ue.matrix.inverse(),He=Re.inverse(),ze=me(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){B=jn.getStartTransform(),jn.setStartTransform(We.getAttribute("transform"));var Xe=W(We),Qe=n.createSVGTransform();Qe.setTranslate(O,V),Xe.numberOfItems?Xe.insertItemBefore(Qe,0):Xe.appendItem(Qe),g.addSubCommand(e(We)),jn.setStartTransform(B)}}E&&(r.numberOfItems?r.insertItemBefore(Ue,0):r.appendItem(Ue))}}else{var Ke=Mt(t);if(!Ke&&"path"!==t.tagName)return null;var Ze=n.createSVGMatrix(),$e=qt(t);if($e){S={x:Ke.x+Ke.width/2,y:Ke.y+Ke.height/2},k=ge(Ke.x+Ke.width/2,Ke.y+Ke.height/2,be(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,Ze=be(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,Ze=be(r).matrix;var ht=n.createSVGTransform();ht.setMatrix(Ze),r.clear(),r.appendItem(ht),Ze=n.createSVGMatrix()}else if((1===it||it>1&&3!==r.getItem(1).type)&&2===r.getItem(0).type){at=2;var pt=r.getItem(0).matrix,ft=be(r,1).matrix,gt=ft.inverse();Ze=me(gt,pt,ft),r.removeItem(0)}else{if(1!==it||1!==r.getItem(0).type||$e){if(at=4,$e){var vt=n.createSVGTransform();vt.setRotate($e,k.x,k.y),r.numberOfItems?r.insertItemBefore(vt,0):r.appendItem(vt)}return 0===r.numberOfItems&&t.removeAttribute("transform"),null}switch(Ze=be(r).matrix,t.tagName){case"line":v=Vn(t).attr(["x1","y1","x2","y2"]);case"polyline":case"polygon":if(v.points=t.getAttribute("points"),v.points){var mt=t.points,_t=mt.numberOfItems;v.points=new Array(_t);for(var yt=0;yt<_t;++yt){var bt=mt.getItem(yt);v.points[yt]={x:bt.x,y:bt.y}}}case"path":v.d=t.getAttribute("d"),at=1,r.clear()}}if(1!==at&&2!==at&&3!==at||On(t,v,Ze),2===at){if($e){_e(r)||(k={x:S.x+Ze.e,y:S.y+Ze.f});var xt=n.createSVGTransform();xt.setRotate($e,k.x,k.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:Vn(kt).attr("x")||0,y:Vn(kt).attr("y")||0};On(kt,Ct,Ze)}}}else if(3===at&&$e){var At=be(r).matrix,Et=n.createSVGTransform();Et.setRotate($e,S.x,S.y);var Gt=Et.matrix,Nt=n.createSVGTransform();Nt.setRotate($e,k.x,k.y);var It=Nt.matrix.inverse(),Tt=At.inverse(),Lt=me(Tt,It,Gt,At);On(t,v,Lt),$e&&(r.numberOfItems?r.insertItemBefore(Nt,0):r.appendItem(Nt))}}return 0===r.numberOfItems&&t.removeAttribute("transform"),g.addSubCommand(new ue(t,m)),g},Dn=jQuery,Un=void 0,Fn=void 0,Hn=void 0,zn=R()?10:4,qn=function(){function e(t,n,a){r(this,e),this.id=t,this.selectedElement=n,this.locked=!0,this.selectorGroup=Un.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}}),this.selectorRect=this.selectorGroup.appendChild(Un.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 a(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=void 0,n=[],r=Math.round(e/45);for(t in r<0&&(r+=8),Hn.selectorGrips)n.push(t);for(;r>0;)n.push(n.shift()),r--;var a=0;for(t in Hn.selectorGrips)Hn.selectorGrips[t].setAttribute("style","cursor:"+n[a]+"-resize"),a++}},{key:"showGrips",value:function(e){var t=e?"inline":"none";Hn.selectorGripsGroup.setAttribute("display",t);var n=this.selectedElement;this.hasGrips=e,n&&e&&(this.selectorGroup.append(Hn.selectorGripsGroup),this.updateGripCursors(qt(n)))}},{key:"resize",value:function(e){var t=this.selectorRect,n=Hn,r=n.selectorGrips,a=this.selectedElement,i=a.getAttribute("stroke-width"),o=Un.getCurrentZoom(),s=1/o;"none"===a.getAttribute("stroke")||isNaN(i)||(s+=i/2);var l=a.tagName;"text"===l&&(s+=2/o);var c=W(a),u=be(c).matrix;if(u.e*=o,u.f*=o,e||(e=Mt(a)),"g"===l&&!Dn.data(a,"gsvg")){var d=Ut([a.childNodes]);d&&(e=d)}var h=e.x,p=e.y,f=e.width,g=e.height;e={x:h,y:p,width:f,height:g},s*=o;var v=ye(h*o,p*o,f*o,g*o,u),m=v.aabox,_=m.x-s,y=m.y-s,b=m.width+2*s,x=m.height+2*s,w=_+b/2,S=y+x/2,k=qt(a);if(k){var C=Un.svgRoot().createSVGTransform();C.setRotate(-k,w,S);var A=C.matrix;v.tl=ge(v.tl.x,v.tl.y,A),v.tr=ge(v.tr.x,v.tr.y,A),v.bl=ge(v.bl.x,v.bl.y,A),v.br=ge(v.br.x,v.br.y,A);var E=v.tl,G=E.x,P=E.y,N=E.x,I=E.y,T=Math.min,L=Math.max;_=G=T(G,T(v.tr.x,T(v.bl.x,v.br.x)))-s,y=P=T(P,T(v.tr.y,T(v.bl.y,v.br.y)))-s,b=(N=L(N,L(v.tr.x,L(v.bl.x,v.br.x)))+s)-G,x=(I=L(I,L(v.tr.y,L(v.bl.y,v.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*zn),n.rotateGrip.setAttribute("cx",_+b/2),n.rotateGrip.setAttribute("cy",y-5*zn)}}]),e}(),Yn=function(){function e(){r(this,e),this.selectorParentGroup=null,this.rubberBandBox=null,this.selectors=[],this.selectorMap={},this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null},this.selectorGripsGroup=null,this.rotateGripConnector=null,this.rotateGrip=null,this.initGroup()}return a(e,[{key:"initGroup",value:function(){for(var e in this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.remove(),this.selectorParentGroup=Un.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}}),this.selectorGripsGroup=Un.createSVGElement({element:"g",attr:{display:"none"}}),this.selectorParentGroup.append(this.selectorGripsGroup),Un.svgRoot().append(this.selectorParentGroup),this.selectorMap={},this.selectors=[],this.rubberBandBox=null,this.selectorGrips){var t=Un.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+e,fill:"#22C",r:zn,style:"cursor:"+e+"-resize","stroke-width":2,"pointer-events":"all"}});Dn.data(t,"dir",e),Dn.data(t,"type","resize"),this.selectorGrips[e]=this.selectorGripsGroup.appendChild(t)}if(this.rotateGripConnector=this.selectorGripsGroup.appendChild(Un.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}})),this.rotateGrip=this.selectorGripsGroup.appendChild(Un.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:zn,stroke:"#22C","stroke-width":2,style:"cursor:url("+Fn.imgPath+"rotate.png) 12 12, auto;"}})),Dn.data(this.rotateGrip,"type","rotate"),!Dn("#canvasBackground").length){var n=l(Fn.dimensions,2),r=n[0],a=n[1],i=Un.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:r,height:a,x:0,y:0,overflow:L()?"none":"visible",style:"pointer-events:none"}}),o=Un.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),Un.svgRoot().insertBefore(i,Un.svgContent())}}},{key:"requestSelector",value:function(e,n){if(null==e)return null;var r=this.selectors.length;if("object"===t(this.selectorMap[e.id]))return this.selectorMap[e.id].locked=!0,this.selectorMap[e.id];for(var a=0;a').documentElement,!0);a.append(f);var g=p.createElementNS(u.SVG,"svg");(h.clearSvgContentElement=function(){Wn(g).empty(),Wn(g).attr({id:"svgcontent",width:s[0],height:s[1],x:s[0],y:s[1],overflow:o.show_outside_canvas?"visible":"hidden",xmlns:u.SVG,"xmlns:se":u.SE,"xmlns:xlink":u.XLINK}).appendTo(f);var e=p.createComment(" Created with SVG-edit - https://github.com/SVG-Edit/svgedit");g.append(e)})();var v="svg_";h.setIdPrefix=function(e){v=e},h.current_drawing_=new bn(g,v);var m=h.getCurrentDrawing=function(){return h.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=Wn.extend(!0,{},b.shape),Wn.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 p.createTextNode(e);var t=Wt(e.attr.id),n=m().getCurrentLayer();if(t&&e.element!==t.tagName&&(t.remove(),t=null),!t){var r=e.namespace||u.SVG;t=p.createElementNS(r,e.element),n&&(y||n).append(t)}return e.curStyles&&Xt(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),Xt(t,e.attr,100),Qt(t),e.children&&e.children.forEach(function(e){t.append(k(e))}),t};h.getTransformList=W,h.matrixMultiply=me,h.hasMatrixTransform=_e,h.transformListToTransform=be;var C=function(){return o.baseUnit};!function(e){Z=e;var t=document.createElementNS(u.SVG,"svg");document.body.append(t);var n=document.createElementNS(u.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;$={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:Wt,getHeight:function(){return g.getAttribute("height")/_},getWidth:function(){return g.getAttribute("width")/_},getRoundDigits:function(){return ke.round_digits}}),h.convertToNum=re;var A,G=function(){return g},P=this.getSelectedElems=function(){return w},N=ut,I=function(){return f};ft=A={pathActions:N,getSVGContent:G,addSVGElementFromJson:k,getSelectedElements:P,getDOMDocument:function(){return p},getDOMContainer:function(){return a},getSVGRoot:I,getBaseUnit:C,getSnappingStep:function(){return o.snappingStep}},gt=A.getDOMDocument(),vt=A.getDOMContainer(),mt=A.getSVGRoot(),h.findDefs=It,h.getUrlFromAttr=Gt,h.getHref=Pt,h.setHref=Nt,h.getBBox=Mt,h.getRotationAngle=qt,h.getElem=Wt,h.getRefElem=Yt,h.assignAttributes=Xt,this.cleanupElement=Qt;var T=function(){return o.gridSnapping};!function(e){Mn=e}({getDrawing:function(){return m()},getSVGRoot:I,getGridSnapping:T}),this.remapElement=On,function(e){jn=e}({getSVGRoot:I,getStartTransform:function(){return Oe},setStartTransform:function(e){Oe=e}}),this.recalculateDimensions=Bn;var j=d();h.sanitizeSvg=In;var R=h.undoMgr=new Jn({handleHistoryEvent:function(e,t){var n=er;if(e===n.BEFORE_UNAPPLY||e===n.BEFORE_APPLY)h.clearSelection();else if(e===n.AFTER_APPLY||e===n.AFTER_UNAPPLY){var r=t.elements();h.pathActions.clear(),Q("changed",r);var a=t.type(),i=e===n.AFTER_APPLY;if(a===Xn.type())(i?t.newParent:t.oldParent)===g&&kn();else if(a===Qn.type()||a===Kn.type())t.parent===g&&kn(),a===Qn.type()?i&&he(t.elem):i||he(t.elem),"use"===t.elem.tagName&&Jt(t.elem);else if(a===Zn.type()){"title"===t.elem.tagName&&t.elem.parentNode.parentNode===g&&kn();var o=i?t.newValues:t.oldValues;o.stdDeviation&&h.setBlurOffsets(t.elem.parentNode,o.stdDeviation)}}}}),B=function(e){h.undoMgr.addCommandToHistory(e)},U=this.getZoom=function(){return _},F=this.round=function(e){return parseInt(e*_,10)/_};!function(e,t){Fn=e,Un=t,Hn=new Yn}(o,{createSVGElement:function(e){return h.addSVGElementFromJson(e)},svgRoot:function(){return f},svgContent:function(){return g},getCurrentZoom:U});var H=this.selectorManager=Hn,Y=h.getNextId=function(){return m().getNextId()},X=h.getId=function(){return m().getId()},Q=function(e,t){if(We[e])return We[e](window,t)},K=this.clearSelection=function(e){w.forEach(function(e){null!=e&&H.releaseSelector(e)}),w=[],e||Q("selected",w)},ne=this.addToSelection=function(e,t){if(e.length){for(var n=0;n1&&o.showGrips(!1)}}}for(Q("selected",w),t||1===w.length?H.requestSelector(w[0]).showGrips(!0):H.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)}},ae=function(){return x.opacity},ie=this.getMouseTarget=function(e){if(null==e)return null;var t=e.target;if(t.correspondingUseElement&&(t=t.correspondingUseElement),[u.MATH,u.HTML].includes(t.namespaceURI)&&"svgcanvas"!==t.id)for(;"foreignObject"!==t.nodeName;)if(!(t=t.parentNode))return f;var n=m().getCurrentLayer();if([f,a,g,n].includes(t))return f;if(Wn(t).closest("#selectorParentGroup").length)return H.selectorParentGroup;for(;t.parentNode!==(y||n);)t=t.parentNode;return t};h.pathActions=N,Le({selectorManager:H,canvas:h,call:Q,resetD:function(e){e.setAttribute("d",N.convertPath(e))},round:F,clearSelection:K,addToSelection:ne,addCommandToHistory:B,remapElement:On,addSVGElementFromJson:k,getGridSnapping:T,getOpacity:ae,getSelectedElements:P,getContainer:function(){return a},setStarted:function(e){Me=e},getRubberBox:function(){return De},setRubberBox:function(e){return De=e},addPtsToSelection:function(e){var t=e.closedSubpath,n=e.grips;N.canDeleteNodes=!0,N.closed_subpath=t,Q("pointsAdded",{closedSubpath:t,grips:n}),Q("selected",n)},endChanges:function(e){var t=e.cmd,n=e.elem;B(t),Q("changed",[n])},getCurrentZoom:U,getId:X,getNextId:Y,getMouseTarget:ie,getCurrentMode:function(){return Ve},setCurrentMode:function(e){return Ve=e},getDrawnPath:function(){return Ot},setDrawnPath:function(e){return Ot=e},getSVGRoot:I});var oe={},se="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=Wn.data,ue=document.createElementNS(u.SVG,"animate");Wn(ue).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(f);var de,he=function e(t){var n=Wn(t).attr(le);for(var r in n){var a=n[r];if(a&&a.startsWith("url(")){var i=Gt(a).substr(1);Wt(i)||(It().append(Pe[i]),delete Pe[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=ge(i,o,be(s).matrix),c=f.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 u=n.getAttribute("transform");n.setAttribute("transform",r),un("transform",u,w),Q("changed",w)}var d=H.requestSelector(w[0]);d.resize(),d.updateGripCursors(e)};var Ke=this.recalculateAllSelectedDimensions=function(){for(var e=new $n("none"===je?"position":"size"),t=w.length;t--;){var n=w[t],r=Bn(n);r&&e.addSubCommand(r)}e.isEmpty()||(B(e),Q("changed",w))},Ze=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},$e=null,Je=this.selectOnly=function(e,t){K(!0),ne(e,t)};this.removeFromSelection=function(e){if(null!=w[0]&&e.length){for(var t=[],n=w.length,r=0;r0&&h.removeFromSelection(G),P.length>0&&h.addToSelection(P);break;case"resize":C=W(d);var M=_e(C),O=(u=M?ot:Mt(d)).x,V=u.y,j=u,R=j.width,B=j.height;if(i=x-nt,s=k-rt,o.gridSnapping&&(i=Kt(i),s=Kt(s),B=Kt(B),R=Kt(R)),c=qt(d)){var D=Math.sqrt(i*i+s*s),U=Math.atan2(s,i)-c*Math.PI/180;i=D*Math.cos(U),s=D*Math.sin(U)}je.includes("n")||je.includes("s")||(s=0),je.includes("e")||je.includes("w")||(i=0);var F=0,z=0,q=B?(B+s)/B:1,Y=R?(R+i)/R:1;je.includes("n")&&(q=B?(B-s)/B:1,z=B),je.includes("w")&&(Y=R?(R-i)/R:1,F=R);var K=f.createSVGTransform(),Z=f.createSVGTransform(),$=f.createSVGTransform();if(o.gridSnapping&&(O=Kt(O),F=Kt(F),V=Kt(V),z=Kt(z)),K.setTranslate(-(O+F),-(V+z)),e.shiftKey&&(1===Y?Y=q:q=Y),Z.setScale(Y,q),$.setTranslate(O+F,V+z),M){var J=c?1:0;C.replaceItem(K,2+J),C.replaceItem(Z,1+J),C.replaceItem($,Number(J))}else{var ee=C.numberOfItems;C.replaceItem($,ee-3),C.replaceItem(Z,ee-2),C.replaceItem(K,ee-1)}H.requestSelector(d).resize(),Q("transition",w);break;case"zoom":b*=_,S*=_,Xt(De,{x:Math.min(at*_,b),y:Math.min(it*_,S),width:Math.abs(b-at*_),height:Math.abs(S-it*_)},100);break;case"text":Xt(y,{x:x,y:k},1e3);break;case"line":o.gridSnapping&&(x=Kt(x),k=Kt(k));var te=x,ne=k;e.shiftKey&&(te=(n=we(nt,rt,te,ne)).x,ne=n.y),y.setAttributeNS(null,"x2",te),y.setAttributeNS(null,"y2",ne);break;case"foreignObject":case"square":case"rect":case"image":var re="square"===Ve||e.shiftKey,ae=Math.abs(x-nt),ie=Math.abs(k-rt),oe=void 0,se=void 0;re?(ae=ie=Math.max(ae,ie),oe=nt.8){st-=.8;var he=g.createSVGPoint();he.x=xt.x,he.y=xt.y,y.points.appendItem(he)}lt={x:ct.x,y:ct.y},ct={x:ht.x,y:ht.y},ht={x:pt.x,y:pt.y};break;case"path":case"pathedit":if(x*=_,k*=_,o.gridSnapping&&(x=Kt(x),k=Kt(k),nt=Kt(nt),rt=Kt(rt)),e.shiftKey){var pe=Ie,fe=void 0,ve=void 0;pe?(fe=pe.dragging?pe.dragging[0]:nt,ve=pe.dragging?pe.dragging[1]:rt):(fe=nt,ve=rt);var me=n=we(fe,ve,x,k);x=me.x,k=me.y}De&&"none"!==De.getAttribute("display")&&(b*=_,S*=_,Xt(De,{x:Math.min(at*_,b),y:Math.min(it*_,S),width:Math.abs(b-at*_),height:Math.abs(S-it*_)},100)),N.mouseMove(x,k);break;case"textedit":x*=_,k*=_,Bt.mouseMove(v,m);break;case"rotate":r=(u=Mt(d)).x+u.width/2,a=u.y+u.height/2;var ye=xe(d),be=ge(r,a,ye);r=be.x,a=be.y,c=(Math.atan2(a-k,r-x)*(180/Math.PI)-90)%360,o.gridSnapping&&(c=Kt(c)),e.shiftKey&&(c=45*Math.round(c/45)),h.setRotationAngle(c<-180?360+c:c,!0),Q("transition",w)}He("mouseMove",{event:e,mouse_x:v,mouse_y:m,selected:d})}}).click(function(e){return e.preventDefault(),!1}).dblclick(function(e){var t=e.target.parentNode;if(t!==y){var n=ie(e),r=n.tagName;if("text"===r&&"textedit"!==Ve){var a=ge(e.pageX,e.pageY,$e);Bt.select(n,a.x,a.y)}"g"!==r&&"a"!==r||!qt(n)||(dn(n),n=w[0],K(!0)),y&&Cn(),"g"!==t.tagName&&"a"!==t.tagName||t===m().getCurrentLayer()||n===H.selectorParentGroup||An(n)}}).mouseup(function(e){if(2!==e.button){var t=Be;if(Be=null,Me){var n=ge(e.pageX,e.pageY,$e),r=n.x*_,a=n.y*_,i=r/_,s=a/_,l=Wt(X()),c=!1,u=i,d=s;Me=!1;var p=void 0,f=void 0;switch(Ve){case"resize":case"multiselect":null!=De&&(De.setAttribute("display","none"),Ue=[]),Ve="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:Re.fill=g.getAttribute("fill"),Re.fill_opacity=g.getAttribute("fill-opacity"),Re.stroke=g.getAttribute("stroke"),Re.stroke_opacity=g.getAttribute("stroke-opacity"),Re.stroke_width=g.getAttribute("stroke-width"),Re.stroke_dasharray=g.getAttribute("stroke-dasharray"),Re.stroke_linejoin=g.getAttribute("stroke-linejoin"),Re.stroke_linecap=g.getAttribute("stroke-linecap")}"text"===g.tagName&&(Ae.font_size=g.getAttribute("font-size"),Ae.font_family=g.getAttribute("font-family")),H.requestSelector(g).showGrips(!0)}if(Ke(),u!==at||d!==it)for(var v=w.length,y=0;y=0?C.indexOf(",",A+1)>=0:C.indexOf(" ",C.indexOf(" ")+1)>=0)&&(l=N.smoothPolylineIntoPath(l));break;case"line":p=Wn(l).attr(["x1","x2","y1","y2"]),c=p.x1!==p.x2||p.y1!==p.y2;break;case"foreignObject":case"square":case"rect":case"image":p=Wn(l).attr(["width","height"]),c=p.width||p.height||"image"===Ve;break;case"circle":c="0"!==l.getAttribute("r");break;case"ellipse":p=Wn(l).attr(["rx","ry"]),c=p.rx||p.ry;break;case"fhellipse":et.maxx-et.minx>0&&et.maxy-et.miny>0&&(l=k({element:"ellipse",curStyles:!0,attr:{cx:(et.minx+et.maxx)/2,cy:(et.miny+et.maxy)/2,rx:(et.maxx-et.minx)/2,ry:(et.maxy-et.miny)/2,id:X()}}),Q("changed",[l]),c=!0);break;case"fhrect":et.maxx-et.minx>0&&et.maxy-et.miny>0&&(l=k({element:"rect",curStyles:!0,attr:{x:et.minx,y:et.miny,width:et.maxx-et.minx,height:et.maxy-et.miny,id:X()}}),Q("changed",[l]),c=!0);break;case"text":c=!0,Je([l]),Bt.start(l);break;case"path":l=null,Me=!0;var E=N.mouseUp(e,l,r,a);l=E.element,c=E.keep;break;case"pathedit":c=!0,l=null,N.mouseUp(e);break;case"textedit":c=!1,l=null,Bt.mouseUp(e,r,a);break;case"rotate":c=!0,l=null,Ve="select";var G=h.undoMgr.finishUndoableChange();G.isEmpty()||B(G),Ke(),Q("changed",w)}var P=He("mouseUp",{event:e,mouse_x:r,mouse_y:a},!0);if(Wn.each(P,function(e,t){t&&(c=t.keep||c,l=t.element,Me=t.started||Me)}),c||null==l){if(null!=l){h.addedNew=!0;var I=.2,T=void 0;if(ue.beginElement&&parseFloat(l.getAttribute("opacity"))!==x.opacity){T=Wn(ue).clone().attr({to:x.opacity,dur:I}).appendTo(l);try{T[0].beginElement()}catch(e){}}else I=0;setTimeout(function(){T&&T.remove(),l.setAttribute("opacity",x.opacity),l.setAttribute("style","pointer-events:inherit"),Qt(l),"path"===Ve?N.toEditMode(l):o.selectNew&&Je([l],!0),B(new Qn(l)),Q("changed",[l])},1e3*I)}}else{for(m().releaseId(X()),l.remove(),l=null,f=e.target;f&&f.parentNode&&f.parentNode.parentNode&&"g"===f.parentNode.parentNode.tagName;)f=f.parentNode;"path"===Ve&&Ot||!f||!f.parentNode||"selectorParentGroup"===f.parentNode.id||"svgcanvas"===f.id||"svgroot"===f.id||(h.setMode("select"),Je([f],!0))}Oe=null}}}),Wn(a).bind("mousewheel DOMMouseScroll",function(e){if(e.shiftKey){e.preventDefault();var t=e.originalEvent;$e=Wn("#svgcontent g")[0].getScreenCTM().inverse();var n=Wn("#workarea"),r=o.showRulers?16:0,a=ge(t.pageX,t.pageY,$e),i=n.width(),s=n.height(),l=i-15-r,c=s-15-r,u=l*$e.a,d=c*$e.d,p=n.offset(),f=p.left+r,g=p.top+r,v=t.wheelDelta?t.wheelDelta:t.detail?-t.detail:0;if(v){var m=Math.max(.75,Math.min(4/3,v)),y=void 0,b=void 0;m>1?(y=Math.ceil(l/u*m*100)/100,b=Math.ceil(c/d*m*100)/100):(y=Math.floor(l/u*m*100)/100,b=Math.floor(c/d*m*100)/100);var x=Math.min(y,b);if((x=Math.min(10,Math.max(.01,x)))!==_){m=x/_;var w=ge(f,g,$e),S={x:(a.x-(a.x-w.x)/m)*x-r+i/2,y:(a.y-(a.y-w.y)/m)*x-r+s/2};h.setZoom(x),Wn("#zoom").val((100*x).toFixed(1)),Q("updateCanvas",{center:!1,newCtr:S}),Q("zoomDone")}}}});var Bt=h.textActions=function(){var e=void 0,t=void 0,n=void 0,r=void 0,a=void 0,i=[],o=void 0,s=void 0,l=void 0,c=void 0,d=void 0;function p(e){var s=""===t.value;if(Wn(t).focus(),!arguments.length)if(s)e=0;else{if(t.selectionEnd!==t.selectionStart)return;e=t.selectionEnd}var l=i[e];s||t.setSelectionRange(e,e),(n=Wt("text_cursor"))||(n=document.createElementNS(u.SVG,"line"),Xt(n,{id:"text_cursor",stroke:"#333","stroke-width":1}),n=Wt("selectorParentGroup").appendChild(n)),a||(a=setInterval(function(){var e="none"===n.getAttribute("display");n.setAttribute("display",e?"inline":"none")},600));var c=x(l.x,o.y),d=x(l.x,o.y+o.height);Xt(n,{x1:c.x,y1:c.y,x2:d.x,y2:d.y,visibility:"visible",display:"inline"}),r&&r.setAttribute("d","")}function g(e,a,s){if(e!==a){s||t.setSelectionRange(e,a),(r=Wt("text_selectblock"))||(r=document.createElementNS(u.SVG,"path"),Xt(r,{id:"text_selectblock",fill:"green",opacity:.5,style:"pointer-events:none"}),Wt("selectorParentGroup").append(r));var l=i[e],c=i[a];n.setAttribute("visibility","hidden");var d=x(l.x,o.y),h=x(l.x+(c.x-l.x),o.y),f=x(l.x,o.y+o.height),g=x(l.x+(c.x-l.x),o.y+o.height),v="M"+d.x+","+d.y+" L"+h.x+","+h.y+" "+g.x+","+g.y+" "+f.x+","+f.y+"z";Xt(r,{d:v,display:"inline"})}else p(a)}function v(t,n){var r=f.createSVGPoint();if(r.x=t,r.y=n,1===i.length)return 0;var a=e.getCharNumAtPosition(r);a<0?(a=i.length-2,t<=i[0].x&&(a=0)):a>=i.length-2&&(a=i.length-2);var o=i[a];return t>o.x+o.width/2&&a++,a}function m(e,t){p(v(e,t))}function y(e,n,r){var a=t.selectionStart,i=v(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/=_,s){var r=ge(n.x,n.y,s.inverse());n.x=r.x,n.y=r.y}return n}function x(e,t){var n={x:e,y:t};if(s){var r=ge(n.x,n.y,s);n.x=r.x,n.y=r.y}return n.x*=_,n.y*=_,n}function S(t){g(0,e.textContent.length),Wn(this).unbind(t)}function k(t){if(d&&e){var n=ge(t.pageX,t.pageY,$e),r=b(n.x*_,n.y*_),a=v(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),Wn(t.target).click(S),setTimeout(function(){Wn(t.target).unbind("click",S)},300)}}return{select:function(t,n,r){e=t,Bt.toEditMode(n,r)},start:function(t){e=t,Bt.toEditMode()},mouseDown:function(e,n,r,a){var i=b(r,a);t.focus(),m(i.x,i.y),l=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&&nl-2&&rc-2&&Bt.toSelectMode(!0)},setCursor:p,toEditMode:function(t,n){if(d=!1,Ve="textedit",H.requestSelector(e).showGrips(!1),H.requestSelector(e),Bt.init(),Wn(e).css("cursor","text"),arguments.length){var r=b(t,n);m(r.x,r.y)}else p();setTimeout(function(){d=!0},300)},toSelectMode:function(i){Ve="select",clearInterval(a),a=null,r&&Wn(r).attr("display","none"),n&&Wn(n).attr("visibility","hidden"),Wn(e).css("cursor","move"),i&&(K(),Wn(e).css("cursor","move"),Q("selected",[e]),ne([e],!0)),e&&!e.textContent.length&&h.deleteSelectedElements(),Wn(t).blur(),e=!1},setInputElem:function(e){t=e},clear:function(){"textedit"===Ve&&Bt.toSelectMode()},init:function(n){if(e){var r=void 0,a=void 0;e.parentNode||(e=w[0],H.requestSelector(e).showGrips(!1));var l=e.textContent.length,c=e.getAttribute("transform");for(o=Mt(e),s=c?xe(e):null,(i=[]).length=l,t.focus(),Wn(e).unbind("dblclick",k).dblclick(k),l||(a={x:o.x+o.width/2,width:0}),r=0;r")[0].getContext("2d")||(n.text=oe.exportNoText),Wn.each(n,function(n,a){r.find(n).length&&(t.push(n),e.push(a))}),{issues:e,issueCodes:t}}this.svgCanvasToString=function(){for(;Dt()>0;);N.clear(!0),Wn.each(g.childNodes,function(e,t){e&&8===t.nodeType&&t.data.includes("Created with")&&g.firstChild.before(t)}),y&&(Cn(),Je([y]));var e=[];Wn(g).find("g:data(gsvg)").each(function(){for(var t=this.attributes,n=t.length,r=0;rt.name?-1:1}),s=0;s=0;s--){var v=i[s],m=_t(v.value);if(!g.includes(v.localName)&&""!==m){if(m.startsWith("pointer-events"))continue;if("class"===v.localName&&m.startsWith("se_"))continue;if(n.push(" "),"d"===v.localName&&(m=N.convertPath(e,!0)),isNaN(m)?a.test(m)&&(m=ee(m)+r):m=ee(m),ke.apply&&"image"===e.nodeName&&"href"===v.localName&&ke.images&&"embed"===ke.images){var _=fe[m];_&&(m=_)}v.namespaceURI&&v.namespaceURI!==u.SVG&&!j[v.namespaceURI]||(n.push(v.nodeName),n.push('="'),n.push(m),n.push('"'))}}}if(e.hasChildNodes()){n.push(">"),t++;var y=!1;for(s=0;s");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"),s=0;s")}else n.push("/>")}return n.join("")},this.embedImage=function(e,t){return new Promise(function(n,r){Wn(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"),fe[e]=l}catch(t){fe[e]=!1}Te=e,t&&t(fe[e]),n(fe[e])}else r(new Error("Error loading image: "+o.status+" "+o.statusText))}).attr("src",e)})},this.setGoodImage=function(e){Te=e},this.open=function(){},this.save=function(e){K(),e&&Wn.extend(ke,e),ke.apply=!0;var t=this.svgCanvasToString();Q("saved",t)};var zt=void 0;this.rasterExport=function(e,t,r,a){var i,s=this,l="ICO"===e?"BMP":e||"PNG",c="image/"+l.toLowerCase(),u=Ut(),d=u.issues,p=u.issueCodes,f=this.svgCanvasToString();return new Promise((i=n(regeneratorRuntime.mark(function n(i,u){var g,v,m,_,y,b;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(b=function(){var n={datauri:_,bloburl:y,svg:f,issues:d,issueCodes:p,type:e,mimeType:c,quality:t,exportWindowName:r};Q("exported",n),a&&a(n),i(n)},zt){n.next=6;break}return n.next=4,on(o.canvgPath+"canvg.js",{global:"canvg"});case 4:g=n.sent,zt=g.canvg;case 6:return Wn("#export_canvas").length||Wn("",{id:"export_canvas"}).hide().appendTo("body"),(v=Wn("#export_canvas")[0]).width=h.contentW,v.height=h.contentH,n.next=12,zt(v,f);case 12:if(m=l.toLowerCase(),_=t?v.toDataURL("image/"+m,t):v.toDataURL("image/"+m),y=void 0,!v.toBlob){n.next=18;break}return v.toBlob(function(e){y=kt(e),b()},c,t),n.abrupt("return");case 18:y=St(_),b();case 20:case"end":return n.stop()}},n,s)})),function(e,t){return i.apply(this,arguments)}))},this.exportPDF=function(e,t,r){var a,i=this,s=this;return new Promise((a=n(regeneratorRuntime.mark(function n(a,l){var c,u,d,h,p,f,g,v,m,_;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(window.jsPDF){n.next=6;break}return n.next=3,sn(["jspdf/underscore-min.js","jspdf/jspdf.min.js"]);case 3:return c=!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules),n.next=6,sn(o.jspdfPath+"jspdf.plugin.svgToPdf.js",{type:c?"module":"text/javascript"});case 6:u=nn(),d=u.w>u.h?"landscape":"portrait","pt",h=jsPDF({orientation:d,unit:"pt",format:[u.w,u.h]}),p=rn(),h.setProperties({title:p}),f=Ut(),g=f.issues,v=f.issueCodes,m=s.svgCanvasToString(),h.addSVG(m,0,0),(_={svg:m,issues:g,issueCodes:v,exportWindowName:e,outputType:t=t||"dataurlstring"}).output=h.output(t,"save"===t?e||"svg.pdf":void 0),r&&r(_),a(_),Q("exportedPDF",_);case 21:case"end":return n.stop()}},n,i)})),function(e,t){return a.apply(this,arguments)}))},this.getSvgString=function(){return ke.apply=!1,this.svgCanvasToString()},this.randomizeIds=function(e){arguments.length>0&&!1===e?xn(!1,m()):xn(!0,m())};var $t=this.uniquifyElems=function(e){var t={},n=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];for(var r in Et(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),Wn.each(le,function(n,r){var a=e.getAttributeNode(r);if(a){var i=Gt(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=Pt(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=Y();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];Nt(d,"#"+i)}}}},Jt=this.setUseData=function(e){var t=Wn(e);"use"!==e.tagName&&(t=t.find("use")),t.each(function(){var e=Pt(this).substr(1),t=Wt(e);t&&(Wn(this).data("ref",t),"symbol"!==t.tagName&&"svg"!==t.tagName||Wn(this).data("symbol",t).data("ref",t))})},en=this.convertGradients=function(e){var t=Wn(e).find("linearGradient, radialGradient");!t.length&&L()&&(t=Wn(e).find("*").filter(function(){return this.tagName.includes("Gradient")})),t.each(function(){if("userSpaceOnUse"===Wn(this).attr("gradientUnits")){var e=Wn(g).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(!e.length)return;var t=Mt(e[0]);if(!t)return;if("linearGradient"===this.tagName){var n=Wn(this).attr(["x1","y1","x2","y2"]),r=this.gradientTransform.baseVal;if(r&&r.numberOfItems>0){var a=be(r).matrix,i=ge(n.x1,n.y1,a),o=ge(n.x2,n.y2,a);n.x1=i.x,n.y1=i.y,n.x2=o.x,n.y2=o.y,this.removeAttribute("gradientTransform")}Wn(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")}}})},tn=this.convertToGroup=function(e){e||(e=w[0]);var t=Wn(e),n=new $n,r=void 0;if(t.data("gsvg")){var a=e.firstChild,i=Wn(a).attr(["x","y"]);Wn(e.firstChild.firstChild).unwrap(),Wn(e).removeData("gsvg");var o=W(e),s=f.createSVGTransform();s.setTranslate(i.x,i.y),o.appendItem(s),Bn(e),Q("selected",[e])}else if(t.data("symbol")){e=t.data("symbol"),r=t.attr("transform");var l=t.attr(["x","y"]),c=e.getAttribute("viewBox");if(c){var d=c.split(" ");l.x-=+d[0],l.y-=+d[1]}r+=" translate("+(l.x||0)+","+(l.y||0)+")";var h=t.prev();n.addSubCommand(new Kn(t[0],t[0].nextSibling,t[0].parentNode)),t.remove();var v=Wn(g).find("use:data(symbol)").length,m=p.createElementNS(u.SVG,"g"),_=e.childNodes,y=void 0;for(y=0;y<_.length;y++)m.append(_[y].cloneNode(!0));if(M()){var b=Wn(It()).children("linearGradient,radialGradient,pattern").clone();Wn(m).append(b)}r&&m.setAttribute("transform",r);var x=e.parentNode;if($t(m),M()&&Wn(It()).append(Wn(m).find("linearGradient,radialGradient,pattern")),m.id=Y(),h.after(m),x){if(!v){var S=e.nextSibling;e.remove(),n.addSubCommand(new Kn(e,S,x))}n.addSubCommand(new Qn(m))}Jt(m),M()?en(It()):en(m),function(e,t){if(e&&1===e.nodeType){for(var n=e.childNodes.length;n--;)Et(e.childNodes.item(n),t);t(e)}}(m,function(e){try{Bn(e)}catch(e){console.log(e)}}),Wn(m).find(se).each(function(){this.id||(this.id=Y())}),Je([m]);var k=dn(m,!0);k&&n.addSubCommand(k),B(n)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e,t){try{var n=At(e);if(n.firstElementChild&&n.firstElementChild.namespaceURI!==u.SVG)return!1;this.prepareSvg(n);var r=new $n("Change Source"),a=g.nextSibling,i=f.removeChild(g);r.addSubCommand(new Kn(i,a,f)),g=p.adoptNode?p.adoptNode(n.documentElement):p.importNode(n.documentElement,!0),f.append(g);var s=Wn(g);h.current_drawing_=new bn(g,v);var l=m().getNonce();l?Q("setnonce",l):Q("unsetnonce"),s.find("image").each(function(){var e=this;Zt(e);var t=Pt(this);if(t){if(t.startsWith("data:")){var n=t.match(/svgedit_url=(.*?);/);if(n){var r=decodeURIComponent(n[1]);Wn(new Image).load(function(){e.setAttributeNS(u.XLINK,"xlink:href",r)}).attr("src",r)}}h.embedImage(t)}}),s.find("svg").each(function(){if(!Wn(this).closest("defs").length){$t(this);var e=this.parentNode;1===e.childNodes.length&&"g"===e.nodeName?(Wn(e).data("gsvg",this),e.id=e.id||Y()):Ye(this)}}),M()&&s.find("linearGradient, radialGradient, pattern").appendTo(It()),Jt(s),en(s[0]);var c={id:"svgcontent",overflow:o.show_outside_canvas?"visible":"hidden"},d=!1;if(s.attr("viewBox")){var y=s.attr("viewBox").split(" ");c.width=y[2],c.height=y[3]}else Wn.each(["width","height"],function(e,t){var n=s.attr(t)||"100%";"%"===String(n).substr(-1)?d=!0:c[t]=re(t,n)});if(kn(),s.children().find(se).each(function(){this.id||(this.id=Y())}),d){var b=Ht();c.width=b.width+b.x,c.height=b.height+b.y}c.width<=0&&(c.width=100),c.height<=0&&(c.height=100),s.attr(c),this.contentW=c.width,this.contentH=c.height,r.addSubCommand(new Qn(g));var x=s.attr(["width","height"]);r.addSubCommand(new Zn(f,x)),_=1,z={},K(),Ne={},f.append(H.selectorParentGroup),t||B(r),Q("changed",[g])}catch(e){return console.log(e),!1}return!0},this.importSvgString=function(e){var t=void 0,n=void 0,r=void 0;try{var a=yt(e.length+e).substr(0,32),i=!1;Ce[a]&&Wn(Ce[a].symbol).parents("#svgroot").length&&(i=!0);var o=new $n("Import Image"),s=void 0;if(i)s=Ce[a].symbol,n=Ce[a].xform;else{var l=At(e);this.prepareSvg(l);var c=void 0;c=p.adoptNode?p.adoptNode(l.documentElement):p.importNode(l.documentElement,!0),$t(c);var d=re("width",c.getAttribute("width")),h=re("height",c.getAttribute("height")),f=c.getAttribute("viewBox"),v=f?f.split(" "):[0,0,d,h];for(t=0;t<4;++t)v[t]=+v[t];var _=+g.getAttribute("height");n="translate(0) "+(n=h>d?"scale("+_/3/v[3]+")":"scale("+_/3/v[2]+")")+" translate(0)",s=p.createElementNS(u.SVG,"symbol");var b=It();for(M()&&Wn(c).find("linearGradient, radialGradient, pattern").appendTo(b);c.firstChild;){var x=c.firstChild;s.append(x)}for(var w=c.attributes,S=0;S0&&(n?cn(e,t,r):(un(e,t,r),Q("changed",r)))};var an=this.setGradient=function(e){if(Re[e+"_paint"]&&"solidColor"!==Re[e+"_paint"].type){var t=h[e+"Grad"],n=ln(t),r=It();n?t=n:(t=r.appendChild(p.importNode(t,!0))).id=Y(),h.setColor(e,"url(#"+t.id+")")}},ln=function(e){for(var t=It(),n=Wn(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=Wn(e).attr(a),n=Wn(i).attr(a),r=!1;if(Wn.each(a,function(e,a){t[a]!==n[a]&&(r=!0)}),r)return"continue"}())continue;var o=e.getElementsByTagNameNS(u.SVG,"stop"),s=i.getElementsByTagNameNS(u.SVG,"stop");if(o.length===s.length){for(var l=o.length;l--;){var c=o[l],d=s[l];if(c.getAttribute("offset")!==d.getAttribute("offset")||c.getAttribute("stop-opacity")!==d.getAttribute("stop-opacity")||c.getAttribute("stop-color")!==d.getAttribute("stop-color"))break}if(-1===l)return i}}return null};this.setPaint=function(e,t){var n=new Wn.jGraduate.Paint(t);switch(this.setPaintOpacity(e,n.alpha/100,!0),Re[e+"_paint"]=n,n.type){case"solidColor":this.setColor(e,"none"!==n.solidColor?"#"+n.solidColor:"none");break;case"linearGradient":case"radialGradient":h[e+"Grad"]=n[n.type],an(e)}},this.setStrokePaint=function(e){this.setPaint("stroke",e)},this.setFillPaint=function(e){this.setPaint("fill",e)},this.getStrokeWidth=function(){return Re.stroke_width},this.setStrokeWidth=function(e){if(0===e&&["line","path"].includes(Ve))h.setStrokeWidth(1);else{Re.stroke_width=e;for(var t=[],n=w.length;n--;){var r=w[n];r&&("g"===r.tagName?Et(r,a):t.push(r))}t.length>0&&(un("stroke-width",e,t),Q("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?Et(a,function(e){"g"!==e.nodeName&&n.push(e)}):n.push(a))}n.length>0&&(un(e,t,n),Q("changed",w))},this.getStyle=function(){return x},this.getOpacity=ae,this.setOpacity=function(e){x.opacity=e,un("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?cn(e+"-opacity",t):un(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=Wt(e.id+"_blur");n&&(t=n.firstChild.getAttribute("stdDeviation"))}return t},function(){var e=null,t=null,n=!1;function r(){var n=h.undoMgr.finishUndoableChange();e.addSubCommand(n),B(e),e=null,t=null}h.setBlurNoUndo=function(e){if(t)if(0===e)cn("filter",""),n=!0;else{var r=w[0];n&&cn("filter","url(#"+r.id+"_blur)"),L()&&(console.log("e",r),r.removeAttribute("filter"),r.setAttribute("filter","url(#"+r.id+"_blur)")),cn("stdDeviation",e,[t.firstChild]),h.setBlurOffsets(t,e)}else h.setBlur(e)},h.setBlurOffsets=function(e,t){t>3?Xt(e,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100):L()||(e.removeAttribute("x"),e.removeAttribute("y"),e.removeAttribute("width"),e.removeAttribute("height"))},h.setBlur=function(n,a){if(e)r();else{var i=w[0],o=i.id;t=Wt(o+"_blur"),n-=0;var s=new $n;if(t)0===n&&(t=null);else{var l=k({element:"feGaussianBlur",attr:{in:"SourceGraphic",stdDeviation:n}});(t=k({element:"filter",attr:{id:o+"_blur"}})).append(l),It().append(t),s.addSubCommand(new Qn(t))}var c={filter:i.getAttribute("filter")};if(0===n)return i.removeAttribute("filter"),void s.addSubCommand(new Zn(i,c));un("filter","url(#"+o+"_blur)"),s.addSubCommand(new Zn(i,c)),h.setBlurOffsets(t,n),e=s,h.undoMgr.beginUndoableChange("stdDeviation",[t?t.firstChild:null]),a&&(h.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]&&un("font-weight",e?"bold":"normal"),w[0].textContent||Bt.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]&&un("font-style",e?"italic":"normal"),w[0].textContent||Bt.setCursor()},this.getFontFamily=function(){return Ae.font_family},this.setFontFamily=function(e){Ae.font_family=e,un("font-family",e),w[0]&&!w[0].textContent&&Bt.setCursor()},this.setFontColor=function(e){Ae.fill=e,un("fill",e)},this.getFontColor=function(){return Ae.fill},this.getFontSize=function(){return Ae.font_size},this.setFontSize=function(e){Ae.font_size=e,un("font-size",e),w[0].textContent||Bt.setCursor()},this.getText=function(){var e=w[0];return null==e?"":e.textContent},this.setTextContent=function(e){un("#text",e),Bt.init(e),Bt.setCursor()},this.setImageURL=function(e){var t=w[0];if(t){var n=Wn(t).attr(["width","height"]),r=!n.width||!n.height,a=Pt(t);if(a!==e)r=!0;else if(!r)return;var i=new $n("Change Image URL");Nt(t,e),i.addSubCommand(new Zn(t,{"#href":a})),r?Wn(new Image).load(function(){var e=Wn(t).attr(["width","height"]);Wn(t).attr({width:this.width,height:this.height}),H.requestSelector(t).resize(),i.addSubCommand(new Zn(t,e)),B(i),Q("changed",[t])}).attr("src",e):B(i)}},this.setLinkURL=function(e){var t=w[0];if(t){if("a"!==t.tagName){var n=Wn(t).parents("a");if(!n.length)return;t=n[0]}var r=Pt(t);if(r!==e){var a=new $n("Change Link URL");Nt(t,e),a.addSubCommand(new Zn(t,{"#href":r})),B(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),B(new Zn(t,{rx:n,ry:n},"Radius")),Q("changed",[t]))}},this.makeHyperlink=function(e){h.groupSelectedElements("a",e)},this.removeHyperlink=function(){h.ungroupSelectedElement()},this.setSegType=function(e){N.setSegType(e)},this.convertToPath=function(e,t){if(null!=e)return t?Rt(e,k,N):function(e,t,n,r,a,i,o,s){var l=new o.BatchCommand("Convert element to Path"),c=n({element:"path",attr:t=dt.extend({},t,jt(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 p=Vt(e);if(p){if(c.setAttribute("d",p),u){var f=W(c);_e(f)&&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,N,K,ne,pe,B);var n=w;Wn.each(n,function(e,t){t&&h.convertToPath(t)})};var cn=function(e,t,n){"pathedit"===Ve&&N.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=Ht([o]),l="x"===e?t-s.x:0,c="y"===e?t-s.y:0;return h.moveSelectedElements(l*_,c*_,!0),"continue"}"g"===o.tagName&&i.includes(e);var u="#text"===e?o.textContent:o.getAttribute(e);if(null==u&&(u=""),u!==String(t)){"#text"===e?(o.textContent=t,/rotate/.test(o.getAttribute("transform"))&&(o=Qe(o))):"#href"===e?Nt(o,t):o.setAttribute(e,t),"textedit"===Ve&&"#text"!==e&&o.textContent.length&&Bt.toSelectMode(o),M()&&"text"===o.nodeName&&/rotate/.test(o.getAttribute("transform"))&&(String(t).startsWith("url")||["font-size","font-family","x","y"].includes(e)&&o.textContent)&&(o=Qe(o)),w.includes(o)&&setTimeout(function(){o.parentNode&&H.requestSelector(o).resize()},0);var d=qt(o);if(0!==d&&"transform"!==e)for(var p=W(o),g=p.numberOfItems;g--;){if(4===p.getItem(g).type){p.removeItem(g);var v=Mt(o),m=ge(v.x+v.width/2,v.y+v.height/2,be(p).matrix),y=m.x,b=m.y,x=f.createSVGTransform();x.setRotate(d,y,b),p.insertItemBefore(x,g);break}}}};r--;)o()},un=this.changeSelectedAttribute=function(e,t,n){n=n||w,h.undoMgr.beginUndoableChange(e,n),cn(e,t,n);var r=h.undoMgr.finishUndoableChange();r.isEmpty()||B(r)};this.deleteSelectedElements=function(){for(var e=new $n("Delete Elements"),t=w.length,n=[],r=0;rn[u].width)||("t"===e||"m"===e||"b"===e)&&(c===Number.MIN_VALUE||c>n[u].height))&&(a=n[u].x,o=n[u].y,i=n[u].x+n[u].width,s=n[u].y+n[u].height,l=n[u].width,c=n[u].height);break;case"largest":(("l"===e||"c"===e||"r"===e)&&(l===Number.MIN_VALUE||li&&(i=n[u].x+n[u].width),n[u].y+n[u].height>s&&(s=n[u].y+n[u].height)}}"page"===t&&(a=0,o=0,i=h.contentW,s=h.contentH);for(var p=new Array(r),f=new Array(r),g=0;g=a.length?t=0:t<0&&(t=a.length-1),r=a[t];break}Je([r],!0),Q("selected",w)}},this.clear(),this.getPrivateMethods=function(){return{addCommandToHistory:B,BatchCommand:$n,ChangeElementCommand:Zn,decode64:bt,encode64:yt,ffClone:Qe,findDefs:It,findDuplicateGradient:ln,getElem:Wt,getPathBBox:Tt,getTypeMap:J,getUrlFromAttr:Gt,identifyLayers:kn,InsertElementCommand:Qn,isChrome:V,isIdentity:ve,isIE:O,logMatrix:Ze,MoveElementCommand:Xn,NS:u,preventClickDefault:Zt,RemoveElementCommand:Kn,SVGEditTransformList:q,text2xml:At,transformBox:ye,transformPoint:ge,walkTree:Et}}};var nr={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};window.console||(window.console={log:function(e){},dir:function(e){}}),Math.precision=function(e,t){return void 0===t&&(t=0),Math.round(e*Math.pow(10,t))/Math.pow(10,t)};var rr,ar=jQuery,ir=void 0,or=function(e,t,n){var r=ar("#svg_editor").parent();Object.entries(t).forEach(function(t){var a=l(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":for(var c,u=0;c=s.childNodes[u];u++)if(3===c.nodeType&&c.textContent.trim()){c.textContent=o;break}break;case"title":s.title=o}}else console.log("Missing: "+i)})},sr=void 0,lr=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,sr.addLangData(ir);case 2:if(n=e.sent,ar.each(n,function(e,n){n.data&&(t=ar.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,or("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={},ar.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]}),ar.each(["dupe","merge_down","merge_all"],function(){u['#cmenu_layers a[href="#'+this+'"]']=s[this]}),u['#cmenu_layers a[href="#delete"]']=s.del,or("content",u),or("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:ir,langData:t});case 15:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}(),cr=(rr=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?ir=t:((ir=ar.pref("lang"))||(navigator.userLanguage?ir=navigator.userLanguage:navigator.language&&(ir=navigator.language)),console.log("Lang: "+ir),n.includes(ir)||"test"===ir||(ir="en")),a=r.langPath+"lang."+ir+".js",e.t0=lr,e.next=5,an(a,{global:"svgEditorLang_"+ir.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)})),function(e,t,n){return rr.apply(this,arguments)});var ur={},dr=[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||!/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(e){return function(e,n){var r,a,i,o,s,l,c,u,d=Array.prototype.slice,h=decodeURIComponent,p=e.param,f=e.bbq=e.bbq||{},g=e.event.special,v="hashchange",m="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(t,a,o,s,l){var c,d,f,g,v;return s!==r?(v=(f=o.match(t?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/))[3]||"",2===l&&A(s)?d=s.replace(t?k:S,""):(g=i(f[2]),s=A(s)?i[t?_:m](s):s,d=2===l?s:1===l?e.extend({},s,g):e.extend({},g,s),d=p(d),t&&(d=d.replace(u,h))),c=f[1]+(t?"#":d||!f[1]?"?":"")+d+v):c=a(o!==r?o:n[b][x]),c}function P(e,t,n){return t===r||"boolean"==typeof t?(n=t,t=p[e?_:m]()):t=A(t)?t.replace(e?k:S,""):t,i(t,n)}function N(n,a,i,o){return A(i)||"object"===(void 0===i?"undefined":t(i))||(o=i,i=a,a=r),this.each(function(){var t=e(this),r=a||c()[(this.nodeName||"").toLowerCase()]||"",s=r&&t.attr(r)||"";t.attr(r,p[n](s,i,o))})}p[m]=E(G,0,function(e){return e.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}),p[_]=a=E(G,1,function(e){return e.replace(/^[^#]*#?(.*)$/,"$1")}),a.noEscape=function(t){t=t||"";var n=e.map(t.split(""),encodeURIComponent);u=new RegExp(n.join("|"),"g")},a.noEscape(",/"),e.deparam=i=function(t,n){var a={},i={true:!0,false:!1,null:null};return e.each(t.replace(/\+/g," ").split("&"),function(t,o){var s,l=o.split("="),c=h(l[0]),u=a,d=0,p=c.split("]["),f=p.length-1;if(/\[/.test(p[0])&&/\]$/.test(p[f])?(p[f]=p[f].replace(/\]$/,""),f=(p=p.shift().split("[").concat(p)).length-1):f=0,2===l.length)if(s=h(l[1]),n&&(s=s&&!isNaN(s)?+s:"undefined"===s?r:i[s]!==r?i[s]:s),f)for(;d<=f;d++)u=u[c=""===p[d]?u.length:p[d]]=d').hide().insertAfter("body")[0].contentWindow,s=function(){return m(i.document[u][h])},(o=function(e,t){if(e!==t){var n=i.document;n.open().close(),n[u].hash="#"+e}})(m()))),function r(){var i=m(),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}(e,window),e},function(e){var t={},n=void 0;return e.svgIcons=function(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xlink",s=a.w||24,l=a.h||24,c=void 0,u=void 0,d=void 0,h=!1,p=!1,f=0,g=!!window.opera,v="data:image/svg+xml;charset=utf-8;base64,",m=void 0;if(a.svgz){m=e('').appendTo("body").hide();try{u=m[0].contentDocument,m.load(y),y(0,!0)}catch(e){k()}}else{var _=new DOMParser;e.ajax({url:r,dataType:"string",success:function(t){t?(u=_.parseFromString(t,"text/xml"),e(function(){y("ajax")})):e(k)},error:function(t){window.opera?e(function(){k()}):t.responseText?((u=_.parseFromString(t.responseText,"text/xml")).childNodes.length||e(k),e(function(){y("ajax")})):e(k)}})}function y(t,n){if("ajax"!==t){if(p)return;var r=(u=m[0].contentDocument)&&u.getElementById("svg_eof");if(!(r||n&&r))return void(++f<50?setTimeout(y,20):(k(),p=!0));p=!0}if(c=e(u.firstChild).children(),a.no_img)setTimeout(function(){h||S()},500);else{var i=v+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";d=e(new Image).attr({src:i,width:0,height:0}).appendTo("body").load(function(){S(!0)}).error(function(){S()})}}function b(e,t,n,r){if(g&&t.css("visibility","hidden"),a.replace){r&&t.attr("id",n);var i=e.attr("class");i&&t.attr("class","svg_icon "+i),e.replaceWith(t)}else e.append(t);g&&setTimeout(function(){t.removeAttr("style")},1)}var x=void 0;function w(e,n){void 0!==a.id_match&&!1===a.id_match||b(x,e,n,!0),t[n]=e}function S(r,u){if(!h){a.no_img&&(r=!1);var p=void 0;if(r&&(p=e(document.createElement("div"))).hide().appendTo("body"),u){var f=a.fallback_path||"";e.each(u,function(t,n){x=e("#"+t),w(e(new Image).attr({class:"svg_icon",src:f+n,width:s,height:l,alt:"icon"}),t)})}else for(var _=c.length,y=0;y<_;y++){var S=c[y],k=S.id;if("svg_eof"===k)break;x=e("#"+k);var A=document.createElementNS(i,"svg");A.setAttributeNS(null,"viewBox",[0,0,s,l].join(" "));var E=S.getElementsByTagNameNS(i,"svg")[0],G=E.getAttribute("width"),P=E.getAttribute("height");E.removeAttribute("width"),E.removeAttribute("height"),E.getAttribute("viewBox")||E.setAttribute("viewBox",[0,0,G,P].join(" ")),A.setAttribute("xmlns",i),A.setAttribute("width",s),A.setAttribute("height",l),A.setAttribute("xmlns:xlink",o),A.setAttribute("class","svg_icon"),g||(E=E.cloneNode(!0)),A.append(E);var N=void 0;if(r){p.empty().append(A);var I=v+C(unescape(encodeURIComponent((new XMLSerializer).serializeToString(A))));N=e(new Image).attr({class:"svg_icon",src:I})}else N=n(e(A),y);w(N,k)}a.placement&&e.each(a.placement,function(a,i){t[i]&&e(a).each(function(a){var o=t[i].clone();a>0&&!r&&(o=n(o,a,!0)),b(e(this),o,i)})}),u||(r&&p.remove(),m&&m.remove(),d&&d.remove()),a.resize&&e.resizeSvgIcons(a.resize),h=!0,a.callback&&a.callback(t)}}function k(){if(r.includes(".svgz")){var t=r.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg"),e.svgIcons(t,a)}else a.fallback&&S(!1,a.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 f=e(c+"> .jGraduate_colPick"),g=e(c+"> .jGraduate_gradPick");g.html('

    '+s.window.pickerTitle+'


    ');var v=256,m=v-0,_=v-0,y={};e(".jGraduate_SliderBar").width(145);var b=e("#"+l+"_jGraduate_GradContainer")[0],x=a("svg",{id:l+"_jgraduate_svg",width:v,height:v,xmlns:nr.svg},b),w=o.paint.type,S=o.paint[w],k=S,C=o.paint.alpha,A="solidColor"===w;switch(w){case"solidColor":case"linearGradient":if(A||(k.id=l+"_lg_jgraduate_grad",S=k=x.appendChild(k)),a("radialGradient",{id:l+"_rg_jgraduate_grad"},x),"linearGradient"===w)break;case"radialGradient":A||(k.id=l+"_rg_jgraduate_grad",S=k=x.appendChild(k)),a("linearGradient",{id:l+"_lg_jgraduate_grad"},x)}var E=void 0;if(A){S=k=e("#"+l+"_lg_jgraduate_grad")[0],Me(0,"#"+(h=o.paint[w]),1);var G=t(s.newstop);if("string"===G)switch(s.newstop){case"same":Me(1,"#"+h,1);break;case"inverse":for(var P="",N=0;N<6;N+=2){var I=(255-parseInt(h.substr(N,2),16)).toString(16);I.length<2&&(I=0+I),P+=I}Me(1,"#"+P,1);break;case"white":Me(1,"#ffffff",1);break;case"black":Me(1,"#000000",1)}else if("object"===G){var T="opac"in s.newstop?s.newstop.opac:1;Me(1,s.newstop.color||"#"+h,T)}}var L=parseFloat(S.getAttribute("x1")||0),M=parseFloat(S.getAttribute("y1")||0),O=parseFloat(S.getAttribute("x2")||1),V=parseFloat(S.getAttribute("y2")||0),j=parseFloat(S.getAttribute("cx")||.5),R=parseFloat(S.getAttribute("cy")||.5),B=parseFloat(S.getAttribute("fx")||j),D=parseFloat(S.getAttribute("fy")||R),U=a("rect",{id:l+"_jgraduate_rect",x:0,y:0,width:m,height:_,fill:"url(#"+l+"_jgraduate_grad)","fill-opacity":C/100},x),F=e("
    ").attr({class:"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:M*v,left:L*v}).data("coord","start").appendTo(b),H=F.clone().text(2).css({top:V*v,left:O*v}).attr("title","End stop").data("coord","end").appendTo(b),z=e("
    ").attr({class:"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:R*v,left:j*v}).data("coord","center").appendTo(b),q=z.clone().text("F").css({top:D*v,left:B*v,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(b);q[0].id=l+"_jGraduate_focusCoord";var Y=void 0;e.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(t,n){var r=isNaN(n[1]),a=k.getAttribute(n);a||(a=r?"0.5":"x2"===n?"1.0":"0.0"),y[n]=e("#"+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]||Y)&&(r&&"radialGradient"===w||!r&&"linearGradient"===w)&&k.setAttribute(n,this.value);var e=r?"c"===n[0]?z:q:"1"===n[1]?F:H,t=n.includes("x")?"left":"top";e.css(t,this.value*v)}).change()});var W=e("#"+l+"_jGraduate_StopSlider"),X=void 0,Q=void 0,K=void 0,Z=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),$=void 0,J=1,ee=1,te=0,ne=j,re=R,ae=a("svg",{width:"100%",height:45},W[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(nr.xlink,"xlink:href",se),e(ae).click(function(e){if($=W.offset(),"path"!==e.target.tagName){var t=e.pageX-$.left-8;Me((t=t<10?10:t>v+10?v+10:t)/v,0,0,!0),e.stopPropagation()}}),e(ae).mouseover(function(){ae.append(Z)}),E=a("g",{},ae),a("line",{x1:10,y1:15,x2:v+10,y2:15,"stroke-width":2,stroke:"#000"},ae);var le=g.find(".jGraduate_spreadMethod").change(function(){k.setAttribute("spreadMethod",e(this).val())}),ce=null,ue=function(e){var t=e.pageX-fe.left,n=e.pageY-fe.top;t=t<0?0:t>v?v:t,n=n<0?0:n>v?v:n,ce.css("left",t).css("top",n);var r=t/m,a=n/_,i=ce.data("coord"),o=k;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()},de=function e(){ce=null,p.unbind("mousemove",ue).unbind("mouseup",e)},he=(X=k.getElementsByTagNameNS(nr.svg,"stop")).length;if(he<2){for(;he<2;)k.append(document.createElementNS(nr.svg,"stop")),++he;X=k.getElementsByTagNameNS(nr.svg,"stop")}for(var pe=0;pe99.5&&(n=99.5),n>0?ee=1-n/100:J=-n/100-1,a=(n+100)/2*145/100,e&&je();break;case"angle":a=(te=n)/180,a+=.5,a*=145,e&&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=me.offset,n=me.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,me.type){case"radius":(r=Math.pow(2*r,2.5))>.98&&r<1.02&&(r=1),r<=.01&&(r=.01),k.setAttribute("r",r);break;case"opacity":o.paint.alpha=parseInt(100*r),U.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}me.elem.css({"margin-left":a}),r=Math.round(100*r),me.input.val(r)}(e),e.preventDefault()},Ne=function e(t){p.unbind("mousemove",Pe).unbind("mouseup",e),me=null},Ie=(255*o.paint.alpha/100).toString(16);Ie.length<2;)Ie="0"+Ie;Ie=Ie.split(".")[0],h="none"===o.paint.solidColor?"":o.paint.solidColor+Ie,A||(h=X[0].getAttribute("stop-color")),e.extend(e.fn.jPicker.defaults.window,{alphaSupport:!0,effects:{type:"show",speed:0}}),f.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 Te=e(c+" .jGraduate_tabs li");Te.click(function(){Te.removeClass("jGraduate_tab_current"),e(this).addClass("jGraduate_tab_current"),e(c+" > div").hide();var t=e(this).attr("data-type");if(e(c+" .jGraduate_gradPick").show(),"rg"===t||"lg"===t){e(".jGraduate_"+t+"_field").show(),e(".jGraduate_"+("lg"===t?"rg":"lg")+"_field").hide(),e("#"+l+"_jgraduate_rect")[0].setAttribute("fill","url(#"+l+"_"+t+"_jgraduate_grad)"),w="lg"===t?"linearGradient":"radialGradient",e("#"+l+"_jGraduate_OpacInput").val(o.paint.alpha).change();var n=e("#"+l+"_"+t+"_jgraduate_grad")[0];if(k!==n){var r=e(k).find("stop");e(n).empty().append(r),k=n;var a=le.val();k.setAttribute("spreadMethod",a)}Y="rg"===t&&null!=k.getAttribute("fx")&&!(j===B&&R===D),e("#"+l+"_jGraduate_focusCoord").toggle(Y),Y&&(e("#"+l+"_jGraduate_match_ctr")[0].checked=!1)}else e(c+" .jGraduate_gradPick").hide(),e(c+" .jGraduate_colPick").show()}),e(c+" > div").hide(),Te.removeClass("jGraduate_tab_current");var Le=void 0;switch(o.paint.type){case"linearGradient":Le=e(c+" .jGraduate_tab_lingrad");break;case"radialGradient":Le=e(c+" .jGraduate_tab_radgrad");break;default:Le=e(c+" .jGraduate_tab_color")}o.show(),setTimeout(function(){Le.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(t,n,r,i,o){var c=o||a("stop",{"stop-color":n,"stop-opacity":r,offset:t},k);o?(n=o.getAttribute("stop-color"),r=o.getAttribute("stop-opacity"),t=o.getAttribute("offset")):k.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+t*v)+", 26)"},E),h=a("path",{d:u,fill:n,"fill-opacity":r,transform:"translate("+(10+t*v)+", 26)",stroke:"#000","stroke-width":1.5},E);return e(h).mousedown(function(e){return Oe(this),K=Q,p.mousemove(Re).mouseup(Ve),$=W.offset(),e.preventDefault(),!1}).data("stop",c).data("bg",d).dblclick(function(){e("div.jGraduate_LightBox").show();for(var t=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,e("#"+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,t.setAttribute("fill",a),t.setAttribute("fill-opacity",r),c.setAttribute("stop-color",a),c.setAttribute("stop-opacity",r),e("div.jGraduate_LightBox").hide(),e("#"+l+"_jGraduate_stopPicker").hide()},null,function(){e("div.jGraduate_LightBox").hide(),e("#"+l+"_jGraduate_stopPicker").hide()})}),e(k).find("stop").each(function(){var r=e(this);if(+this.getAttribute("offset")>t){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){Q&&Q.setAttribute("stroke","#000"),e.setAttribute("stroke","blue"),(Q=e).parentNode.append(Q)}function Ve(){p.unbind("mousemove",Re),"none"!==Z.getAttribute("display")&&function(){Z.setAttribute("display","none");var t=e(Q),n=t.data("stop"),r=t.data("bg");e([Q,n,r]).remove()}(),K=null}function je(){var e=te?"rotate("+te+","+ne+","+re+") ":"";if(1===J&&1===ee)k.removeAttribute("gradientTransform");else{var t=-ne*(J-1),n=-re*(ee-1);k.setAttribute("gradientTransform",e+"translate("+t+","+n+") scale("+J+","+ee+")")}}function Re(t){var n=t.pageX-$.left,r=t.pageY-$.top,a="translate("+(n=n<10?10:n>v+10?v+10:n)+", 26)";r<-60||r>130?(Z.setAttribute("display","block"),Z.setAttribute("transform",a)):Z.setAttribute("display","none"),K.setAttribute("transform",a),e.data(K,"bg").setAttribute("transform",a);var i=e.data(K,"stop"),o=(n-10)/v;i.setAttribute("offset",o);var s=0;e(k).find("stop").each(function(t){var n=this.getAttribute("offset"),r=e(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},U,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&&j()){if(l.stopPropagation(),e(".contextMenu").hide(),i.hasClass("disabled"))return!1;var d=l.pageX,h=l.pageY,p=t.width()-s.width(),f=t.height()-s.height();d>p-15&&(d=p-15),h>f-30&&(h=f-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*v+f,y:o/a*y+m})}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 p;case"xy":default:return{x:h,y:p}}if(null==n||n!==r){var a=!1,i=void 0,o=void 0;switch(null==e&&(e="xy"),e.toLowerCase()){case"x":i=t&&(t.x&&0|t.x||0|t)||0;break;case"y":o=t&&(t.y&&0|t.y||0|t)||0;break;case"xy":default:i=t&&t.x&&0|t.x||0,o=t&&t.y&&0|t.y||0}null!=i&&(ig&&(i=g),h!==i&&(h=i,a=!0)),null!=o&&(o_&&(o=_),p!==o&&(p=o,a=!0)),a&&function(e){for(var t=0;t0&&(i=h===g?e:h/v*e|0),y>0&&(o=p===_?n:p/y*n|0),r>=e?i=(e>>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(t,n,r,a){var i=this,o=t.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 p.get(0):switch(e.keyCode){case 38:return p.val(d.call(i,1+(p.val()<<0),0,255)),n.val("r",p.val(),e.target),!1;case 40:return p.val(d.call(i,(p.val()<<0)-1,0,255)),n.val("r",p.val(),e.target),!1}break;case f.get(0):switch(e.keyCode){case 38:return f.val(d.call(i,1+(f.val()<<0),0,255)),n.val("g",f.val(),e.target),!1;case 40:return f.val(d.call(i,(f.val()<<0)-1,0,255)),n.val("g",f.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 v&&v.get(0):switch(e.keyCode){case 38:return v.val(d.call(i,parseFloat(v.val())+1,0,100)),n.val("a",Math.precision(255*v.val()/100,a),e.target),!1;case 40:return v.val(d.call(i,parseFloat(v.val())-1,0,100)),n.val("a",Math.precision(255*v.val()/100,a),e.target),!1}break;case m.get(0):switch(e.keyCode){case 38:return m.val(d.call(i,1+(m.val()<<0),0,360)),n.val("h",m.val(),e.target),!1;case 40:return m.val(d.call(i,(m.val()<<0)-1,0,360)),n.val("h",m.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 p.get(0):p.val(d.call(i,p.val(),0,255)),n.val("r",p.val(),e.target);break;case f.get(0):f.val(d.call(i,f.val(),0,255)),n.val("g",f.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 v&&v.get(0):v.val(d.call(i,v.val(),0,100)),n.val("a",Math.precision(255*v.val()/100,a),e.target);break;case m.get(0):m.val(d.call(i,m.val(),0,360)),n.val("h",m.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 p.get(0):p.val(n.val("r"));break;case f.get(0):f.val(n.val("g"));break;case g.get(0):g.val(n.val("b"));break;case v&&v.get(0):v.val(Math.precision(100*n.val("a")/255,a));break;case m.get(0):m.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,m=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;e.extend(!0,i,{destroy:function(){p.add(f).add(g).add(v).add(m).add(_).add(y).add(b).add(r).add(x).unbind("keyup",l).unbind("blur",c),p.add(f).add(g).add(v).add(m).add(_).add(y).unbind("keydown",s),n.unbind(h),p=null,f=null,g=null,v=null,m=null,_=null,y=null,b=null,x=null}}),p.add(f).add(g).add(v).add(m).add(_).add(y).add(b).add(r).add(x).bind("keyup",l).bind("blur",c),p.add(f).add(g).add(v).add(m).add(_).add(y).bind("keydown",s),n.bind(h)}e.loadingStylesheets.includes("jgraduate/css/jPicker.css")||e.loadingStylesheets.push("jgraduate/css/jPicker.css"),e.jPicker={List:[],Color:function(t){var n=this;function r(e){for(var t=0;t255&&(y.r=255),i!==y.r&&(i=y.r,m=!0);break;case"g":if(x)continue;b=!0,y.g=t&&t.g&&0|t.g||t&&0|t||0,y.g<0?y.g=0:y.g>255&&(y.g=255),o!==y.g&&(o=y.g,m=!0);break;case"b":if(x)continue;b=!0,y.b=t&&t.b&&0|t.b||t&&0|t||0,y.b<0?y.b=0:y.b>255&&(y.b=255),l!==y.b&&(l=y.b,m=!0);break;case"a":y.a=t&&null!=t.a?0|t.a:null!=t?0|t:255,y.a<0?y.a=0:y.a>255&&(y.a=255),c!==y.a&&(c=y.a,m=!0);break;case"h":if(b)continue;x=!0,y.h=t&&t.h&&0|t.h||t&&0|t||0,y.h<0?y.h=0:y.h>360&&(y.h=360),u!==y.h&&(u=y.h,m=!0);break;case"s":if(b)continue;x=!0,y.s=t&&null!=t.s?0|t.s:null!=t?0|t:100,y.s<0?y.s=0:y.s>100&&(y.s=100),d!==y.s&&(d=y.s,m=!0);break;case"v":if(b)continue;x=!0,y.v=t&&null!=t.v?0|t.v:null!=t?0|t:100,y.v<0?y.v=0:y.v>100&&(y.v=100),h!==y.v&&(h=y.v,m=!0)}if(m){if(b){i=i||0,o=o||0,l=l||0;var S=s.rgbToHsv({r:i,g:o,b:l});u=S.h,d=S.s,h=S.v}else if(x){u=u||0,d=null!=d?d:100,h=null!=h?h:100;var k=s.hsvToRgb({h:u,s:d,v:h});i=k.r,o=k.g,l=k.b}c=null!=c?c:255,r.call(n,p||n)}}}}var i=void 0,o=void 0,l=void 0,c=void 0,u=void 0,d=void 0,h=void 0,p=[];e.extend(!0,n,{val:a,bind:function(e){"function"==typeof e&&p.push(e)},unbind:function(e){if("function"==typeof e)for(var t=void 0;t=p.includes(e);)p.splice(t,1)},destroy:function(){p=null}}),t&&(null!=t.ahex?a("ahex",t):null!=t.hex?a((null!=t.a?"a":"")+"hex",null!=t.a?{ahex:t.hex+s.intToHex(t.a)}:t):null!=t.r&&null!=t.g&&null!=t.b?a("rgb"+(null!=t.a?"a":""),t):null!=t.h&&null!=t.s&&null!=t.v&&a("hsv"+(null!=t.a?"a":""),t))},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=e.r/255,n=e.g/255,r=e.b/255,a={h:0,s:0,v:0},i=0,o=0;t>=n&&t>=r?(o=t,i=n>r?r:n):n>=r&&n>=t?(o=n,i=t>r?r:t):(o=r,i=n>t?t:n),a.v=o,a.s=o?(o-i)/o:0;var s=void 0;return a.s?(s=o-i,a.h=t===o?(n-r)/s:n===o?2+(r-t)/s:4+(t-n)/s,a.h=parseInt(60*a.h),a.h<0&&(a.h+=360)):a.h=0,a.s=100*a.s|0,a.v=100*a.v|0,a},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=e.jPicker,i=a.Color,o=a.List,s=a.ColorMethods;return e.fn.jPicker=function(a){var l=arguments;return this.each(function(){var c=this,u=e.extend(!0,{},e.fn.jPicker.defaults,a);"input"===e(c).get(0).nodeName.toLowerCase()&&(e.extend(!0,u,{window:{bindToInput:!0,expandable:!0,input:e(c)}}),""===e(c).val()?(u.color.active=new i({hex:null}),u.color.current=new i({hex:null})):s.validateHex(e(c).val())&&(u.color.active=new i({hex:e(c).val(),a:u.color.active.val("a")}),u.color.current=new i({hex:e(c).val(),a:u.color.active.val("a")}))),u.window.expandable?e(c).after('    '):u.window.liveUpdate=!1;var d=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters;function h(e){var t=V.active,n=t.val("hex"),r=void 0,a=void 0;switch(u.color.mode=e,e){case"h":if(setTimeout(function(){v.call(c,F,"transparent"),_.call(c,z,0),y.call(c,z,100),_.call(c,q,260),y.call(c,q,100),v.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==t.val("ahex"))break;J.val("xy",{x:t.val("s"),y:100-t.val("v")},J),ee.val("y",360-t.val("h"),ee);break;case"s":if(setTimeout(function(){v.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==t.val("ahex"))break;J.val("xy",{x:t.val("h"),y:100-t.val("v")},J),ee.val("y",100-t.val("s"),ee);break;case"v":if(setTimeout(function(){v.call(c,F,"000000"),_.call(c,z,-780),_.call(c,q,260),v.call(c,H,n),_.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==t.val("ahex"))break;J.val("xy",{x:t.val("h"),y:100-t.val("s")},J),ee.val("y",100-t.val("v"),ee);break;case"r":if(r=-1040,a=-780,J.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ee.range("rangeY",{minY:0,maxY:255}),null==t.val("ahex"))break;J.val("xy",{x:t.val("b"),y:255-t.val("g")},J),ee.val("y",255-t.val("r"),ee);break;case"g":if(r=-1560,a=-1820,J.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ee.range("rangeY",{minY:0,maxY:255}),null==t.val("ahex"))break;J.val("xy",{x:t.val("b"),y:255-t.val("r")},J),ee.val("y",255-t.val("g"),ee);break;case"b":if(r=-2080,a=-2860,J.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ee.range("rangeY",{minY:0,maxY:255}),null==t.val("ahex"))break;J.val("xy",{x:t.val("r"),y:255-t.val("g")},J),ee.val("y",255-t.val("b"),ee);break;case"a":if(setTimeout(function(){v.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==t.val("ahex"))break;J.val("xy",{x:t.val("h"),y:100-t.val("v")},J),ee.val("y",255-t.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(){v.call(c,F,"transparent"),v.call(c,H,"transparent"),y.call(c,W,100),y.call(c,z,100),_.call(c,z,r),_.call(c,q,r-260),_.call(c,W,a-780),_.call(c,X,a-520),_.call(c,Q,a),_.call(c,K,a-260),_.call(c,$,260),y.call(c,$,100)},0)}null!=t.val("ahex")&&p.call(c,t)}function p(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&&Math.precision(100*t.a/255,4)||0)}catch(e){}}).call(c,e),function(e){switch(u.color.mode){case"h":v.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,Math.precision((e.val("r")||0)/255*100,4));break;case"g":y.call(c,q,Math.precision((e.val("g")||0)/255*100,4));break;case"b":y.call(c,q,Math.precision((e.val("b")||0)/255*100))}var r=e.val("a");y.call(c,Y,Math.precision(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,Math.precision(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});v.call(c,H,r.val("hex")),y.call(c,X,100-(null!=n?n.v:100)),y.call(c,Z,Math.precision(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});v.call(c,H,o.val("hex")),y.call(c,Z,Math.precision(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?Math.precision((l-d)/(255-d)*100,4):0),y.call(c,Q,d>l?Math.precision((d-l)/(255-l)*100,4):0),y.call(c,K,Math.precision(h/255*100,4)),y.call(c,Z,Math.precision(100*(255-(s&&s.a||0))/255,4));break;case"a":var p=e.val("a");v.call(c,H,e.val("hex")||"000000"),y.call(c,Z,null!=p?0:100),y.call(c,$,null!=p?100:0)}}.call(c,e)},0)}function f(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 v(e,t){e.css({backgroundColor:t&&6===t.length&&"#"+t||"transparent"})}function m(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:Math.precision(t/100,4)})}else e.css({opacity:Math.precision(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(t){e(this).parents("tbody:first").find('input:radio[value!="'+t.target.value+'"]').removeAttr("checked"),h.call(c,t.target.value)}function w(){b.call(c)}function S(){b.call(c),u.window.expandable&&L.call(c),"function"==typeof pe&&pe.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(){T.call(c)}function A(e,t){var n=e.val("hex");re.css({backgroundColor:n&&"#"+n||"transparent"}),y.call(c,re,Math.precision(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,Math.precision(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(t){j=parseInt(U.css("left")),R=parseInt(U.css("top")),B=t.pageX,D=t.pageY,e(document).bind("mousemove",P).bind("mouseup",N),t.preventDefault()}function P(t){return U.css({left:j-(B-t.pageX)+"px",top:R-(D-t.pageY)+"px"}),u.window.expandable&&!e.support.boxModel&&U.prev().css({left:U.css("left"),top:U.css("top")}),t.stopPropagation(),t.preventDefault(),!1}function N(t){return e(document).unbind("mousemove",P).unbind("mouseup",N),t.stopPropagation(),t.preventDefault(),!1}function I(t){return t.preventDefault(),t.stopPropagation(),V.active.val("ahex",e(this).attr("title")||null,t.target),!1}function T(){function t(){if(u.window.expandable&&!e.support.boxModel){var t=U.find("table:first");U.before("